public function validate($file = '', $rule = '', $encode = 'utf8', $VAL = null)
 {
     q4mController::useHelper('validator');
     if ($file == '') {
         $file = str_replace('Model', '', get_class($this)) . 'Rules.php';
     }
     if ($rule == '') {
         $rule = str_replace('Model', '', get_class($this));
     }
     if (file_exists(_SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php')) {
         include_once _SETTINGS_DIR_ . $file . 'Rules.php';
         if (!isset(${$rule}) || !count(${$rule})) {
             q4mSystem::haltOnError('The requested rule "' . ${$rule} . '" is empty in ', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
             exit;
         }
     } else {
         q4mSystem::haltOnError('The file is not found', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
         exit;
     }
     $rules = ${$rule};
     $vc = new validator($rules, $encode, $VAL);
     if (count($vc->RULES)) {
         foreach ($vc->RULES as $key => $SV) {
             $vc->validate($key);
         }
     }
     if (count($vc->ERRORS)) {
         return $vc->ERRORS;
     } else {
         return false;
     }
 }
Example #2
0
   $country_list = (require_once $current_dir . "/protected/components/CountryCode.php");
   $forms = new forms();
   $currency_list = array('AUD' => "AUD-$", 'CAD' => "CAD-$", 'CNY' => "CNY-¥", 'EUR' => "EUR-€", 'HKD' => "HKD-$", 'JPY' => "JPY-¥", 'MXN' => "MXN-$", 'USD' => "USD-$", 'NZD' => "NZD-$");
   $currency_list = array_flip($currency_list);
   ?>
 
 <?php 
   if ($_SERVER['REQUEST_METHOD'] == 'POST') {
       ?>
 <?php 
       $err = '';
       $data = $_POST;
       $req = array('website_title' => "Website title is required", 'admin_country_set' => "Country is required", 'website_address' => "Address is required", 'website_contact_phone' => "Phone is required", 'website_contact_email' => "Email is required", 'admin_currency_set' => "Currency is required", 'username' => "Username is required", 'password' => "Password is required");
       $validator = new validator();
       $validator->required($req, $data);
       if ($validator->validate()) {
           $admin_currency_set = explode("-", $data['admin_currency_set']);
           $db_con = $_SESSION['kr_install_data'];
           $table_prefix = isset($db_con['db_table_prefix']) ? $db_con['db_table_prefix'] : '';
           $table_prefix = !empty($table_prefix) ? $table_prefix : "mt_";
           require_once $current_dir . "/protected/config/table_structure.php";
           require_once $current_dir . "/install/class.MySQL.php";
           echo "<p class=\"uk-icon-chevron-right\"> Connecting to database..</p>";
           //$db = new Db( 'mysql', $db_con['db_host'], $db_con['db_name'], $db_con['db_username'],$db_con['db_pass'] );
           $db = new MySQL($db_con['db_name'], $db_con['db_username'], $db_con['db_pass'], $db_con['db_host']);
           echo "<div>Connection [ok]</div>";
           echo "<p class=\"uk-icon-chevron-right\"> Saving information ...</p>";
           $params = array('website_title' => $data['website_title'], 'admin_country_set' => $data['admin_country_set'], 'website_address' => $data['website_address'], 'website_contact_phone' => $data['website_contact_phone'], 'website_contact_email' => $data['website_contact_email'], 'admin_currency_set' => $admin_currency_set[0]);
           $truncate = "TRUNCATE TABLE " . $table_prefix . "option";
           $db->raw($truncate);
           try {
Example #3
0
<?php

// Require app files
require 'app/User.php';
require 'app/Validator.php';
require 'app/Helper.php';
//Set data and validation rules
$rules = array('email' => 'required|email', 'password' => 'required|min:8');
$data = array('email' => '*****@*****.**', 'password' => '12346789', 'foo' => 'bar');
// Run validation
$validator = new validator();
if ($validator->validate($data, $rules) == true) {
    //Validation passed. Set user values.
    $joost = new User($data);
    $joost->email = '*****@*****.**';
    $joost->password = '******';
    //var_dump($joost->email);
    //var_dump($joost->password);
    //Dump user
    // var_dump($joost);
    echo $joost;
} else {
    // Validation failed. Dump validation errors.
    var_dump($validator->getErrors());
}
Example #4
0
<head>
<title>Gmail</title>

<script type="text/javascript" src="../js/registration.js"></script> 
<script type="text/javascript" src="../js/common.js"></script> 
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body>
	<h1 align="center">Gmail</h1>
	<h2 align="center">signup</h2>
	<?php 
if (!empty($_POST)) {
    require_once 'function.php';
    $errors = array();
    $validatorObj = new validator($_POST);
    $validatorObj->validate();
    if ($validatorObj->getIsValid()) {
        // create user object for OOP manipulation
        $userObj = new User($_POST);
    } else {
        $errors = $validatorObj->getErrors();
    }
}
if (!empty($errors)) {
    ?>
<p> errors occured:please check</p>
<p class="error">
<?php 
    if (is_array($errors)) {
        foreach ($errors as $val) {
            echo $val . '<br />';