Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- switch ($type) {
- case '1':
- $size = ($_REQUEST['size']);
- if (preg_match('/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/', $size)) {
- $optValue = $size;
- $optName = $categories[$type - 1][1];
- break;
- } else {
- header("location: ../views/productAdd.php");
- return;
- }
- case '2':
- $bWeight = ($_REQUEST['bWeight']);
- if (preg_match('/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/', $bWeight)) {
- $optValue = $bWeight;
- $optName = $categories[$type - 1][1];
- break;
- } else {
- header("location: ../views/productAdd.php");
- return;
- }
- case '3':
- $tempH = ($_REQUEST['fHeight']);
- $tempW = ($_REQUEST['fWidth']);
- $tempL = ($_REQUEST['fLenght']);
- if (preg_match('/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/', $tempH)) {
- $fHeight = $tempH;
- }
- if (preg_match('/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/', $tempW)) {
- $fWidth = $tempW;
- }
- if (preg_match('/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/', $tempL)) {
- $fLenght = $tempL;
- }
- if (!isset($fHeight, $fWidth, $fLenght)) {
- header("location: ../views/productAdd.php");
- return;
- }
- $optValue = $fHeight . 'x' . $fWidth . 'x' . $fLenght;
- $optName = $categories[$type - 1][1];
- break;
- }
- class Type
- {
- public $type;
- function __construct($type)
- {
- $this->temp = $type;
- }
- function fetchType()
- {
- include "../config/categories.php";
- $val = ($_REQUEST[$categories[$this->temp - 1][3]]);
- if (preg_match('/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/', $val)) {
- return $val;
- }
- }
- }
- define('VALID_DIMENSION_PATTERN', '/^(0|b[1-9]|[1-9][0-9]{1,6})(.[0-9]{1,2}+)?$/')
- if (preg_match(VALID_DIMENSION_PATTERN, $bWeight)) {
- function valid_dimension($dimension) {
- return preg_match(VALID_DIMENSION_PATTERN, $dimension)
- }
- if (valid_dimension($bWeight)) {
- function valid_dimensions(...$dimensions) {
- foreach($dimensions as $dimension) {
- if (!preg_match(VALID_DIMENSION_PATTERN, $dimension))
- return FALSE;
- }
- return TRUE;
- }
- if (valid_dimensions($tempH, $tempW, $tempL)) {
Add Comment
Please, Sign In to add comment