Skip to content

Commit

Permalink
Change eregi to preg_match
Browse files Browse the repository at this point in the history
Allowed activity codes to be 3-6 digits instead of just 6
Moved version number to app.inc.php
  • Loading branch information
root committed Mar 5, 2019
1 parent ec45ce2 commit 97012b8
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions admin/editOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
$activityCode = strtoupper(trim(rtrim($activityCode)));

$error = false;
if (!eregi('^1-[0-9]{6}-[0-9]{6}-[0-9]{6}$',$cfop)) {
if (!preg_match('/^1-[0-9]{6}-[0-9]{6}-[0-9]{6}$/',$cfop)) {
$error = true;
$cfopMsg = "<br><b class='error'>Invalid CFOP Number</b>";
}
elseif (!eregi('^[a-zA-Z0-9]{6}',$activityCode) && (strlen($activityCode) > 0)) {
elseif (!preg_match('/^[a-zA-Z0-9]{3,6}/',$activityCode) && (strlen($activityCode) > 0)) {
$error = true;
$activityCodeMsg = "<b><b class='error'>Invalid Activity Code</b>";
}
Expand Down
1 change: 1 addition & 0 deletions admin/includes/main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//
//////////////////////////////////////////////////////

require_once '../includes/app.inc.php';
require_once '../includes/settings.inc.php';
require_once '../vendor/autoload.php';
set_include_path(get_include_path() . ':../libs');
Expand Down
9 changes: 9 additions & 0 deletions includes/apps.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/*
Store Application Variables
*/

define("app_version","1.2.4");


?>
2 changes: 1 addition & 1 deletion includes/poster.inc.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function validateCFOP(cfop) {
}

function validateActivityCode(activityCode) {
var activityCodeRegex = /^[a-zA-Z0-9]{6}/;
var activityCodeRegex = /^[a-zA-Z0-9]{3,6}/;
if ((activityCode != "") && (!activityCode.match(activityCodeRegex))) {
document.getElementById('activityCodeWarning').innerHTML = "Please enter a valid activity code.";
return false;
Expand Down
1 change: 0 additions & 1 deletion includes/settings.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
////////////////////////////////////////////////

define("enable",TRUE);
define("app_version","1.2.3");
define("admin_email","");
define("mysql_host","");
define("mysql_user","");
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//////////////////////////////////////////////////////

//include files for the script to run
require_once 'includes/app.inc.php';
require_once 'includes/settings.inc.php';
require_once 'vendor/autoload.php';
set_include_path(get_include_path() . ':libs');
Expand Down
6 changes: 3 additions & 3 deletions libs/finishOptions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ function addFinishOption($db,$name,$cost,$maxWidth,$maxLength,$default = 0) {
$message .= "<br><b class='error'>Pleae enter finish option name</b>";
$errors++;
}
if (($cost == "") || !eregi('^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$',$cost)) {
if (($cost == "") || !preg_match('/^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$/',$cost)) {
$message .= "<br><b class='error'>Please enter a valid cost</b>";
$errors++;
}

if (($maxWidth == "") || ($maxWidth > max_printer_width) || !(eregi("^[0-9]{1,2}$", $maxWidth))) {
if (($maxWidth == "") || ($maxWidth > max_printer_width) || !(preg_match("/^[0-9]{1,2}$/", $maxWidth))) {
$message .= "<br><b class='error'>Please enter a valid Max Width. Maximum is " . max_printer_width . " inches</b>";
$errors++;
}
if (($maxLength == "") || !(eregi("^[0-9]{1,3}$", $maxLength))) {
if (($maxLength == "") || !(preg_match("/^[0-9]{1,3}$/", $maxLength))) {
$message .= "<br><b class='error'>Please enter a valid Max Length</b>";
$errors++;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/paperTypes.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ function addPaperType($db,$name,$cost,$width,$default = 0) {
$message .= "<br><b class='error'>Please enter finish option name</b>";
$errors++;
}
if (($cost == "") || !eregi('^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$',$cost)) {
if (($cost == "") || !preg_match('/^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$/',$cost)) {
$message .= "<br><b class='error'>Please enter a valid cost</b>";
$errors++;
}

if (($width == "") || ($width > max_printer_width) || !(eregi("^[0-9]{1,2}$", $width))) {
if (($width == "") || ($width > max_printer_width) || !(preg_match("/^[0-9]{1,2}$/", $width))) {
$message .= "<br><b class='error'>Please enter a valid Width. Maximum is " . max_printer_width . "</b>";
$errors++;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/posterTube.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getPosterTubeInfo($db) {
}

function updatePosterTube($db,$cost) {
if (($cost == "") || !eregi('^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$',$cost)) {
if (($cost == "") || !preg_match('/^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$/',$cost)) {
$message = "<b class='error'>Please enter a valid poster tube cost.</b>";
return array('RESULT'=>FALSE,
'MESSAGE'=>$message);
Expand Down
2 changes: 1 addition & 1 deletion libs/rushOrder.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getRushOrderInfo($db) {

function updateRushOrder($db, $cost) {

if (($cost == "") || !eregi('^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$',$cost)) {
if (($cost == "") || !preg_match('/^[0-9]{1}[0-9]*[.]{1}[0-9]{2}$/',$cost)) {
$message = "<b class='error'>Please enter a valid rush order cost</b>";
return array('RESULT'=>FALSE,
'MESSAGE'=>$message);
Expand Down

0 comments on commit 97012b8

Please sign in to comment.