function test_it_can_validate_with_safe_text_rule_with_valid_input() { Validator::loadStaticRules(); $validator = new \Valitron\Validator(array('name' => 'Darshan')); $validator->rule('safeText', 'name'); $this->assertTrue($validator->validate()); }
private static function ingredient_validator($attributes) { $validator = new Valitron\Validator($attributes); $validator->rule('required', array('ingredient_name', 'ingredient_type', 'price')); $validator->rule('numeric', 'price'); return $validator; }
public function signin() { $email = $this->f3->get('POST.email'); $password = $this->f3->get('POST.password'); $v = new Valitron\Validator(array('Email' => $email, 'Password' => $password)); $v->rule('required', ['Email', 'Password']); $v->rule('email', 'Email'); if ($v->validate()) { $account = new Account($this->db); $pwd = md5($password); $acc = $account->select("*", "email='$email' and password='******'"); if ($acc) { $this->f3->set('SESSION.acc', $acc); $acc = $acc[0]; $acc['lastlogin'] = date('Y-m-d H:i:s'); $account->update($acc,'id='.$acc['id']); $this->f3->reroute('/dashboard'); } else { $this->f3->set('email', $email); $this->f3->set('errors', array(array('Login fail, wrong username or password'))); echo Template::instance()->render('index.html'); } } else { $this->f3->set('email', $email); $this->f3->set('errors', $v->errors()); echo Template::instance()->render('index.html'); } }
public function postPostNew($request, $response, $args) { if (!$this->app->auth()->isLoggedIn()) { $response = new \RedirectResponse('/unauthorised'); return $response; } $template = $this->twig->loadTemplate('post/new.twig'); $validator = new \Valitron\Validator(array('title' => $this->app->input()->post('title'), 'body' => $this->app->input()->post('body'), 'status' => $this->app->input()->post('status'))); $validator->rule('required', ['title', 'body', 'status']); $validator->rule('integer', ['status']); if ($validator->validate()) { $post = \Model::factory('App\\Models\\Post')->create(); $post->title = $this->app->input()->post('title'); $post->body = $this->app->input()->post('body'); $post->created_at = date('Y-m-d H:i:s'); $post->updated_at = date('Y-m-d H:i:s'); $post->status = $this->app->input()->post('status'); if ($post->save()) { $response = new RedirectResponse('/'); return $response; } else { $response->setContent($template->render(['errors' => [['Unable to create post']], 'input' => $this->app->input()->all('post')])); return $response; } } else { $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')])); return $response; } }
/** * Update User Configuration * * @param string $username * @param string $password0 * @param string $password1 * @param string $email * @param string $language * @param optional string $firstname * @param optional string $lastname * * @author Nikita Rousseau */ public function updateUserConfig($username, $password0, $password1, $email, $language, $firstname = '', $lastname = '') { $form = array('username' => $username, 'password0' => $password0, 'password1' => $password1, 'email' => $email, 'language' => $language); $errors = array(); // array to hold validation errors $data = array(); // array to pass back data $dbh = Core_DBH::getDBH(); // Get Database Handle // Get languages $languages = parse_ini_file(CONF_LANG_INI); $languages = array_flip(array_values($languages)); // validate the variables ====================================================== $v = new Valitron\Validator($form); $rules = ['required' => [['username'], ['password0'], ['password1'], ['email'], ['language']], 'alphaNum' => [['username']], 'lengthMin' => [['username', 4], ['password0', 8]], 'equals' => [['password0', 'password1']], 'email' => [['email']], 'in' => [['language', $languages]]]; $labels = array('username' => 'Username', 'password0' => 'Password', 'password1' => 'Confirmation Password', 'email' => 'Email', 'language' => 'Language'); $v->rules($rules); $v->labels($labels); $v->validate(); $errors = $v->errors(); // Apply the form ============================================================== if (empty($errors)) { // Database update $db_data['username'] = $form['username']; $db_data['password'] = Core_AuthService::getHash($form['password0']); $db_data['email'] = $form['email']; $db_data['lang'] = $form['language']; if (!empty($firstname)) { $db_data['firstname'] = $firstname; } if (!empty($lastname)) { $db_data['lastname'] = $lastname; } $authService = Core_AuthService::getAuthService(); $uid = Core_AuthService::getSessionInfo('ID'); foreach ($db_data as $key => $value) { $sth = $dbh->prepare("\tUPDATE " . DB_PREFIX . "user\n\t\t\t\t\t\t\t\t\t\tSET " . $key . " = :" . $key . "\n\t\t\t\t\t\t\t\t\t\tWHERE user_id = '" . $uid . "';"); $sth->bindParam(':' . $key, $value); $sth->execute(); } // Reload Session $authService->rmSessionInfo(); $authService->setSessionInfo($uid, $db_data['username'], $db_data['firstname'], $db_data['lastname'], $db_data['lang'], BGP_USER_TEMPLATE); $authService->setSessionPerms(); $this->rmCookie('LANG'); } // return a response =========================================================== // response if there are errors if (!empty($errors)) { // if there are items in our errors array, return those errors $data['success'] = false; $data['errors'] = $errors; $data['msgType'] = 'warning'; $data['msg'] = T_('Bad Settings!'); } else { $data['success'] = true; } // return all our data to an AJAX call return $data; }
public function save(){ $name = $this->f3->get('POST.name'); $email = $this->f3->get('POST.email'); $comments = $this->f3->get('POST.comments'); $v = new Valitron\Validator(array('Name' => $name,'Email'=>$email,'Comments'=>$comments)); $v->rule('required', ['Name','Email','Comments']); $v->rule('email',[Email]); if ($v->validate()) { $contact = new Contact($this->db); $data = array( 'name' => $name, 'email' => $email, 'comments' => $comments, 'contact_date' => date('Y-m-d H:i:s') ); $contact->insert($data); $response = array( 'status' => true, 'message' => 'Your message saved!' ); }else{ $response = array( 'status' => false, 'errors' => $v->errors() ); } echo json_encode($response); }
protected function validate($queryParams) { $v = new \Valitron\Validator($queryParams); $v->rules($this->rules); if (!$v->validate()) { throw new ValidationFailed($v->errors()); } }
public function validate_distance($input) { $errors = array(); $validator = new Valitron\Validator(array('input' => $input)); $validator->rule('numeric', 'input'); if (!$validator->validate()) { $errors[] = 'Etäisyys ei ollut sopiva!'; } return $errors; }
public function update($id) { if (!empty($_POST)) { $data['post'] = $_POST; //enabling validation $v = new Valitron\Validator($_POST); // Input array $v->rule('required', 'username'); $v->rule('required', 'name'); $v->rule('required', 'email'); $v->rule('required', 'location'); $v->rule('required', 'gender'); $v->rule('email', 'email'); if ($v->validate()) { $data['result'] = $this->model->updateUser($_POST, "users", $id); } else { // Errors $data['errors'] = $v->errors(); } } else { $data['post'] = $this->model->getUserById($id); } $data['user_id'] = $id; $data['ep_title'] = "Update User"; //setting title name $data['view_page'] = "users/update.php"; //controller view page $data['ep_header'] = $GLOBALS['ep_header']; //header view (Also Ex: "header.php") $data['ep_footer'] = $GLOBALS['ep_footer']; //footer view return $data; }
function validate($data) { $v = new \Valitron\Validator($data); $v->rule('required', 'email')->message('Email is required'); $v->rule('email', 'email')->message('Email Address is not a valid email address.'); if ($v->validate()) { return null; } else { return $v->errors(); } }
public function postContact($request, $response, $args) { $template = $this->twig->loadTemplate('contact.twig'); $validator = new \Valitron\Validator(array('name' => $this->app->input()->post('name'), 'email' => $this->app->input()->post('email'), 'message' => $this->app->input()->post('message'))); $validator->rule('required', ['name', 'email', 'message']); $validator->rule('email', 'email'); if ($validator->validate()) { die('I would send an email or store in a db now'); } else { $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')])); return $response; } }
function validate($array, $rules) { require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php'; $v = new Valitron\Validator($array); // Input array from $_POST/$_GET/Custom array $v->rules($rules); $v->labels(array('fname' => 'First Name', 'lname' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'Email address', 'dob' => 'Date of Birth', 'streetAddress' => 'Street Address')); if (!$v->validate()) { foreach ($v->errors() as $field => $messages) { echo implode(', ', $messages) . ". "; } die; } }
public static function store() { $params = $_POST; $v = new Valitron\Validator($_POST); $v->rule('required', 'nimi')->message('{field} pitää antaa')->label('Nimi'); $v->rule('required', 'ainekset')->message('Valitse vähintään yksi {field}')->label('Aines'); $v->rule('lengthMin', 'nimi', 1)->message('{field} pitää olla 1-50 merkkiä pitkä')->label('Nimi'); $v->rule('lengthMax', 'nimi', 50)->message('{field} pitää olla 1-50 merkkiä pitkä')->label('Nimi'); $v->rule('lengthMax', 'tyyppi', 30)->message('{field} saa olla korkeintaan 30 merkkiä pitkä')->label('Tyyppi'); $v->rule('lengthMax', 'lasi', 30)->message('{field} nimi saa olla korkeintaan 30 merkkiä pitkä')->label('Lasin'); if (!isset($params['alkoholiton'])) { $params['alkoholiton'] = 0; } $params['tyovaiheet'] = " "; $drink = new Drink(array('nimi' => $params['nimi'], 'tyyppi' => $params['tyyppi'], 'alkoholiton' => $params['alkoholiton'], 'lasi' => $params['lasi'], 'kuvaus' => $params['kuvaus'], 'tyovaiheet' => $params['tyovaiheet'])); if ($v->validate()) { $ainekset = $params['ainekset']; $drink->save($ainekset); Redirect::to('/drinks/' . $drink->drinkki_id, array('message' => 'Resepti lisätty tietokantaan')); } else { if (!isset($params['ainekset'])) { $ainekset = array(); } else { $ainekset = $params['ainekset']; } $aineslista = Aines::all(); View::make('drinks/addnew.html', array('errors' => $v->errors(), 'ainekset' => $ainekset, 'aineslista' => $aineslista, 'attributes' => $drink)); } }
/** * Gets the country information by id * * @param array $params Array with params, id is required * * @return array Name and locale of the country */ public function read($params) { $v = new Valitron\Validator($params); $v->rule('required', 'id'); if ($v->validate()) { if ($this->empty_values($params, array('id')) === true) { $sql = "SELECT name, locale FROM country WHERE id = :id"; $query = $this->db->prepare($sql); $parameters = array(':id' => $params['id']); $query->execute($parameters); $result = $query->fetch(); return array('name' => $result->name, 'locale' => $result->locale); } else { return $this->indentifier_error(); } } else { return $this->param_error(); } }
public function updateAction() { $v = new Valitron\Validator($_POST); $v->rule('required', array('store_name', 'county', 'street', 'country_code_type', 'ebay_website', 'postal_code', 'currency_code', 'item_location', 'dispatch_time', 'listing_duration', 'listing_type', 'condition_type', 'PAYMENT', 'RETURN_POLICY', 'SHIPPING', 'shipping_service', 'shippingservice_priority', 'shippingservice_cost', 'shippingservice_additionalcost')); if ($v->validate()) { $id = 1; $store_name = $_POST['store_name']; $street = $_POST['street']; $county = $_POST['county']; $country_code_type = $_POST['country_code_type']; $ebay_website = $_POST['ebay_website']; $postal_code = $_POST['postal_code']; $category_mapping = !empty($_POST['category_mapping']) ? 1 : 0; $category_prefill = !empty($_POST['category_prefill']) ? 1 : 0; $optimal_picturesize = !empty($_POST['optimal_picturesize']) ? 1 : 0; $out_of_stock_control = !empty($_POST['out_of_stock_control']) ? 1 : 0; $get_it_fast = !empty($_POST['get_it_fast']) ? 1 : 0; $include_prefilled = !empty($_POST['include_prefilled']) ? 1 : 0; $currency_code = $_POST['currency_code']; $item_location = $_POST['item_location']; $dispatch_time = $_POST['dispatch_time']; $listing_duration = $_POST['listing_duration']; $listing_type = $_POST['listing_type']; $condition_type = $_POST['condition_type']; $payment_policy = $_POST['PAYMENT']; $return_policy = $_POST['RETURN_POLICY']; $shipping_policy = $_POST['SHIPPING']; $shipping_service = $_POST['shipping_service']; $shippingservice_priority = $_POST['shippingservice_priority']; $shippingservice_cost = $_POST['shippingservice_cost']; $shippingservice_additionalcost = $_POST['shippingservice_additionalcost']; if ($query = $this->app->db->prepare("UPDATE store_settings SET store_name = ?, county = ?, street = ?, \n \tcountry_code_type = ?, ebay_website = ?, postal_code = ?, category_mapping = ?, category_prefill = ?, \n \tcurrency_code = ?, item_location = ?, dispatch_time = ?, listing_duration = ?, listing_type = ?, \n \tcondition_type = ?, optimal_picturesize = ?, out_of_stock_control = ?, get_it_fast = ?, include_prefilled = ?, \n \tshipping_profile = ?, return_profile = ?, payment_profile = ?, shipping_service = ?,\n \tshippingservice_priority = ?, shippingservice_cost = ?, shippingservice_additionalcost = ? \n \tWHERE id = ?")) { $query->bind_param("ssssssiississsiiiissssiddi", $store_name, $county, $street, $country_code_type, $ebay_website, $postal_code, $category_mapping, $category_prefill, $currency_code, $item_location, $dispatch_time, $listing_duration, $listing_type, $condition_type, $optimal_picturesize, $out_of_stock_control, $get_it_fast, $include_prefilled, $shipping_policy, $return_policy, $payment_policy, $shipping_service, $shippingservice_priority, $shippingservice_cost, $shippingservice_additionalcost, $id); $query->execute(); $this->app->flash('message', array('type' => 'success', 'text' => 'Settings was updated!')); $this->app->redirect('/tester/ebay_trading_api/settings'); } } else { $this->app->flash('form', $_POST); $this->app->flash('message', array('type' => 'danger', 'text' => 'Please fix the following errors', 'data' => $v->errors())); $this->app->redirect('/tester/ebay_trading_api/settings'); } }
function validate($data) { $v = new \Valitron\Validator($data); $v->rule('required', 'password')->message('Password is required.'); $v->rule('required', 'new_password')->message('New Password is required.'); $v->rule('required', 'new_password_confirmation')->message('New Password Confirmation is required.'); $v->rule('regex', 'new_password', '/^\\S*(?=\\S{6,})(?=\\S*[a-z])(?=\\S*[A-Z])(?=\\S*[\\d])(?=\\S*[\\W]*)\\S*$/')->message('New Password contains invalid characters.'); $v->rule('equals', 'new_password_confirmation', 'new_password')->message('New Password Confirmation must match with New Password'); if ($v->validate()) { return null; } else { return $v->errors(); } }
public function createAction() { $v = new Valitron\Validator($_POST); $v->rule('required', array('title', 'category_id', 'price', 'quantity', 'brand', 'description')); $v->rule('numeric', 'price'); $v->rule('integer', 'quantity'); if ($v->validate()) { $store_settings_result = $this->app->db->query("SELECT payment_profile, return_profile, shipping_profile, out_of_stock_control, get_it_fast, category_prefill,\n category_mapping, condition_type, country_code_type, currency_code, dispatch_time, optimal_picturesize,\n listing_duration, listing_type, item_location, postal_code, store_name, county,\n street, ebay_website, shippingservice_priority, shipping_service, shippingservice_cost, shippingservice_additionalcost\n FROM store_settings WHERE id = 1"); $store_settings = $store_settings_result->fetch_object(); $response = $this->app->ebay->addItem($store_settings, $_POST); if ($response->Ack == 'Success') { if ($query = $this->app->db->prepare("INSERT INTO products SET title = ?, category_id = ?, price = ?, qty = ?, brand = ?, description = ?")) { $title = $_POST['title']; $category_id = $_POST['category_id']; $price = $_POST['price']; $qty = $_POST['quantity']; $brand = $_POST['brand']; $description = $_POST['description']; $query->bind_param("ssdiss", $title, $category_id, $price, $qty, $brand, $description); $query->execute(); $this->app->flash('message', array('type' => 'success', 'text' => 'Product was created!')); } } else { $long_message = json_decode(json_encode($response->Errors->LongMessage), true); $this->app->flash('message', array('type' => 'danger', 'text' => $long_message[0])); } } else { $this->app->flash('form', $_POST); $this->app->flash('message', array('type' => 'danger', 'text' => 'Please fix the following errors', 'data' => $v->errors())); } $this->app->redirect('/tester/ebay_trading_api/products/new'); }
public static function update($aines_id) { $params = $_POST; $v = new Valitron\Validator($_POST); $v->rule('required', 'nimi')->message('{field} pitää antaa')->label('Nimi'); $v->rule('required', 'alkpitoisuus')->message('{field} pitää antaa')->label('Alkoholipitoisuus'); $v->rule('lengthMax', 'nimi', 50)->message('{field} ei saa olla yli 50 merkkiä pitkä')->label('Nimi'); $v->rule('numeric', 'alkpitoisuus')->message('{field} pitää olla numeerinen kokonaisluku tai desimaaliluku erotettuna pisteellä'); $v->rule('min', 'alkpitoisuus', 0)->message('{field} pitää olla 0-100')->label('Alkoholipitoisuus'); $v->rule('max', 'alkpitoisuus', 100)->message('{field} pitää olla 0-100')->label('Alkoholipitoisuus'); $aines = new Aines(array('nimi' => $params['nimi'], 'alkpitoisuus' => $params['alkpitoisuus'])); if ($v->validate()) { $aines->update($aines_id); Redirect::to('/ingredients/' . $aines->aines_id, array('message' => 'Ainesta muokattu onnistuneesti')); } else { $aines->aines_id = $aines_id; View::make('ingredients/edit_ingredient.html', array('errors' => $v->errors(), 'attributes' => $aines)); } }
public static function update_user($id) { $params = $_POST; $v = new Valitron\Validator($params); $v->rule('required', 'reader_name'); $v->rule('lengthMin', 'reader_name', 3); $v->rule('lengthMax', 'reader_name', 15); $v->rule('required', 'reader_password'); $v->rule('lengthMin', 'reader_password', 4); $v->rule('lengthMax', 'reader_password', 15); $attributes = array('id' => $id, 'reader_name' => $params['reader_name'], 'reader_password' => $params['reader_password']); if ($v->validate()) { $reader = new Reader($attributes); $reader->update(); Redirect::to('/reader/' . $reader->id, array('message' => 'Tietojasi on muokattu onnistuneesti.')); } }
function validate($data) { $v = new \Valitron\Validator($data); $v->rule('required', ['name', 'email', 'message']); $v->rule('email', 'email'); $v->rule('max', 'email', 80); if ($v->validate()) { return null; } else { return $v->errors(); } }
public static function save() { $params = $_POST; $v = new Valitron\Validator($params); $v->rule('required', 'content'); $v->rule('lengthMin', 'content', 1); $v->rule('required', 'site-id'); $v->rule('numeric', 'site-id'); if ($v->validate()) { $kommentti = new Kommentti(array('comment_content' => $params['content'], 'site_id' => $params['site-id'], 'kayttaja_id' => $_SESSION['user'])); $kommentti->save(); Redirect::to('/site/show_site/' . $params['site-id'], array('message' => 'Kommentti lisätty')); } else { $site = Site::find($params['site-id']); $kommentit = Kommentti::getAllComments($params['site-id']); View::make('site/show_site.html', array('site' => $site, 'kommentit' => $kommentit, 'errors' => $v->errors())); } }
public function postLogin($request, $response, $args) { $template = $this->twig->loadTemplate('login.twig'); $validator = new \Valitron\Validator(array('email' => $this->app->input()->post('email'), 'password' => $this->app->input()->post('password'))); $validator->rule('required', ['email', 'password']); $validator->rule('email', 'email'); $validator->rule('lengthMin', 'password', 6); if ($validator->validate()) { if ($this->app->auth()->login($this->app->input()->post('email'), $this->app->input()->post('password'))) { $response = new RedirectResponse('/'); return $response; } else { $response->setContent($template->render(['errors' => [['Unable to login, username and/or password may be incorrect']], 'input' => $this->app->input()->all('post')])); return $response; } } else { $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')])); return $response; } }
//for move within OPERATION page $param2 = http_build_query(array_diff_key($_GET, $ignore)); if (!empty($param2)) { $param2 = '?' . $param2 . '&'; } else { $param2 = '?'; } $conf_id = (int) getgpcvar("conf_id", "G"); $back_page = "system_config.php"; $cur_page = cur_page(); ///////////////////////////////////////////////////////////////// if (isset($_POST['title'])) { $conf_id = (int) getgpcvar("conf_id", "P"); ##/ Validate Fields include_once '../../includes/form_validator.php'; $form_v = new Valitron\Validator($_POST); $rules = ['required' => [['title'], ['c_value']], 'lengthMax' => [['title', 100], ['c_value', 50]]]; $form_v->labels(array('title' => 'Title', 'c_value' => 'Value')); $form_v->rules($rules); $form_v->validate(); $fv_errors = $form_v->errors(); //var_dump("<pre>", $_POST, $fv_errors); die(); #- if (!is_array($fv_errors) || empty($fv_errors) || count($fv_errors) <= 0) { if ($conf_id > 0) { ###/ Updating Database #/ system_config $sql_tb1 = "UPDATE system_config SET title='{$_POST['title']}', c_value='{$_POST['c_value']}'\n WHERE id='{$conf_id}'"; mysql_exec($sql_tb1, 'save'); #- $_SESSION["CUSA_ADMIN_MSG_GLOBAL"] = array(true, 'The Site data has been successfully Updated');
<?php include '../main/config.php'; $db = new PDO("mysql:host={$dbhost};dbname={$dbname};charset=utf8", $dbuser, $dbpass); $v = new Valitron\Validator($_POST); $v->rule('accepted', ['isPlugName', 'isPlugFam', 'isPlugInfo', 'isPlugOut', 'isService', 'isCvss', 'isVulnPub', 'isExploit', 'isSynopsis', 'isDescription', 'isSolution', 'isSeeAlso', 'isCve', 'isBid', 'isOsvdb', 'isCert', 'isIava', 'isCWE', 'isMS', 'isSec', 'isEdb', 'isAffected', 'isNotes', 'cover']); //$v->rule('numeric', ['scan_start1', 'scan_end1', 'scan_start2', 'scan_end2']); //$v->rule('slug', ['agency1', 'agency2']); //$v->rule('regex',['report_name1', 'report_name2'],'/[a-zA-Z]+/'); $v->rule('length', 1, ['critical', 'high', 'medium', 'low', 'info']); $v->rule('integer', ['critical', 'high', 'medium', 'low', 'info']); if (!$v->validate()) { print_r($v->errors()); exit; } $critical = $_POST["critical"]; $high = $_POST["high"]; $medium = $_POST["medium"]; $low = $_POST["low"]; $info = $_POST["info"]; $sArray = array($critical, $high, $medium, $low, $info); $sql = "CREATE temporary TABLE nessus_tmp_severity (severity VARCHAR(255), INDEX ndx_severity (severity))"; $stmt = $db->prepare($sql); $stmt->execute(); foreach ($sArray as $s) { if ($s != "") { $sql = "INSERT INTO nessus_tmp_severity (severity) VALUES (?)"; $stmt = $db->prepare($sql); $stmt->execute(array($s)); } }
$success = false; if (@in_array('success', $url_comp) != false) { $success = true; } $member_id = $user_id; ///////////////////////////////////////////////////////////////////// #/ Process Post if (isset($_POST['email_add'])) { #/ Check Attempts include_once '../includes/check_attempts.php'; //if(check_attempts(7)==false){ //update_attempt_counts(); redirect_me($seo_tag); //} ##/ Validate Fields include_once '../includes/form_validator.php'; $form_v = new Valitron\Validator($_POST); $rules = ['required' => [['email_add'], ['screen_name'], ['first_name'], ['last_name'], ['identify_by'], ['country_code'], ['state'], ['zip'], ['city'], ['address_ln_1']], 'lengthMin' => [['screen_name', 5]], 'lengthMax' => [['email_add', 150], ['screen_name', 50], ['first_name', 65], ['middle_name', 20], ['last_name', 50], ['company_name', 100], ['identify_by', 50], ['country_code', 2], ['state', 50], ['zip', 20], ['city', 200], ['address_ln_1', 200], ['address_ln_2', 150], ['phone_number', 20]], 'email' => [['email_add']], 'slug' => [['screen_name']]]; $form_v->labels(array('email_add' => 'Email Address', 'identify_by' => 'Identification', 'country_code' => 'Country')); $form_v->rules($rules); $form_v->validate(); $fv_errors = $form_v->errors(); //var_dump("<pre>", $_POST, $fv_errors); die(); #- #/ Check if Email Add exists if (!is_array($fv_errors) || empty($fv_errors) || count($fv_errors) <= 0) { $chk_user = mysql_exec("SELECT email_add FROM users WHERE email_add='{$_POST['email_add']}' and id!='{$user_id}'", 'single'); if (!empty($chk_user)) { $fv_errors[] = array('This Email Address is already used, please try a different one!'); } } #/ Check if screen_name Add exists
<?php include_once 'phpincluds.php'; include_once 'phpsettings.php'; header("content-type: application/json"); //проверка капчи if (!isset($_POST['g-recaptcha-response']) || !captchaCheck($_POST['g-recaptcha-response'])) { exit(createMessageJson(false, 'Не прошла проверка Каптчи')); } //проверка введённых данных, используем модуль $v = new Valitron\Validator($_POST); $v->rule('required', ['name', 'email', 'text']); $v->rule('email', 'email'); if (!$v->validate()) { exit(createMessageJson(false, 'Неверные введённые данные')); } //echo( $_post ); $body = ''; //foreach($_POST as $key => $value){ $body .= '<p><strong>Name</strong>' . $_POST['name'] . '</p>'; $body .= '<p><strong>Email</strong>' . $_POST['email'] . '</p>'; $body .= '<p><strong>Text</strong>' . $_POST['text'] . '</p>'; //} $res = sendEmail($_POST['name'], $_POST['email'], 'Сообщение с сайта visermort.ru', $body); if ($res) { exit(createMessageJson(false, $res)); } else { exit(createMessageJson(true, 'Ваше сообщение отправлено!')); }
* * Open eClass is an open platform distributed in the hope that it will * be useful (without any warranty), under the terms of the GNU (General * Public License) as published by the Free Software Foundation. * The full license can be read in "/info/license/license_gpl.txt". * * Contact address: GUnet Asynchronous eLearning Group, * Network Operations Center, University of Athens, * Panepistimiopolis Ilissia, 15784, Athens, Greece * e-mail: info@openeclass.org * ======================================================================== */ $require_current_course = TRUE; $require_editor = true; include '../../include/baseTheme.php'; if (isset($_POST['submitCat'])) { $v = new Valitron\Validator($_POST); $v->rule('required', array('questionCatName')); $v->labels(array('questionCatName' => "{$langTheField} {$langTitle}")); if ($v->validate()) { $q_cat_name = $_POST['questionCatName']; if (isset($_GET['modifyCat'])) { $q_cat_id = $_GET['modifyCat']; Database::get()->query("UPDATE exercise_question_cats SET question_cat_name = ?s " . "WHERE question_cat_id = ?d", $q_cat_name, $q_cat_id); Session::Messages($langEditCatSuccess, 'alert-success'); } else { $PollActive = 1; $q_cat_id = Database::get()->query("INSERT INTO exercise_question_cats\n (question_cat_name, course_id)\n VALUES (?s, ?d)", $q_cat_name, $course_id)->lastInsertID; Session::Messages($langNewCatSuccess, 'alert-success'); } redirect_to_home_page("modules/exercise/question_categories.php?course={$course_code}"); } else {
$v1->rule('integer', ['critical', 'high', 'medium', 'low', 'info']); if (!$v1->validate()) { print_r($v1->errors()); exit; } $nodeArray = $_POST["node"]; foreach ($nodeArray as $key => $value) { if ($value == "REMOVE") { unset($nodeArray[$key]); } } $sql = "CREATE temporary TABLE nexpose_tmp_nodes (node_address VARCHAR(255), node_device_id VARCHAR(255), INDEX ndx_node_address (node_address))"; $stmt = $db->prepare($sql); $stmt->execute(); foreach ($nodeArray as $nA) { $v2 = new Valitron\Validator(array('node' => $nA)); $v2->rule('regex', 'node', '/^([\\w.-])+$/i'); if (!$v2->validate()) { print_r($v2->errors()); exit; } $temp_nodes_array = explode(":", $nA); $sql = "INSERT INTO nexpose_tmp_nodes (node_address, node_device_id) VALUES (?,?)"; $stmt = $db->prepare($sql); $stmt->execute(array($temp_nodes_array[0], $temp_nodes_array[1])); } $tags = $_POST["tags"]; $sql = "CREATE temporary TABLE nexpose_tmp_tags (tag VARCHAR(255), INDEX ndx_tag (tag))"; $stmt = $db->prepare($sql); $stmt->execute(); foreach ($tags as $t) {
<?php //Custom Report 1 //this custom report is for my current employer. If it helps you than cool. include '../main/config.php'; $db = new PDO("mysql:host={$dbhost};dbname={$dbname};charset=utf8", $dbuser, $dbpass); $v = new Valitron\Validator($_POST); $v->rule('accepted', ['isSSLIssues', 'isRDPIssues', 'isSMBIssues', 'isCleartext', 'isAllIssues']); $v->rule('slug', 'agency'); if (!$v->validate()) { print_r($v->errors()); exit; } $agency_temp = explode("xxxxXXXXxxxx", $_POST["agency"]); $agency = $agency_temp[0]; $scan_id = $agency_temp[1]; $severity = $_POST["severity"]; date_default_timezone_set('UTC'); $date = date('mdYHis'); $myDir = getcwd() . "/csvfiles/"; $vuln_table_filename = $agency . "_vuln_table_" . $date . ".csv"; $vuln_table_file = $myDir . $vuln_table_filename; $fh_vuln = fopen($vuln_table_file, 'w') or die("can't open {$vuln_table_file} for writing. Please check folder permissions."); $exposure_rating_filename = $agency . "_exposure_table_" . $date . ".csv"; $exposure_rating_file = $myDir . $exposure_rating_filename; $fh_exposure = fopen($exposure_rating_file, 'w') or die("can't open {$exposure_rating_file} for writing. Please check folder permissions."); $vuln_cat = $_POST["vuln_cat"]; if ($vuln_cat == "isAllIssues") { $isAllIssues = "yes"; } $vuln_id_array = array();
$result = $sth->fetch(PDO::FETCH_ASSOC); $dateme = strtotime($result['GDD_START_DATE']); $futuredate = strtotime('-1 year'); $isit = strtotime($dateme) < strtotime('-1 year'); #echo $dateme."\r"; #echo $futuredate."\r"; if (strtotime($result['GDD_START_DATE']) > strtotime('-1 year')) { // echo "score"; } else { $GDDSTATUS = "invalid"; } } if ($_SERVER["REQUEST_METHOD"] == "POST") { // Set Error Fields $regex1 = "/^[a-zA-Z]+(?:[\\s-][a-zA-Z]+)*\$/"; $v = new Valitron\Validator($_POST); $v->rule('required', ['HIVENAME', 'HIVEID', 'BEEKEEPERID', 'YARDID', 'CITY', 'STATE', 'COUNTRY'], 1)->message('{field} is required'); $v->rule('slug', ['HIVENAME', 'POWER', 'INTERNET', 'STATUS', 'COMPUTER']); $v->rule('integer', ['YARDID', 'BEEKEEPERID'], 1)->message('{field} can only be an integer'); $v->rule('alphaNum', ['HIVEID'], 1)->message('{field} can only be alpha numeric'); $v->rule('lengthmin', ['HIVEID'], 1)->message('{field} is required to be 13 characters'); $v->rule('lengthmax', ['HIVENAME', 'HIVEID', 'BEEKEEPERID', 'YARDID', 'CITY', 'STATE', 'COUNTRY', 'LATITUDE', 'LONGITUDE', 'ZIP'], 40); $v->rule('regex', ['CITY', 'STATE', 'COUNTRY'], $regex1); $v->rule('numeric', ['BEEKEEPERID', 'YARDID', 'GDD_BASE_TEMP', 'ZIP']); } //Check input for badness function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data);