本文整理汇总了PHP中validate_id函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_id函数的具体用法?PHP validate_id怎么用?PHP validate_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* Handling a post.
*/
function post()
{
$new_id = $_POST['id'];
$this->load->helper('validate_helper');
// Check to see if the ID already exists
if ($this->accounts->get($new_id) == null) {
$this->data['errors'][] = 'ID does not exist.';
}
// Check to see if the ID is invalid
if (!validate_id($_POST['id'])) {
$this->data['errors'][] = 'Invalid ID.';
}
// Check to see if the status is invalid.
if (!validate_status($_POST['status'])) {
$this->data['errors'][] = 'Invalid status.';
}
// If more than 0 errors exist, adding entry fails, error produced
if (count($this->data['errors']) > 0) {
redirect('../update');
//$this -> index();
} else {
$this->accounts->update($_POST);
redirect('../');
}
}
示例2: post
/**
* Handling a post.
*/
function post()
{
// Call to neccessary variables and helpers
$new_id = $_POST['id'];
$this->load->helper('validate_helper');
// Check to see if the ID already exists
if ($this->products->get($new_id) != null) {
$this->data['errors'][] = 'ID already in use.';
}
// Check to see if the ID is invalid
if (!validate_id($_POST['id'])) {
$this->data['errors'][] = 'Invalid ID.';
}
// Check to see if the status is invalid.
if (!validate_status($_POST['status'])) {
$this->data['errors'][] = 'Invalid status.';
}
// If more than 0 errors exist, adding entry fails, error produced
if (count($this->data['errors']) > 0) {
redirect('../add');
//$this -> index();
} else {
$this->products->add($_POST);
redirect('../');
}
}
示例3: download_file
function download_file($file)
{
validate_id(array_get($file, 'id'));
// do we read the file off AWS S3?
if (CONFIG_AWS_S3_KEY_ID && CONFIG_AWS_S3_SECRET && CONFIG_AWS_S3_BUCKET) {
try {
// Instantiate the S3 client with your AWS credentials
$client = S3Client::factory(array('key' => CONFIG_AWS_S3_KEY_ID, 'secret' => CONFIG_AWS_S3_SECRET));
$file_key = '/challenges/' . $file['id'];
$client->registerStreamWrapper();
// Send a HEAD request to the object to get headers
$command = $client->getCommand('HeadObject', array('Bucket' => CONFIG_AWS_S3_BUCKET, 'Key' => $file_key));
$filePath = 's3://' . CONFIG_AWS_S3_BUCKET . $file_key;
} catch (Exception $e) {
message_error('Caught exception uploading file to S3: ' . $e->getMessage());
}
} else {
$filePath = CONST_PATH_FILE_UPLOAD . $file['id'];
if (!is_readable($filePath)) {
log_exception(new Exception("Could not read the requested file: " . $filePath));
message_error("Could not read the requested file. An error report has been lodged.");
}
}
$file_title = $file['title'];
if (defined('CONFIG_APPEND_MD5_TO_DOWNLOADS') && CONFIG_APPEND_MD5_TO_DOWNLOADS && $file['md5']) {
$pos = strpos($file['title'], '.');
if ($pos) {
$file_title = substr($file['title'], 0, $pos) . '-' . $file['md5'] . substr($file['title'], $pos);
} else {
$file_title = $file_title . '-' . $file['md5'];
}
}
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
// required for certain browsers
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="' . $file_title . '";');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $file['size']);
// Stop output buffering
if (ob_get_level()) {
ob_end_flush();
}
flush();
readfile($filePath);
}
示例4: cdotw
function cdotw($id)
{
$id = validate_id($id);
if ($id == '') {
$date = "SELECT date, DATE_FORMAT(date, '%c/%d/%y' ) as fdate FROM cdotw GROUP BY date ORDER BY date DESC LIMIT 0,1";
$date_result = mysql_query($date);
if (!$date_result) {
die('Invalid');
}
$datepicker = mysql_fetch_assoc($date_result);
$query = "SELECT * FROM cdotw WHERE deleted = 'no' AND date = \"" . $datepicker['date'] . "\"";
$result = mysql_query($query);
} else {
$date = "SELECT DATE_FORMAT(date, '%c/%d/%y' ) as fdate FROM cdotw WHERE id = " . $id;
$date_result = mysql_query($date);
if (!$date_result) {
die('Invalid');
}
$datepicker = mysql_fetch_assoc($date_result);
$query = "SELECT * FROM cdotw WHERE deleted = 'no' AND id = " . $id;
$result = mysql_query($query);
}
if (!$result) {
echo "error: " . $query;
die('Invalid');
}
echo "Week of " . $datepicker['fdate'];
echo '<ul>';
for ($i = 1; $i <= mysql_num_rows($result); $i++) {
$info = mysql_fetch_assoc($result);
echo "<h3>" . $info['artist'] . " - <em>" . $info['title'] . "</em> (" . $info['label'] . ")</h3>\n" . "<div class='review'> <a href=\"" . $info['band'] . "\" target=_new><img src=\"" . $info['cd_pic_url'] . "\" height=\"200\"> </a>\n" . $info['review'] . "</div>\n" . "<div class=\"footnote\">Review by " . $info['reviewer'] . "</div>\n";
if ($i != mysql_num_rows($result)) {
echo "<p>\n<hr width=80%>\n";
}
}
echo '</ul>';
}
示例5: user_exception_log
function user_exception_log($user_id, $limit = null)
{
validate_id($user_id);
echo '
<table id="hints" class="table table-striped table-hover">
<thead>
<tr>
<th>Message</th>
<th>Added</th>
<th>IP</th>
<th>Trace</th>
</tr>
</thead>
<tbody>
';
$exceptions = db_query_fetch_all('
SELECT
e.id,
e.message,
e.added,
e.added_by,
e.trace,
INET_NTOA(e.user_ip) AS user_ip,
u.team_name
FROM exceptions AS e
LEFT JOIN users AS u ON u.id = e.added_by
WHERE e.added_by = :user_id
ORDER BY e.id DESC
' . ($limit ? 'LIMIT ' . $limit : ''), array('user_id' => $user_id));
foreach ($exceptions as $exception) {
echo '
<tr>
<td>', htmlspecialchars($exception['message']), '</td>
<td>', date_time($exception['added']), '</td>
<td><a href="', CONFIG_SITE_ADMIN_URL, 'list_ip_log.php?ip=', htmlspecialchars($exception['user_ip']), '">', htmlspecialchars($exception['user_ip']), '</a></td>
<td>', htmlspecialchars($exception['trace']), '</td>
</tr>
';
}
echo '
</tbody>
</table>
';
}
示例6: validate_id
<!--#####################################################################
#
# File : DELETE IMAGE
# Project : Game Magazine Project
# Author : Béo Sagittarius
# Created : 07/01/2015
#
##################################################################### -->
<?php
include '../includes/functions.php';
include '../includes/backend/header-admin.php';
include '../includes/backend/mysqli_connect.php';
$iid = validate_id($_GET['iid']);
// Neu muon delete page
$result = delete_images($iid);
if (mysqli_affected_rows($dbc) == 1) {
echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\talert('{$lang['AD_DEL_SUCCESS']}');\n window.location = 'list_images.php';\n\t\t\t\t</script>\n\t\t\t";
} else {
echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\talert('{$lang['AD_DEL_FAIL']}');\n window.location = 'list_images.php';\n\t\t\t\t</script>\n\t\t\t";
}
示例7: array
<?php
include '../includes/backend/mysqli_connect.php';
include '../includes/functions.php';
include '../includes/errors.php';
if ($gid = validate_id($_GET['gid'])) {
$set = get_news_by_id($gid);
$games = array();
if (mysqli_num_rows($set) > 0) {
$games = mysqli_fetch_array($set, MYSQLI_ASSOC);
} else {
redirect_to('admin/list_games.php');
}
} else {
redirect_to('admin/list_games.php');
}
$title_page = $games['type_name'];
include '../includes/backend/header-admin.php';
?>
<div class="content-wrapper">
<div class="container">
<div class="row">
<div class="col-md-11" style="margin-left: 4.1%">
<div class="panel panel-default">
<div class="panel-heading">
<h2 style="text-align: center"><?php
echo $games['title'];
?>
</h2>
<h4 style="text-align: center" ><a href="index.php"><?php
示例8: writelog
$data = $data[0];
$this_birthdate = $data['birthday'];
$id_player = $data['id'];
if ($this_birthdate != "" && $this_birthdate != $birthdate) {
writelog($logFile, "warning", "\t{$full_name_corr} ({$id_player}) a des birthday differents (table: {$this_birthdate}, capgeek: {$birthdate}) (2)");
insert_or_update_corr_values($INSERTFILE, $id_player, $playerName, $birthdate);
}
} else {
writelog($logFile, "warning", "\t{$playerName} est plus d'une fois dans la table nhl_players, mais les birthday ne fitte pas ({$birthdate})...");
continue;
}
if ($id_player == "") {
writelog($logFile, "info", "Joueur {$playerName}: pas dans la table nhl_players (2)");
continue;
}
$data = validate_id($id_player, 'id_waronice');
$this_id_waronice = $data['id_waronice'];
if ($id_war_on_ice != $this_id_waronice) {
writelog($logFile, "info", "\tJoueur {$playerName} ({$id_player}) : id_waronice différent (2)");
$q = "update nhl_players set id_waronice={$id_war_on_ice} where id = {$id_player} and date_expiration = '2099-12-31';";
insert_query_in_file($INSERTFILE, $q);
}
// ajout/update dans la table de corr.
insert_or_update_corr_values($INSERTFILE, $id_player, $playerName, $birthdate);
} else {
// on a trouvé le joueur
$data = $data[0];
$id_player = $data['id'];
$this_id_waronice = $data['id_waronice'];
if ($this_id_waronice != $id_war_on_ice) {
writelog($logFile, "info", "\t Joueur {$playerName} ({$id_player}): id_waronice différent");
示例9: user_ip_log
function user_ip_log($user_id)
{
validate_id($user_id);
echo '
<table id="files" class="table table-striped table-hover">
<thead>
<tr>
<th>IP</th>
<th>Hostname</th>
<th>First used</th>
<th>Last used</th>
<th>Times used</th>
</tr>
</thead>
<tbody>
';
$entries = db_select_all('ip_log', array('INET_NTOA(ip) AS ip', 'added', 'last_used', 'times_used'), array('user_id' => $_GET['id']));
foreach ($entries as $entry) {
echo '
<tr>
<td><a href="list_ip_log.php?ip=', htmlspecialchars($entry['ip']), '">', htmlspecialchars($entry['ip']), '</a></td>
<td>', CONFIG_GET_IP_HOST_BY_ADDRESS ? gethostbyaddr($entry['ip']) : '<i>Lookup disabled in config</i>', '</td>
<td>', date_time($entry['added']), '</td>
<td>', date_time($entry['last_used']), '</td>
<td>', number_format($entry['times_used']), '</td>
</tr>
';
}
echo '
</tbody>
</table>
';
}
示例10: message_dialog
if ($_GET['status'] == 'correct') {
message_dialog('Congratulations! You got the flag!', 'Correct flag', 'Yay!', 'challenge-attempt correct on-page-load');
} else {
if ($_GET['status'] == 'incorrect') {
message_dialog('Sorry! That wasn\'t correct', 'Incorrect flag', 'Ok', 'challenge-attempt incorrect on-page-load');
} else {
if ($_GET['status'] == 'manual') {
message_inline_blue('<h1>Your submission is awaiting manual marking.</h1>', false);
}
}
}
}
$categories = db_select_all('categories', array('id', 'title', 'description', 'available_from', 'available_until'), array('exposed' => 1), 'title ASC');
// determine which category to display
if (isset($_GET['category'])) {
validate_id($_GET['category']);
$current_category = array_search_matching_key($_GET['category'], $categories, 'id');
if (!$current_category) {
message_error(lang_get('no_category_for_id'), false);
}
} else {
// if no category is selected, display
// the first available category
foreach ($categories as $cat) {
if ($time > $cat['available_from'] && $time < $cat['available_until']) {
$current_category = $cat;
break;
}
}
// if no category has been made available
// we'll just set it to the first one
示例11: validate_id
<!--#####################################################################
#
# File : CHANGE STATUS VIDEO
# Project : Game Magazine Project
# Author : Béo Sagittarius
# Created : 07/01/2015
#
##################################################################### -->
<?php
include '../includes/functions.php';
include '../includes/backend/mysqli_connect.php';
if (isset($_GET)) {
$iid = validate_id($_GET['iid']);
$stt = validate_id($_GET['stt']);
// Change status
$result = change_status_image($iid, $stt);
if (mysqli_affected_rows($dbc) == 1) {
redirect_to('admin/list_images.php');
} else {
redirect_to('admin/list_images.php');
}
}
示例12: array
<!--#####################################################################
#
# File : EDIT VIDEO
# Project : Game Magazine Project
# Author : Béo Sagittarius
# Created : 07/01/2015
#
##################################################################### -->
<?php
include '../includes/backend/mysqli_connect.php';
include '../includes/functions.php';
include '../includes/errors.php';
$title_page = 'Edit Video';
if ($vid = validate_id($_GET['vid'])) {
$result = get_video_item($vid);
if (mysqli_num_rows($result) == 1) {
$videos = mysqli_fetch_array($result, MYSQLI_ASSOC);
} else {
redirect_to('admin/list_videos.php');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$errors = array();
//validate title
if (empty($_POST['title'])) {
$errors[] = "title";
} else {
$title = mysqli_real_escape_string($dbc, strip_tags($_POST['title']));
}
//validate description
if (empty($_POST['description'])) {
$errors[] = 'description';
示例13: validate_id
<!--#####################################################################
#
# File : DELETE NEWS
# Project : Game Magazine Project
# Author : Béo Sagittarius
# Created : 07/01/2015
#
##################################################################### -->
<?php
include '../includes/functions.php';
include '../includes/backend/header-admin.php';
include '../includes/backend/mysqli_connect.php';
$nid = validate_id($_GET['nid']);
// Neu muon delete page
$result = delete_news_games($nid);
if (mysqli_affected_rows($dbc) == 1) {
echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\talert('{$lang['AD_DEL_SUCCESS']}');\n window.location = 'list_news.php';\n\t\t\t\t</script>\n\t\t\t";
} else {
echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\tert('{$lang['AD_DEL_FAIL']}');\n window.location = 'list_news.php';\n\t\t\t\t</script>\n\t\t\t";
}
示例14: writelog
$data = $data[0];
$this_birthdate = $data['birthday'];
$id_player = $data['id'];
if ($this_birthdate != "" && $this_birthdate != $birthdate) {
writelog($logFile, "warning", "\t{$full_name_corr} ({$id_player}) a des birthday differents (table: {$this_birthdate}, rotoworld: {$birthdate}) (2)");
insert_or_update_corr_values($INSERTFILE, $id_player, $playerName, $birthdate);
}
} else {
writelog($logFile, "warning", "\t{$playerName} est plus d'une fois dans la table nhl_players, mais les birthday ne fitte pas ({$birthdate})...");
continue;
}
if ($id_player == "") {
writelog($logFile, "info", "Joueur {$playerName}: pas dans la table nhl_players (2)");
continue;
}
$data = validate_id($id_player, 'id_rotoworld');
$this_id_rotoworld = $data['id_rotoworld'];
if ($id_rotoworld != $this_id_rotoworld) {
writelog($logFile, "info", "\tJoueur {$playerName} ({$id_player}) : id_rotoworld différent (2)");
$q = "update nhl_players set id_rotoworld={$id_rotoworld} where id = {$id_player} and date_expiration = '2099-12-31';";
insert_query_in_file($INSERTFILE, $q);
}
// ajout/update dans la table de corr.
insert_or_update_corr_values($INSERTFILE, $id_player, $playerName, $birthdate);
} else {
// on a trouvé le joueur
$data = $data[0];
$id_player = $data['id'];
$this_id_rotoworld = $data['id_rotoworld'];
if ($this_id_rotoworld != $id_rotoworld) {
writelog($logFile, "info", "\t Joueur {$playerName} ({$id_player}): id_rotoworld différent");
示例15: array
<?php
include 'includes/mysqli_connect.php';
include 'includes/functions.php';
if ($pid = validate_id($_GET['pid'])) {
// neu ton tai bien pid thi tiep tuc truy van csdl
$set = get_page_by_id($pid);
$posts = array();
if (mysqli_num_rows($set) > 0) {
$pages = mysqli_fetch_array($set, MYSQLI_ASSOC);
$title = $pages['page_name'];
$posts[] = array('page_name' => $pages['page_name'], 'content' => $pages['content'], 'author' => $pages['name'], 'post-on' => $pages['date'], 'aid' => $pages['user_id']);
}
} else {
redirest_to();
}
include 'includes/header.php';
include 'includes/sidebar-a.php';
?>
<div id="content">
<?php
foreach ($posts as $post) {
echo "\n <div class='post'>\n <h2>" . $post['page_name'] . "</h2>\n <p>" . the_content($post['content']) . "</p>\n <p class='meta'><strong>Posted by: </strong><a href='author.php?aid={$post['aid']}'>" . $post['author'] . "</a> | <strong>On: </strong>" . $post['post-on'] . "</p>\n\n </div>\n ";
}
?>
<?php
include 'includes/comment_form.php';
?>
</div><!--end content-->
<?php
include 'includes/sidebar-b.php';