本文整理汇总了PHP中validateInput函数的典型用法代码示例。如果您正苦于以下问题:PHP validateInput函数的具体用法?PHP validateInput怎么用?PHP validateInput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateInput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processInput
/**
* Check for input.
* If there is none, return waiting signal.
* If there is input, validate it, and either report errors or move on to next step.
*/
function processInput()
{
global $RESPONSE, $SESSION;
if (sessionExpired()) {
return;
}
// did we get the information necessary to move on to the next step?
if (isset($_POST['click'])) {
// data was submitted
if (!validateInput()) {
return;
}
storeInput();
$SESSION->setStatus(Session::finished_step);
if (readyToMoveOn()) {
executeGroupCallbacks();
advanceStep();
}
} else {
// no user input
if ($SESSION->current_step->time_limit > 0) {
// if there is a time limit, announce remaining time
$RESPONSE = array('action' => 'countdown', 'seconds' => $SESSION->expires - time());
} else {
// tell client to wait
$RESPONSE = array('action' => 'wait');
}
}
}
示例2: validateForm
function validateForm(&$errors)
{
global $username, $password, $verifyPassword;
if (!validateInput($username)) {
$errors['username'][] = 'Your username must be between 4 and 8 symbols long. You can use latin characters, digits and - or _';
}
if (!validateInput($password) || !validateInput($verifyPassword)) {
$errors['password'][] = 'Your password must be between 4 and 8 symbols long. You can use lating characters, digits and - or _';
}
if (!samePassword($password, $verifyPassword)) {
$errors['password'][] = 'You must enter the same password twice.';
} else {
$password = password_hash($password, PASSWORD_DEFAULT);
}
}
示例3: validateInput
<h3 style ="text_align:center">Using IF ELSE</h3>
<form name="BirthYear" action="BirthYear_ifelse.php" method="post">
<p>Year of Birth: <input type="number" name="Year" value="<?php
echo $YearOfBirth;
?>
" /></p>
<p><input type="reset" value="Clear Form" /> <input type="submit" name="Submit" value"Show Me My Sign" /></p>
</form>
<?php
}
$ShowForm = TRUE;
$errorCount = 0;
$YearOfBirth = 0;
if (isset($_POST['Submit'])) {
$YearOfBirth = validateInput($_POST['Year'], "Year of Birth");
if ($errorCount == 0) {
$ShowForm = FALSE;
} else {
$ShowForm = TRUE;
}
}
if ($ShowForm == TRUE) {
if ($errorCount > 0) {
echo "<p>Please re-enter the form information below.</p>\n";
}
displayForm($Sender, $Email, $Subject, $Message);
} else {
$yearSign = getYearSign($YearOfBirth);
echo "<pre>You were born under the sign of the " . strtolower($yearSign) . ".\n\n";
echo "<img src='" . $yearSign . ".jpg'/>";
示例4: session_set_cookie_params
if (validateInput($_GET["task"], 'nospace') === true) {
$selTask = $_GET["task"];
}
}
session_set_cookie_params(43200);
// 8 hours
session_name("hlstats-session");
session_start();
session_regenerate_id(true);
$auth = false;
require 'class/admin.class.php';
$adminObj = new Admin();
$auth = $adminObj->getAuthStatus();
// process the logout
if (!empty($_GET['logout'])) {
if (validateInput($_GET['logout'], 'digit') === true && $_GET['logout'] == "1") {
$adminObj->doLogout();
header('Location: index.php');
}
}
if ($auth === true) {
if (!empty($selTask)) {
if (file_exists(getcwd() . '/hlstatsinc/admintasks/' . $selTask . '.inc.php')) {
require 'hlstatsinc/admintasks/' . $selTask . '.inc.php';
} else {
require 'hlstatsinc/admintasks/overview.php';
}
} else {
// show overview
require 'hlstatsinc/admintasks/overview.php';
}
示例5: sanitize
$gameCode = sanitize($_GET['gameCode']);
if (!empty($gameCode) && validateInput($gameCode, 'nospace')) {
$query = "SELECT\n\t\t\t \t\t\tt1.playerId,lastName,skill\n\t\t\t \t\tFROM\n\t\t\t \t\t\thlstats_Players as t1 INNER JOIN hlstats_PlayerUniqueIds as t2\n\t\t\t \t\t\tON t1.playerId = t2.playerId\n\t\t\t \t\tWHERE\n\t\t\t \t\t\tt1.game='" . $gameCode . "'\n\t\t\t \t\t\tAND t1.hideranking=0\n\t\t\t \t\t\tAND t2.uniqueId not like 'BOT:%'\n\t\t\t \t\tORDER BY skill DESC\n\t\t\t \t\tLIMIT 10";
}
break;
/**
* return some information about the given server like livestats view
*/
/**
* return some information about the given server like livestats view
*/
case 'serverinfo':
default:
// we want some server info
$serverId = sanitize($_GET['serverId']);
if (!empty($serverId) && validateInput($serverId, 'digit')) {
// check if we have such server
$query = mysql_query("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\ts.serverId,\n\t\t\t\t\t\t\ts.name,\n\t\t\t\t\t\t\ts.address,\n\t\t\t\t\t\t\ts.port,\n\t\t\t\t\t\t\ts.publicaddress,\n\t\t\t\t\t\t\ts.game,\n\t\t\t\t\t\t\ts.rcon_password,\n\t\t\t\t\t\t\tg.name gamename\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\thlstats_Servers s\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t\thlstats_Games g\n\t\t\t\t\t\tON\n\t\t\t\t\t\t\ts.game=g.code\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tserverId=" . $serverId . "\n\t\t\t\t\t\t\t");
if (mysql_num_rows($query) === 1) {
// get the server data
$serverData = mysql_fetch_assoc($query);
$xmlBody = "<server>";
$xmlBody .= "<name>" . $serverData['name'] . "</name>";
$xmlBody .= "<ip>" . $serverData['address'] . "</ip>";
$xmlBody .= "<port>" . $serverData['port'] . "</port>";
$xmlBody .= "<game>" . $serverData['gamename'] . "</game>";
// load the required stuff
include 'hlstatsinc/binary_funcs.inc.php';
include 'hlstatsinc/hlquery_funcs.inc.php';
$xmlBody .= "<additional>";
// run some query to display some more info
示例6: trim
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$return['status'] = false;
$return['msg'] = false;
if (isset($_POST['sub']['auth'])) {
if (isset($_POST['login']['username']) && isset($_POST['login']['pass'])) {
$username = trim($_POST['login']['username']);
$pass = trim($_POST['login']['pass']);
$check = validateInput($username, 'nospace');
$check1 = validateInput($pass, 'nospace');
if ($check === true && $check1 === true) {
$do = $adminObj->doLogin($username, $pass);
if ($do === true) {
$return['status'] = "3";
$return['msg'] = l('Login successfull');
header('Location: index.php?mode=admin');
} else {
$return['status'] = "2";
$return['msg'] = l('Invalid auth data');
}
} else {
$return['status'] = "1";
$return['msg'] = l('Please provide authentication data');
}
}
示例7: array
////
//// Main
////
$modes = array("players", "clans", "weapons", "maps", "actions", "claninfo", "playerinfo", "weaponinfo", "mapinfo", "actioninfo", "playerhistory", "search", "admin", "help", "livestats", "playerchathistory", "teams");
$mode = '';
if (!empty($_GET["mode"])) {
if (in_array($_GET["mode"], $modes) && validateInput($_GET['mode'], 'nospace') === true) {
$mode = $_GET['mode'];
}
}
// decide if we show the games or the game file
$queryAllGames = mysql_query("SELECT code,name FROM " . DB_PREFIX . "_Games WHERE hidden='0' ORDER BY name ASC");
$num_games = mysql_num_rows($queryAllGames);
$game = '';
if (isset($_GET['game'])) {
$check = validateInput($_GET['game'], 'nospace');
if ($check === true) {
$game = $_GET['game'];
$query = mysql_query("SELECT name FROM " . DB_PREFIX . "_Games WHERE code='" . mysql_escape_string($game) . "' AND `hidden` = '0'");
if (mysql_num_rows($query) < 1) {
error("No such game '{$game}'.");
} else {
$result = mysql_fetch_assoc($query);
$gamename = $result['name'];
if (empty($mode)) {
$mode = 'game';
}
}
}
} else {
if ($num_games == 1) {
示例8: _checkAuth
/**
* check if the user is logged in
*/
private function _checkAuth()
{
if (isset($_SESSION['hlstatsAuth']['authCode'])) {
$check = validateInput($_SESSION['hlstatsAuth']['authCode'], 'nospace');
if ($check === true) {
// check if we have such code into the db
$userData = $this->_getSessionDataFromDB($_SESSION['hlstatsAuth']['authCode']);
if ($userData !== false) {
// we have a valid user with valid authCode
// re create the authcode with current data
$authCode = sha1($_SERVER["REMOTE_ADDR"] . $_SERVER['HTTP_USER_AGENT'] . $userData['password']);
if ($authCode === $_SESSION['hlstatsAuth']['authCode']) {
$this->_authStatus = true;
}
} else {
$this->_logoutCleanUp($_SESSION['hlstatsAuth']['authCode']);
}
}
}
}
示例9: viewRegister
function viewRegister()
{
$errors = array();
if (!empty($_POST)) {
//vorm esitati
if (empty($_POST["name"])) {
$errors[] = "Nimi puudub.";
}
//nimi olemas
$u = validateInput($_POST["name"]);
$p1 = '';
$p2 = '';
$userMatch = false;
$sql = "SELECT username FROM rsaarmae_users";
$result = mysqli_query($_SESSION['connection'], $sql);
while ($row = mysqli_fetch_assoc($result)) {
if ($row['username'] == $u) {
$userMatch = true;
$errors[] = "Sellise nimega kasutaja on juba registreeritud, proovige teist nime";
}
}
if (empty($_POST["name"])) {
}
if (empty($_POST["password"])) {
$errors[] = "Salasõna puudub.";
} else {
$p1 = validateInput($_POST["password"]);
}
if (empty($_POST["password_check"])) {
$errors[] = "Salasõna kontroll puudub.";
} else {
$p2 = validateInput($_POST["password_check"]);
}
if ($p1 != $p2) {
$errors[] = "Salasõnad ei ühti.";
}
if (!$userMatch && empty($errors)) {
$salt = sha1($p1 . $u . $p1);
//salasõna räsi tekitamine ja soolamine
$query = "INSERT INTO rsaarmae_users (username, pass) VALUES ('{$u}', '{$salt}');";
mysqli_query($_SESSION['connection'], $query);
startSession();
startSession();
$_SESSION["teade"] = "Registreeritud kasutaja nimega '" . $u . "'.";
header("Location: controller.php?mode=index");
exit(0);
}
}
require_once 'register.php';
}
示例10: isset
require 'dbconnection.php';
$action = isset($_POST['action']) ? $_POST['action'] : 'default';
function validateInput()
{
if (empty($_POST['year']) || empty($_POST['month']) || empty($_POST['day'])) {
return False;
}
$timestamp = strtotime($_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day']);
if (!is_numeric($timestamp)) {
return False;
}
return checkdate(date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));
}
switch ($action) {
case 'Show':
if (validateInput() === True) {
$inputValidated = True;
$date = sprintf('%d-%d-%d', $_POST['year'], $_POST['month'], $_POST['day']);
$mongodate = new MongoDate(strtotime($date));
$mongodb = DBConnection::instantiate();
$collection = $mongodb->getCollection('daily_sales');
$doc = $collection->findOne(array('sales_date' => $mongodate));
} else {
$inputValidated = False;
}
break;
default:
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
示例11: validateInput
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
// JSON return strings
$sErr = "";
$sMsg = "";
$sData = "";
//
// basepath
$sConnBse = "../../";
include "config.php";
include "functions.php";
//
// security file checking
$aVldt = validateInput($sConnBse, array("fileList" => array(0, 2, 0), "duplicate" => array(0, 3, 0), "upload" => array(0, 5, 1), "swfUpload" => array(5, 2, 1), "delete" => array(0, 3, 0), "download" => array(2, 0, 0), "read" => array(0, 3, 0), "rename" => array(0, 4, 0), "addFolder" => array(0, 3, 0), "moveFiles" => array(0, 4, 0)));
$sAction = $aVldt["action"];
$sSFile = $aVldt["file"];
$sErr .= $aVldt["error"];
if ($sErr != "") {
die('{"error":"' . $sErr . '","msg":"' . $sMsg . '","data":{' . $sData . '}}');
}
//
$sErr = '';
switch ($sAction) {
case "fileList":
// retreive file list
$sImg = "";
$sDir = $sConnBse . (isset($_POST["folder"]) ? $_POST["folder"] : "data/");
$i = 0;
if ($handle = opendir($sDir)) {
示例12: die
* + 2007 - 2012
* +
*
* This program is free software is licensed under the
* COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
*
* You should have received a copy of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
* along with this program; if not, visit http://hlstats-community.org/License.html
*
*/
// Live Stats
// The binary functions need to be included
// Along with the HL Query functions
$serverId = '';
if (!empty($_GET["server"])) {
if (validateInput($_GET["server"], 'digit') === true) {
$serverId = $_GET["server"];
} else {
die("No server ID specified.");
}
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
include 'hlstatsinc/binary_funcs.inc.php';
include 'hlstatsinc/hlquery_funcs.inc.php';
$query = $DB->query("SELECT s.serverId, s.name, s.address,\n\t\t\ts.port, s.publicaddress, s.game, s.rcon_password,\n\t\t\tg.name gamename\n\t\tFROM `" . DB_PREFIX . "_Servers` AS s\n\t\tLEFT JOIN `" . DB_PREFIX . "_Games` AS g ON s.game = g.code\n\t\tWHERE serverId = '" . $DB->real_escape_string($serverId) . "'");
if (SHOW_DEBUG && $DB->error) {
var_dump($DB->error);
}
示例13: trim
* + 2007 - 2012
* +
*
* This program is free software is licensed under the
* COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
*
* You should have received a copy of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
* along with this program; if not, visit http://hlstats-community.org/License.html
*
*/
$return = false;
if (isset($_POST['sub']['newgame'])) {
$newGame = trim($_POST['newGame']);
if (!empty($newGame)) {
// read the gamesupport_file
$check = validateInput($newGame, 'nospace');
if (file_exists("hlstatsinc/sql_files/" . $newGame) && $check === true) {
$sqlContent = file_get_contents("hlstatsinc/sql_files/" . $_POST['newGame']);
$sqlContent = str_replace(array("\n", "\t", "\r"), array("\n"), $sqlContent);
// replace the table prefix with the constant
$sqlContent = str_replace("++DB_PREFIX++", DB_PREFIX, $sqlContent);
$sqlContentArr = explode("\n", $sqlContent);
$i = 0;
foreach ($sqlContentArr as $line) {
$line = trim($line);
if (!preg_match("/^#/", $line) && $line != "") {
$query = $DB->query($line);
if (!$query) {
echo "Query Failed: " . $line;
$i++;
break;
示例14: PDO
global $postpass;
global $postemail;
global $result;
$db = new PDO('sqlite:database.db');
$stmt = $db->prepare('SELECT * FROM users WHERE email LIKE ?');
$stmt->execute(array($postemail));
$result = $stmt->fetchAll();
return count($result);
}
// ----------------------- REGISTER CASE
if ($_POST['choice'] == "REGISTER") {
if ($_POST['log_password_conf'] != $postpass) {
header("location: main.php?errorMsg=" . urlencode("\"password\" field is different than \"confirm password\""));
return '';
}
if (validateInput($mail_match, $postemail) === false) {
header("location: main.php?errorMsg=" . urlencode("\"email\" not accepted"));
return '';
}
if (number_of_usersnamed() === 0) {
if (number_of_users_with_email() === 0) {
//generate activation code
$length = 10;
$code = "";
$valid = "0123456789abcdefghijklmnopqrstuvwxyz";
do {
for ($i = 0; $i < $length; $i++) {
$code .= $valid[mt_rand(0, strlen($valid))];
}
} while (activation_code($code) > 0);
$dbh = new PDO('sqlite:database.db');
示例15: saveNewPaths
function saveNewPaths($group = 'Core')
{
global $rescueFields, $_DB_table_prefix;
$retval = array();
$sql = "SELECT * FROM " . $_DB_table_prefix . "conf_values WHERE group_name='" . DB_escapeString($group) . "' AND ((type <> 'subgroup') AND (type <> 'fieldset'))";
$result = DB_query($sql);
while ($row = DB_fetchArray($result)) {
if ($group != 'Core' || in_array($row['name'], $rescueFields)) {
$config[$row['name']] = @unserialize($row['value']);
$default[$row['name']] = $row['default_value'];
}
}
$cfgvalues = array();
$reset = array();
$cfgvalues = $_POST['cfgvalue'];
$reset = isset($_POST['default']) ? $_POST['default'] : array();
$changed = 0;
foreach ($cfgvalues as $option => $value) {
if (isset($reset[$option]) && $reset[$option] == 1) {
$sql = "UPDATE " . $_DB_table_prefix . "conf_values SET value='" . $default[$option] . "' WHERE name='" . $option . "' AND group_name='" . $group . "'";
DB_query($sql);
$retval[] = 'Resetting ' . $option;
$changed++;
} else {
$sVal = validateInput($value);
if ($config[$option] != $sVal && $option != 'user_login_method' && $option != 'event_types' && $option != 'default_permissions' && $option != 'grouptags') {
$fn = 'rescue_' . $option . '_validate';
if (function_exists($fn)) {
$sVal = $fn($sVal);
}
$sql = "UPDATE " . $_DB_table_prefix . "conf_values SET value='" . serialize($sVal) . "' WHERE name='" . $option . "' AND group_name='" . $group . "'";
DB_query($sql);
$retval[] = 'Saving ' . $option;
$changed++;
}
}
}
if ($changed == 0) {
$retval[] = 'No changes detected';
} else {
@unlink($cfgvalue['path_data'] . '$$$config$$$.cache');
@unlink($config['path_data'] . '$$$config$$$.cache');
@unlink($cfgvalue['path_data'] . 'layout_cache/$$$config$$$.cache');
@unlink($config['path_data'] . 'layout_cache/$$$config$$$.cache');
}
return $retval;
}