本文整理汇总了PHP中GDO::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP GDO::escape方法的具体用法?PHP GDO::escape怎么用?PHP GDO::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDO
的用法示例。
在下文中一共展示了GDO::escape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isFlooding
public function isFlooding()
{
$uid = GWF_Session::getUserID();
$uname = GWF_Shoutbox::generateUsername();
$euname = GDO::escape($uname);
$table = GDO::table('GWF_Shoutbox');
$max = $uid === 0 ? $this->module->cfgMaxPerDayGuest() : $this->module->cfgMaxPerDayUser();
// $cut = GWF_Time::getDate(GWF_Time::LEN_SECOND, time()-$this->module->cfgTimeout());
// $cnt = $table->countRows("shout_uname='$euname' AND shout_date>'$cut'");
# Check captcha
if ($this->module->cfgCaptcha()) {
require_once GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
if (!PhpCaptcha::Validate(Common::getPostString('captcha'), true)) {
return GWF_HTML::err('ERR_WRONG_CAPTCHA');
}
}
# Check date
$timeout = $this->module->cfgTimeout();
$last_date = $table->selectVar('MAX(shout_date)', "shout_uid={$uid} AND shout_uname='{$euname}'");
$last_time = $last_date === NULL ? 0 : GWF_Time::getTimestamp($last_date);
$next_time = $last_time + $timeout;
if ($last_time + $timeout > time()) {
return $this->module->error('err_flood_time', array(GWF_Time::humanDuration($next_time - time())));
}
# Check amount
$today = GWF_Time::getDate(GWF_Date::LEN_SECOND, time() - $timeout);
$count = $table->countRows("shout_uid={$uid} AND shout_date>='{$today}'");
if ($count >= $max) {
return $this->module->error('err_flood_limit', array($max));
}
# All fine
return false;
}
示例2: templateUsers
private function templateUsers($term = '')
{
$ipp = $this->module->cfgIPP();
$form = $this->getFormQuick();
$usertable = GDO::table('GWF_User');
$by = Common::getGet('by', '');
$dir = Common::getGet('dir', '');
$orderby = $usertable->getMultiOrderby($by, $dir);
if ($term === '') {
$users = array();
$page = 1;
$nPages = 0;
} else {
$eterm = GDO::escape($term);
$deleted = GWF_User::DELETED;
$conditions = "user_name LIKE '%{$eterm}%' AND user_options&{$deleted}=0";
$nItems = $usertable->countRows($conditions);
$nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
$page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
$from = GWF_PageMenu::getFrom($page, $ipp);
$users = $usertable->selectObjects('*', $conditions, $orderby, $ipp, $from);
}
$href_pagemenu = GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=%PAGE%';
$tVars = array('form' => $form->templateX(false, false), 'users' => $users, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1', 'page_menu' => GWF_PageMenu::display($page, $nPages, $href_pagemenu), 'href_adv' => $this->module->getMethodURL('SearchAdv'));
return $this->module->templatePHP('search.php', $tVars);
}
示例3: getByName
public static function getByName($name, $user = true)
{
if ($user === true) {
$user = GWF_Session::getUser();
}
$uid = $user->getID();
$name = GDO::escape($name);
return self::table(__CLASS__)->selectFirst('1', "pmf_name='{$name}' AND pmf_uid={$uid}") !== false;
}
示例4: getFailedData
public static function getFailedData(GWF_User $user, $time)
{
$ip = GDO::escape(GWF_IP6::getIP(GWF_IP_EXACT));
$cut = time() - $time;
if (false === ($result = GDO::table(__CLASS__)->selectFirst('COUNT(*) c, MIN(logfail_time) min', "logfail_ip='{$ip}' AND logfail_time>{$cut}"))) {
return array(0, 0);
}
return array((int) $result['c'], (int) $result['min']);
}
示例5: deletePlayer
private static function deletePlayer(SR_Player $player)
{
$epname = GDO::escape($player->getName());
if (false === GDO::table('SR_BazarShop')->deleteWhere("sr4bs_pname='{$epname}'")) {
return false;
}
if (false === GDO::table('SR_BazarItem')->deleteWhere("sr4ba_pname='{$epname}'")) {
return false;
}
}
示例6: getRequest
/**
* Get the player for a join request.
* @param SR_Player $leader
* @param SR_Clan $clan
* @param string $pname
* @return SR_Player
*/
public static function getRequest(SR_Player $leader, SR_Clan $clan, $pname)
{
$ename = GDO::escape($pname);
if (false === ($pid = self::table(__CLASS__)->selectVar('sr4cr_pid', "sr4cr_pname='{$ename}'"))) {
return false;
}
if (false === ($player = Shadowrun4::getPlayerByPID($pid))) {
if (false === ($player = SR_Player::getByID($pid))) {
return false;
}
}
return $player;
}
示例7: calcMaps
private static function calcMaps(GDO_Database $db_from, GDO_Database $db_to, array &$db_offsets, $prefix, $prevar)
{
$classname = 'GWF_ForumBoard';
$db_offsets[$classname] = array();
GDO::setCurrentDB($db_from);
$table_from = GDO::table($classname);
if (false === ($result = $table_from->select('*', '', 'board_bid ASC'))) {
echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
return false;
}
GDO::setCurrentDB($db_to);
$table_to = GDO::table($classname);
while (false !== ($row = $table_from->fetch($result, GDO::ARRAY_A))) {
$bid_from = $row['board_bid'];
$title_from = $row['board_title'];
$etitle_from = GDO::escape($title_from);
if (false !== ($oldbid = $table_to->selectVar('board_bid', "board_title='{$etitle_from}'"))) {
$db_offsets[$classname][$bid_from] = $oldbid;
echo "BID {$bid_from} => {$oldbid}\n";
$table_to->update("board_postcount = board_postcount + {$row['board_postcount']}", "board_bid = {$oldbid}");
$table_to->update("board_threadcount = board_threadcount + {$row['board_threadcount']}", "board_bid = {$oldbid}");
} else {
if ($row['board_pid'] > 0) {
$row['board_bid'] = '0';
$row['board_pid'] |= 0x40000000;
// PID HAS TO GET CONVERTED after this run
$row['board_gid'] = $db_offsets['GWF_Group'][$row['board_gid']];
$row['board_pos'] = $table_to->selectVar('COUNT(*)') + 1;
$table_to->insertAssoc($row);
$newbid = $db_to->insertID();
$db_offsets[$classname][$bid_from] = $newbid;
echo "BID {$bid_from} => {$newbid}\n";
} else {
$db_offsets[$classname][$bid_from] = $oldbid;
echo "BID {$bid_from} => {$oldbid}\n";
$table_to->update("board_postcount = board_postcount + {$row['board_postcount']}", "board_pid = 0");
$table_to->update("board_threadcount = board_threadcount + {$row['board_threadcount']}", "board_pid = 0");
}
}
}
$table_from->free($result);
return true;
}
示例8: insertTag
private static function insertTag($tag, $pid, $langid)
{
# Insert tagname
$etag = GDO::escape($tag);
$langid = (int) $langid;
if (false === ($tid = GDO::table(__CLASS__)->selectVar('ptag_tid', "ptag_tag='{$etag}' AND ptag_lang={$langid}"))) {
$newtag = new self(array('ptag_tid' => '0', 'ptag_lang' => $langid, 'ptag_tag' => $tag, 'ptag_count' => '1'));
if (false === $newtag->insert()) {
return GWF_Error::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
if (0 == ($tid = $newtag->getID())) {
return GWF_Error::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
}
# Insert into map
$data = array('ptm_pid' => $pid, 'ptm_tid' => $tid);
if (false === GDO::table('GWF_PageTagMap')->insertAssoc($data, true)) {
return GWF_Error::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
return true;
}
示例9: onSearch
private function onSearch()
{
$form = $this->formSearch();
if (false !== ($error = $form->validate($this->module))) {
return $error . $this->templateSearch();
}
$ipp = self::IPP;
$term = $form->getVar('searchterm');
$tagname = NULL;
$table = GDO::table('Slay_Song');
$whitelist = array('(ss_lyrics>0)', '(ss_options&1)', '(ss_sid_path!=NULL)');
$joins = array('lyrics');
if (false === ($where = GWF_QuickSearch::getQuickSearchConditions($table, array('ss_artist', 'ss_title', 'ss_composer'), $term))) {
return GWF_HTML::err('ERR_SEARCH_TERM') . $this->templateSearch();
}
$term2 = GDO::escape($term);
// $term2 = str_replace(array('%', '_'), array('\\%', '\\_'), $term);
$term3 = '1';
if ('0' !== ($tag = $form->getVar('searchtag'))) {
$tagname = Slay_Tag::getNameByID($tag);
$term3 = 'sst_count>0';
$joins[] = 'searchtag';
}
$where = "(({$where}) OR (ssl_lyrics LIKE '%{$term2}%')) AND ({$term3})";
$nItems = $table->countRows($where, $joins);
$nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
$page = Common::clamp(Common::getGetInt('page'), 1, $nPages);
$from = GWF_PageMenu::getFrom($page, $ipp);
$by = Common::getGetString('by', self::BY);
$dir = Common::getGetString('dir', self::DIR);
$orderby = $table->getMultiOrderby($by, $dir, false, $whitelist);
$matches = $table->selectAll('*', $where, $orderby, $joins, $ipp, $from, GDO::ARRAY_O);
$headers = array(array(), array($this->module->lang('L'), '(ss_lyrics>0)'), array($this->module->lang('T'), 'ss_taggers'), array($this->module->lang('D'), '(ss_options&1)'), array($this->module->lang('th_artist'), 'ss_artist'), array($this->module->lang('th_title'), 'ss_title'), array($this->module->lang('th_duration'), 'ss_duration'), array($this->l('th_bpm'), 'ss_bpm'), array($this->l('th_key'), 'ss_key'));
if ($tag > 0) {
$headers[] = array($this->module->lang(Slay_Tag::getNameByID($tag)), 'sst_count');
}
$headers[] = array($this->module->lang('th_tags'));
$tVars = array('form' => $form->templateX($this->module->lang('ft_search'), GWF_WEB_ROOT . 'index.php'), 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=Slaytags&me=Search&searchterm=%s&searchtag=%s&by=%s&dir=%s&page=%%PAGE%%', urlencode($term), $tag, urlencode($by), urlencode($dir))), 'matches' => $matches, 'sort_url' => GWF_WEB_ROOT . sprintf('index.php?mo=Slaytags&me=Search&searchterm=%s&searchtag=%s&by=%%BY%%&dir=%%DIR%%&page=1', urlencode($term), $tag), 'is_admin' => GWF_User::isStaffS(), 'headers' => $headers, 'singletag' => $tagname, 'no_match' => count($matches) === 0);
return $this->module->template('search.tpl', $tVars);
}
示例10: execute
public function execute()
{
GWF_Website::plaintext();
if (false === ($datestamp = Common::getGet('datestamp'))) {
return 'TRY ?datestamp=YYYYMMDDHHIISS&limit=5';
}
if (strlen($datestamp) !== 14) {
return 'TRY ?datestamp=YYYYMMDDHHIISS&limit=5';
}
if (0 === ($limit = Common::getGetInt('limit', 0))) {
return 'TRY ?datestamp=YYYYMMDDHHIISS&limit=5';
}
$date = GDO::escape($datestamp);
$limit = Common::clamp($limit, 1, 25);
if (false === ($result = GDO::table('GWF_ForumThread')->selectObjects('*', "thread_lastdate>='{$date}' AND thread_options&4=0", 'thread_lastdate DESC', $limit))) {
return GWF_HTML::lang('ERR_DATABASE', __FILE__, __LINE__);
}
$back = '';
$unknown = GWF_HTML::lang('unknown');
foreach (array_reverse($result) as $thread) {
#timestamp::lock::postid::threadid::posturl::userurl::username::title
$thread instanceof GWF_ForumThread;
$locked = $thread->getVar('thread_gid') === '0' ? '0' : '1';
$back .= $thread->getVar('thread_tid');
$back .= '::';
$back .= $thread->getVar('thread_lastdate');
$back .= '::';
$back .= $thread->getVar('thread_gid');
$back .= '::';
$back .= 'https://' . GWF_DOMAIN . $thread->getLastPageHREF($locked === '1');
$back .= '::';
$back .= $locked === '1' ? $unknown : $this->getLastPosterName($thread);
$back .= '::';
$back .= $locked === '1' ? $unknown : $thread->getVar('thread_title');
$back .= PHP_EOL;
}
return $back;
}
示例11: hookRenameUser
public function hookRenameUser(GWF_User $user, array $args)
{
list($oldname, $newname) = $args;
$newname = GDO::escape($newname);
$uid = $user->getID();
$sid = WC_Site::getWeChall()->getID();
return GDO::table('WC_RegAt')->update("regat_onsitename='{$newname}'", "regat_uid={$uid} AND regat_sid={$sid}");
}
示例12: setRootOptions
/**
* Set options that may be set by the owner of the root page, like group and stuff.
* @param GWF_Page $page
* @param string $gstring
* @return boolean
*/
private function setRootOptions(GWF_Page $page, $gstring)
{
$pages = GDO::table('GWF_Page');
$bits = GWF_Page::LOGIN_REQUIRED | GWF_Page::SHOW_TRANS | GWF_Page::SHOW_SIMILAR | GWF_Page::SHOW_MODIFIED;
$page->setOption($bits, false);
$otherid = $page->getOtherID();
# Kill all bits.
$bits = ~$bits;
if (false === $pages->update("page_options=page_options&{$bits}", "page_otherid={$otherid}")) {
return false;
}
# Set the new bits.
$bits = 0;
$bits |= isset($_POST['noguests']) ? GWF_Page::LOGIN_REQUIRED : 0;
$bits |= isset($_POST['show_similar']) ? GWF_Page::SHOW_SIMILAR : 0;
$bits |= isset($_POST['show_modified']) ? GWF_Page::SHOW_MODIFIED : 0;
$bits |= isset($_POST['show_trans']) ? GWF_Page::SHOW_TRANS : 0;
$page->setOption($bits, true);
$page->setVar('page_groups', $gstring);
$gstring = GDO::escape($gstring);
# Fire the sql
return GDO::table('GWF_Page')->update("page_groups='{$gstring}', page_options=page_options|{$bits}", "page_otherid={$otherid}");
}
示例13: validateSolution3
public static function validateSolution3($code)
{
$code = strtolower($code);
if (false === ($playername = Common::substrUntil($code, '!', false))) {
return -1;
}
$solution = self::getSolution3($playername);
if ($code !== $solution) {
return 0;
}
$table = GDO::table(__CLASS__);
$epname = GDO::escape($playername);
if (false !== ($row = $table->selectFirst('1', "csl_player='{$epname}' AND csl_cnum=3"))) {
return -2;
}
if (false === $table->insertAssoc(array('csl_player' => $playername, 'csl_cnum' => 3, 'csl_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)))) {
return -3;
}
return 1;
}
示例14: helpRace
private static function helpRace($race)
{
$base = SR_Player::$RACE_BASE[$race];
$bonus = SR_Player::$RACE[$race];
$out = array();
foreach ($base as $k => $v) {
$out[$k] = array(0, 0);
}
foreach ($bonus as $k => $v) {
$out[$k] = array(0, 0);
}
foreach ($base as $k => $v) {
$out[$k] = array($v, $v);
}
foreach ($bonus as $k => $v) {
$out[$k][1] += $v;
}
unset($out['height']);
unset($out['age']);
unset($out['bmi']);
$erace = GDO::escape($race);
$pop = GDO::table('SR_Player')->selectVar('COUNT(*)', "sr4pl_race='{$erace}'");
$back = sprintf(', Population(%d)', $pop);
foreach ($out as $k => $data) {
$back .= sprintf(', %s: %s(%s)', $k, $data[0], $data[1]);
}
return sprintf(' Stats: %s.', substr($back, 2));
}
示例15: getByOnsitename
/**
* Get a regat row by onsitename.
* @param int $siteid
* @param string $onsitename
* @return WC_RegAt
*/
public static function getByOnsitename($siteid, $onsitename)
{
$siteid = (int) $siteid;
$onsitename = GDO::escape($onsitename);
return self::table(__CLASS__)->selectFirstObject('*', "regat_sid={$siteid} AND regat_onsitename='{$onsitename}'");
}