Ejemplo n.º 1
0
function forgotPwd()
{
    global $req;
    global $connection;
    global $module;
    $req->hasParams("email");
    $email = $req->getParam("email");
    $POST = array('email' => $email);
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('email', 'email', true, 2, 100, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $connection->close();
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Error: " . $errors);
    } else {
        $POST = $val->sanitized;
        $email = $module->escape($POST['email']);
        $output = $module->forgotPwd($email);
        if (is_bool($output)) {
            Res::sendInvalid($module->message);
        } else {
            $res = new Res();
            $res->send();
        }
    }
}
Ejemplo n.º 2
0
 public function dologinAction()
 {
     Db::connect();
     $bean = R::dispense('user');
     // the redbean model
     $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash'];
     \RedBeanFVM\RedBeanFVM::registerAutoloader();
     // for future use
     $fvm = \RedBeanFVM\RedBeanFVM::getInstance();
     $fvm->generate_model($bean, $required);
     //the magic
     R::store($bean);
     $val = new validation();
     $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false);
     $val->run();
     if (count($val->errors)) {
         Debug::r($val->errors);
         foreach ($val->errors as $error) {
             Notification::setMessage($error, Notification::TYPE_ERROR);
         }
         $this->redirect(Request::createUrl('login', 'login'));
     } else {
         Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS);
         Debug::r($val->sanitized);
         session::set('user', ['sanil']);
         $this->redirect(Request::createUrl('index', 'index'));
     }
 }
Ejemplo n.º 3
0
 public function _validate($data, $rules_array = array())
 {
     $val = new validation();
     $val->addSource($data);
     $val->AddRules($rules_array);
     $val->run();
     // exit();
     if (sizeof($val->errors) > 0) {
         $this->valid = false;
         return $val->errors;
     } else {
         $this->valid = true;
         return $val->sanitized;
     }
 }
Ejemplo n.º 4
0
 public static function validate()
 {
     $val = validation::forge();
     $val->add_field('Cname', 'カレッジ名', 'required');
     $val->add_field('Ckana', 'カレッジ名(カナ)', 'required');
     return $val;
 }
Ejemplo n.º 5
0
 /**
  * Short description of method instance
  *
  * @access public
  * @author Jean-Francois Levesque, <*****@*****.**>
  * @return void
  */
 public static function &instance()
 {
     if (!validation::$instance) {
         validation::$instance = new validation();
     }
     return validation::$instance;
 }
Ejemplo n.º 6
0
 public static function validate()
 {
     $val = validation::forge();
     $val->add_field('college', 'College', 'required');
     $val->add_field('Did', 'Depart(略称)', 'required');
     $val->add_field('Dname', 'Depart', 'required');
     $val->add_field('Dkana', 'Depart(カナ)', 'required');
     return $val;
 }
Ejemplo n.º 7
0
 public static function validate()
 {
     $val = validation::forge();
     //バリデーションフィールドの追加
     $val->add_field('cla', 'クラス', 'required|max_length[20]');
     $val->add_field('title', 'タイトル', 'required');
     $val->add_field('Pcontent', '内容', 'required|max_length[200]');
     return $val;
 }
Ejemplo n.º 8
0
 public static function validate()
 {
     $val = validation::forge();
     //バリデーションフィールドの追加
     $val->add_field('Galtuka', '学科', 'required');
     $val->add_field('class', 'クラス名', 'required');
     $val->add_field('classkana', 'クラス名(カナ)', 'required');
     return $val;
 }
Ejemplo n.º 9
0
 public static function validate()
 {
     $val = validation::forge();
     //バリデーションフィールドの追加
     $val->add_field('college', 'カレッジ', 'required');
     $val->add_field('Kname', 'カテゴリ名', 'required');
     $val->add_field('Kkana', 'カテゴリ名(カナ)', 'required');
     return $val;
 }
Ejemplo n.º 10
0
 public static function validate()
 {
     $val = validation::forge();
     //バリデーションフィールドの追加
     $val->add_field('username', 'ユーザID', 'required|max_length[9]');
     $val->add_field('name', 'ユーザ名', 'required|max_length[50]');
     $val->add_field('password', 'パスワード', 'required|min_length[4]|max_length[20]');
     $val->add_field('email', 'Eメール', 'required|valid_email');
     $val->add_field('class', 'クラス', 'required');
     return $val;
 }
Ejemplo n.º 11
0
 public static function validate_admin()
 {
     if (isset($_POST['submit'])) {
         $required_fields = array("username", "password");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("password" => 30);
         validation::validate_max_lengths($fields_with_max_lengths);
         return empty(validation::$errors) ? true : false;
     } else {
         return false;
     }
 }
