error = false; $this->arErrorMessages = array(); //print_r($arr_config); return true; } /** * class constructor for php4 * * @return cDatabase */ function Error() { $argcv = func_get_args(); call_user_func_array( array( &$this, '__construct' ), $argcv ); } function formatHTMLError( $message, $format = __VLD_ERROR_DISPLAY__ ) { if( !empty( $message ) ) { if( is_array( $message) ) { $message = implode( "
", $message ); } return str_replace( "{ERROR}", $message, $format ); } else { return false; } } function addError( $error_field, $message ) { $this->error = true; if(!empty($message)) { if( isset( $this->arErrorMessages[$error_field] ) ) { if( is_array( $this->arErrorMessages[$error_field] ) ) { if( !in_array( $message, $this->arErrorMessages[$error_field] ) ) { $this->arErrorMessages[$error_field][] = $message; } } else { if( $message != $this->arErrorMessages[$error_field] ) { $this->arErrorMessages[$error_field] = $this->arErrorMessages[$error_field]."
".$message; } } } else { $this->arErrorMessages[$error_field] = $message; } } else { $this->arErrorMessages[$error_field] = " Error in ".$error_field; } } function validateInput( $value, $validation, $error_field, $error_message, $min_length = false, $max_length = false, $required = false ) { $value = trim( $value ); $szErrorMessage = $error_message; $error = false; if( $required === true ) { // ***** check message exits ***** // if(!empty($this->arr_config)) { if(array_key_exists('REQUIRED',$this->arr_config)) { $required = $this->arr_config['REQUIRED']['text_Msg']; //echo $required; $is_required = preg_replace('/\{([a-zA-Z0-9_]+)\}/e', '$szErrorMessage', $required); } } //*******************// if( empty( $value ) && $value !== "0" && $value !== 0 ) { if( ( $validation != __VLD_CASE_BOOL__ || $validation != __VLD_CASE_STRICTBOOL__ ) && $value !== false ) { $error = true; $this->addError( $error_field, $is_required); return false; } } } if( !empty( $value ) ) { switch( $validation ) { case "NUMERIC": if( ( !is_numeric( $value ) ) ) { if(!empty($this->arr_config)) { if(array_key_exists('IS_NUMERIC',$this->arr_config)) { $required = $this->arr_config['IS_NUMERIC']['text_Msg']; $is_required = preg_replace('/\{([a-zA-Z0-9_]+)\}/e', '$szErrorMessage', $required); } } $error = true; $this->addError( $error_field, $is_required); return false; } elseif( $min_length !== false || $max_length !== false ) { if( $min_length !== false && strlen((string)$value) < $min_length ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be " . $min_length . " or more." ); return false; } if( $max_length !== false && strlen((string)$value) > $max_length ) { $error = true; if(!empty($this->arr_config)) { if(array_key_exists('GREATER_THAN',$this->arr_config)) { $required = $this->arr_config['GREATER_THAN']['text_Msg']; $is_required = preg_replace('/\{([a-zA-Z0-9_]+)\}/e', '$szErrorMessage', $required); } } $this->addError( $error_field, $is_required.$max_length . "." ); return false; } } break; case "CARD": if( ( !is_numeric( $value ) && $required === true ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be only numbers." ); return false; } elseif( $min_length !== false || $max_length !== false ) { if( $min_length !== false && strlen( (string)$value ) < $min_length ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be " . $min_length . " digits" ); return false; } if( $max_length !== false && strlen( (string)$value ) > $max_length ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be no more than " . $max_length . " digits." ); return false; } } break; case "ALPHA": if( !preg_match( "/^[a-z]+$/i", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be only letters." ); return false; } break; case "ALPHANUMERIC": if( !preg_match( "/^[a-z0-9\-\_]+$/i", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be only letters and numbers." ); return false; } break; case "URI": if( !preg_match( "/^[a-z0-9\-\_\.]+$/i", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be only letters and numbers." ); return false; } break; case "EMAIL": if( !preg_match( "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z0-9]{2,4})$/i", $value ) ) { $error = true; $this->addError( $error_field, "Sorry, that doesn't look like a valid email address - please check and try again." ); return false; } break; case "BOOL": if( !is_bool( $value ) && !( $value != "true" || $value != "false" ) && !( $value != "1" || $value != "0" ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be boolean value."); return false; } break; case "STRICTBOOL": if( !is_bool( $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be boolean value." ); return false; } break; case "ADDRESS": case "NAME": if( !preg_match( "/^[a-z0-9\,\.\#\-\_\s\']+$/i", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " can only be letters, numbers, spaces, underscores, dashes, periods, commas, and pound signs." ); return false; } break; case "URL": if( !preg_match( "/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be a valid web address." ); return false; } break; case "USERNAME": if(!preg_match('/[a-zA-Z]{0,1}[a-zA-Z0-9_-]$/i', $value)) { $error = true; $this->addError( $error_field, $szErrorMessage . " cannot contain any spaces or special characters." ); return false; } break; case "PASSWORD": if( !preg_match( "/^[\S]+$/i", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " cannot contain any spaces." ); return false; } break; case "DATE": if( !strtotime( $value ) || strtotime( $value ) == -1 ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be a valid date [ie. YYYY-MM-DD]." ); return false; } else { $value = strtotime( $value ); } break; case "PHONE": if( !preg_match( "/^[0-9\(\)\+]*$/", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be a valid phone number. Only numberals 0-9, and the characters + ( ) allowed." ); return false; } break; case "DOLLARS": case "MONEY_US": if( !preg_match( "/^[0-9]+(\.[0-9]{2})*$/", $value ) ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be a valid money format. (Ex. 00.00 )" ); return false; } break; case "CC_EXP": if( !preg_match( "/^[0-9]{2}[-][0-9]{2}$/", $value ) ) { $error = true; $this->error = true; $this->addError( $error_field, $szErrorMessage . " must be MM/YY." ); return false; } break; case "REDIRCT_URL": if( !preg_match( "/^[a-z0-9\-\_\.\?\&\=\/]+$/i", $value ) ) { $error = true; //$this->addError( $error_field, $szErrorMessage . " must be only letters and numbers and {/,-,_}." ); return false; } break; case "ANYTHING": break; default: $error = true; $this->addError( "error", "Unknown validation type. I was sent this type: " . $validation ); break; } } if( $min_length !== false && $validation == "NUMERIC" && $value!="" ) { if( $value < $min_length ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be " . $min_length . " or more." ); return false; } } if( $min_length !== false && $validation != "NUMERIC" && !empty( $value ) ) { if( strlen( $value ) < $min_length ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must be at least " . $min_length . " characters in length." ); return false; } } if( $max_length !== false && $validation != "NUMERIC" && !empty( $value ) ) { if( strlen( $value ) > $max_length ) { $error = true; $this->addError( $error_field, $szErrorMessage . " must not be longer than " . $max_length . " characters in length." ); return false; } } if( $error === true ) { $this->addError( "error", "Unknown error validating field. The field was: " . $error_field . ". Validation: " . $validation . ". Value: " . $value ); return false; } else { //return str_replace( "\$", "\\\$", $value ); return $value; } } function resetErrors() { $this->error = false; $this->arErrorMessages = array(); } function formatError( $message, &$container ) { $container .= str_replace( "{ERROR}", $message, __VLD_ERROR_DISPLAY__ ); } function logError( $error_field, $message, $error_type, $class_name, $function, $line, $error_severity="critical") { $error_severity = strtolower(trim($error_severity)); $class_name = strtolower(trim($class_name)); $function = trim($function); $line = (int)$line; $message = trim($message); $error_field = trim($error_field); $this->addError($error_field, $message); switch ($error_severity) { case "info": break; case "low": $error_severity = "info"; case "warning": break; case "medium": $log_file = "warning"; case "high": $log_file = "warning"; case "crit": $log_file = "critical"; break; case "critical": break; case "stdout": break; case "std_out": $log_file = "stdout"; break; case "command_line": $log_file = "stdout"; default: $log_file = "critical"; break; } $find_ary = array("{TIME}", "{SEVERITY}", "{ERROR_TYPE}", "{FILE}", "{FUNCTION}", "{LINE}", "{ERROR}"); $replace_ary = array(date(__LOG_DATE_FORMAT__, time()), strtoupper($error_severity), $error_type, $class_name, $function, $line, $message); $error_string = str_replace($find_ary, $replace_ary, __LOG_LINE_FORMAT__); $log_file = __APP_PATH_LOGS__."/".$error_severity.".log"; $log_file_class = __APP_PATH_LOG_CLASSES__."/".$class_name."_".$error_severity.".log"; if ($error_severity == "stdout") { echo $error_string; } else { $handle = fopen($log_file, "a+"); fwrite($handle, $error_string); fclose($handle); $handle = fopen ($log_file_class, "a+"); fwrite($handle, $error_string); fclose($handle); } return true; } function getErrorMessage($fieldName,$keyName) { if(!empty($this->arr_config)) { if(array_key_exists($keyName,$this->arr_config)) { $txt_msg = $this->arr_config[$keyName]['text_Msg']; //echo $required; $is_required = preg_replace('/\{([a-zA-Z0-9_]+)\}/e', '$fieldName', $txt_msg); return $is_required; } else { return NULL; } } else return NULL; } } ?>
Fatal error: Class 'Error' not found in /var/sites/public_html/classes/database.class.php on line 9