本文整理汇总了PHP中XenForo_Application::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Application::getConfig方法的具体用法?PHP XenForo_Application::getConfig怎么用?PHP XenForo_Application::getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Application
的用法示例。
在下文中一共展示了XenForo_Application::getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cliRunDeferredTask
function cliRunDeferredTask($deferred)
{
global $cliHelper;
$runner = XenForo_Deferred_Abstract::create($deferred['execute_class']);
@set_time_limit(0);
if (!$runner) {
$cliHelper->printWarning("{$deferred['execute_class']} deferred class not found.");
return false;
}
$cliHelper->printStatus('');
if (!is_array($deferred['execute_data'])) {
$data = unserialize($deferred['execute_data']);
} else {
$data = $deferred['execute_data'];
}
$targetRunTime = XenForo_Application::getConfig()->rebuildMaxExecution;
while ($data = $runner->execute($deferred, $data, $targetRunTime, $status) and is_array($data)) {
$cliHelper->printStatus($status);
}
if (empty($status)) {
$status = $deferred['execute_class'] . ' (0)';
}
$cliHelper->printStatus($status . ' - Done.');
$cliHelper->printMessage('');
}
示例2: _sendEmail
protected function _sendEmail(array $email, array $user, Zend_Mail_Transport_Abstract $transport)
{
if (!$user['email']) {
return;
}
$phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($email['email_title'] . $email['email_body']);
/** @var XenForo_Model_Phrase $phraseModel */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']);
foreach ($phraseTitles as $search => $phraseTitle) {
if (isset($phrases[$phraseTitle])) {
$email['email_title'] = str_replace($search, $phrases[$phraseTitle], $email['email_title']);
$email['email_body'] = str_replace($search, $phrases[$phraseTitle], $email['email_body']);
}
}
$mailObj = new Zend_Mail('utf-8');
$mailObj->setSubject($email['email_title'])->addTo($user['email'], $user['username'])->setFrom($email['from_email'], $email['from_name']);
$options = XenForo_Application::getOptions();
$bounceEmailAddress = $options->bounceEmailAddress;
if (!$bounceEmailAddress) {
$bounceEmailAddress = $options->defaultEmailAddress;
}
$toEmail = $user['email'];
$bounceHmac = substr(hash_hmac('md5', $toEmail, XenForo_Application::getConfig()->globalSalt), 0, 8);
$mailObj->addHeader('X-To-Validate', "{$bounceHmac}+{$toEmail}");
if ($options->enableVerp) {
$verpValue = str_replace('@', '=', $toEmail);
$bounceEmailAddress = str_replace('@', "+{$bounceHmac}+{$verpValue}@", $bounceEmailAddress);
}
$mailObj->setReturnPath($bounceEmailAddress);
if ($email['email_format'] == 'html') {
$replacements = array('{name}' => htmlspecialchars($user['username']), '{email}' => htmlspecialchars($user['email']), '{id}' => $user['user_id']);
$email['email_body'] = strtr($email['email_body'], $replacements);
$text = trim(htmlspecialchars_decode(strip_tags($email['email_body'])));
$mailObj->setBodyHtml($email['email_body'])->setBodyText($text);
} else {
$replacements = array('{name}' => $user['username'], '{email}' => $user['email'], '{id}' => $user['user_id']);
$email['email_body'] = strtr($email['email_body'], $replacements);
$mailObj->setBodyText($email['email_body']);
}
if (!$mailObj->getMessageId()) {
$mailObj->setMessageId();
}
$thisTransport = XenForo_Mail::getFinalTransportForMail($mailObj, $transport);
try {
$mailObj->send($thisTransport);
} catch (Exception $e) {
if (method_exists($thisTransport, 'resetConnection')) {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
$thisTransport->resetConnection();
try {
$mailObj->send($thisTransport);
} catch (Exception $e) {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed (after retry): ");
}
} else {
XenForo_Error::logException($e, false, "Email to {$user['email']} failed: ");
}
}
}
示例3: processBounceEmail
public function processBounceEmail($rawMessage)
{
$message = new Zend_Mail_Message(array('raw' => $rawMessage));
$options = XenForo_Application::getOptions();
$bounce = new XenForo_BounceParser($message, $options->enableVerp ? $options->bounceEmailAddress : null, XenForo_Application::getConfig()->globalSalt);
$recipient = $bounce->getRecipient();
if ($recipient) {
$userId = $this->_getDb()->fetchOne('SELECT user_id FROM xf_user WHERE email = ?', $recipient);
if (!$userId) {
$userId = null;
}
} else {
$userId = null;
}
$action = '';
if ($userId && $bounce->isActionableBounce()) {
if ($bounce->recipientTrusted()) {
$details = $bounce->getStatusDetails();
if ($details) {
$action = $this->takeBounceAction($userId, $details['type'], $bounce->getMessageDate());
}
} else {
$action = 'untrusted';
}
}
return $this->_logBounceMessage($userId, $action, $bounce, $rawMessage);
}
示例4: getImageProxy
/**
* Checks if image proxy settings need to be applied and applies them
*
* @param string $logoProxy
*
* @return string
*/
public function getImageProxy($logoProxy)
{
if (!empty(XenForo_Application::getOptions()->imageLinkProxy['images'])) {
$hash = hash_hmac('md5', $logoProxy, XenForo_Application::getConfig()->globalSalt . XenForo_Application::getOptions()->imageLinkProxyKey);
$logoProxy = 'proxy.php?' . 'image' . '=' . urlencode($logoProxy) . '&hash=' . $hash;
}
return $logoProxy;
}
示例5: decryptTypeOne
public static function decryptTypeOne($data, $timestamp)
{
if ($timestamp < XenForo_Application::$time) {
throw new XenForo_Exception('$timestamp has expired', false);
}
$algo = self::getDefaultAlgo();
$key = $timestamp . XenForo_Application::getConfig()->get('globalSalt');
return self::decrypt($data, $algo, $key);
}
示例6: getRequestUrl
public static function getRequestUrl(array $provider, $redirectUri, array $extraParams = array())
{
$url = call_user_func_array('sprintf', array('%s/index.php?oauth/authorize/&client_id=%s&redirect_uri=%s&response_type=code&scope=%s', rtrim($provider['root'], '/'), rawurlencode($provider['client_id']), rawurlencode($redirectUri), rawurlencode(self::SCOPE)));
if (XenForo_Application::getConfig()->get(bdApiConsumer_Option::CONFIG_TRACK_AUTHORIZE_URL_STATE) && !isset($extraParams['state'])) {
$extraParams['state'] = base64_encode(json_encode(array('time' => XenForo_Application::$time, 'ip' => XenForo_Helper_Ip::convertIpBinaryToString(XenForo_Application::getSession()->get('ip')))));
}
foreach ($extraParams as $key => $value) {
$url .= sprintf('&%s=%s', $key, rawurlencode($value));
}
return $url;
}
示例7: configure
public function configure(XenForo_ControllerAdmin_Abstract $controller, array &$config)
{
if ($config) {
$db = XenForo_Application::getConfig()->get('db');
$config['db'] = array('host' => $db->host, 'port' => $db->port, 'username' => $db->username, 'password' => $db->password, 'dbname' => $db->dbname);
$this->_bootstrap($config);
return true;
} else {
$input = array('category_id' => 0);
return $controller->responseView('sonnb_XenGallery_ViewAdmin_Import_XenMediaGallery_Config', 'sonnb_xengallery_import_xmg_config', array('input' => $input, 'categories' => $this->_getCategoryModel()->getAllCachedCategories()));
}
}
示例8: actionLogin
public function actionLogin()
{
if (!$this->_request->isPost()) {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildAdminLink('index'));
}
$data = $this->_input->filter(array('login' => XenForo_Input::STRING, 'password' => XenForo_Input::STRING, 'redirect' => XenForo_Input::STRING, 'cookie_check' => XenForo_Input::UINT));
$redirect = $data['redirect'] ? $data['redirect'] : XenForo_Link::buildAdminLink('index');
$loginModel = $this->_getLoginModel();
if ($data['cookie_check'] && count($_COOKIE) == 0) {
// login came from a page, so we should at least have a session cookie.
// if we don't, assume that cookies are disabled
return $this->responseError(new XenForo_Phrase('cookies_required_to_log_in_to_site'));
}
$needCaptcha = $loginModel->requireLoginCaptcha($data['login']);
if ($needCaptcha) {
// just block logins here instead of using the captcha
return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
}
$userModel = $this->_getUserModel();
$userId = $userModel->validateAuthentication($data['login'], $data['password'], $error);
if (!$userId) {
$loginModel->logLoginAttempt($data['login']);
if ($loginModel->requireLoginCaptcha($data['login'])) {
return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
}
if ($this->_input->filterSingle('upgrade', XenForo_Input::UINT)) {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
} else {
// note - JSON view will return responseError($text)
return $this->responseView('XenForo_ViewAdmin_Login_Error', 'login_form', array('text' => $error, 'defaultLogin' => $data['login'], 'redirect' => $redirect), array('containerTemplate' => 'LOGIN_PAGE'));
}
}
$loginModel->clearLoginAttempts($data['login']);
$user = $this->_getUserModel()->getFullUserById($userId, array('join' => XenForo_Model_User::FETCH_USER_PERMISSIONS));
// now check that the user will be able to get into the ACP (is_admin)
if (!$user['is_admin']) {
return $this->responseError(new XenForo_Phrase('your_account_does_not_have_admin_privileges'));
}
/** @var XenForo_ControllerHelper_Login $loginHelper */
$loginHelper = $this->getHelper('Login');
if ($loginHelper->userTfaConfirmationRequired($user)) {
$loginHelper->setTfaSessionCheck($user['user_id']);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('login/two-step', null, array('redirect' => $redirect)));
} else {
$permissions = XenForo_Permission::unserializePermissions($user['global_permission_cache']);
if (empty($user['use_tfa']) && XenForo_Application::getConfig()->enableTfa && (XenForo_Application::getOptions()->adminRequireTfa || XenForo_Permission::hasPermission($permissions, 'general', 'requireTfa'))) {
return $this->responseError(new XenForo_Phrase('you_must_enable_two_step_access_control_panel', array('link' => XenForo_Link::buildPublicLink('account/two-step'))));
}
$postVars = $this->_input->filterSingle('postVars', XenForo_Input::JSON_ARRAY);
return $this->completeLogin($userId, $redirect, $postVars);
}
}
示例9: getTargetRunTime
public function getTargetRunTime($targetRunTime = null)
{
if ($targetRunTime === null) {
$targetRunTime = XenForo_Application::getConfig()->rebuildMaxExecution;
}
if ($targetRunTime < 0) {
$targetRunTime = 0;
} else {
if ($targetRunTime > 0 && $targetRunTime < 2) {
$targetRunTime = 2;
}
}
return $targetRunTime;
}
示例10: _setUp
protected function _setUp()
{
$config = \XenForo_Application::getConfig()->toArray();
$config = $config['db'];
// XenForo only supports MySQL I think...
$config['driver'] = 'mysql';
$config['database'] = $config['dbname'];
$config['collation'] = 'utf8_general_ci';
$config['charset'] = 'utf8';
$pdo = Connector::create($config, true);
$this->_connection = Connection::create($config['driver'], $pdo, $config['database']);
$this->_schema = $this->_connection->getSchemaBuilder();
$this->_db = \XenForo_Application::getDb();
}
示例11: bootstrap
public function bootstrap()
{
if (defined('WIDGET_FRAMEWORK_LOADED')) {
return false;
}
$globalWidgets = $this->_getModelWidget()->getGlobalWidgets(true, false);
$this->addWidgets($globalWidgets);
// sondh@2013-04-02
// detect if we are in debug mode
// previously, put WF in debug mode when XF is in debug mode
// it's no longer the case now, we will look for wfDebug flag in config.php
$wfDebug = XenForo_Application::getConfig()->get('wfDebug');
self::$_debug = !empty($wfDebug);
define('WIDGET_FRAMEWORK_LOADED', 1);
}
示例12: configure
public function configure(XenForo_ControllerAdmin_Abstract $controller, array &$config)
{
if ($config && !empty($config['node_id'])) {
$this->_bootstrap($config);
return true;
} else {
/* @var $nodeModel XenForo_Model_Node*/
$nodeModel = $controller->getModelFromCache('XenForo_Model_Node');
/* @var $categoryModel sonnb_XenGallery_Model_Category*/
$categoryModel = $controller->getModelFromCache('sonnb_XenGallery_Model_Category');
$db = XenForo_Application::getConfig()->get('db');
$viewParams = array('db' => array('host' => $db->host, 'port' => $db->port, 'username' => $db->username, 'password' => $db->password, 'dbname' => $db->dbname), 'nodes' => $nodeModel->getAllNodes(), 'categories' => $categoryModel->getAllCachedCategories());
return $controller->responseView('sonnb_XenGallery_ViewAdmin_Import_Thread_Config', 'sonnb_xengallery_import_thread_config', $viewParams);
}
}
示例13: configure
public function configure(XenForo_ControllerAdmin_Abstract $controller, array &$config)
{
if ($config) {
$errors = $this->validateConfiguration($config);
if ($errors) {
return $controller->responseError($errors);
}
return true;
} else {
$config = XenForo_Application::getConfig();
$dbConfig = $config->get('db');
$viewParams = array('config' => array('db' => array('host' => $dbConfig->host, 'port' => $dbConfig->port, 'username' => $dbConfig->username, 'password' => $dbConfig->password, 'dbname' => $dbConfig->dbname)), 'addOnName' => str_replace('XenTrader: Import From ', '', self::getName()));
}
return $controller->responseView('NixFifty_XenTrader_ViewAdmin_Import_Config', 'nixfifty_xentrader_import_config', $viewParams);
}
示例14: userTfaConfirmationRequired
public function userTfaConfirmationRequired(array $user)
{
$tfaModel = $this->_getTfaModel();
if (!XenForo_Application::getConfig()->enableTfa) {
return false;
}
if ($user['use_tfa'] && $tfaModel->userRequiresTfa($user['user_id'])) {
$trustedKey = $this->getUserTfaTrustedKey();
if ($trustedKey && $tfaModel->getUserTrustedRecord($user['user_id'], $trustedKey)) {
// computer is trusted
} else {
return true;
}
}
return false;
}
示例15: _preSave
protected function _preSave()
{
parent::_preSave();
$config = XenForo_Application::getConfig()->toArray();
if ($this->isChanged('template') && isset($config['template_security'][$this->get('title')])) {
$cfgData = explode(',', $config['template_security'][$this->get('title')]);
$visitor = XenForo_Visitor::getInstance();
if (!in_array($visitor['user_id'], $cfgData)) {
$this->error(new XenForo_Phrase('ats_you_cannot_edit_this_template'), 'template_security');
$superAdmins = $this->getSuperAdmins();
foreach ($superAdmins as $superAdmin) {
XenForo_Model_Alert::alert($superAdmin['user_id'], $visitor['user_id'], $visitor['username'], 'user', $visitor['user_id'], 'forbidden_template');
}
}
}
}