本文整理汇总了PHP中PMF_Configuration类的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Configuration类的具体用法?PHP PMF_Configuration怎么用?PHP PMF_Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PMF_Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Returns the single instance
*
* @access static
* @return PMF_Configuration
*/
public static function getInstance()
{
if (null == self::$instance) {
$className = __CLASS__;
self::$instance = new $className();
}
return self::$instance;
}
示例2: buildInsertQueries
/**
* This function builds the the queries for the backup
*
* @param string $query
* @param string $table
*
* @return array
*/
public function buildInsertQueries($query, $table)
{
if (!($result = $this->_config->getDb()->query($query))) {
[];
}
$ret = [];
$ret[] = "\r\n-- Table: " . $table;
while ($row = $this->_config->getDb()->fetchArray($result)) {
$p1 = [];
$p2 = [];
foreach ($row as $key => $val) {
$p1[] = $key;
if ('rights' != $key && is_numeric($val)) {
$p2[] = $val;
} else {
if (is_null($val)) {
$p2[] = 'NULL';
} else {
$p2[] = sprintf("'%s'", $this->_config->getDb()->escape($val));
}
}
}
$ret[] = "INSERT INTO " . $table . " (" . implode(",", $p1) . ") VALUES (" . implode(",", $p2) . ");";
}
return $ret;
}
示例3: 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();
}
示例4: getAllRelatedById
/**
* Returns all relevant articles for a FAQ record with the same language
*
* @param integer $recordId FAQ ID
* @param string $question FAQ title
* @param string $keywords FAQ keywords
*
* @return array
*/
public function getAllRelatedById($recordId, $question, $keywords)
{
$terms = str_replace('-', ' ', $question) . $keywords;
$search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
$search->setTable(PMF_Db::getTablePrefix() . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS question', 'fd.content AS answer'))->setJoinedTable(PMF_Db::getTablePrefix() . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
$result = $search->search($terms);
return $this->_config->getDb()->fetchAll($result);
}
示例5: getBreadcrumbs
/**
* Get an array with minimalistic attachment meta data
*
* @return array
*/
public function getBreadcrumbs()
{
$retval = array();
$query = sprintf("\n SELECT\n fa.id AS ID,\n fa.record_id AS record_id,\n fa.record_lang AS record_lang,\n fa.filename AS filename,\n fa.filesize AS filesize,\n fa.mime_type AS mime_type,\n fd.thema AS thema\n FROM\n %s fa\n JOIN\n %s fd\n ON\n fa.record_id = fd.id\n GROUP BY\n fa.id", PMF_Db::getTablePrefix() . 'faqattachment', PMF_Db::getTablePrefix() . 'faqdata');
$result = $this->config->getDb()->query($query);
if ($result) {
$retval = $this->config->getDb()->fetchAll($result);
}
return $retval;
}
示例6: getCategoryRecordsMatrix
/**
* Create a matrix for representing categories and faq records
*
* @return array
*/
public function getCategoryRecordsMatrix()
{
$matrix = [];
$query = sprintf('
SELECT
fcr.category_id AS id_cat,
fd.id AS id
FROM
%sfaqdata fd
INNER JOIN
%sfaqcategoryrelations fcr
ON
fd.id = fcr.record_id
AND
fd.lang = fcr.category_lang
ORDER BY
fcr.category_id, fd.id', PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix());
$result = $this->_config->getDb()->query($query);
if ($this->_config->getDb()->numRows($result) > 0) {
while ($row = $this->_config->getDb()->fetchObject($result)) {
$matrix[$row->id_cat][$row->id] = true;
}
}
return $matrix;
}
示例7: 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;
}
示例8: garbageCollector
/**
* Delete old captcha records.
*
* During normal use the <b>faqcaptcha</b> table would be empty, on average:
* each record is created when a captcha image is showed to the user
* and deleted upon a successful matching, so, on average, a record
* in this table is probably related to a spam attack.
*
* @param int $time The time (sec) to define a captcha code old and ready
* to be deleted (default: 1 week)
* @return void
*/
private function garbageCollector($time = 604800)
{
$delete = sprintf("\n DELETE FROM \n %sfaqcaptcha \n WHERE \n captcha_time < %d", PMF_Db::getTablePrefix(), $_SERVER['REQUEST_TIME'] - $time);
$this->_config->getDb()->query($delete);
$delete = sprintf("\n DELETE FROM\n %sfaqcaptcha\n WHERE\n useragent = '%s' AND language = '%s' AND ip = '%s'", PMF_Db::getTablePrefix(), $this->userAgent, $this->_config->getLanguage()->getLanguage(), $this->ip);
$this->_config->getDb()->query($delete);
}
示例9: getReportingData
/**
* Generates a huge array for the report
* @return array
*/
public function getReportingData()
{
$report = [];
$query = sprintf("\n SELECT\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n c.name as category_name,\n c.parent_id as parent_id,\n fd.sticky AS sticky,\n fd.thema AS question,\n fd.author AS original_author,\n fd.datum AS creation_date,\n fv.visits AS visits,\n u.display_name AS last_author\n FROM\n %sfaqdata fd\n LEFT JOIN\n %sfaqcategoryrelations fcr\n ON\n (fd.id = fcr.record_id AND fd.lang = fcr.record_lang)\n LEFT JOIN\n %sfaqvisits fv\n ON\n (fd.id = fv.id AND fd.lang = fv.lang)\n LEFT JOIN\n %sfaqchanges as fc\n ON\n (fd.id = fc.id AND fd.lang = fc.lang)\n LEFT JOIN\n %sfaquserdata as u\n ON\n (u.user_id = fc.usr)\n LEFT JOIN\n %sfaqcategories as c\n ON\n (c.id = fcr.category_id AND c.lang = fcr.record_lang)\n ORDER BY\n fd.id\n ASC", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix());
$result = $this->_config->getDb()->query($query);
$lastId = 0;
while ($row = $this->_config->getDb()->fetchObject($result)) {
if ($row->id == $lastId) {
$report[$row->id]['faq_translations'] += 1;
} else {
$report[$row->id] = array('faq_id' => $row->id, 'faq_language' => $row->lang, 'category_id' => $row->category_id, 'category_parent' => $row->parent_id, 'category_name' => $row->category_name, 'faq_translations' => 0, 'faq_sticky' => $row->sticky, 'faq_question' => $row->question, 'faq_org_author' => $row->original_author, 'faq_creation' => PMF_Date::createIsoDate($row->creation_date), 'faq_visits' => $row->visits, 'faq_last_author' => $row->last_author);
}
$lastId = $row->id;
}
return $report;
}
示例10: delete
/**
* Deletes logging data older than 30 days
*
* @return boolean
*/
public function delete()
{
$query = sprintf("DELETE FROM\n %sfaqadminlog\n WHERE\n time < %d", PMF_Db::getTablePrefix(), $_SERVER['REQUEST_TIME'] - 30 * 86400);
if ($this->_config->getDb()->query($query)) {
return true;
}
return false;
}
示例11: deleteGlossaryItem
/**
* Deletes an item and definition into the database
*
* @param integer $id Glossary ID
*
* @return boolean
*/
public function deleteGlossaryItem($id)
{
$query = sprintf("\n DELETE FROM\n %sfaqglossary\n WHERE\n id = %d AND lang = '%s'", PMF_Db::getTablePrefix(), (int) $id, $this->config->getLanguage()->getLanguage());
if ($this->config->getDb()->query($query)) {
return true;
}
return false;
}
示例12: deleteNews
/**
* Deletes a news entry identified by its ID
*
* @todo check if there are comments attached to the deleted news
*
* @param integer $id News ID
*
* @return boolean
*/
function deleteNews($id)
{
$query = sprintf("DELETE FROM\n %sfaqnews\n WHERE\n id = %d\n AND\n lang = '%s'", PMF_Db::getTablePrefix(), $id, $this->_config->getLanguage()->getLanguage());
if (!$this->_config->getDb()->query($query)) {
return false;
}
return true;
}
示例13: getAllData
/**
* Get all the entries from the table faqvisits
*
* @return array
*/
public function getAllData()
{
$data = [];
$query = sprintf("\n SELECT\n *\n FROM\n %sfaqvisits\n ORDER BY\n visits DESC", PMF_Db::getTablePrefix());
$result = $this->_config->getDb()->query($query);
while ($row = $this->_config->getDb()->fetchObject($result)) {
$data[] = array('id' => $row->id, 'lang' => $row->lang, 'visits' => $row->visits, 'last_visit' => $row->last_visit);
}
return $data;
}
示例14: 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;
}
示例15: getAllComments
/**
* Returns all comments with their categories
*
* @param string $type Type of comment: faq or news
* @return array
*/
public function getAllComments($type = self::COMMENT_TYPE_FAQ)
{
$comments = [];
$query = sprintf("\n SELECT\n fc.id_comment AS comment_id,\n fc.id AS record_id,\n %s\n fc.usr AS username,\n fc.email AS email,\n fc.comment AS comment,\n fc.datum AS comment_date\n FROM\n %sfaqcomments fc\n %s\n WHERE\n type = '%s'", $type == self::COMMENT_TYPE_FAQ ? "fcg.category_id,\n" : '', PMF_Db::getTablePrefix(), $type == self::COMMENT_TYPE_FAQ ? "LEFT JOIN\n " . PMF_Db::getTablePrefix() . "faqcategoryrelations fcg\n ON\n fc.id = fcg.record_id\n" : '', $type);
$result = $this->config->getDb()->query($query);
if ($this->config->getDb()->numRows($result) > 0) {
while ($row = $this->config->getDb()->fetchObject($result)) {
$comments[] = array('comment_id' => $row->comment_id, 'record_id' => $row->record_id, 'category_id' => isset($row->category_id) ? $row->category_id : null, 'content' => $row->comment, 'date' => $row->comment_date, 'username' => $row->username, 'email' => $row->email);
}
}
return $comments;
}