本文整理汇总了PHP中PMF_Configuration::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Configuration::getInstance方法的具体用法?PHP PMF_Configuration::getInstance怎么用?PHP PMF_Configuration::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Configuration
的用法示例。
在下文中一共展示了PMF_Configuration::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generates the export
*
* @param integer $categoryId Category Id
* @param boolean $downwards If true, downwards, otherwise upward ordering
* @param string $language Language
*
* @return string
*/
public function generate($categoryId = 0, $downwards = true, $language = '')
{
global $PMF_LANG;
// Initialize categories
$this->category->transform($categoryId);
$faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XML, $categoryId, $downwards, $language);
$version = PMF_Configuration::getInstance()->get('main.currentVersion');
$comment = sprintf('XHTML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
$this->xml->startDocument('1.0', 'utf-8');
$this->xml->writeDtd('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
$this->xml->startElement('html');
$this->xml->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
$this->xml->writeAttribute('xml:lang', $language);
$this->xml->writeComment($comment);
$this->xml->startElement('head');
$this->xml->writeElement('title', PMF_Configuration::getInstance()->get('main.titleFAQ'));
$this->xml->startElement('meta');
$this->xml->writeAttribute('http-equiv', 'Content-Type');
$this->xml->writeAttribute('content', 'application/xhtml+xml; charset=utf-8');
$this->xml->endElement();
$this->xml->endElement();
// </head>
$this->xml->startElement('body');
$this->xml->writeAttribute('dir', $PMF_LANG['dir']);
if (count($faqdata)) {
$lastCategory = 0;
foreach ($faqdata as $data) {
if ($data['category_id'] != $lastCategory) {
$this->xml->writeElement('h1', $this->category->getPath($data['category_id'], ' >> '));
}
$this->xml->writeElement('h2', strip_tags($data['topic']));
$this->xml->writeElement('p', $data['content']);
$this->xml->writeElement('p', $PMF_LANG['msgAuthor'] . ': ' . $data['author_email']);
$this->xml->writeElement('p', $PMF_LANG['msgLastUpdateArticle'] . PMF_Date::createIsoDate($data['lastmodified']));
$lastCategory = $data['category_id'];
}
}
$this->xml->endElement();
// </body>
$this->xml->endElement();
// </html>
header('Content-type: text/html');
return $this->xml->outputMemory();
}
示例2: 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 string
*/
public function getLatestData($showArchive = false, $active = true, $forceConfLimit = false)
{
$news = array();
$counter = 0;
$now = date('YmdHis');
$faqconfig = PMF_Configuration::getInstance();
$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", SQLPREFIX, $now, $now, $active ? "AND active = 'y'" : '', $this->language);
$result = $this->db->query($query);
if ($faqconfig->get('main.numberOfShownNewsEntries') > 0 && $this->db->num_rows($result) > 0) {
while ($row = $this->db->fetch_object($result)) {
$counter++;
if ($showArchive && $counter > $faqconfig->get('main.numberOfShownNewsEntries') || !$showArchive && !$forceConfLimit && $counter <= $faqconfig->get('main.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;
}
示例3: 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)
{
$bannedList = PMF_Configuration::getInstance()->get('security.bannedIPs');
$bannedIps = explode(' ', $bannedList);
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;
}
示例4: generate
/**
* Generates the export
*
* @param integer $categoryId Category Id
* @param boolean $downwards If true, downwards, otherwise upward ordering
* @param string $language Language
*
* @return string
*/
public function generate($categoryId = 0, $downwards = true, $language = '')
{
// Initialize categories
$this->category->transform($categoryId);
$faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XML, $categoryId, $downwards, $language);
$version = PMF_Configuration::getInstance()->get('main.currentVersion');
$comment = sprintf('XML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
$this->xml->startDocument('1.0', 'utf-8', 'yes');
$this->xml->writeComment($comment);
$this->xml->startElement('phpmyfaq');
if (count($faqdata)) {
foreach ($faqdata as $data) {
// Build the <article/> node
$this->xml->startElement('article');
$this->xml->writeAttribute('id', $data['id']);
$this->xml->writeElement('language', $data['lang']);
$this->xml->writeElement('category', $this->category->getPath($data['category_id'], ' >> '));
if (!empty($data['keywords'])) {
$this->xml->writeElement('keywords', $data['keywords']);
} else {
$this->xml->writeElement('keywords');
}
$this->xml->writeElement('question', strip_tags($data['topic']));
$this->xml->writeElement('answer', PMF_String::htmlspecialchars($data['content']));
if (!empty($data['author_name'])) {
$this->xml->writeElement('author', $data['author_name']);
} else {
$this->xml->writeElement('author');
}
$this->xml->writeElement('data', PMF_Date::createIsoDate($data['lastmodified']));
$this->xml->endElement();
}
}
$this->xml->endElement();
header('Content-type: text/xml');
return $this->xml->outputMemory();
}
示例5: sendAskedQuestion
function sendAskedQuestion($username, $usermail, $usercat, $content)
{
global $PMF_LANG, $faq;
$retval = false;
$faqconfig = PMF_Configuration::getInstance();
$categoryNode = new PMF_Category_Node();
if ($faqconfig->get('records.enableVisibilityQuestions')) {
$visibility = 'N';
} else {
$visibility = 'Y';
}
$questionData = array('id' => null, 'username' => $username, 'email' => $usermail, 'category_id' => $usercat, 'question' => $content, 'date' => date('YmdHis'), 'is_visible' => $visibility);
list($user, $host) = explode("@", $questionData['email']);
if (PMF_Filter::filterVar($questionData['email'], FILTER_VALIDATE_EMAIL) != false) {
$faqQuestions = new PMF_Faq_Questions();
$faqQuestions->create($questionData);
$categoryData = $categoryNode->fetch($questionData['category_id']);
$questionMail = "User: " . $questionData['username'] . ", mailto:" . $questionData['email'] . "\n" . $PMF_LANG["msgCategory"] . ": " . $categoryData->name . "\n\n" . wordwrap($content, 72);
$userId = $categoryData->user_id;
$oUser = new PMF_User();
$oUser->getUserById($userId);
$userEmail = $oUser->getUserData('email');
$mainAdminEmail = $faqconfig->get('main.administrationMail');
$mail = new PMF_Mail();
$mail->unsetFrom();
$mail->setFrom($questionData['email'], $questionData['username']);
$mail->addTo($mainAdminEmail);
// Let the category owner get a copy of the message
if ($userEmail && $mainAdminEmail != $userEmail) {
$mail->addCc($userEmail);
}
$mail->subject = '%sitename%';
$mail->message = $questionMail;
$retval = $mail->send();
}
return $retval;
}
示例6: userTracking
/**
* Tracks the user and log what he did
*
* @param string $action String User action string
* @param integer $id ID
*
* @return void
*/
public function userTracking($action, $id = 0)
{
global $sid, $user, $botBlacklist;
$faqconfig = PMF_Configuration::getInstance();
if (!$faqconfig->get('main.enableUserTracking')) {
return;
}
$bots = 0;
$agent = $_SERVER['HTTP_USER_AGENT'];
$sid = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
$sidc = PMF_Filter::filterInput(INPUT_COOKIE, PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);
if (!is_null($sidc)) {
$sid = $sidc;
}
if ($action == "old_session") {
$sid = null;
}
foreach ($botBlacklist as $bot) {
if (strpos($agent, $bot)) {
$bots++;
}
}
if ($bots > 0) {
return;
}
if (!isset($sid)) {
$sid = $this->db->nextID(SQLPREFIX . "faqsessions", "sid");
// Sanity check: force the session cookie to contains the current $sid
if (!is_null($sidc) && !$sidc != $sid) {
self::setCookie($sid);
}
$query = sprintf("\n INSERT INTO \n %sfaqsessions\n (sid, user_id, ip, time)\n VALUES\n (%d, %d, '%s', %d)", SQLPREFIX, $sid, $user ? $user->getUserId() : -1, $_SERVER["REMOTE_ADDR"], $_SERVER['REQUEST_TIME']);
$this->db->query($query);
}
$data = $sid . ';' . str_replace(';', ',', $action) . ';' . $id . ';' . $_SERVER['REMOTE_ADDR'] . ';' . str_replace(';', ',', $_SERVER['QUERY_STRING']) . ';' . str_replace(';', ',', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . ';' . str_replace(';', ',', urldecode($_SERVER['HTTP_USER_AGENT'])) . ';' . $_SERVER['REQUEST_TIME'] . ";\n";
file_put_contents('./data/tracking' . date('dmY'), $data, FILE_APPEND);
}
示例7: 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 = array();
$currentUserId = $this->user->getUserId();
if ('medium' == PMF_Configuration::getInstance()->get('security.permLevel')) {
$currentGroupIds = $this->user->perm->getUserGroups($currentUserId);
}
foreach ($this->rawResultset as $index => $result) {
$permission = false;
// check permissions for groups
if ('medium' == PMF_Configuration::getInstance()->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' == PMF_Configuration::getInstance()->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);
}
示例8: renderFieldset
/**
* Renders the main navigation
*
* @param string $legend Text of the HTML Legend element
* @param string $img HTML code for the Captcha image
* @param string $error Error message
*
* @return string
*/
public function renderFieldset($legend, $img, $error = '')
{
$html = '';
if (PMF_Configuration::getInstance()->get('spam.enableCaptchaCode')) {
$html = sprintf('<fieldset><legend>%s</legend>', $legend);
$html .= '<div style="text-align:left;">';
if ($error != '') {
$html .= '<div class="error">' . $error . '</div>';
}
$html .= $img;
$html .= ' <input class="inputfield" type="text" name="captcha" id="captcha" value="" size="7" style="vertical-align: top; height: 35px; text-valign: middle; font-size: 20pt;" />';
$html .= '</div></fieldset>';
}
return $html;
}
示例9: ob_flush
$count++;
if (!($count % 10)) {
ob_flush();
flush();
}
}
ob_flush();
flush();
print "</div>";
}
// Clear the array with the queries
unset($query);
$query = array();
// Always the last step: Update version number
if (version_compare($version, NEWVERSION, '<')) {
$oPMFConf = PMF_Configuration::getInstance();
$oPMFConf->update(array('main.currentVersion' => NEWVERSION));
}
// optimize tables
switch ($DB["type"]) {
case 'mssql':
case 'sybase':
// Get all table names
$db->getTableNames(SQLPREFIX);
foreach ($db->tableNames as $tableName) {
$query[] = 'DBCC DBREINDEX (' . $tableName . ')';
}
break;
case 'mysql':
case 'mysqli':
// Get all table names
示例10: Footer
/**
* The footer of the PDF file
*
* @return void
*/
public function Footer()
{
global $PMF_LANG;
$faqconfig = PMF_Configuration::getInstance();
$currentTextColor = $this->TextColor;
$this->SetTextColor(0, 0, 0);
$this->SetY(-25);
$this->SetFont('dejavusans', '', 10);
$this->Cell(0, 10, $PMF_LANG['ad_gen_page'] . ' ' . $this->PageNo() . ' / ' . $this->getAliasNbPages(), 0, 0, 'C');
$this->SetY(-20);
$this->SetFont('dejavusans', 'B', 8);
$this->Cell(0, 10, "(c) " . date("Y") . " " . $faqconfig->get('main.metaPublisher') . " <" . $faqconfig->get('main.administrationMail') . ">", 0, 1, "C");
if ($this->enableBookmarks == false) {
$this->SetY(-15);
$this->SetFont('dejavusans', '', 8);
$baseUrl = '/index.php';
if (is_array($this->faq) && !empty($this->faq)) {
$baseUrl .= '?action=artikel&cat=' . $this->categories[$this->category]['id'];
$baseUrl .= '&id=' . $this->faq['id'];
$baseUrl .= '&artlang=' . $this->faq['lang'];
}
$url = PMF_Link::getSystemScheme() . $_SERVER['HTTP_HOST'] . $baseUrl;
$urlObj = new PMF_Link($url);
$urlObj->itemTitle = $this->thema;
$_url = str_replace('&', '&', $urlObj->toString());
$this->Cell(0, 10, 'URL: ' . $_url, 0, 1, 'C', 0, $_url);
}
$this->TextColor = $currentTextColor;
}
示例11: resolveMarkers
/**
* Resolves the PMF markers like e.g. %sitename%.
*
* @public
* @static
* @param string $text Text contains PMF markers
* @return string
*/
public static function resolveMarkers($text)
{
// Available markers: key and resolving value
$markers = array('%sitename%' => PMF_Configuration::getInstance()->get('main.titleFAQ'));
// Resolve any known pattern
return str_replace(array_keys($markers), array_values($markers), $text);
}
示例12: printInputFieldByType
function printInputFieldByType($key, $type)
{
global $PMF_LANG;
$faqconfig = PMF_Configuration::getInstance();
switch ($type) {
case 'area':
printf('<textarea name="edit[%s]" cols="60" rows="6" style="width: 500px;">%s</textarea>', $key, str_replace('<', '<', str_replace('>', '>', $faqconfig->get($key))));
printf("<br />\n");
break;
case 'input':
printf('<input type="text" name="edit[%s]" size="75" value="%s" style="width: 500px;" />', $key, str_replace('"', '"', $faqconfig->get($key)));
printf("<br />\n");
break;
case 'select':
printf('<select name="edit[%s]" size="1" style="width: 500px;">', $key);
switch ($key) {
case 'main.language':
$languages = PMF_Language::getAvailableLanguages();
if (count($languages) > 0) {
print PMF_Language::languageOptions(str_replace(array("language_", ".php"), "", $faqconfig->get('main.language')), false, true);
} else {
print '<option value="language_en.php">English</option>';
}
break;
case 'records.orderby':
print sortingOptions($faqconfig->get($key));
break;
case 'records.sortby':
printf('<option value="DESC"%s>%s</option>', 'DESC' == $faqconfig->get($key) ? ' selected="selected"' : '', $PMF_LANG['ad_conf_desc']);
printf('<option value="ASC"%s>%s</option>', 'ASC' == $faqconfig->get($key) ? ' selected="selected"' : '', $PMF_LANG['ad_conf_asc']);
break;
case 'main.permLevel':
print PMF_Perm::permOptions($faqconfig->get($key));
break;
case "main.templateSet":
/**
* TODO: do get availiable template sets in the PMF_Template
*/
foreach (new DirectoryIterator('../template') as $item) {
if (!$item->isDot() && $item->isDir()) {
$selected = PMF_Template::getTplSetName() == $item ? ' selected="selected"' : '';
printf("<option%s>%s</option>", $selected, $item);
}
}
break;
case "main.attachmentsStorageType":
foreach ($PMF_LANG['att_storage_type'] as $i => $item) {
$selected = $faqconfig->get($key) == $i ? ' selected="selected"' : '';
printf('<option value="%d"%s>%s</option>', $i, $selected, $item);
}
break;
}
print "</select>\n<br />\n";
break;
case 'checkbox':
printf('<input type="checkbox" name="edit[%s]" value="true"', $key);
if ($faqconfig->get($key)) {
print ' checked="checked"';
}
print " /><br />\n";
break;
case 'print':
printf('<input type="hidden" name="edit[%s]" size="80" value="%s" />%s<br />', $key, str_replace('"', '"', $faqconfig->get($key)), $faqconfig->get($key));
break;
}
}
示例13: __construct
/**
* Constructor
*
* @param integer $user User
* @param array $groups Groups
*
* @return PMF_Sitemap
*/
public function __construct($user = null, $groups = null)
{
global $DB;
$this->db = PMF_Db::getInstance();
$this->language = PMF_Language::$language;
$this->type = $DB['type'];
if (is_null($user)) {
$this->user = -1;
} else {
$this->user = $user;
}
if (is_null($groups)) {
$this->groups = array(-1);
} else {
$this->groups = $groups;
}
if (PMF_Configuration::getInstance()->get('security.permLevel') == 'medium') {
$this->groupSupport = true;
}
}
示例14: 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);
$faqUser = new PMF_Faq_User();
$faqGroup = new PMF_Faq_Group();
$duplicateResults = array();
$currentUserId = $this->user->getUserId();
if ('medium' == PMF_Configuration::getInstance()->get('main.permLevel')) {
$currentGroupIds = $this->user->perm->getUserGroups($currentUserId);
}
foreach ($this->rawResultset as $index => $result) {
$permission = false;
// check permissions for groups
if ('medium' == PMF_Configuration::getInstance()->get('main.permLevel')) {
$groupPerm = $faqGroup->fetch($result->id);
if (count($groupPerm) && in_array($groupPerm->group_id, $currentGroupIds)) {
$permission = true;
}
}
// check permission for user
if ($permission || 'basic' == PMF_Configuration::getInstance()->get('main.permLevel')) {
$userPerm = $faqUser->fetch($result->id);
if (-1 == $userPerm->user_id || $this->user->getUserId() == $userPerm->user_id) {
$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);
}
示例15: __construct
/**
* Constructor
*
* @param PMF_Perm $perm Permission object
* @param array $auth Authorization array
* @return void
*/
public function __construct(PMF_Perm $perm = null, array $auth = array())
{
$this->db = PMF_Db::getInstance();
if ($perm !== null) {
if (!$this->addPerm($perm)) {
return false;
}
} else {
$permLevel = PMF_Configuration::getInstance()->get('security.permLevel');
$perm = PMF_Perm::selectPerm($permLevel);
if (!$this->addPerm($perm)) {
return false;
}
}
// authentication objects
// always make a 'local' $auth object (see: $auth_data)
$this->auth_container = array();
$authLocal = PMF_Auth::selectAuth($this->auth_data['authSource']['name']);
$authLocal->selectEncType($this->auth_data['encType']);
$authLocal->setReadOnly($this->auth_data['readOnly']);
if (!$this->addAuth($authLocal, $this->auth_data['authSource']['type'])) {
return false;
}
// additionally, set given $auth objects
if (count($auth) > 0) {
foreach ($auth as $name => $auth_object) {
if (!$this->addAuth($auth_object, $name)) {
break;
}
}
}
// user data object
$this->userdata = new PMF_User_UserData();
}