本文整理汇总了PHP中Vars类的典型用法代码示例。如果您正苦于以下问题:PHP Vars类的具体用法?PHP Vars怎么用?PHP Vars使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vars类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLang
/**
* Sets initial language configuration for global use.
*/
public function setLang()
{
$session = new Session();
$vars = new Vars();
if (!$session->exists('lang') || $vars->get('lang')) {
$session->set('lang', $vars->get('lang') ? $vars->get('lang') : self::DEFAULT_LANG);
}
}
示例2: run
public function run()
{
$model = new Vars();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Vars'])) {
$model->attributes = $_POST['Vars'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例3: beginRequest
function beginRequest($event)
{
$app = Yii::app();
$app->name = Vars::model()->find("varname='SITE_NAME'")->varvalue;
$app->params['adminEmail'] = Vars::model()->find("varname='adminEmail'")->varvalue;
$app->params['footerinfo'] = Vars::model()->find("varname='FOOTERINFO'")->varvalue;
}
示例4: draw
static function draw()
{
$page = self::urlArray(0);
if ($page != "setupcomplete" && $page != "action" && file_exists(getSitePath() . "install/")) {
forward("setupcomplete");
}
$body = $header = $nav = $footer = NULL;
if ($page) {
$page_handler_class = "SocialApparatus\\" . ucfirst($page) . "PageHandler";
} else {
$page_handler_class = "SocialApparatus\\HomePageHandler";
}
Vars::clear();
if (class_exists($page_handler_class)) {
$body = (new $page_handler_class())->view();
} else {
new SystemMessage("Page not found.");
forward("home");
}
Vars::clear();
$header = display("page_elements/header");
Vars::clear();
$nav = display("page_elements/navigation");
Vars::clear();
$footer = display("page_elements/footer");
Vars::clear();
echo $header;
echo $nav;
echo $body;
echo $footer;
Debug::clear();
Dbase::con()->close();
die;
}
示例5: getAllAssets
static function getAllAssets($which_end)
{
// if cached already, return it
if (isset(self::$assets)) {
return self::$assets;
}
// otherwise, get it from settings
$settings = Vars::getSettings();
$assets = array();
$i = 0;
$indexes = array();
foreach ($settings['assets'][$which_end] as $type => $asset_group) {
foreach ($asset_group as $asset_key => $asset_attributes) {
$asset = new Asset();
$asset->type = $type;
$asset->path = $asset_attributes['path'];
$asset->source = $asset_attributes['source'];
$asset->position = $asset_attributes['position'];
$asset->weight = $asset_attributes['weight'];
$asset->key = $asset_key;
$assets[$i] = $asset;
$indexes[$i] = $asset->weight;
$i++;
}
}
asort($indexes);
$rtn = array();
foreach ($indexes as $key => $val) {
$rtn[] = $assets[$key];
}
return $rtn;
}
示例6: getThumbnailUrl
public function getThumbnailUrl()
{
if ($this->getThumbnail()) {
return get_sub_root() . "/files/avatars/" . $this->getThumbnail();
}
$settings = Vars::getSettings();
return get_sub_root() . "/files/avatars/" . $settings['profile']['avatar_default'];
}
示例7: loadEngineTasks
public static function loadEngineTasks()
{
CodonRewrite::ProcessRewrite();
Vars::setParameters();
self::$activeModule = strtoupper(CodonRewrite::$current_module);
Config::loadSettings();
self::loadModules();
}
示例8: delete
public function delete()
{
$settings = Vars::getSettings();
// we delete avatar image first
if ($this->getThumbnail() != $settings['profile']['avatar_default']) {
@unlink(AVATAR_DIR . '/' . $this->getThumbnail());
}
parent::delete();
}
示例9: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
*/
public function loadModel()
{
if ($this->_model === null) {
if (isset($_GET['id'])) {
$this->_model = Vars::model()->findbyPk($_GET['id']);
}
if ($this->_model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
return $this->_model;
}
示例10: testExecute
function testExecute()
{
$f1 = new Filter1();
$f2 = new Filter2();
$fc = new \Hiano\Filter\FilterChain(function () {
Vars::$callback_executed = TRUE;
});
$fc->addFilter($f1);
$fc->addFilter($f2);
$fc->execute();
$this->assertEquals(TRUE, Vars::$f1_executed);
$this->assertEquals(TRUE, Vars::$f2_executed);
$this->assertEquals(TRUE, Vars::$callback_executed);
}
示例11: getArticles
public function getArticles($page = 1, $category = null, $unread = null)
{
global $mysqli;
$user_account_table = 'user_' . $this->getId() . '_account';
$user_category_table = 'user_' . $this->getId() . '_category';
$user_read_table = 'user_' . $this->getId() . '_read';
// where
$where = array();
if ($category) {
$where[] = " ua.category_id={$category} ";
}
if (sizeof($where)) {
$where = " WHERE " . implode(' AND ', $where) . " ";
if ($unread == 1) {
$where .= " AND ur.article_id IS NULL ";
}
} else {
$where = '';
if ($unread == 1) {
$where = " WHERE ur.article_id IS NULL";
}
}
// join
$join = "";
if ($unread == 1) {
$join = " LEFT JOIN {$user_read_table} as ur ON ur.article_id=wa.id ";
}
// limit
$limit = "";
if ($page) {
$settings = Vars::getSettings();
$limit = " LIMIT " . ($page - 1) * $settings['articles_per_page'] . ", " . $settings['articles_per_page'];
}
// order by
$order_by = ' ORDER BY wa.published_at DESC ';
///// final query
$query = "SELECT wa.*, ua.id AS user_wechat_account_id FROM wechat_article as wa JOIN {$user_account_table} as ua ON ua.account_id=wa.account_id {$join} {$where} {$order_by} {$limit}";
//_debug($query);
$result = $mysqli->query($query);
$rtn = array();
while ($result && ($b = $result->fetch_object())) {
$obj = new WechatArticle();
DBObject::importQueryResultToDbObject($b, $obj);
$obj->user_wechat_account_id = $b->user_wechat_account_id;
$rtn[] = $obj;
}
return $rtn;
}
示例12: sendTicketToClient
function sendTicketToClient($subject, $msg, array $attachements, $to)
{
$settings = Vars::getSettings();
$username = $settings['mail']['ticket']['username'];
$password = $settings['mail']['ticket']['password'];
if (strpos($username, '@') == false) {
$username = decrypt($username);
$password = decrypt($password);
}
load_library_phpmailer();
$mail = new PHPMailer(true);
try {
// $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->Mailer = $settings['mail']['ticket']['mailer'];
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->CharSet = 'UTF-8';
$mail->SMTPSecure = $settings['mail']['ticket']['SMTPSecure'];
// sets the prefix to the servier
$mail->Host = $settings['mail']['ticket']['host'];
// sets GMAIL as the SMTP server
$mail->Port = $settings['mail']['ticket']['port'];
// set the SMTP port for the GMAIL server
$mail->Username = $username;
// GMAIL username
$mail->Password = $password;
// GMAIL password
$mail->AddReplyTo($settings['mail']['ticket']['from']);
$mail->AddAddress($to);
$mail->SetFrom($settings['mail']['ticket']['from'], $settings['sitename']);
$mail->Subject = $subject;
$mail->MsgHTML($msg);
foreach ($attachements as $ticket) {
$mail->addAttachment($ticket);
}
$mail->Send();
} catch (phpmailerException $e) {
$log = new Log('mail', Log::ERROR, 'Failed to send email: ' . $e->errorMessage());
$log->save();
return false;
} catch (Exception $e) {
$log = new Log('mail', Log::ERROR, 'Failed to send email: ' . $e->getMessage());
$log->save();
return false;
}
return true;
}
示例13: ValidateConfirm
public static function ValidateConfirm()
{
$confid = Vars::GET('confirmid');
$sql = "UPDATE " . TABLE_PREFIX . "pilots SET confirmed=1, retired=0 WHERE salt='{$confid}'";
$res = DB::query($sql);
if (DB::errno() != 0) {
return false;
}
return true;
}
示例14: denyDirect
*
* NOTICE: All information contained herein is, and remains the property of SocialApparatus
* and its suppliers, if any. The intellectual and technical concepts contained herein
* are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign
* Patents, patents in process, and are protected by trade secret or copyright law.
*
* Dissemination of this information or reproduction of this material is strictly forbidden
* unless prior written permission is obtained from SocialApparatus.
*
* Contact Shane Barron admin@socia.us for more information.
*/
namespace SocialApparatus;
denyDirect();
$label = Vars::get("label");
$class = Vars::get("class");
$cancel = Vars("cancel");
if (!$label) {
$label = "Save";
}
if (!$class) {
$class = "btn btn-success";
}
if ($cancel) {
echo <<<HTML
<span class='btn-group'>
HTML;
}
echo <<<HTML
<input type="submit" class="{$class}" value="{$label}">
HTML;
示例15: exit
<?php
if (!defined('BASEPATH')) {
exit('Nu poti accesa acest fisier direct.');
}
$expire = $CFG->get('rank_regenerate');
$expire = 0;
if (Cache::is_cached('top_10_players', $expire)) {
Vars::set('players_rank', Cache::get('top_10_players'));
} else {
$players = array();
$sql = "SELECT player.id, player.name, player.level, player_index.empire \n FROM " . PLAYER_DATABASE . ".player \n LEFT JOIN " . PLAYER_DATABASE . ".player_index ON player_index.id=player.account_id \n LEFT JOIN " . PLAYER_DATABASE . ".guild_member ON guild_member.pid=player.id \n INNER JOIN " . ACCOUNT_DATABASE . ".account \n ON account.id=player.account_id\n WHERE player.name NOT LIKE '[%]%' AND account.status!='BLOCK'\n ORDER BY player.level DESC, player.exp DESC LIMIT 10";
$query = $DB->query($sql);
while ($row = $DB->fetch($query)) {
$players[] = $row;
}
Cache::set('top_10_players', $players);
Vars::set('players_rank', $players);
}
if (Cache::is_cached('top_10_guilds', $expire)) {
Vars::set('guilds_rank', Cache::get('top_10_guilds'));
} else {
$guilds = array();
$sql = "SELECT \n guild.name, guild.level, guild.win, guild.ladder_point, player_index.empire\n FROM " . PLAYER_DATABASE . ".guild \n LEFT JOIN " . PLAYER_DATABASE . ".player ON guild.master = player.id \n LEFT JOIN " . PLAYER_DATABASE . ".player_index ON player_index.id = player.account_id \n WHERE player.name NOT LIKE '[%]%' \n ORDER BY guild.ladder_point DESC LIMIT 10";
$query = $DB->query($sql);
while ($row = $DB->fetch($query)) {
$guilds[] = $row;
}
Cache::set('top_10_guilds', $guilds);
Vars::set('guilds_rank', $guilds);
}