本文整理汇总了PHP中Tbl类的典型用法代码示例。如果您正苦于以下问题:PHP Tbl类的具体用法?PHP Tbl怎么用?PHP Tbl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tbl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: customInitBeforeObjects
protected function customInitBeforeObjects()
{
Tbl::registerTableNames('TextsGroupManager');
Tbl::registerTableNames('TextsManager');
Tbl::registerTableNames('TextsValuesManager');
Tbl::registerTableNames('TextsAliasManager');
}
示例2: checkCredentials
/**
* Check validity of username, password and other auth factors
*
* @param string $username
* @param string $password
* @param array $additionalCredentials
* @param boolean $writeCookie
* @throws UserAuthFailedException
* @return User
*/
public function checkCredentials($username, $password, $additionalCredentials = array(), $writeCookie = false)
{
$qb = new QueryBuilder();
$qb->select(new Field('id'), new Field('password'), new Field('salt'))->from(Tbl::get('TBL_USERS', 'UserManager'))->where($qb->expr()->equal(new Field('login'), $username));
$this->query->exec($qb->getSQL());
if ($this->query->countRecords() == 1) {
$userData = $this->query->fetchRecord();
$hashToCheck = static::getUserPasswordHash($password, $userData['salt']);
if ($userData['password'] === $hashToCheck) {
$usr = $this->doLogin($userData['id'], $additionalCredentials, $writeCookie);
try {
$hookParams = array("user" => $usr, "additionalCredentials" => $additionalCredentials);
HookManager::callHook("UserAuthSuccess", $hookParams);
} catch (UserAuthFailedException $e) {
$this->doLogout();
throw $e;
}
return $usr;
}
}
// Failed login nothing returned from above code
$hookParams = array("username" => $username, "password" => $password, "additionalCredentials" => $additionalCredentials);
HookManager::callHook("UserAuthFail", $hookParams);
throw new UserAuthFailedException("Incorrect login/password combination");
}
示例3: queryString
protected static function queryString($lang_id = null, $host_id = null, $module = null, $page = null, $cacheMinutes = null)
{
$qb = new QueryBuilder();
$qb->select(new Field('title'), new Field('meta_keywords'), new Field('meta_description'))->from(Tbl::get('TBL_PAGE_INFO'));
if ($lang_id === null) {
$qb->andWhere($qb->expr()->isNull(new Field('lang_id')));
} else {
$qb->andWhere($qb->expr()->equal(new Field('lang_id'), $lang_id));
}
if ($host_id === null) {
$qb->andWhere($qb->expr()->isNull(new Field('host_id')));
} else {
$qb->andWhere($qb->expr()->equal(new Field('host_id'), $host_id));
}
if ($module === null) {
$qb->andWhere($qb->expr()->isNull(new Field('module')));
} else {
$qb->andWhere($qb->expr()->equal(new Field('module'), $module));
}
if ($page === null) {
$qb->andWhere($qb->expr()->isNull(new Field('page')));
} else {
$qb->andWhere($qb->expr()->equal(new Field('page'), $page));
}
return $qb->getSQL();
}
示例4: doLogin
/**
* Does login operation
* @param string $username
* @param string $password
* @param bool $writeCookie
* @param bool $isPasswordEncrypted
*
* @throws RuntimeException (Codes: 1 - Incorrect login/password combination, 2 - Account is disabled)
*/
public function doLogin($username, $password, $writeCookie = false, $isPasswordEncrypted = false)
{
if ($this->um->checkCredentials($username, $password, $isPasswordEncrypted)) {
$this->usr = $this->um->getObjectByLogin($username);
$this->authorize($this->usr);
$this->saveUserId($this->usr->getId());
if ($writeCookie) {
$secs = getdate();
$exp_time = $secs[0] + 60 * 60 * 24 * $this->config->rememberDaysCount;
$cookie_value = $this->usr->getId() . ":" . hash('sha256', $username . ":" . md5($password));
setcookie($this->config->loginCookieName, $cookie_value, $exp_time, '/');
}
if (Reg::get('packageMgr')->isPluginLoaded("Security", "RequestLimiter") and $this->config->bruteForceProtectionEnabled) {
$this->query->exec("DELETE FROM `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` WHERE `ip`='" . $_SERVER['REMOTE_ADDR'] . "'");
}
} else {
if (Reg::get('packageMgr')->isPluginLoaded("Security", "RequestLimiter") and $this->config->bruteForceProtectionEnabled) {
$this->query->exec("SELECT `count` \n\t\t\t\t\t\t\t\t\t\t\tFROM `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` \n\t\t\t\t\t\t\t\t\t\t\tWHERE `ip`='" . $_SERVER['REMOTE_ADDR'] . "'");
$failedAuthCount = $this->query->fetchField('count');
$newFailedAuthCount = $failedAuthCount + 1;
if ($newFailedAuthCount >= $this->config->failedAuthLimit) {
Reg::get(ConfigManager::getConfig("Security", "RequestLimiter")->Objects->RequestLimiter)->blockIP();
$this->query->exec("DELETE FROM `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` WHERE `ip`='" . $_SERVER['REMOTE_ADDR'] . "'");
throw new RequestLimiterTooManyAuthTriesException("Too many unsucessful authorization tries.");
}
$this->query->exec("INSERT INTO `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` (`ip`) \n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $_SERVER['REMOTE_ADDR'] . "')\n\t\t\t\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE `count` = `count` + 1");
}
throw new RuntimeException("Incorrect login/password combination", static::EXCEPTION_INCORRECT_LOGIN_PASSWORD);
}
}
示例5: getLastId
public function getLastId()
{
$qb = new QueryBuilder();
$qb->select($qb->expr()->max(new Field('id'), 'lastId'))->from(Tbl::get('TBL_CHAT_MESSAGES'));
$lastId = $this->query->exec($qb->getSQL())->fetchField('lastId');
return empty($lastId) ? 0 : $lastId;
}
示例6: unblockIP
/**
* Unblock blocked IP
* @param string $ip
*/
public function unblockIP($ip = null)
{
if ($ip === null) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$this->query->exec("DELETE FROM `" . Tbl::get('TBL_SECURITY_FLOODER_IPS') . "` WHERE `ip` = '{$ip}'");
}
示例7: logCustom
public static function logCustom($name, $value)
{
$remoteIP = "";
if (isset($_SERVER['REMOTE_ADDR'])) {
$remoteIP = $_SERVER['REMOTE_ADDR'];
}
Reg::get('sql')->exec("INSERT DELAYED INTO `" . Tbl::get("TBL_MIXED_LOG") . "` \n\t\t\t\t\t\t\t\t\t\t(`session_id`,`name`,`value`,`ip`)\n\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . session_id() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($name) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($value) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'{$remoteIP}'\n\t\t\t\t\t\t\t\t\t\t\t\t)");
}
示例8: fillUsersGps
public function fillUsersGps($userId, $leafId)
{
$this->query->exec("delete from `" . Tbl::get('TBL_USERS_GPS') . "` where `user_id`='{$userId}'");
$gpsTree = $this->getNodeTree($leafId);
foreach ($gpsTree as $treeNode) {
$this->query->exec("INSERT INTO `" . Tbl::get('TBL_USERS_GPS') . "` (`user_id`,`node_id`) VALUES('{$userId}','{$treeNode["node_id"]}')");
}
}
示例9: isValidCountryCode
/**
* Check if given country code is valid
*
* @param string $countryCode
* @param int $cacheMinutes
*/
public function isValidCountryCode($countryCode = null, $cacheMinutes = null)
{
$this->query->exec("SELECT count(*) as `count` FROM " . Tbl::get('TBL_LOCATIONS') . "\n\t\t\t\t\t\t\t\tWHERE `country`='{$countryCode}'", $cacheMinutes);
$count = $this->query->fetchField('count');
if ($count > 0) {
return true;
}
return false;
}
示例10: queryString
protected static function queryString($lang_id = null, $host_id = null, $module = null, $page = null)
{
$lang_where = "lang_id " . ($lang_id === null ? "IS NULL " : "=" . $lang_id);
$host_where = "host_id " . ($host_id === null ? "IS NULL " : "=" . $host_id);
$module_where = "module " . ($module === null ? "IS NULL " : "='" . $module . "'");
$page_where = "page " . ($page === null ? "IS NULL " : "='" . $page . "'");
$query = "SELECT `title`,\t`meta_keywords`, `meta_description` FROM `" . Tbl::get('TBL_PAGE_INFO') . "` \n\t\t\t\t\tWHERE " . $lang_where . "\n\t\t\t\t\tAND " . $host_where . "\n\t\t\t\t\tAND " . $module_where . "\n\t\t\t\t\tAND " . $page_where;
return $query;
}
示例11: logCustom
public static function logCustom($name, $value)
{
$remoteIP = "";
if (isset($_SERVER['REMOTE_ADDR'])) {
$remoteIP = $_SERVER['REMOTE_ADDR'];
}
$qb = new QueryBuilder();
$qb->insert(Tbl::get('TBL_MIXED_LOG'))->values(array("session_id" => session_id(), "name" => $name, "value" => $value, "ip" => $remoteIP));
Reg::get('sql')->exec($qb->getSQL());
}
示例12: __construct
public function __construct($headersOnly = true)
{
parent::__construct();
if ($headersOnly) {
$this->qb->select(new Field("*"));
} else {
$this->qb->select(array(new Field('id', 'main'), new Field('subject', 'main'), new Field('date', 'main'), new Field('sender', 'extra'), new Field('read', 'extra'), new Field('trashed', 'extra'), new Field('deleted', 'extra')));
}
$this->qb->from(Tbl::get('TBL_MESSAGES', 'MessageManagement'), "main")->leftJoin(Tbl::get('TBL_EXTRA', 'MessageManagement'), "extra", $this->qb->expr()->equal(new Field('id', 'main'), new Field('message_id', 'extra')));
}
示例13: deleteGroup
public function deleteGroup(TextsGroup $group)
{
if (empty($group->id)) {
throw new InvalidArgumentException("Group ID have to be specified");
}
if (!is_numeric($group->id)) {
throw new InvalidArgumentException("Group ID have to be integer");
}
$this->query->exec("DELETE FROM `" . Tbl::get('TBL_TEXTS_GROUPS') . "` WHERE `id`='{$group->id}'");
return $this->query->affected();
}
示例14: deleteAllAliasesForTextValue
public function deleteAllAliasesForTextValue(TextValue $textValue)
{
if (empty($textValue->id)) {
throw new InvalidArgumentException("Text Value ID have to be specified");
}
if (!is_numeric($textValue->id)) {
throw new InvalidArgumentException("Text Value ID have to be integer");
}
$this->query->exec("DELETE FROM `" . Tbl::get('TBL_TEXTS_ALIASES') . "` WHERE `value_id`='{$textValue->id}'");
return $this->query->affected();
}
示例15: isValidCountryCode
/**
* Check if given country code is valid
*
* @param string $countryCode
* @param int $cacheMinutes
*/
public function isValidCountryCode($countryCode = null, $cacheMinutes = null)
{
$qb = new QueryBuilder();
$qb->select($qb->expr()->count("*", "count"))->from(Tbl::get('TBL_LOCATIONS'))->where($qb->expr(new Field('country'), $countryCode));
$this->query->exec($qb->getSQL(), $cacheMinutes);
$count = $this->query->fetchField('count');
if ($count > 0) {
return true;
}
return false;
}