本文整理汇总了PHP中valid函数的典型用法代码示例。如果您正苦于以下问题:PHP valid函数的具体用法?PHP valid怎么用?PHP valid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了valid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Load a the user, roles, and settings internally. If no user ID
* is specified user the one from the session.
*
* @param integer $userId
*/
public function load($userId)
{
if (!valid($userId)) {
throw new \Base\Exception('No user ID specified or exists in the session');
}
$this->loadUser($userId);
}
示例2: auth
function auth()
{
if (!valid('janitor_board')) {
// Admin.php login
$temp = "" . "<div align='center' vertical-align='middle'>" . ($temp = '<form action="' . PHP_ASELF . '" method="post"><table>' . '<tr><td>Username</td><td><input type="text" name="usernm" style="width:100%" /></td></tr>' . '<tr><td>Password</td><td><input type="password" name="passwd" style="width:100%" /></td></tr>');
if (SECURE_LOGIN) {
if (RECAPTCHA) {
$temp .= "<tr><td colspan='2'><script src='//www.google.com/recaptcha/api.js'></script><div class='g-recaptcha' data-sitekey='" . RECAPTCHA_SITEKEY . "'></td></tr>";
} else {
$temp .= "<tr><td><img src='" . CORE_DIR_PUBLIC . "/general/captcha.php' /></td><td><input type='text' name='num' size='20' placeholder='Captcha'></td></tr>";
}
}
$temp .= "<tr><td colspan='2'><input type='submit' value='" . S_MANASUB . "'></td></tr></table>" . "<br></form></div>";
echo $temp;
if (isset($_POST['usernm']) && isset($_POST['passwd'])) {
if (SECURE_LOGIN) {
require_once CORE_DIR . '/general/captcha.php';
$captcha = new Captcha();
if ($captcha->isValid() !== true) {
$this->error(S_CAPFAIL);
}
}
$this->doLogin($_POST['usernm'], $_POST['passwd']);
echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=" . PHP_ASELF_ABS . "\">";
}
die("</body></html>");
}
return $temp;
}
示例3: destroy_key
function destroy_key($ip, $mode, $other = null)
{
// Removes a key
if (valid($mode) && $other != null && valid($ip)) {
mysql_query("DELETE FROM `keys` WHERE other='{$other}' AND `ip`='{$ip}' LIMIT 1") or die(mysql_error());
}
}
示例4: theme_play_build_menu
function theme_play_build_menu()
{
global $arr_menu, $username;
$content = '<ul class="nav">';
$i = 0;
foreach ($arr_menu as $cat => $value) {
$i++;
$content .= "<li class=\"dropdown\">";
$content .= '<a href="#" class="dropdown-toggle">' . $cat . '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($value as $sub_key => $menu) {
$content .= '<li><a href="' . $menu[0] . '">' . $menu[1] . '</a></li>';
}
$content .= "</ul>";
$content .= "</li>";
}
$content .= '</ul>';
if (valid()) {
$content .= '<ul class="nav secondary-nav">';
$content .= "<li class=\"dropdown pull-right\">";
$content .= '<a href="#" class="dropdown-toggle">' . $username . '</a>';
$content .= '<ul class="dropdown-menu">';
$content .= '<li><a href="index.php?app=page&op=auth_logout">Logout</a></li>';
$content .= "</ul>";
$content .= "</li>";
$content .= '</ul>';
}
return $content;
}
示例5: generateAdmin
function generateAdmin()
{
require_once CORE_DIR . "/admin/report.php";
$getReport = new Report();
$boardTitle = SHOWTITLETXT > 0 ? "<div class='boardTitle'>" . $this->info['page']['title'] . "</div><div class='boardSubtitle'>" . S_HEADSUB . "</div><hr>" : '';
$bannerImg .= SHOWTITLEIMG ? '<img class="bannerImg" src="' . TITLEIMG . '" onclick="this.src=this.src;" alt="' . TITLE . '" /><br>' : '';
/* begin page content */
$dat = "<!DOCTYPE html><head>\n <meta name='description' content='" . S_DESCR . "'/></meta>\n <meta http-equiv='content-type' content='text/html;charset=utf-8' /></meta>\n <meta name='viewport' content='width=device-width, initial-scale=1'></meta>\n <meta http-equiv='cache-control' content='max-age=0' />\n <meta http-equiv='cache-control' content='no-cache' />\n <meta http-equiv='expires' content='0' />\n <meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />\n <meta http-equiv='pragma' content='no-cache' />\n <link rel='shortcut icon' href='" . CSS_PATH . "imgs/favicon.ico'>\n <title>" . $this->info['page']['title'] . "</title>";
//$dat .= "<link class='togglesheet' rel='stylesheet' type='text/css' href='" . CSS_PATH . "/panel.css' title='Admin Panel' />";
if (NSFW) {
$dat .= "<link class='togglesheet' rel='stylesheet' type='text/css' href='" . CSS_PATH . CSS1 . "' title='Yotsuba' />\n <link rel='stylesheet' type='text/css' href='" . CSS_PATH . "/stylesheets/mobile.css' title='mobile' />\n <link class='togglesheet' rel='alternate stylesheet' type='text/css' media='screen' href='" . CSS_PATH . CSS2 . "' title='Yotsuba B' />";
} else {
$dat .= "<link class='togglesheet' rel='stylesheet' type='text/css' media='screen' href='" . CSS_PATH . CSS2 . "' title='Yotsuba B' />\n <link rel='stylesheet' type='text/css' href='" . CSS_PATH . "/stylesheets/mobile.css' title='mobile' />\n <link class='togglesheet' rel='alternate stylesheet' type='text/css' href='" . CSS_PATH . CSS1 . "' title='Yotsuba' />";
}
//<link class='togglesheet' rel='alternate stylesheet' type='text/css' media='screen' href='" . CSS_PATH . CSS4 . "' title='Burichan'/> RIP Burichan 1862-2015
$dat .= "<link class='togglesheet' rel='alternate stylesheet' type='text/css' media='screen' href='" . CSS_PATH . CSS3 . "' title='Tomorrow' />";
$dat .= "<script src='" . JS_PATH . "/extension.min.js' type='text/javascript'></script>\n <script src='" . JS_PATH . "/main.js' type='text/javascript'></script>";
$dat .= '</head><div class="beforePostform" />' . $titlebar . '
<span class="boardList desktop">' . (file_exists(BOARDLIST) ? file_get_contents(BOARDLIST) : '') . '</div>
<div class="linkBar">[<a href="' . HOME . '" target="_top">' . S_HOME . '</a>][<a href="' . PHP_ASELF_ABS . '">' . S_ADMIN . '</a>]
</span><div class="boardBanner">' . $bannerImg . $boardTitle . '</div>';
$dat .= "<div class='panelOps' style='text-align:left;' />[<a href=\"" . PHP_SELF2 . "\">" . S_RETURNS . "</a>]";
$dat .= "[<a href=\"" . PHP_SELF . "\">" . S_LOGUPD . "</a>]";
if (valid('moderator')) {
$dat .= "[<a href='" . PHP_ASELF_ABS . "?mode=rebuild' >Пересобрать</a>]";
$dat .= "[<a href='" . PHP_ASELF_ABS . "?mode=rebuildall' >Пересобрать все треды</a>]";
$dat .= "[<a href='" . PHP_ASELF_ABS . "?mode=reports' >" . $getReport->reportGetAllBoard() . "</a>]";
}
if (valid('admin')) {
$dat .= "[<a href='" . PHP_ASELF_ABS . "?mode=staff' >Управление пользователями</a>]";
}
$dat .= "[<a href='" . PHP_ASELF . "?mode=logout'>" . S_LOGOUT . "</a>]";
return $dat;
}
示例6: versionCheck
function versionCheck($version)
{
$versions = array("1.0.0", "1.1.0", "1.1.1", "1.2.0", "1.3.0", "1.4.0", "1.5.0", "1.5.1", "1.6.0", "1.7.0-SNAPSHOT", "IRC", "DesktopAPI");
$ip = $_SERVER['REMOTE_ADDR'];
if (in_array($version, $versions) || $ip == "68.151.211.33") {
return valid($version);
}
return false;
}
示例7: getByToken
/**
* Load a user by login token, stored as a setting
*/
static function getByToken($token)
{
$config = self::getStaticService('config');
$setting = \Db\Sql\Settings::getByKeyValue($config->settings->cookieToken, $token->getValue(), ['first' => TRUE]);
if (!$setting || !valid($setting->object_id)) {
return FALSE;
}
return \Db\Sql\Users::findFirst($setting->object_id);
}
示例8: getNextPass
function getNextPass($current)
{
//Lazy solution - loop over each and check it's valid
$current++;
while (!valid($current)) {
$current++;
}
return $current;
}
示例9: quitAction
public function quitAction($message = '', $status = SUCCESS, $redirect = NULL, $code = NULL)
{
if (valid($message, STRING)) {
$this->addMessage($message, $status);
}
if ($code) {
$this->code = $code;
}
if ($redirect) {
$this->redirect = $redirect;
}
}
示例10: form
function form($no)
{
global $mysql;
$host = $mysql->result("SELECT host FROM " . SQLBANLOG . " WHERE no='" . $mysql->escape_string($no) . "'");
$alart = $host ? $mysql->num_rows("SELECT COUNT(*) FROM " . SQLBANLOG . " WHERE ip='" . $host . "'") : 0;
$alert = $alart > 0 ? "<b><font color=\"FF101A\"> {$alart} ban(s) on record for {$host}!</font></b>" : "No bans on record for IP {$host}";
$temp = head(1);
$temp .= "<br><table border='0' cellpadding='0' cellspacing='0' /><form action='admin.php?mode=ban' method='POST' />\n <input type='hidden' name='no' value='{$no}' />\n <input type='hidden' name='ip' value='{$host}' />\n <tr><td class='postblock'>IP History: </td><td>{$alert}</td></tr>\n <tr><td class='postblock'>Unban in:</td><td><input type='number' min='0' size='4' name='banlength' /> days</td></tr>\n <center><tr><td class='postblock'>Ban type:</td><td></center>\n <select name='banType' />\n <option value='warn' />Warning only</option>\n <option value='thisboard' />This board - /" . BOARD_DIR . "/ </option>\n <option value='global' />All boards</option>\n <option value='perma' />Permanent - All boards</option>\n </select>\n </td></tr>\n <tr><td class='postblock'>Public reason:</td><td><textarea rows='2' cols='25' name='pubreason' /></textarea></td></tr>\n <tr><td class='postblock'>Staff notes:</td><td><input type='text' name='staffnote' /></td></tr>\n <tr><td class='postblock'>Append user's comment:</td><td><input type='text' name='custmess' placeholder='Leave blank for USER WAS BAN etc.' /> [ Show message<input type='checkbox' name='showbanmess' /> ] </td></tr>\n <tr><td class='postblock'>After-ban options:</td><td>\n <select name='afterban' />\n <option value='none' />None</option>\n <option value='delpost' />Delete this post</option>\n <option value='delallbyip' />Delete all by this IP</option>\n <option value='delimgonly' />Delete image only</option>\n </select>\n </td></tr>";
if (valid('admin')) {
$temp .= "\n <tr><td class='postblock'>Add to Blacklist:</td><td>[ Comment<input type='checkbox' name='blacklistcom' /> ] [ Image MD5<input type='checkbox' name='blacklistimage' /> ] </td></tr>";
}
$temp .= "<center><tr><td><input type='submit' value='Ban'/></td></tr></center></table></form>";
echo $temp;
}
示例11: remStaff
function remStaff($targUser = '', $actUser, $actPass)
{
global $mysql;
//remove staff member
$targUser = $mysql->escape_string($targUser);
if (!valid('admin')) {
error("Permission denied");
}
if ($this->isStaff($targUser)) {
error("User doesn't exist! (GET error?)");
}
if ($_COOKIE['saguaro_auser'] == $targUser) {
error("You can't delete yourself!");
}
//oi ya cheeky shit ill bash yer fookin head in i sware on me mum
$mysql->query("DELETE FROM " . SQLMODSLOG . " WHERE user='" . $targUser . "'");
}
示例12: greedy
function greedy($n, $a, $pq)
{
$t = explode(" ", $pq);
$p = $t[0];
$q = $t[1];
$a = explode(" ", $a);
$result = array();
if ($n != 1) {
sort($a);
for ($i = 0; $i < $n - 1; $i++) {
$diff = $a[$i + 1] - $a[$i];
$val = $a[$i] + $diff / 2;
if (valid($p, $q, $val)) {
$result[] = $val;
}
$val = $a[$i + 1] - $diff / 2;
if (valid($p, $q, $val)) {
$result[] = $val;
}
}
$result[] = $p;
$result[] = $q;
sort($result);
$sz = count($result);
$best = -1;
$bestval = 0;
for ($i = 0; $i < $sz; $i++) {
$val = 2147483647;
for ($j = 0; $j < $n; $j++) {
if (abs($a[$j] - $result[$i]) < $val) {
$val = abs($a[$j] - $result[$i]);
}
}
if ($val > $best) {
$best = $val;
$bestval = $result[$i];
}
}
return $bestval;
}
$val1 = abs($a[0] - $p);
$val2 = abs($a[0] - $q);
return $val1 >= $val2 ? $p : $q;
}
示例13: authorizeToken
/**
* Authorize a user's login token
*
* @return object | bool
*/
public function authorizeToken()
{
$cookies = $this->getService('cookies');
// read the cookie, check if the token belongs to a user
if (!$cookies->has('token')) {
return FALSE;
}
$token = $cookies->get('token');
if (!valid($token->getValue(), STRING)) {
return FALSE;
}
// try to get the user by token
$user = \Db\Sql\Users::getByToken($token);
if (!$user || !valid($user->id)) {
return FALSE;
}
// save the session data
$session = $this->getService('session');
$session->set('user_id', $user->id);
return $user;
}
示例14: theme_play_build_menu
function theme_play_build_menu()
{
global $menu_config, $username, $name;
$content = '<ul class="nav">';
$i = 0;
foreach ($menu_config as $cat => $value) {
$i++;
$content .= "<li class=\"dropdown\">";
$content .= '<a href="#" class="dropdown-toggle">' . $cat . '</a>';
$content .= '<ul class="dropdown-menu">';
foreach ($value as $sub_key => $sub_menu) {
$sub_menu_url = $sub_menu[0];
$sub_menu_title = $sub_menu[1];
$sub_menu_index = $sub_menu[2] ? $sub_menu[2] : 3;
$m[$sub_menu_index . '.' . $sub_menu_title] = "<li><a href='" . $sub_menu_url . "'>" . $sub_menu_title . "</a></li>";
}
ksort($m);
foreach ($m as $mm) {
$content .= $mm;
}
unset($m);
$content .= "</ul>";
$content .= "</li>";
}
$content .= '</ul>';
if (valid()) {
$content .= '<ul class="nav secondary-nav">';
$content .= "<li class=\"dropdown pull-right\">";
$content .= '<a href="#" class="dropdown-toggle">' . $name . ' (' . $username . ')</a>';
$content .= '<ul class="dropdown-menu">';
$content .= '<li><a href="index.php?app=menu&inc=user_config&op=user_config">' . _('User configuration') . '</a></li>';
$content .= '<li><a href="index.php?app=menu&inc=user_pref&op=user_pref">' . _('Preferences') . '</a></li>';
$content .= '<li><a href="index.php?app=page&op=auth_logout">Logout</a></li>';
$content .= "</ul>";
$content .= "</li>";
$content .= '</ul>';
}
return $content;
}
示例15: rebuild
function rebuild($all = 0)
{
global $mysql, $my_log;
if (!valid('moderator')) {
die('Update failed...');
}
header("Pragma: no-cache");
echo "Rebuilding " . ($all ? "all" : "missing") . ' replies and pages... <a href="' . PHP_SELF2_ABS . '">Go back</a><br><br>';
ob_end_flush();
$starttime = microtime(true);
if (!($treeline = $mysql->query("select no,resto from " . SQLLOG . " where root>0 order by root desc"))) {
echo S_SQLFAIL;
}
echo "Writing...\n";
if ($all || !defined('CACHE_TTL')) {
while (list($no, $resto) = $mysql->fetch_row($treeline)) {
if (!$resto) {
$my_log->update($no, 1);
echo "No.{$no} created.<br>\n";
}
}
$my_log->update();
echo "Index pages created.<br>\n";
} else {
$posts = rebuildqueue_take_all();
foreach ($posts as $no) {
$deferred = $my_log->update($no, 1) ? ' (deferred)' : '';
if ($no) {
echo "No.{$no} created.{$deferred}<br>\n";
} else {
echo "Index pages created.{$deferred}<br>\n";
}
}
}
$totaltime = microtime(true) - $starttime;
echo "<br>Time elapsed (lock excluded): {$totaltime} seconds", "<br>Pages created.<br><br>\nRedirecting back to board.\n<META HTTP-EQUIV=\"refresh\" content=\"10;URL=" . PHP_SELF2 . "\">";
}