Ejemplo n.º 12
0
function addUsers()
{
    global $req;
    global $connection;
    $req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
    $adminUName = $req->getParam("adminUName");
    $adminFName = $req->getParam("adminFName");
    $adminGender = $req->getParam("adminGender");
    $adminEMail = $req->getParam("adminEMail");
    $adminPassword = $req->getParam("adminPassword");
    $adminPhone = $req->getParam("adminPhone");
    $POST = array('adminUName' => $adminUName, 'adminFName' => $adminFName, 'adminGender' => $adminGender, 'adminEMail' => $adminEMail, 'adminPassword' => $adminPassword, 'adminPhone' => $adminPhone);
    $genderValues = array('m', 'f', 'u');
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('adminUName', 'string', true, 2, 50, true)->addRule('adminFName', 'string', true, 2, 50, true)->addRule('adminGender', 'string', true, 1, 1, true)->addRule('adminEMail', 'email', true, 5, 100, true)->addRule('adminPassword', 'string', true, 4, 35, true)->addRule('adminPhone', 'string', true, 4, 20, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Errors:" . $errors);
    } else {
        $POST = $val->sanitized;
        $adminTable = new adminTable($connection);
        $adminUName = $adminTable->escape($POST['adminUName']);
        $adminFName = $adminTable->escape($POST['adminFName']);
        $adminGender = $adminTable->escape($POST['adminGender']);
        $adminEMail = $adminTable->escape($POST['adminEMail']);
        $adminPassword = $adminTable->escape($POST['adminPassword']);
        $adminPhone = $adminTable->escape($POST['adminPhone']);
        $adminId = $adminTable->insertUsers($adminUName, $adminFName, $adminGender, $adminEMail, $adminPassword, $adminPhone);
        if (is_bool($adminId)) {
            Res::sendInvalid("Errors:" . $adminTable->message);
        } else {
            $res = new Res();
            $res->addData("adminId", $adminId);
            $res->send();
        }
    }
}
Ejemplo n.º 13
0
 function login($user, $pwd, $rem)
 {
     global $adminSession;
     global $adminCookieUser;
     global $adminCookiePassword;
     global $invalidUserIdOrPassword;
     $POST = array('user' => $user, 'pwd' => $pwd, 'rem' => $rem);
     $val = new validation();
     $val->addSource($POST);
     $val->addRule('user', 'string', true, 1, 35, true)->addRule('pwd', 'string', true, 1, 35, true)->addRule('rem', 'bool');
     $val->run();
     if (sizeof($val->errors) > 0) {
         $connection->close();
         $errors = implode(" <br/> ", $val->errors);
         return "Error: " . $errors;
     } else {
         $POST = $val->sanitized;
         $user = $this->escape($POST['user']);
         $pwd = $this->escape($POST['pwd']);
         $rem = $this->escape($POST['rem']);
         $adminTable = new adminTable($this->connection);
         $result = $adminTable->verifyAdminLogin($user, $pwd);
         if (is_bool($result)) {
             return $invalidUserIdOrPassword;
         } else {
             if (!isset($_SESSION)) {
                 session_start();
             }
             $_SESSION[$adminSession] = $result;
             if ($rem) {
                 setcookie($adminCookieUser, $user, time() + 10 * 365 * 24 * 60 * 60, "/");
                 setcookie($adminCookiePassword, $pwd, time() + 10 * 365 * 24 * 60 * 60, "/");
             }
             return true;
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * edit page according the passed page id
  * @param string $page_id
  * update session message
  */
 public static function edit_page($page_id)
 {
     global $dbo;
     if (isset($_POST['submit'])) {
         // validations
         $required_fields = array("menu_name", "position", "visible", "content");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("menu_name" => 200, "description" => 500, "content" => 2000);
         validation::validate_max_lengths($fields_with_max_lengths);
         if (empty(validation::$errors)) {
             // process form perform update
             $id = $page_id;
             $subject_id = (int) $_POST["belong_subject"];
             $menu_name = $dbo->mysql_prep($_POST["menu_name"]);
             // Escape all strings
             $position = (int) $_POST["position"];
             $visible = (int) $_POST["visible"];
             $home_page = (int) $_POST["home_display"];
             $archive = (int) $_POST["archive_display"];
             $description = $dbo->mysql_prep($_POST["description"]);
             //$content = str_replace("&nbsp", "", );
             $content = $dbo->mysql_prep($_POST["content"]);
             // perform database query
             $query = "UPDATE pages SET ";
             $query .= "subject_id = '{$subject_id}', ";
             $query .= "menu_name = '{$menu_name}', ";
             $query .= "position = {$position}, ";
             $query .= "visible = {$visible}, ";
             $query .= "home_page = {$home_page}, ";
             $query .= "archive = {$archive}, ";
             $query .= "description = '{$description}', ";
             $query .= "content = '{$content}' ";
             $query .= "WHERE id = {$id}";
             $query .= " LIMIT 1";
             $result = self::find_by_sql($query);
         }
         if (isset($result) && $dbo->affected_rows($result) >= 0) {
             // success
             $_SESSION["message"] = "Page Updated.";
             utility::redirect_to("manage_content.php?page={$id}");
         } else {
             // failure
             $_SESSION["message"] = "Page update failed.";
         }
     } else {
         // This is probably a GET request
     }
 }
Ejemplo n.º 15
0
 /**
  * Create a comment
  * no return value, update $_SESSION message
  */
 public static function create_comment()
 {
     global $dbo;
     global $current_page;
     if (isset($_POST['submit'])) {
         // validations
         $required_fields = array("author", "body");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("body" => 200);
         validation::validate_max_lengths($fields_with_max_lengths);
         if (empty(validation::$errors)) {
             // process form
             $page_id = $current_page['id'];
             $created = strftime("%Y-%m-%d %H-%M-%S", time());
             //	$created = time();	// store time stam or string
             $author = $dbo->mysql_prep($_POST["author"]);
             $body = $dbo->mysql_prep($_POST["body"]);
             // perform database query
             $query = "INSERT INTO comments (";
             $query .= " page_id, created, author, body";
             $query .= ") VALUES (";
             $query .= " {$page_id}, '{$created}', '{$author}', '{$body}'";
             $query .= ")";
             $result = $dbo->query($query);
             $dbo->confirm_query($result);
         }
         if (isset($result) && $dbo->affected_rows($result) >= 0) {
             // success
             $_SESSION["message"] = "comment created.";
             //utility::redirect_to("manage_admins.php");
         } else {
             // failure
             $_SESSION["message"] = "comment creation failed.";
         }
     } else {
         $_SESSION["message"] = "There is some problem.";
         // not a post submit
     }
 }
Ejemplo n.º 16
0
 /**
  * edit subject according to form submit
  * @param string $subject_id A field provide by user click edit button
  * 
  */
 public static function edit_subject($subject_id)
 {
     global $dbo;
     if (isset($_POST['submit'])) {
         // validations
         $required_fields = array("menu_name", "position", "visible");
         validation::validate_presentces($required_fields);
         $fields_with_max_lengths = array("menu_name" => 30);
         validation::validate_max_lengths($fields_with_max_lengths);
         if (empty(validation::$errors)) {
             // process form perform update
             $id = $subject_id;
             $menu_name = $dbo->mysql_prep($_POST["menu_name"]);
             // Escape all strings
             $position = (int) $_POST["position"];
             $visible = (int) $_POST["visible"];
             // perform database query
             $query = "UPDATE subjects SET ";
             $query .= "menu_name = '{$menu_name}', ";
             $query .= "position = {$position}, ";
             $query .= "visible = {$visible} ";
             $query .= "WHERE id = {$id}";
             $query .= " LIMIT 1";
             $result = $dbo->query($query);
         }
         if (isset($result) && $dbo->affected_rows($result) >= 0) {
             // success
             $_SESSION["message"] = "Subject Updated.";
             utility::redirect_to("manage_content.php");
         } else {
             // failure
             $_SESSION["message"] = "Subject updit failed.";
         }
     } else {
         // This is probably a GET request
     }
     // end: if(isset($_POST['submit']))
 }
Ejemplo n.º 17
0
                 if ($users) {
                     $managerCourse->add(new Course(array('name' => $v1->sanitized['name'], 'description' => $v1->sanitized['desc'], 'pictureId' => isset($v1->sanitized['pictureId']) ? $v1->sanitized['pictureId'] : '', 'categories' => $cats, 'authors' => $users)));
                 } else {
                     $error_course_add = $tr->__("Please select at least one author");
                 }
             } else {
                 $error_course_add = $tr->__("Please select at least one category");
             }
         }
     } else {
         $error_course_add = $tr->__("Please select a category");
     }
 }
 if (isset($_POST['remove'])) {
     if (isset($_POST['id']) && !empty($_POST['id'])) {
         $v1 = new validation();
         $rules = array();
         $v1->addSource($_POST['id']);
         for ($i = 0; $i < count($_POST['id']); ++$i) {
             $rules[] = array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '10000', 'trim' => true);
         }
         $v1->AddRules($rules);
         $v1->run();
         foreach ($v1->sanitized as $id) {
             if ($managerCourse->hasActivities($id)) {
                 $v1->errors['HasLesson'] = $tr->__('The course you want to remove is attached to one or more lessons. Please, first delete these lessons');
                 break;
             }
         }
         if (sizeof($v1->errors) > 0) {
             $error_course_remove = $v1->getMessageErrors();
Ejemplo n.º 18
0
                $mailbody = $artical;
                $headers = "MIME-Version: 1.0\r\n";
                $headers .= "Content-type: text/html\r\n";
                $headers .= FROMEMAILADDRESS;
                @mail(base64_decode($sel_project_backer_user['emailAddress']), $subject, $mailbody, $headers);
            }
        }
        $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => "Update Added Successfully");
        redirect(SITE_URL . "browseproject/" . $_GET['projectId'] . "/" . Slug($sel_project_name['projectTitle']) . "/&update=" . $num_of_rows . "#b");
    }
}
if (isset($_POST['submitUpdate']) && isset($_GET['projectId']) && $_GET['projectId'] != '' && isset($_POST['operation']) && $_POST['operation'] != '') {
    //echo $_GET['projectId'];exit;
    //echo 'edit';exit;
    extract($_POST);
    $obj = new validation();
    $obj->add_fields($updateTitle, 'req', 'Please Enter Title Of Update');
    $error = $obj->validate();
    if ($_POST['content'] == '') {
        $error .= "Please Enter Content" . '<br>';
    }
    if ($_POST['content'] != '') {
        $sel_projectupdateno = mysql_fetch_assoc($con->recordselect("SELECT count(*) as total FROM projectupdate WHERE projectId='" . $_GET['projectId'] . "'"));
        $num_of_rows = $sel_projectupdateno['total'] + 1;
        $currentTime = time();
        $textcontent = unsanitize_string($content);
        //$textcontent= trim(strip_tags($content));
        //echo 'abc'.$updateTitle;exit;
        //echo 'aaaa'.$updateTitle;exit;
        //echo "UPDATE projectupdate SET updateTitle='".sanitize_string($updateTitle)."' AND updateDescription='".$textcontent."' WHERE projectupdateId='".$_GET['projectId']."'";exit;
        $con->update("UPDATE projectupdate SET updateDescription='' WHERE projectupdateId='" . $_GET['projectId'] . "'");
Ejemplo n.º 19
0
/**
 * Проверка данных из формы.
 */
function tu_validation(&$tservice, $is_exist_feedbacks = 0)
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_categories.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/validation.php';
    $errors = array();
    $validator = new validation();
    $tservices_categories = new tservices_categories();
    //---
    //$tservice->title = trim(htmlspecialchars(InPost('title'),ENT_QUOTES,'cp1251'));
    //$tservice->title = antispam(__paramInit('string', NULL, 'name', NULL, 60, TRUE));
    $tservice->title = sentence_case(__paramInit('html', null, 'title', null, 100, true));
    $title = trim(stripslashes(InPost('title')));
    if (!$validator->required($title)) {
        $errors['title'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif (!$validator->symbols_interval($title, 4, 100)) {
        $errors['title'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 100);
    }
    //---
    $tservice->price = intval(trim(InPost('price')));
    if (!$validator->is_natural_no_zero($tservice->price)) {
        $errors['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE;
    } elseif (!$validator->greater_than_equal_to($tservice->price, 300)) {
        $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_GREATER_THAN_EQUAL_TO, '300 р.');
    } elseif (!$validator->less_than_equal_to($tservice->price, 999999)) {
        $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_LESS_THAN_EQUAL_TO, '999 999 р.');
    }
    //---
    $days_db_id = intval(trim(InPost('days_db_id')));
    if (!$validator->is_natural_no_zero($days_db_id) || !in_array($days_db_id, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 21, 30, 45, 60, 90))) {
        $errors['days'] = validation::VALIDATION_MSG_FROM_LIST;
        $days_db_id = 1;
    }
    $tservice->days = $days_db_id;
    //---
    //Если есть отзывы то не даем изменить категорию
    if (!(InPost('action') == 'save' && $is_exist_feedbacks > 0)) {
        $category_id = intval(trim(InPost('category_db_id')));
        $parent_category_id = $tservices_categories->getCategoryParentId($category_id);
        if ($parent_category_id === false) {
            $errors['category'] = validation::VALIDATION_MSG_CATEGORY_FROM_LIST;
        } else {
            $tservice->category_id = $category_id;
            //$this->property()->parent_category_id = $parent_category_id;
        }
    }
    //---
    $str_tags = trim(preg_replace('/\\s+/s', ' ', strip_tags(InPost('tags'))));
    $tags = strlen($str_tags) > 0 ? array_unique(array_map('trim', explode(',', $str_tags))) : array();
    $tags = array_filter($tags, function ($el) {
        $len = strlen(stripslashes($el));
        return $len < 80 && $len > 2;
    });
    $tags_cnt = count(array_unique(array_map('strtolower', $tags)));
    $tags = array_map(function ($value) {
        return htmlspecialchars($value, ENT_QUOTES, 'cp1251');
    }, $tags);
    $tservice->tags = $tags;
    if (!$validator->required($str_tags)) {
        $errors['tags'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif ($tags_cnt > 10) {
        $errors['tags'] = sprintf(validation::VALIDATION_MSG_MAX_TAGS, 10);
    }
    //---
    $videos = __paramInit('array', null, 'videos', array());
    $videos = is_array($videos) ? array_values($videos) : array();
    if (count($videos)) {
        $tservice->videos = null;
        foreach ($videos as $key => $video) {
            if ($validator->required($video)) {
                $_video_data = array('url' => $video, 'video' => false, 'image' => false);
                //$_video = $validator->video_validate($video);
                $_video = $validator->video_validate($video);
                $is_error = true;
                if ($_video) {
                    $_video_data['url'] = $_video;
                    if ($_video_meta = $validator->video_validate_with_thumbs($_video, 0)) {
                        $_video_data = array_merge($_video_data, $_video_meta);
                        $is_error = false;
                    }
                }
                if ($is_error) {
                    $errors['videos'][$key] = validation::VALIDATION_MSG_BAD_LINK;
                }
                $tservice->videos[$key] = $_video_data;
            }
        }
    }
    //---
    //$tservice->description = trim(htmlspecialchars(InPost('description'),ENT_QUOTES, "cp1251"));
    //$description = trim(InPost('description'));
    $tservice->description = trim(__paramInit('html', null, 'description', null, 5000, true));
    $description = trim(stripslashes(InPost('description')));
    if (!$validator->required($description)) {
        $errors['description'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif (!$validator->symbols_interval($description, 4, 5000)) {
        $errors['description'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000);
    }
    //---
    //$tservice->requirement = trim(htmlspecialchars(InPost('requirement'),ENT_QUOTES, "cp1251"));
    //$requirement = trim(InPost('requirement'));
    $tservice->requirement = trim(__paramInit('html', null, 'requirement', null, 5000, true));
    $requirement = trim(stripslashes(InPost('requirement')));
    if (!$validator->required($requirement)) {
        $errors['requirement'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif (!$validator->symbols_interval($requirement, 4, 5000)) {
        $errors['requirement'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000);
    }
    //---
    $extra = __paramInit('array', null, 'extra', array());
    $extra = is_array($extra) ? array_values($extra) : array();
    $total_extra_price = 0;
    if (count($extra)) {
        $key = 0;
        $tservice->extra = null;
        foreach ($extra as $el) {
            if (isset($el['title'], $el['price'], $el['days_db_id'])) {
                $el['title'] = stripslashes($el['title']);
                $title = trim(htmlspecialchars($el['title'], ENT_QUOTES, 'cp1251'));
                $title_native = trim($el['title']);
                $price = trim($el['price']);
                if (!$validator->required($title_native) && !$validator->required($price)) {
                    continue;
                }
                $is_title = $validator->min_length($title_native, 4) && $validator->max_length($title_native, 255);
                $is_price = $validator->is_integer_no_zero($price) && $validator->numeric_interval($price, -999999, 999999);
                if (!$is_price) {
                    $errors['extra'][$key]['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE;
                }
                if (!$is_title) {
                    $errors['extra'][$key]['title'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 255);
                }
                $days = trim($el['days_db_id']);
                $is_days = $validator->is_natural($days) && $validator->less_than_equal_to($days, 5);
                if (!$is_days) {
                    $errors['extra'][$key]['days'] = sprintf(validation::VALIDATION_MSG_INTERVAL, '0', '5 дней');
                    $days = 1;
                }
                $price = intval($price);
                $days = intval($days);
                $tservice->extra[$key] = array('title' => $title, 'price' => $price, 'days' => $days);
                ++$key;
                if ($price < 0) {
                    $total_extra_price += $price;
                }
            }
        }
    }
    //---
    $tservice->is_express = 'f';
    $tservice->express_price = 0;
    $tservice->express_days = 1;
    if (InPost('express_activate') == 1 && $tservice->days > 1) {
        $express = InPost('express');
        $price = trim($express['price']);
        if (!$validator->is_natural_no_zero($price) || !$validator->less_than_equal_to($price, 999999)) {
            $errors['express']['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE;
        }
        $days_db_id = intval(trim($express['days_db_id']));
        if (!$validator->is_natural_no_zero($days_db_id) || !in_array($days_db_id, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 21, 30, 45, 60, 90))) {
            $errors['express']['days'] = validation::VALIDATION_MSG_FROM_LIST;
            $days_db_id = 1;
        }
        $tservice->is_express = 't';
        $tservice->express_price = intval($price);
        $tservice->express_days = $days_db_id;
    }
    //---
    //Проверка общей суммы с учетом скидок, опций (срочность не учитываю так как она выбирается по желанию)
    if (!isset($errors['price']) && !$validator->greater_than_equal_to($tservice->price + $total_extra_price, 300)) {
        $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_MIN_TOTAL, '300 р.');
    }
    //---
    //TODO: Есть проблема с контроллом выпадающего списка
    // он не отрабатывает новое значение укзанное по умолчанию
    if (!in_array(intval(InPost('distance')), array(1, 2))) {
        $errors['distance'] = validation::VALIDATION_MSG_FROM_RADIO;
    } elseif (intval(InPost('distance')) == 2) {
        $city_db_id = intval(InPost('city_db_id'));
        $city = new city();
        if ($city_db_id <= 0 || !$city->getCityName($city_db_id)) {
            $errors['distance'] = validation::VALIDATION_MSG_CITY_FROM_LIST;
        } else {
            $tservice->city = intval(InPost('city_db_id'));
            $tservice->is_meet = 't';
        }
    } else {
        $tservice->is_meet = 'f';
    }
    //---
    $tservice->agree = InPost('agree') == 1 ? 't' : 'f';
    if ($tservice->agree === 'f') {
        $errors['agree'] = validation::VALIDATION_MSG_ONE_REQUIRED;
    }
    //---
    if (in_array(InPost('active'), array(0, 1))) {
        $tservice->active = intval(InPost('active')) == 1 ? 't' : 'f';
        if ($tservice->is_angry) {
            $tservice->active = 't';
        }
    }
    //---
    //Вырезаем слеши если ошибка
    if (count($errors) > 0) {
        $attrs = array('title', 'description', 'requirement', 'tags');
        foreach ($attrs as $attr) {
            if (is_array($tservice->{$attr})) {
                foreach ($tservice->{$attr} as &$value) {
                    $value = stripslashes($value);
                }
            } else {
                $tservice->{$attr} = stripslashes($tservice->{$attr});
            }
        }
    }
    return $errors;
}
<?php

/*************************************************************************************************************
#Description : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
$path = LIST_ROOT . '/images/home/banner/';
#Code to Fetch page category data
#END
$publish = 1;
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $obj->add_fields($tabtitle, 'req', 'Please Enter Tab Title');
    if ($id == "") {
        $obj->add_fields($tabtitle, 'uniquevalue', 'Please Enter Unique Tab Title', array('content_page', "tab_title='" . mysql_real_escape_string($tabtitle) . "' and page_name= 'Logistique'"));
    } else {
        $obj->add_fields($tabtitle, 'uniquevalue', 'Please Enter Unique Tab Title', array('content_page', "tab_title='" . mysql_real_escape_string($tabtitle) . "' and page_name= 'Logistique' and id!=" . $id));
    }
    $obj->add_fields($content, 'req', 'Please Enter Content');
    if (!isset($_GET['id'])) {
        $obj->add_fields($_FILES['file']['name'], 'req', 'Please Upload Banner Image');
    }
    $obj->add_fields($_FILES['file'], 'ftype=jpg,gif,png', 'Please Upload Valid Banner Image');
    if ($_FILES['file']['name'] != "") {
        $obj->add_fields($_FILES['file'], "imgwh=251,207", "Please Upload Valid Banner Image(251pxX207px)");
Ejemplo n.º 21
0
                echo $tr->__("This name already exist") . " !!";
            } else {
                echo "true";
            }
        }
    }
} else {
    if (!defined('ABSPATH')) {
        exit;
    }
    global $tr;
    $managerDomain = new DomainManager();
    $error_domain_add = "";
    $error_domain_remove = "";
    if (isset($_POST)) {
        $validation = new validation();
    }
    if (isset($_POST['add'])) {
        $validation->addSource($_POST);
        $validation->AddRules(array('name' => array('type' => 'string', "required" => true, 'min' => '1', 'max' => '200', 'trim' => true), 'desc' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true)));
        $validation->run();
        if (sizeof($validation->errors) > 0) {
            $error_domain_add = $validation->getMessageErrors();
        } else {
            $managerDomain->add(new Domain(array('name' => $validation->sanitized['name'], 'description' => $validation->sanitized['desc'])));
            if ($managerDomain->isError()) {
                $error_domain_add = $tr->__("This name already exist");
            }
        }
    }
    if (isset($_POST['remove'])) {
<?php

/*************************************************************************************************************
#Coder         : Kapil Verma
#Description : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
#Code to Fetch page category data
#END
$publish = 1;
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $obj->add_fields($content, 'req', 'Please Enter Content');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please fill all required fields.</font>";
    } else {
        /*save welcome section content*/
        $dataArr = array('content' => $content);
        $banner_insert = $obj_setting->update('editor_rows', $dataArr, "id=1");
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/home/welcome.php";</script>';
        exit;
    }
}
Ejemplo n.º 23
0
<?php

/*************************************************************************************************************

#Coder       : Kapil Verma

*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj = new validation();
if (isset($submit) && $submit != "" && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($name, 'req', 'Please Enter Name');
    $obj->add_fields($position, 'req', 'Please Enter Status Number');
    $obj->add_fields($short, 'req', 'Please Enter Short Description');
    $obj->add_fields($desc, 'req', 'Please Enter Description');
    $error = $obj->validate();
    $devicesInfo = $objCommon->read('status', "name='{$name}' and id != '{$id}'");
    if (mysql_num_rows($devicesInfo)) {
        $error .= "Name already exists";
    }
    $devicesInfo = $objCommon->read('status', "position='{$position}' and id != '{$id}'");
    if (mysql_num_rows($devicesInfo)) {
        $error .= "<br/>Status Number already defined";
    }
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $dataArr = array('name' => ucfirst($name), 'active' => $active, 'short_description' => $short, 'long_description' => $desc, 'position' => $position);
        $update_Article = $objCommon->update("status", $dataArr, "id = '{$id}'");
        unset($objCommon);
Ejemplo n.º 24
0
	if($_GET['page']=='')
	{
		$page=1;
	}
	else
	{
		$page = $_GET['page'];
	}*/
$perpage = 10;
require_once "pagination.php";
if ($_SESSION["admin_user"] == "" || $_SESSION["admin_role"] == 1) {
    redirect(SITE_ADM . "login.php");
}
if (isset($_POST['action'])) {
    extract($_POST);
    $obj = new validation();
    $obj->add_fields($project_title, 'req', 'Please enter Project Title');
    $obj->add_fields($project_title, 'min=4', 'Project Title should be atleast 4 characters long');
    $obj->add_fields($project_title, 'max=25', 'Project Title should not be more than 25 characters long');
    $obj->add_fields($short_blurb, 'req', 'Name should not be more than 25 characters long');
    $obj->add_fields($short_blurb, 'min=4', 'Short Blurb should be atleast 4 characters long');
    $obj->add_fields($short_blurb, 'max=50', 'Short Blurb should not be more than 25 characters long');
    $obj->add_fields($project_location, 'req', 'Please enter Location');
    $obj->add_fields($project_description, 'req', 'Please Enter Project Description');
    $obj->add_fields($project_description, 'min=4', 'Project Description should be atleast 4 characters long');
    $obj->add_fields($project_description, 'max=250', 'Project Description should not be more than 25 characters long');
    $error = $obj->validate();
}
if (isset($_POST['action']) && $_POST['action'] == 'edit') {
    extract($_POST);
    if ($description == '') {
Ejemplo n.º 25
0
<?php

/*************************************************************************************************************

#Coder       : Keshav Sharma


*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_block = new common();
$obj = new validation();
$obj_handle = new Handle();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
/* Get list of all brands */
$brand_list = $obj_block->getbrand();
if (isset($submit) && $submit != "" && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($model_name, 'req', 'Please Enter Model');
    $obj->add_fields($brand_id, 'req', 'Please Select Brand');
    $obj->add_fields($year, 'req', 'Please Enter Year');
    $obj->add_fields($year, 'num', 'Please Enter vaild Year');
    $obj->add_fields($prix, 'req', 'Please Enter Prix');
    $error = $obj->validate();
    //--------------------------------------------//
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $image = '';
        if ($_FILES["image"]["name"]) {
Ejemplo n.º 26
0
$tbl_nm = "smallprojectamount";
$id = "id";
$target_file = "standardlimit";
if (!isset($_GET) || !isset($_GET['page']) || $_GET['page'] < 1) {
    $_GET['page'] = 1;
}
require_once "pagination.php";
if ($_SESSION["admin_user"] == "") {
    header('location: login.php');
}
if ($_SESSION["admin_role"] == 1) {
    header('location: home.php');
}
if (isset($_POST['action'])) {
    extract($_POST);
    $obj = new validation();
    //$obj->add_fields($standardaffiliated, 'req', 'This field is required.');
    $obj->add_fields($standardcommission, 'req', 'This field is required.');
    //$obj->add_fields($standardwithdrawl, 'req', 'This field is required.');
    //$obj->add_fields($standardaffiliated, 'num,max=6', 'Please Enter only number');
    $obj->add_fields($standardcommission, 'num,max=6', 'Please Enter only number');
    //$obj->add_fields($standardwithdrawl, 'num,max=6', 'Please Enter only number');
    //$obj->add_fields($wlimit, 'lte=1', 'Please Enter valid number');
    $error = $obj->validate();
}
if (isset($_GET) && isset($_GET['action']) && $_GET['action'] == 'edit') {
    $std_edit_qry = mysql_fetch_assoc($con->recordselect("SELECT * FROM smallprojectamount"));
}
// Form Post code start
if (isset($_POST['action']) && ($_POST['action'] == 'add' || $_POST['action'] == 'edit')) {
    extract($_POST);
Ejemplo n.º 27
0
<?php

/*************************************************************************************************************

#Coder       : Manoj Pandit


*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_block = new common();
$obj = new validation();
$obj_handle = new Handle();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
/* Get list of all brands */
if (isset($submit) && $submit != "" && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($brand_name, 'req', 'Please Enter Brand Name');
    $obj->add_fields($year, 'req', 'Please Enter Year');
    $obj->add_fields($year, 'num', 'Please Enter vaild Year');
    $obj->add_fields($prix, 'req', 'Please Enter Prix');
    $obj->add_fields($_FILES["image"]["name"], 'req', 'Please Upload Product Image');
    if (!empty($_FILES["image"]["name"])) {
        $file_type = strtolower(end(explode(".", $_FILES["image"]["name"])));
        if ($file_type == "png" || $file_type == "jpeg" || $file_type == "jpg" || $file_type == "gif") {
            $valid_file_type = 'yeap';
        } else {
            $valid_file_type = '';
        }
        $obj->add_fields($valid_file_type, 'req', 'Please upload image file only.');
Ejemplo n.º 28
0
 /**
  * Tests Validation::check()
  *
  * @test
  * @covers Validation::check
  * @covers Validation::rule
  * @covers Validation::rules
  * @covers Validation::errors
  * @covers Validation::error
  * @dataProvider provider_check
  * @param array   $array            The array of data
  * @param array   $rules            The array of rules
  * @param array   $labels           The array of labels
  * @param boolean $expected         Is it valid?
  * @param boolean $expected_errors  Array of expected errors
  */
 public function test_check($array, $rules, $labels, $expected, $expected_errors)
 {
     $validation = new Validation($array);
     foreach ($labels as $field => $label) {
         $validation->label($field, $label);
     }
     foreach ($rules as $field => $field_rules) {
         foreach ($field_rules as $rule) {
             $validation->rule($field, $rule[0], $rule[1]);
         }
     }
     $status = $validation->check();
     $errors = $validation->errors(TRUE);
     $this->assertSame($expected, $status);
     $this->assertSame($expected_errors, $errors);
     $validation = new validation($array);
     foreach ($rules as $field => $rules) {
         $validation->rules($field, $rules);
     }
     $validation->labels($labels);
     $this->assertSame($expected, $validation->check());
 }
Ejemplo n.º 29
0
 function sanitize_mf(&$param)
 {
     if (empty($this->field_from_parent)) {
         foreach ($this->relations as $rel_info) {
             if ($rel_info['type'] == 'M-1') {
                 $this->field_from_parent = $rel_info['link_child'];
             }
         }
     }
     $minimum_rows = 0;
     foreach ($this->relations as $rel_info) {
         if ($rel_info['type'] == 'M-1') {
             $minimum_rows = $rel_info['minimum'];
         }
     }
     $lst_error = '';
     require_once 'validation_class.php';
     require_once 'char_set_class.php';
     $validator = new validation();
     //Check if some required fields are left blank in the submitted rows.
     foreach ($this->fields as $field_name => $field_details) {
         $dd_field_name = $field_name;
         $field_name = 'cf_' . $this->table_name . '_' . $field_name;
         $label = $field_details['label'];
         $required = $field_details['required'];
         if ($required && $dd_field_name != $this->field_from_parent) {
             if (isset($param[$field_name])) {
                 $lst_error .= $validator->check_if_null($label, $param[$field_name]);
             }
         }
     }
     foreach ($param as $unclean => $unclean_value) {
         $prefix_length = strlen('cf_' . $this->table_name . '_');
         $unclean_no_prefix = substr($unclean, $prefix_length, strlen($unclean));
         if (isset($this->fields[$unclean_no_prefix])) {
             $length = $this->fields[$unclean_no_prefix]['length'];
             $data_type = $this->fields[$unclean_no_prefix]['data_type'];
             $attribute = $this->fields[$unclean_no_prefix]['attribute'];
             $control_type = $this->fields[$unclean_no_prefix]['control_type'];
             $label = $this->fields[$unclean_no_prefix]['label'];
             $char_set_method = $this->fields[$unclean_no_prefix]['char_set_method'];
             $char_set_allow_space = $this->fields[$unclean_no_prefix]['char_set_allow_space'];
             $extra_chars_allowed = $this->fields[$unclean_no_prefix]['extra_chars_allowed'];
             $trim = $this->fields[$unclean_no_prefix]['trim'];
             $valid_set = $this->fields[$unclean_no_prefix]['valid_set'];
             //Apply trimming if specified.
             //Triming should be applied to $unclean_value for purposes of further filtering/checking,
             //and then also applied to $param[$unclean] so as to actually affect the POST variable.
             //Note: since this is an mf-specialized method, we are dealing with arrays. Count first
             $num_items = 0;
             if (is_array($param[$unclean])) {
                 $num_items = count($param[$unclean]);
             }
             for ($a = 0; $a < $num_items; ++$a) {
                 if (strtolower($trim) == 'trim') {
                     $unclean_value[$a] = trim($unclean_value[$a]);
                     $param[$unclean][$a] = trim($unclean_value[$a]);
                 } elseif (strtolower($trim) == 'ltrim') {
                     $unclean_value[$a] = ltrim($unclean_value[$a]);
                     $param[$unclean][$a] = ltrim($unclean_value[$a]);
                 } elseif (strtolower($trim) == 'rtrim') {
                     $unclean_value[$a] = rtrim($unclean_value[$a]);
                     $param[$unclean][$a] = rtrim($unclean_value[$a]);
                 }
                 //Check length
                 if ($length > 0) {
                     if (strlen($unclean_value[$a]) > $length) {
                         $lst_error .= "The field '{$label}' (in line #" . ($a + 1) . ") can only accept {$length} characters.<br>";
                     }
                 }
                 $validator = new validation();
                 //If there is a set of valid inputs, check if 'unclean' conforms to it.
                 if (count($valid_set) > 1) {
                     if ($unclean_value == '') {
                         //No need to check because no value was submitted.
                     } else {
                         $validator->check_data_set($unclean_value[$a], $valid_set, TRUE);
                         if ($validator->validity == FALSE) {
                             $lst_error .= $validator->error_message . $label . '<br>';
                         }
                     }
                 } else {
                     //If a char set method is given, check 'unclean' for invalid characters
                     if ($char_set_method != '') {
                         $cg = new char_set();
                         $cg->allow_space = $char_set_allow_space;
                         $cg->{$char_set_method}($extra_chars_allowed);
                         $allowed = $cg->allowed_chars;
                         $validator->field_name = $label;
                         $validator->validate_data($unclean_value[$a], $data_type, $allowed);
                         if ($validator->validity == FALSE) {
                             $cntInvalidChars = count($validator->invalid_chars);
                             if ($cntInvalidChars == 1) {
                                 $lst_error .= "Invalid character found in '{$label}' in line #" . ($a + 1) . ": " . cobalt_htmlentities($validator->invalid_chars[0]) . '<br>';
                             } elseif ($cntInvalidChars > 1) {
                                 $lst_error .= "Invalid characters found in '{$label}' in line #" . ($a + 1) . ": ";
                                 for ($b = 0; $b < $cntInvalidChars; ++$b) {
                                     $lst_error .= cobalt_htmlentities($validator->invalid_chars[$b]) . ' ';
                                 }
                                 $lst_error .= '<br>';
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->lst_error = $lst_error;
     return $this;
 }
Ejemplo n.º 30
0
<?php

/*************************************************************************************************************

#Coder       : Kapil Verma

*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj = new validation();
if (isset($submit) && $submit != "" && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($title, 'req', 'Please Enter Title');
    $obj->add_fields($fees, 'req', 'Please Enter Amount');
    $obj->add_fields($fees, 'currency', 'Please Enter a valid Amount');
    //	$obj->add_fields($desc, 'req', 'Please Enter Description');
    $error = $obj->validate();
    $devicesInfo = $objCommon->read('fees', "title='{$title}' and id != '{$id}' ");
    if (mysql_num_rows($devicesInfo)) {
        $error .= "Title already exists";
    }
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $dataArr = array('title' => ucfirst($title), 'status' => $status, 'fees' => number_format($fees, 2));
        $update_Article = $objCommon->update("fees", $dataArr, "id = {$id}");
        unset($objCommon);
        $_SESSION['msg'] = 'Successfully Updated';
        echo '<script>location.href="' . DEFAULT_URL . '/admin/fees/index.php";</script>';
        exit;
    }