本文整理汇总了PHP中PMF_Configuration::get方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Configuration::get方法的具体用法?PHP PMF_Configuration::get怎么用?PHP PMF_Configuration::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Configuration
的用法示例。
在下文中一共展示了PMF_Configuration::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendOpenQuestionAnswered
/**
* Sends a notification to user who added a question
*
* @param string $email Email address of the user
* @param string $userName Name of the user
* @param string $url URL of answered FAQ
*
* @return void
*/
public function sendOpenQuestionAnswered($email, $userName, $url)
{
$this->mail->addTo($email, $userName);
$this->mail->subject = $this->config->get('main.titleFAQ') . ' - ' . $this->pmfStr['msgQuestionAnswered'];
$this->mail->message = sprintf($this->pmfStr['msgMessageQuestionAnswered'], $this->config->get('main.titleFAQ')) . "\n\r" . $url;
$this->mail->send();
}
示例2: __construct
/**
* Constructor
*
* @param PMF_Configuration $config
*
* @return PMF_Sitemap
*/
public function __construct(PMF_Configuration $config)
{
$this->_config = $config;
if ($this->_config->get('security.permLevel') == 'medium') {
$this->groupSupport = true;
}
}
示例3: init
/**
* @static
* @param PMF_Configuration $faqConfig
*/
public static function init(PMF_Configuration $faqConfig)
{
$config = array();
if ($faqConfig->get('cache.varnishEnable')) {
$config[VARNISH_CONFIG_PORT] = $faqConfig->get('cache.varnishPort');
$config[VARNISH_CONFIG_SECRET] = $faqConfig->get('cache.varnishSecret');
$config[VARNISH_CONFIG_TIMEOUT] = $faqConfig->get('cache.varnishTimeout');
$config[VARNISH_CONFIG_HOST] = $faqConfig->get('cache.varnishHost');
self::$instance = new PMF_Cache_Varnish($config);
} else {
self::$instance = new PMF_Cache_Dummy($config);
}
}
示例4: checkBannedWord
/**
* This function checks the content against a bad word list if the banned
* word spam protection has been activated from the general phpMyFAQ
* configuration.
*
* @param string $content
*
* @return bool
*/
public function checkBannedWord($content)
{
// Sanity checks
$content = PMF_String::strtolower(trim($content));
if ('' === $content || !$this->_config->get('spam.checkBannedWords')) {
return true;
}
// Check if we check more than one word
$checkWords = explode(' ', $content);
if (1 === count($checkWords)) {
$checkWords = array($content);
}
$bannedWords = $this->getBannedWords();
// We just search a match of, at least, one banned word into $content
if (is_array($bannedWords)) {
foreach ($bannedWords as $bannedWord) {
foreach ($checkWords as $word) {
if (PMF_String::strtolower($word) === PMF_String::strtolower($bannedWord)) {
return false;
}
}
}
}
return true;
}
示例5: printOpenQuestions
/**
* Prints the open questions as a XHTML table
*
* @return string
* @access public
* @since 2002-09-17
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function printOpenQuestions()
{
global $sids, $category;
$date = new PMF_Date($this->_config);
$mail = new PMF_Mail($this->_config);
$query = sprintf("\n SELECT\n COUNT(id) AS num\n FROM\n %sfaqquestions\n WHERE\n is_visible != 'Y'", PMF_Db::getTablePrefix());
$result = $this->_config->getDb()->query($query);
$row = $this->_config->getDb()->fetchObject($result);
$numOfInvisibles = $row->num;
if ($numOfInvisibles > 0) {
$extraout = sprintf('<tr><td colspan="3"><small>%s %s</small></td></tr>', $this->pmf_lang['msgQuestionsWaiting'], $numOfInvisibles);
} else {
$extraout = '';
}
$query = sprintf("\n SELECT\n *\n FROM\n %sfaqquestions\n WHERE\n is_visible = 'Y'\n ORDER BY\n created ASC", PMF_Db::getTablePrefix());
$result = $this->_config->getDb()->query($query);
$output = '';
if ($result && $this->_config->getDb()->numRows($result) > 0) {
while ($row = $this->_config->getDb()->fetchObject($result)) {
$output .= '<tr class="openquestions">';
$output .= sprintf('<td><small>%s</small><br /><a href="mailto:%s">%s</a></td>', $date->format(PMF_Date::createIsoDate($row->created)), $mail->safeEmail($row->email), $row->username);
$output .= sprintf('<td><strong>%s:</strong><br />%s</td>', isset($category->categoryName[$row->category_id]['name']) ? $category->categoryName[$row->category_id]['name'] : '', strip_tags($row->question));
if ($this->_config->get('records.enableCloseQuestion') && $row->answer_id) {
$output .= sprintf('<td><a id="PMF_openQuestionAnswered" href="?%saction=artikel&cat=%d&id=%d">%s</a></td>', $sids, $row->category_id, $row->answer_id, $this->pmf_lang['msg2answerFAQ']);
} else {
$output .= sprintf('<td><a class="btn btn-primary" href="?%saction=add&question=%d&cat=%d">%s</a></td>', $sids, $row->id, $row->category_id, $this->pmf_lang['msg2answer']);
}
$output .= '</tr>';
}
} else {
$output = sprintf('<tr><td colspan="3">%s</td></tr>', $this->pmf_lang['msgNoQuestionsAvailable']);
}
return $output . $extraout;
}
示例6: getUsersOnline
/**
* Returns the number of anonymous users and registered ones.
* These are the numbers of unique users who have perfomed
* some activities within the last five minutes
*
* @param integer $activityTimeWindow Optionally set the time window size in sec.
* Default: 300sec, 5 minutes
*
* @return array
*/
public function getUsersOnline($activityTimeWindow = 300)
{
$users = array(0, 0);
if ($this->config->get('main.enableUserTracking')) {
$timeNow = $_SERVER['REQUEST_TIME'] - $activityTimeWindow;
if (!$this->config->get('security.enableLoginOnly')) {
// Count all sids within the time window for public installations
// @todo add a new field in faqsessions in order to find out only sids of anonymous users
$query = sprintf("\n SELECT\n count(sid) AS anonymous_users\n FROM\n %sfaqsessions\n WHERE\n user_id = -1\n AND\n time > %d", PMF_Db::getTablePrefix(), $timeNow);
$result = $this->config->getDb()->query($query);
if (isset($result)) {
$row = $this->config->getDb()->fetchObject($result);
$users[0] = $row->anonymous_users;
}
}
// Count all faquser records within the time window
$query = sprintf("\n SELECT\n count(session_id) AS registered_users\n FROM\n %sfaquser\n WHERE\n session_timestamp > %d", PMF_Db::getTablePrefix(), $timeNow);
$result = $this->config->getDb()->query($query);
if (isset($result)) {
$row = $this->config->getDb()->fetchObject($result);
$users[1] = $row->registered_users;
}
}
return $users;
}
示例7: checkCaptchaCode
/**
* This function checks the provided captcha code
* if the captcha code spam protection has been activated from the general PMF configuration.
*
* @param string $code Captcha Code
* @return bool
*/
public function checkCaptchaCode($code)
{
if ($this->_config->get('spam.enableCaptchaCode')) {
return $this->validateCaptchaCode($code);
} else {
return true;
}
}
示例8: logAdmin
/**
* Adds a new adminlog entry
*
* @param PMF_User $user User object
* @param string $logText Logged string
*
* @return boolean
*/
public function logAdmin(PMF_User $user, $logText = '')
{
if ($this->_config->get('main.enableAdminLog')) {
$query = sprintf("\n INSERT INTO\n %sfaqadminlog\n (id, time, usr, text, ip)\n VALUES \n (%d, %d, %d, '%s', '%s')", PMF_Db::getTablePrefix(), $this->_config->getDb()->nextId(PMF_Db::getTablePrefix() . 'faqadminlog', 'id'), $_SERVER['REQUEST_TIME'], $user->userdata->get('user_id'), $this->_config->getDb()->escape(nl2br($logText)), $_SERVER['REMOTE_ADDR']);
return $this->_config->getDb()->query($query);
} else {
return false;
}
}
示例9: getLatestData
/**
* Return the latest news data
*
* @param boolean $showArchive Show archived news
* @param boolean $active Show active news
* @param boolean $forceConfLimit Force to limit in configuration
*
* @return array
*/
public function getLatestData($showArchive = false, $active = true, $forceConfLimit = false)
{
$news = [];
$counter = 0;
$now = date('YmdHis');
$query = sprintf("\n SELECT\n *\n FROM\n %sfaqnews\n WHERE\n date_start <= '%s'\n AND \n date_end >= '%s'\n %s\n AND\n lang = '%s'\n ORDER BY\n datum DESC", PMF_Db::getTablePrefix(), $now, $now, $active ? "AND active = 'y'" : '', $this->_config->getLanguage()->getLanguage());
$result = $this->_config->getDb()->query($query);
if ($this->_config->get('records.numberOfShownNewsEntries') > 0 && $this->_config->getDb()->numRows($result) > 0) {
while ($row = $this->_config->getDb()->fetchObject($result)) {
$counter++;
if ($showArchive && $counter > $this->_config->get('records.numberOfShownNewsEntries') || !$showArchive && !$forceConfLimit && $counter <= $this->_config->get('records.numberOfShownNewsEntries') || !$showArchive && $forceConfLimit) {
$item = array('id' => $row->id, 'lang' => $row->lang, 'date' => $row->datum, 'lang' => $row->lang, 'header' => $row->header, 'content' => $row->artikel, 'authorName' => $row->author_name, 'authorEmail' => $row->author_email, 'dateStart' => $row->date_start, 'dateEnd' => $row->date_end, 'active' => 'y' == $row->active, 'allowComments' => 'y' == $row->comment, 'link' => $row->link, 'linkTitle' => $row->linktitel, 'target' => $row->target);
$news[] = $item;
}
}
}
return $news;
}
示例10: checkIp
/**
* Performs a check if an IPv4 or IPv6 address is banned
*
* @param string $ip IPv4 or IPv6 address
*
* @return boolean true, if not banned
*/
public function checkIp($ip)
{
$bannedIps = explode(' ', $this->_config->get('security.bannedIPs'));
foreach ($bannedIps as $ipAddress) {
if (0 == strlen($ipAddress)) {
continue;
}
if (false === filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
// Handle IPv4
if ($this->checkForAddrMatchIpv4($ip, $ipAddress)) {
return false;
}
} else {
// Handle IPv6
if ($this->checkForAddrMatchIpv6($ip, $ipAddress)) {
return false;
}
}
}
return true;
}
示例11: reviewResultset
/**
* Check on user and group permissions and on duplicate FAQs
*
* @param array $resultset Array with search results
*
* @return void
*/
public function reviewResultset(array $resultset)
{
$this->setResultset($resultset);
$duplicateResults = [];
$currentUserId = $this->user->getUserId();
if ('medium' === $this->_config->get('security.permLevel')) {
$currentGroupIds = $this->user->perm->getUserGroups($currentUserId);
} else {
$currentGroupIds = array(-1);
}
foreach ($this->rawResultset as $result) {
$permission = false;
// check permissions for groups
if ('medium' === $this->_config->get('security.permLevel')) {
$groupPermission = $this->faq->getPermission('group', $result->id);
if (count($groupPermission) && in_array($groupPermission[0], $currentGroupIds)) {
$permission = true;
}
}
// check permission for user
if ($permission || 'basic' === $this->_config->get('security.permLevel')) {
$userPermission = $this->faq->getPermission('user', $result->id);
if (in_array(-1, $userPermission) || in_array($this->user->getUserId(), $userPermission)) {
$permission = true;
} else {
$permission = false;
}
}
// check on duplicates
if (!isset($duplicateResults[$result->id])) {
$duplicateResults[$result->id] = 1;
} else {
++$duplicateResults[$result->id];
continue;
}
if ($permission) {
$this->reviewedResultset[] = $result;
}
}
$this->setNumberOfResults($this->reviewedResultset);
}
示例12: getSystemUri
/**
* Checks if the system URI is running with http or https
*
* @param PMF_Configuration $faqConfig
*
* @return mixed
*/
public function getSystemUri(PMF_Configuration $faqConfig)
{
$mainUrl = $faqConfig->get('main.referenceURL');
if (isset($_ENV['REQUEST_SCHEME']) && 'https' === $_ENV['REQUEST_SCHEME']) {
if (false === strpos($mainUrl, 'https')) {
$mainUrl = str_replace('http://', 'https://', $mainUrl);
}
}
if ('/' !== substr($mainUrl, -1)) {
$mainUrl .= '/';
}
return $mainUrl;
}
示例13: startInstall
//.........这里部分代码省略.........
echo '<p class="alert alert-danger"><strong>Error:</strong> Your password and retyped password are too short.' . ' Please set your password and your retyped password with a minimum of 6 characters.</p>';
PMF_System::renderFooter(true);
}
if ($password != $password_retyped) {
echo '<p class="alert alert-danger"><strong>Error:</strong> Your password and retyped password are not equal.' . ' Please check your password and your retyped password.</p>';
PMF_System::renderFooter(true);
}
$language = PMF_Filter::filterInput(INPUT_POST, 'language', FILTER_SANITIZE_STRING, 'en');
$realname = PMF_Filter::filterInput(INPUT_POST, 'realname', FILTER_SANITIZE_STRING, '');
$email = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, '');
$permLevel = PMF_Filter::filterInput(INPUT_POST, 'permLevel', FILTER_SANITIZE_STRING, 'basic');
$instanceSetup = new PMF_Instance_Setup();
$instanceSetup->setRootDir(PMF_ROOT_DIR);
// Write the DB variables in database.php
if (!$instanceSetup->createDatabaseFile($dbSetup)) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Setup cannot write to ./config/database.php.</p>";
$this->_system->cleanInstallation();
PMF_System::renderFooter(true);
}
// check LDAP if available
if (extension_loaded('ldap') && !is_null($ldapEnabled)) {
if (!$instanceSetup->createLdapFile($ldapSetup, '')) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Setup cannot write to ./config/ldap.php.</p>";
$this->_system->cleanInstallation();
PMF_System::renderFooter(true);
}
}
// connect to the database using config/database.php
require PMF_ROOT_DIR . '/config/database.php';
$db = PMF_Db::factory($dbSetup['dbType']);
$db->connect($DB['server'], $DB['user'], $DB['password'], $DB['db']);
if (!$db) {
echo "<p class=\"alert alert-danger\"><strong>DB Error:</strong> " . $db->error() . "</p>\n";
$this->_system->cleanInstallation();
PMF_System::renderFooter(true);
}
require PMF_ROOT_DIR . '/setup/assets/sql/' . $dbSetup['dbType'] . '.sql.php';
// CREATE TABLES
require PMF_ROOT_DIR . '/setup/assets/sql/stopwords.sql.php';
// INSERTs for stopwords
$this->_system->setDatabase($db);
echo '<p>';
// Erase any table before starting creating the required ones
if (!PMF_System::isSqlite($dbSetup['dbType'])) {
$this->_system->dropTables($uninst);
}
// Start creating the required tables
$count = 0;
foreach ($query as $executeQuery) {
$result = @$db->query($executeQuery);
if (!$result) {
echo '<p class="alert alert-danger"><strong>Error:</strong> Please install your version of phpMyFAQ once again or send
us a <a href=\\"http://www.phpmyfaq.de\\" target=\\"_blank\\">bug report</a>.</p>';
printf('<p class="alert alert-danger"><strong>DB error:</strong> %s</p>', $db->error());
printf('<code>%s</code>', htmlentities($executeQuery));
$this->_system->dropTables($uninst);
$this->_system->cleanInstallation();
PMF_System::renderFooter(true);
}
usleep(2500);
$count++;
if (!($count % 10)) {
echo '| ';
}
}
$link = new PMF_Link(null, $configuration);
// add main configuration, add personal settings
$this->_mainConfig['main.metaPublisher'] = $realname;
$this->_mainConfig['main.administrationMail'] = $email;
$this->_mainConfig['main.language'] = $language;
$this->_mainConfig['security.permLevel'] = $permLevel;
foreach ($this->_mainConfig as $name => $value) {
$configuration->add($name, $value);
}
$configuration->update(array('main.referenceURL' => $link->getSystemUri('/setup/index.php')));
$configuration->add('security.salt', md5($configuration->get('main.referenceURL')));
// add admin account and rights
$admin = new PMF_User($configuration);
if (!$admin->createUser($loginname, $password, 1)) {
printf("<p class=\"alert alert-danger\"><strong>Fatal installation error:</strong><br>" . "Couldn't create the admin user: %s</p>\n", $admin->error());
$this->_system->cleanInstallation();
PMF_System::renderFooter(true);
}
$admin->setStatus('protected');
$adminData = array('display_name' => $realname, 'email' => $email);
$admin->setUserData($adminData);
// add default rights
foreach ($this->_mainRights as $right) {
$admin->perm->grantUserRight(1, $admin->perm->addRight($right));
}
// Add anonymous user account
$instanceSetup->createAnonymousUser($configuration);
// Add master instance
$instanceData = array('url' => $link->getSystemUri($_SERVER['SCRIPT_NAME']), 'instance' => $link->getSystemRelativeUri('setup/index.php'), 'comment' => 'phpMyFAQ ' . PMF_System::getVersion());
$faqInstance = new PMF_Instance($configuration);
$faqInstance->addInstance($instanceData);
$faqInstanceMaster = new PMF_Instance_Master($configuration);
$faqInstanceMaster->createMaster($faqInstance);
echo '</p>';
}
示例14: getFromSession
/**
* This static method returns a valid CurrentUser object if there is one
* in the session that is not timed out. The session-ID is updated if
* necessary. The CurrentUser will be removed from the session, if it is
* timed out. If there is no valid CurrentUser in the session or the
* session is timed out, null will be returned. If the session data is
* correct, but there is no user found in the user table, false will be
* returned. On success, a valid CurrentUser object is returned.
*
* @static
*
* @param PMF_Configuration $config
*
* @return null|PMF_User_CurrentUser
*/
public static function getFromSession(PMF_Configuration $config)
{
// there is no valid user object in session
if (!isset($_SESSION[PMF_SESSION_CURRENT_USER]) || !isset($_SESSION[PMF_SESSION_ID_TIMESTAMP])) {
return null;
}
// create a new CurrentUser object
$user = new PMF_User_CurrentUser($config);
$user->getUserById($_SESSION[PMF_SESSION_CURRENT_USER]);
// user object is timed out
if ($user->sessionIsTimedOut()) {
$user->deleteFromSession();
$user->errors[] = 'Session timed out.';
return null;
}
// session-id not found in user table
$session_info = $user->getSessionInfo();
$session_id = isset($session_info['session_id']) ? $session_info['session_id'] : '';
if ($session_id == '' || $session_id != session_id()) {
return false;
}
// check ip
if ($config->get('security.ipCheck') && $session_info['ip'] != $_SERVER['REMOTE_ADDR']) {
return false;
}
// session-id needs to be updated
if ($user->sessionIdIsTimedOut()) {
$user->updateSessionId();
}
// user is now logged in
$user->_loggedIn = true;
// save current user to session and return the instance
$user->saveToSession();
return $user;
}
示例15: addFaqToc
/**
* Adds a table of content for exports of the complete FAQ
*
* @return void
*/
public function addFaqToc()
{
global $PMF_LANG;
$this->addTOCPage();
// Title
$this->SetFont($this->currentFont, 'B', 24);
$this->MultiCell(0, 0, $this->_config->get('main.titleFAQ'), 0, 'C', 0, 1, '', '', true, 0);
$this->Ln();
// TOC
$this->SetFont($this->currentFont, 'B', 16);
$this->MultiCell(0, 0, $PMF_LANG['msgTableOfContent'], 0, 'C', 0, 1, '', '', true, 0);
$this->Ln();
$this->SetFont($this->currentFont, '', 12);
// Render TOC
$this->addTOC(1, $this->currentFont, '.', $PMF_LANG['msgTableOfContent'], 'B', array(128, 0, 0));
$this->endTOCPage();
}