function testIsAlphaNum() { $this->assertEquals(TRUE, is_alphanum(ord('a')), "Assert 'a' is alphanun"); $this->assertEquals(TRUE, is_alphanum(ord('Z')), "Assert 'Z' is alphanun"); $this->assertEquals(TRUE, is_alphanum(ord('0')), "Assert '0' is alphanun"); $this->assertEquals(TRUE, is_alphanum(ord('9')), "Assert '9' is alphanun"); }
$mysqlTime = $mysqlTime > 0 ? floor($mysqlTime) : ceil($mysqlTime); $mysqlSecs = $mysqlTime * 60 * 60; if (isset($_GET['ajax'])) { if (isset($_GET['page']) && is_numeric($_GET['page'])) { $page = $_GET['page']; } if (isset($_GET['size']) && is_numeric($_GET['size'])) { $size = $_GET['size']; } if (isset($_GET['filter']) && $_GET['filter'] != 'filter') { preg_match('/filter\\[([0-9])\\]=([a-z0-9]*)/', $_GET['filter'], $filters); if (!empty($filters)) { if (isset($filters[1]) && is_numeric($filters[1])) { $filterCol = $filters[1]; } if (isset($filters[2]) && is_alphanum($filters[2])) { $filter = $filters[2]; } } } if (isset($_GET['sortby'])) { preg_match('/column\\[([0-9])\\]=([0-9])/', $_GET['sortby'], $orders); if (!empty($orders)) { if (isset($orders[1]) && is_numeric($orders[1])) { $sortByCol = $orders[1]; } if (isset($orders[2]) && is_numeric($orders[2])) { $sortBy = $orders[2] == 0 ? 'ASC' : 'DESC'; } } }
public function anyAdd() { $confirm = $this->input->post('confirm'); $form = $this->input->post('form'); $errors = []; if (!empty($confirm) && $confirm == 'ok') { $validator = new \Wasp\Validator($form, $this->validation); if (!$validator->checkAll()) { $errors = $validator->getMessages(); } $check_user = $this->users->getByEmail($form['email']); $user_data = []; if (!empty($check_user->id)) { if (!isset($errors['email']) || !is_array($errors['email'])) { $errors['email'] = []; } $errors['email'][] = 'Такой пользователь уже есть'; } if (!is_alphanum($form['passwd1']) || !is_alphanum($form['passwd2']) || wasp_strlen($form['passwd1']) > 16 || wasp_strlen($form['passwd1']) < 6 || wasp_strlen($form['passwd2']) > 16 || wasp_strlen($form['passwd2']) < 6 || $form['passwd1'] != $form['passwd2']) { if (!isset($errors['passwd1']) || !is_array($errors['passwd1'])) { $errors['passwd1'] = []; } $errors['passwd1'][] = 'Неверное указан пароль'; } if (array_count($errors) == 0) { $current_user = $this->auth->getAuthUser(); $group_level = $this->users->getGroupLevel($form['group_id']); $passwd = password_crypt($form['passwd1']); $user_data['email'] = $form['email']; $user_data['password'] = $passwd; if ($this->users->groupIdExists($form['group_id']) && ($group_level < $current_user->group->level || $this->auth->isRoot())) { $user_data['group_id'] = intval($form['group_id']); $user_data['blocked'] = intval($form['blocked']); } if ($this->auth->isAdmin()) { foreach ($form as $key => $val) { if (!array_key_isset($key, $user_data)) { $user_data[$key] = $val; } } } $id = $this->users->create($user_data); redirect(['controller' => 'users', 'method' => 'edit', 'id' => $id, 'message' => 'Пользователь успешно добавлен в систему.']); } } $this->layout->useThemeCss('datepicker.css')->useThemeJs('bootstrap-datepicker.js', false); return $this->ui->assign('errors', $errors)->assign('form', $form)->assign('groups', $this->users->getGroups())->fetch('users/add'); }
/** Will expand any ?-? expressions into their actual range. If you want to include '-' as an option escape it with \ */ function expand_chars_exp($exp) { $retval = ""; $i = 0; while ($i < strlen($exp)) { if (substr($exp, $i, 1) == '-' && $i > 0 && substr($exp, $i - 1, 1) != '\\') { $start = ord(substr($exp, $i - 1, 1)); $end = ord(substr($exp, ++$i, 1)); if ($start < $end && is_alphanum($start) && is_alphanum($end)) { for ($j = $start + 1; $j <= $end; $j++) { $retval .= chr($j); } } else { $retval .= substr($exp, $i - 1, 1); $retval .= substr($exp, $i, 1); } } else { if (substr($exp, $i, 1) == '\\') { // If this is escaping a character other than '\' // then do not include. The test will still look // at the original exp, for the '\', so getting rid // of it here will be alright! if ($i > 0 && substr($exp, $i - 1, 1) == '\\') { $retval .= '\\'; } } else { $retval .= substr($exp, $i, 1); } } $i++; } return $retval; }
function is_valide_code($val) { $val = str_replace("_", "", $val); $val = str_replace("-", "", $val); return is_alphanum($val); }