示例#1
0
 protected function getOldFileList($dir)
 {
     $list = array();
     $faq = new PMF_Faq();
     $faq->getAllRecords();
     $records = $faq->faqRecords;
     reset($records);
     while (list(, $record) = each($records)) {
         $recordDir = "{$dir}/{$record['id']}";
         if (file_exists($recordDir) && is_dir($recordDir)) {
             $list[$record['id']]['files'] = array();
             foreach (new DirectoryIterator($recordDir) as $entry) {
                 if (!$entry->isDot() && $entry->isFile()) {
                     $list[$record['id']]['files'][] = "{$recordDir}/{$entry->getFilename()}";
                 }
             }
             $list[$record['id']]['lang'] = $record['lang'];
         }
     }
     return $list;
 }
示例#2
0
 /**
  * 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);
 }
示例#3
0
 * under the License.
 */
if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
$ajax_action = PMF_Filter::filterInput(INPUT_GET, 'ajaxaction', FILTER_SANITIZE_STRING);
if ('save_sticky_records' == $ajax_action && $permission['editbt']) {
    /**
     * Expected is an array of the structure:
     * array( 0 => array((int)id, (string)langugage, (int) checked)),
     * 	      1 => .....
     * )
     */
    $items = isset($_GET['items']) && is_array($_GET['items']) ? $_GET['items'] : array();
    $faq = new PMF_Faq();
    foreach ($items as $item) {
        if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) {
            print $faq->updateRecordSticky((int) $item[0], addslashes($item[1]), (int) $item[2]);
        }
    }
}
if ('delete_record' == $ajax_action && $permission['delbt']) {
    $record_id = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT);
    $record_lang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING);
    adminlog('Beitragdel, ' . $record_id);
    $path = PMF_ROOT_DIR . '/attachments/' . $record_id . '/';
    if (@is_dir($path)) {
        $do = dir($path);
        while ($dat = $do->read()) {
            if ($dat != "." && $dat != "..") {
示例#4
0
            break;
        case 'save_sticky_records':
            $type = 'sticky';
            break;
    }
    if (null !== $type && !empty($items)) {
        $faq = new PMF_Faq();
        foreach ($items as $item) {
            if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) {
                print $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), (int) $item[2], $type);
            }
        }
    }
}
if ('search_records' == $ajax_action && $permission['editbt']) {
    $faq = new PMF_Faq();
    $faqSearch = new PMF_Search($db, $Language);
    $faqSearchResult = new PMF_Search_Resultset($user, $faq);
    $searchResult = '';
    $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED);
    if (!is_null($searchString)) {
        $searchResult = $faqSearch->search($searchString, false);
        $faqSearchResult->reviewResultset($searchResult);
        $faqSearchHelper = PMF_Helper_Search::getInstance();
        $faqSearchHelper->setSearchterm($searchString);
        print $faqSearchHelper->renderAdminSuggestionResult($faqSearchResult);
    }
}
if ('delete_record' == $ajax_action && $permission['delbt']) {
    $record_id = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT);
    $record_lang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING);
示例#5
0
 * @package   Administration
 * @author    Thorsten Rinne <*****@*****.**>
 * @copyright 2007-2010 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
 * @link      http://www.phpmyfaq.de
 * @since     2007-03-04
 */
if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
printf("<h2>%s</h2>\n", $PMF_LANG['ad_comment_administration']);
print '<div id="returnMessage"></div>';
if ($permission['delcomment']) {
    $comment = new PMF_Comment();
    $faq = new PMF_Faq();
    $faqcomments = $comment->getAllComments('faq');
    printf("<h3>%s</h3>\n", $PMF_LANG['ad_comment_faqs']);
    if (count($faqcomments)) {
        ?>
    <form id="commentSelection" name="commentSelection" method="post">
    <input type="hidden" name="ajax" value="comment" />
    <input type="hidden" name="ajaxaction" value="delete" />
    <table class="listrecords">
<?php 
        foreach ($faqcomments as $faqcomment) {
            ?>
    <tr id="comments_<?php 
            print $faqcomment['comment_id'];
            ?>
">
示例#6
0
文件: api.php 项目: atlcurling/tkt
        break;
    case 'search':
        $search = new PMF_Search($db, $Language);
        $searchString = PMF_Filter::filterInput(INPUT_GET, 'q', FILTER_SANITIZE_STRIPPED);
        $result = $search->search($searchString, false);
        $url = $faqconfig->get('main.referenceURL') . '/index.php?action=artikel&cat=%d&id=%d&artlang=%s';
        foreach ($result as &$data) {
            $data->answer = html_entity_decode(strip_tags($data->answer), ENT_COMPAT, 'utf-8');
            $data->answer = PMF_Utils::makeShorterText($data->answer, 12);
            $data->link = sprintf($url, $data->category_id, $data->id, $data->lang);
        }
        break;
    case 'getCategories':
        $category = new PMF_Category($current_user, $current_groups, true);
        $result = $category->categories;
        break;
    case 'getFaqs':
        $faq = new PMF_Faq($current_user, $current_groups);
        $result = $faq->getAllRecordPerCategory($categoryId);
        break;
    case 'getFaq':
        $faq = new PMF_Faq($current_user, $current_groups);
        $faq->getRecord($recordId);
        $result = $faq->faqRecord;
        break;
    default:
        $result = 'I am completely operational, and all my circuits are functioning perfectly.';
        break;
}
// print result as JSON
print json_encode($result);
示例#7
0
文件: index.php 项目: noon/phpMyFAQ
//
// Initalizing static string wrapper
//
PMF_String::init($PMF_LANG["metaCharset"], $LANGCODE);
/**
 * Set actual template set name
 */
PMF_Template::setTplSetName($faqconfig->get('main.templateSet'));
/**
 * Initialize attachment factory
 */
PMF_Attachment_Factory::init($faqconfig->get('main.attachmentsStorageType'), $faqconfig->get('main.defaultAttachmentEncKey'), $faqconfig->get('main.enableAttachmentEncryption'));
//
// Create a new FAQ object
//
$faq = new PMF_Faq();
//
// use mbstring extension if available and when possible
//
$valid_mb_strings = array('ja', 'en', 'uni');
$mbLanguage = 'utf-8' == strtolower($PMF_LANG['metaCharset']) && $PMF_LANG['metaLanguage'] != 'ja' ? 'uni' : $PMF_LANG['metaLanguage'];
if (function_exists('mb_language') && in_array($mbLanguage, $valid_mb_strings)) {
    mb_language($mbLanguage);
    mb_internal_encoding($PMF_LANG['metaCharset']);
}
//
// Get user action
//
$action = PMF_Filter::filterInput(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
// authenticate current user
$auth = null;
示例#8
0
文件: pdf.php 项目: noon/phpMyFAQ
    $LANGCODE = "en";
    require_once "lang/language_en.php";
}
//
// Initalizing static string wrapper
//
PMF_String::init($PMF_LANG["metaCharset"], $LANGCODE);
$category = new PMF_Category();
$currentCategory = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT);
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (is_null($currentCategory) || is_null($id)) {
    header('HTTP/1.1 403 Forbidden');
    print 'Wrong HTTP GET parameters values.';
    exit;
}
$faq = new PMF_Faq();
$faq->getRecord($id);
$pdfFile = $faq->buildPDFFile($currentCategory);
// Sanity check: stop here if no PDF has been created
if (empty($pdfFile) || !file_exists($pdfFile)) {
    header('HTTP/1.1 404 Not Found');
    print 'PDF not available.';
    exit;
}
$file = basename($pdfFile);
$size = filesize($pdfFile);
session_cache_limiter('private');
header("Pragma: public");
header("Expires: 0");
// set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$Language = new PMF_Language($faqConfig);
$LANGCODE = $Language->setLanguage($faqConfig->get('main.languageDetection'), $faqConfig->get('main.language'));
// Preload English strings
require_once PMF_ROOT_DIR . '/lang/language_en.php';
$faqConfig->setLanguage($Language);
if (isset($LANGCODE) && PMF_Language::isASupportedLanguage($LANGCODE)) {
    // Overwrite English strings with the ones we have in the current language
    require_once PMF_ROOT_DIR . '/lang/language_' . $LANGCODE . '.php';
} else {
    $LANGCODE = 'en';
}
//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);
$faq = new PMF_Faq($faqConfig);
$rssData = $faq->getAllOpenQuestions(false);
$num = count($rssData);
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
$rss->startElement('channel');
$rss->writeElement('title', $faqConfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgOpenQuestions']);
$rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription')));
$rss->writeElement('link', $faqConfig->get('main.referenceURL'));
$rss->startElementNS('atom', 'link', 'http://www.w3.org/2005/Atom');
$rss->writeAttribute('rel', 'self');
示例#10
0
文件: rss.php 项目: ae120/phpMyFAQ
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);
if (!$faqConfig->get('main.enableRssFeeds')) {
    exit;
}
$faq = new PMF_Faq($faqConfig);
$faq->setUser($current_user);
$faq->setGroups($current_groups);
$rssData = $faq->getLatestData(PMF_NUMBER_RECORDS_LATEST);
$num = count($rssData);
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', $faqConfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgLatestArticles']);
$rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription')));
$rss->writeElement('link', $faqConfig->get('main.referenceURL'));
if ($num > 0) {
示例#11
0
文件: rss.php 项目: atlcurling/tkt
    $current_user = $user->getUserId();
    if ($user->perm instanceof PMF_Perm_PermMedium) {
        $current_groups = $user->perm->getUserGroups($current_user);
    } else {
        $current_groups = array(-1);
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
$category_id = PMF_Filter::filterInput(INPUT_GET, 'category_id', FILTER_VALIDATE_INT);
$category = new PMF_Category($current_user, $current_groups);
$faq = new PMF_Faq($current_user, $current_groups);
$records = $faq->getAllRecordPerCategory($category_id, $faqconfig->get('records.orderby'), $faqconfig->get('records.sortby'));
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', $faqconfig->get('main.titleFAQ') . ' - ');
$rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription')));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/category/rss.php'));
if (is_array($records)) {
    foreach ($records as $item) {
        $link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['record_link']);
        if (PMF_RSS_USE_SEO) {
示例#12
0
 if (isset($matches['id'])) {
     $id = (int) $matches['id'];
 }
 if (isset($matches['artlang'])) {
     $artlang = $matches['artlang'];
 }
 // Sanity check
 if (is_null($cat) || is_null($id) || is_null($artlang)) {
     header('HTTP/1.1 403 Forbidden');
     print 'Invalid FAQ link.';
     exit;
 }
 // Load categories
 $category = new PMF_Category();
 // Load the required faq
 $faq = new PMF_Faq();
 $faq->getRecord($id);
 // Get the HTML content
 $html = @PMF_Utils::getHTTPContent($link);
 // Try to attach the PDF content
 $pdfFile = $faq->buildPDFFile($cat);
 foreach ($mailto['mailto'] as $recipient) {
     $recipient = trim(strip_tags($recipient));
     if (!empty($recipient)) {
         $mail = new PMF_Mail();
         $mail->unsetFrom();
         $mail->setFrom($mailfrom, $name);
         $mail->addTo($recipient);
         $mail->subject = $PMF_LANG["msgS2FMailSubject"] . $name;
         $mail->message = $faqconfig->get("main.send2friendText") . "\r\n\r\n" . $PMF_LANG["msgS2FText2"] . "\r\n" . $link . "\r\n\r\n" . $attached;
         if ($html !== false) {
             $faq = new PMF_Faq($faqConfig);
             foreach ($items as $item) {
                 if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) {
                     echo $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), $item[2], 'sticky');
                 }
             }
         }
     } else {
         echo $PMF_LANG['err_NotAuth'];
     }
     break;
     // search FAQs for suggestions
 // search FAQs for suggestions
 case 'search_records':
     if ($permission['editbt']) {
         $faq = new PMF_Faq($faqConfig);
         $faqSearch = new PMF_Search($faqConfig);
         $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig);
         $searchResult = '';
         $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED);
         if (!is_null($searchString)) {
             $searchResult = $faqSearch->search($searchString, false);
             $faqSearchResult->reviewResultset($searchResult);
             $searchHelper = new PMF_Helper_Search($faqConfig);
             $searchHelper->setSearchterm($searchString);
             echo $searchHelper->renderAdminSuggestionResult($faqSearchResult);
         }
     } else {
         echo $PMF_LANG['err_NotAuth'];
     }
     break;
示例#14
0
文件: rss.php 项目: ae120/phpMyFAQ
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);
if (!$faqConfig->get('main.enableRssFeeds')) {
    exit;
}
$faq = new PMF_Faq($faqConfig);
$faq->setUser($current_user);
$faq->setGroups($current_groups);
$rssData = $faq->getTopTenData(PMF_NUMBER_RECORDS_TOPTEN);
$num = count($rssData);
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', $faqConfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgTopTen']);
$rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription')));
$rss->writeElement('link', $faqConfig->get('main.referenceURL'));
if ($num > 0) {
示例#15
0
     * Expected is an array of the structure:
     * array( 0 => array((int)id, (string)langugage, (int) checked)),
     * 	      1 => .....
     * )
     */
    $items = isset($_GET['items']) && is_array($_GET['items']) ? $_GET['items'] : array();
    switch ($ajax_action) {
        case 'save_active_records':
            $type = 'active';
            break;
        case 'save_sticky_records':
            $type = 'sticky';
            break;
    }
    if (null !== $type && !empty($items)) {
        $faq = new PMF_Faq();
        foreach ($items as $item) {
            if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) {
                print $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), (int) $item[2], $type);
            }
        }
    }
}
if ('delete_record' == $ajax_action && $permission['delbt']) {
    $record_id = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT);
    $record_lang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING);
    $logging = new PMF_Logging();
    $logging->logAdmin($user, 'Beitragdel, ' . $record_id);
    $path = PMF_ROOT_DIR . '/attachments/' . $record_id . '/';
    if (@is_dir($path)) {
        $do = dir($path);
示例#16
0
            $data->answer = html_entity_decode(strip_tags($data->answer), ENT_COMPAT, 'utf-8');
            $data->answer = PMF_Utils::makeShorterText($data->answer, 12);
            $data->link = sprintf($url, $data->category_id, $data->id, $data->lang);
            $result[] = $data;
        }
        break;
    case 'getCategories':
        $category = new PMF_Category($faqConfig, $currentGroups, true);
        $category->setUser($currentUser);
        $category->setGroups($currentGroups);
        $result = $category->categories;
        break;
    case 'getFaqs':
        $faq = new PMF_Faq($faqConfig);
        $faq->setUser($currentUser);
        $faq->setGroups($currentGroups);
        $result = $faq->getAllRecordPerCategory($categoryId);
        break;
    case 'getFaq':
        $faq = new PMF_Faq($faqConfig);
        $faq->setUser($currentUser);
        $faq->setGroups($currentGroups);
        $faq->getRecord($recordId);
        $result = $faq->faqRecord;
        break;
    default:
        $result = 'I am completely operational, and all my circuits are functioning perfectly.';
        break;
}
// print result as JSON
$response->setData($result)->send();
示例#17
0
    }
}
//
// Found a article language?
//
$lang = PMF_Filter::filterInput(INPUT_POST, 'artlang', FILTER_SANITIZE_STRING);
if (is_null($lang) && !PMF_Language::isASupportedLanguage($lang)) {
    $lang = PMF_Filter::filterInput(INPUT_GET, 'artlang', FILTER_SANITIZE_STRING);
    if (is_null($lang) && !PMF_Language::isASupportedLanguage($lang)) {
        $lang = $LANGCODE;
    }
}
//
// Create a new FAQ object
//
$faq = new PMF_Faq($faqConfig);
$faq->setUser($current_user);
$faq->setGroups($current_groups);
//
// Create a new Category object
//
$category = new PMF_Category($faqConfig, $current_groups, true);
$category->setUser($current_user);
//
// Create a new Tags object
//
$oTag = new PMF_Tags($faqConfig);
//
// Found a record ID?
//
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
示例#18
0
文件: Export.php 项目: noon/phpMyFAQ
 /**
  * Returns the XML export
  * 
  * @param integer $nCatid     Number of categories
  * @param boolean $bDownwards Downwards
  * @param string  $lang       Language
  * 
  * @return string
  */
 public static function getXMLExport($nCatid = 0, $bDownwards = true, $lang = "")
 {
     global $db, $LANGCODE, $PMF_LANG, $PMF_CONF;
     $tree = new PMF_Category();
     $tree->transform(0);
     $my_xml_output = "<?xml version=\"1.0\" encoding=\"" . $PMF_LANG["metaCharset"] . "\" standalone=\"yes\" ?>\n";
     $my_xml_output .= "<!-- XML-Output by phpMyFAQ " . $PMF_CONF['main.currentVersion'] . " | Date: " . PMF_Date::createIsoDate(date("YmdHis")) . " -->\n";
     $my_xml_output .= "<phpmyfaq xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:NamespaceSchemaLocation=\"http://www.phpmyfaq.de/xml/faqschema.xsd\">\n";
     // Get Faq Data
     $oFaq = new PMF_Faq();
     $faqs = $oFaq->get(FAQ_QUERY_TYPE_EXPORT_XML, $nCatid, $bDownwards, $lang);
     // Start composing XML
     if (count($faqs) > 0) {
         foreach ($faqs as $faq) {
             // Get faq properties
             $xml_content = $faq['content'];
             $xml_rubrik = $tree->getPath($faq['category_id'], " >> ");
             $xml_thema = $faq['topic'];
             $xml_keywords = $faq['keywords'];
             // Take care of XML entities
             $xml_content = strip_tags(PMF_String::htmlspecialchars($xml_content, ENT_QUOTES, $PMF_LANG['metaCharset']));
             $xml_rubrik = PMF_htmlentities(strip_tags($xml_rubrik), ENT_QUOTES, $PMF_LANG['metaCharset']);
             $xml_thema = strip_tags($xml_thema);
             // Build the <article/> node
             $my_xml_output .= "\t<article id=\"" . $faq['id'] . "\">\n";
             $my_xml_output .= "\t<language>" . $faq['lang'] . "</language>\n";
             $my_xml_output .= "\t<category>" . $xml_rubrik . "</category>\n";
             if (!empty($xml_keywords)) {
                 $my_xml_output .= "\t<keywords>" . $xml_keywords . "</keywords>\n";
             } else {
                 $my_xml_output .= "\t<keywords />\n";
             }
             $my_xml_output .= "\t<theme>" . $xml_thema . "</theme>\n";
             $my_xml_output .= "\t<content xmlns=\"http://www.w3.org/TR/REC-html40\">" . $xml_content . "</content>\n";
             if (!empty($faq['author_name'])) {
                 $my_xml_output .= "\t<author>" . $faq['author_name'] . "</author>\n";
             } else {
                 $my_xml_output .= "\t<author />\n";
             }
             $my_xml_output .= "\t<date>" . PMF_Date::createIsoDate($faq['lastmodified']) . "</date>\n";
             $my_xml_output .= "\t</article>\n";
         }
     }
     $my_xml_output .= "</phpmyfaq>";
     return $my_xml_output;
 }
 define('IS_VALID_PHPMYFAQ', null);
 require PMF_ROOT_DIR . '/inc/Bootstrap.php';
 // Preload English strings
 require_once PMF_ROOT_DIR . '/lang/language_en.php';
 if (LANGCODE != 'en' && PMF_Language::isASupportedLanguage(LANGCODE)) {
     // Overwrite English strings with the ones we have in the current language
     require_once PMF_ROOT_DIR . '/lang/language_' . LANGCODE . '.php';
 }
 //Load plurals support for selected language
 $plr = new PMF_Language_Plurals(LANGCODE);
 //
 // Initalizing static string wrapper
 //
 PMF_String::init(LANGCODE);
 $oLnk = new PMF_Linkverifier($faqConfig);
 $faq = new PMF_Faq($faqConfig);
 $totStart = microtime(true);
 // Read the data directly from the faqdata table (all faq records in all languages)
 $start = microtime(true);
 $output .= $isRequestedByWebLocalhost ? '' : "\n";
 $output .= 'Extracting faq records...';
 $faq->getAllRecords();
 $_records = $faq->faqRecords;
 $tot = count($_records);
 $end = microtime(true);
 $output .= ' #' . $tot . ', done in ' . round($end - $start, 4) . ' sec.' . ($isRequestedByWebLocalhost ? '' : "\n");
 $output .= $isRequestedByWebLocalhost ? '' : "\n";
 if ($isRequestedByWebLocalhost) {
     echo '<pre>';
 }
 $output = $output . "\n";
示例#20
0
文件: rss.php 项目: rybal06/phpMyFAQ
//
$Language = new PMF_Language();
$LANGCODE = $Language->setLanguage($faqconfig->get('main.languageDetection'), $faqconfig->get('main.language'));
// Preload English strings
require_once PMF_ROOT_DIR . '/lang/language_en.php';
if (isset($LANGCODE) && PMF_Language::isASupportedLanguage($LANGCODE)) {
    // Overwrite English strings with the ones we have in the current language
    require_once PMF_ROOT_DIR . '/lang/language_' . $LANGCODE . '.php';
} else {
    $LANGCODE = 'en';
}
//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);
$faq = new PMF_Faq();
$rssData = $faq->getLatestData(PMF_NUMBER_RECORDS_LATEST);
$num = count($rssData);
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', $faqconfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgLatestArticles']);
$rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription')));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/latests/rss.php'));
if ($num > 0) {
    foreach ($rssData as $item) {
        // Get the url
示例#21
0
             $text = sprintf("New user has been registrated:\n\nUsername: %s\nLoginname: %s\n\n" . "To activate this user do please use the administration interface at %s.", $realname, $loginname, $faqconfig->get('main.referenceURL'));
             $mail = new PMF_Mail();
             $mail->setReplyTo($email, $realname);
             $mail->addTo($faqconfig->get('main.administrationMail'));
             $mail->subject = PMF_Utils::resolveMarkers($PMF_LANG['emailRegSubject']);
             $mail->message = $text;
             $result = $mail->send();
             unset($mail);
             $message = array('success' => $PMF_LANG['successMessage'] . $PMF_LANG['msgRegThankYou']);
         }
     } else {
         $message = array('error' => $PMF_LANG['err_sendMail']);
     }
     break;
 case 'savevoting':
     $faq = new PMF_Faq();
     $type = PMF_Filter::filterInput(INPUT_POST, 'type', FILTER_SANITIZE_STRING, 'faq');
     $recordId = PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT, 0);
     $vote = PMF_Filter::filterInput(INPUT_POST, 'vote', FILTER_VALIDATE_INT);
     $userIp = PMF_Filter::filterVar($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
     if (isset($vote) && $faq->votingCheck($recordId, $userIp) && $vote > 0 && $vote < 6) {
         $faqsession->userTracking('save_voting', $recordId);
         $votingData = array('record_id' => $recordId, 'vote' => $vote, 'user_ip' => $userIp);
         if (!$faq->getNumberOfVotings($recordId)) {
             $faq->addVoting($votingData);
         } else {
             $faq->updateVoting($votingData);
         }
         $faqRating = new PMF_Rating();
         $message = array('success' => $PMF_LANG['msgVoteThanks'], 'rating' => $faqRating->getVotingResult($recordId));
     } elseif (!$faq->votingCheck($recordId, $userIp)) {
示例#22
0
文件: index.php 项目: noon/phpMyFAQ
} else {
    if (!setcookie(PMF_GET_KEY_NAME_LANGUAGE, $LANGCODE, $_SERVER['REQUEST_TIME'] + PMF_LANGUAGE_EXPIRED_TIME)) {
        $sids = sprintf('lang=%s&amp;', $LANGCODE);
    }
}
//
// Found a article language?
//
$lang = PMF_Filter::filterInput(INPUT_POST, 'artlang', FILTER_SANITIZE_STRING);
if (is_null($lang) && !PMF_Language::isASupportedLanguage($lang)) {
    $lang = $LANGCODE;
}
//
// Create a new FAQ object
//
$faq = new PMF_Faq($current_user, $current_groups);
//
// Create a new Category object
//
$category = new PMF_Category($current_user, $current_groups);
//
// Create a new Tags object
//
$oTag = new PMF_Tags();
//
// Found a record ID?
//
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!is_null($id)) {
    $title = ' - ' . $faq->getRecordTitle($id);
    $keywords = ' ' . $faq->getRecordKeywords($id);
示例#23
0
 * @license   http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
 * @link      http://www.phpmyfaq.de
 * @since     2003-02-23
 */
if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
printf("<h2>%s</h2>\n", $PMF_LANG['ad_entry_aor']);
if ($permission['editbt'] || $permission['delbt']) {
    $categoryRelations = new PMF_Category_Relations();
    $categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE);
    $categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData)));
    $linkverifier = new PMF_Linkverifier($user->getLogin());
    $comment = new PMF_Comment();
    $faq = new PMF_Faq();
    if ($linkverifier->isReady()) {
        link_verifier_javascript();
    }
    $cond = $numCommentsByFaq = $numActiveByCat = array();
    $internalSearch = $linkState = $searchterm = '';
    $searchcat = $currentcategory = 0;
    $orderby = 1;
    $sortby = null;
    $linkState = PMF_Filter::filterInput(INPUT_POST, 'linkstate', FILTER_SANITIZE_STRING);
    $searchcat = PMF_Filter::filterInput(INPUT_POST, 'searchcat', FILTER_VALIDATE_INT);
    $searchterm = PMF_Filter::filterInput(INPUT_POST, 'searchterm', FILTER_SANITIZE_STRIPPED);
    if (!is_null($linkState)) {
        $cond[SQLPREFIX . 'faqdata.links_state'] = 'linkbad';
        $linkState = ' checked="checked" ';
        $internalSearch .= '&amp;linkstate=linkbad';
示例#24
0
    }
    $node = '<url>' . '<loc>' . PMF_String::htmlspecialchars($location) . '</loc>' . '<lastmod>' . $lastmod . '</lastmod>' . '<changefreq>' . $changeFreq . '</changefreq>' . (isset($priority) ? '<priority>' . $priority . '</priority>' : '') . '</url>';
    return $node;
}
//
// Future improvements
// WHEN a User PMF Sitemap will be:
//   a. bigger than 10MB (!)
//   b. w/ more than 50K URLs (!)
// we'll manage this issue using a Sitemap Index Files produced by this PHP code
// including Sitemap URLs always produced by this same PHP code (see PMF_SITEMAP_GOOGLE_GET_INDEX)
//
PMF_Init::cleanRequest();
session_name(PMF_COOKIE_NAME_AUTH . trim($faqconfig->get('main.phpMyFAQToken')));
session_start();
$oFaq = new PMF_Faq();
// Load the faq
$items = $oFaq->getTopTenData(PMF_SITEMAP_GOOGLE_MAX_URLS - 1);
$visitsMax = 0;
$visitMin = 0;
if (count($items) > 0) {
    $visitsMax = $items[0]['visits'];
    $visitMin = $items[count($items) - 1]['visits'];
}
// Sitemap header
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"' . ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . ' xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84' . ' http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">';
// 1st entry: the faq server itself
$sitemap .= buildSitemapNode(PMF_Link::getSystemUri('/sitemap.google.php'), PMF_Date::createISO8601Date($_SERVER['REQUEST_TIME'], false), PMF_SITEMAP_GOOGLE_CHANGEFREQ_DAILY, PMF_SITEMAP_GOOGLE_PRIORITY_MAX);
// nth entry: each faq
foreach ($items as $item) {
    $priority = PMF_SITEMAP_GOOGLE_PRIORITY_DEFAULT;
示例#25
0
 * @since     2006-11-12
 */
if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
$captcha = new PMF_Captcha($db, $Language);
$captcha->setSessionId($sids);
if (!is_null($showCaptcha)) {
    $captcha->showCaptchaImg();
    exit;
}
$translationLanguage = PMF_Filter::filterInput(INPUT_POST, 'translation', FILTER_SANITIZE_STRIPPED, $LANGCODE);
if (!PMF_Language::isASupportedLanguage($translationLanguage)) {
    $translationLanguage = $LANGCODE;
}
$faqSource['id'] = 'writeSourceFaqId';
$faqSource['lang'] = $translationLanguage;
$faqSource['title'] = 'writeSourceTitle';
$faqSource['content'] = 'writeSourceContent';
$faqSource['keywords'] = 'writeSourceKeywords';
$faqsession->userTracking('new_translation_entry', 0);
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$srclang = PMF_Filter::filterInput(INPUT_GET, 'srclang', FILTER_SANITIZE_STRIPPED);
if (!is_null($id) && !is_null($srclang) && PMF_Language::isASupportedLanguage($srclang)) {
    $oFaq = new PMF_Faq();
    $oFaq->getRecord($id);
    $faqSource = $oFaq->faqRecord;
}
$tpl->processTemplate('writeContent', array('writeSourceFaqId' => $faqSource['id'], 'writeSourceTitle' => $faqSource['title'], 'writeSourceContent' => $faqSource['content'], 'writeSourceKeywords' => $faqSource['keywords'], 'msgNewTranslationHeader' => $PMF_LANG['msgNewTranslationHeader'], 'msgNewTranslationAddon' => $PMF_LANG['msgNewTranslationAddon'], 'msgNewTransSourcePane' => $PMF_LANG['msgNewTransSourcePane'], 'msgNewTranslationPane' => $PMF_LANG['msgNewTranslationPane'], 'writeSendAdress' => '?' . $sids . 'action=save', 'defaultContentName' => $user ? $user->getUserData('display_name') : '', 'defaultContentMail' => $user ? $user->getUserData('email') : '', 'msgNewTranslationName' => $PMF_LANG['msgNewTranslationName'], 'msgNewTranslationMail' => $PMF_LANG['msgNewTranslationMail'], 'msgNewTranslationKeywords' => $PMF_LANG['msgNewTranslationKeywords'], 'writeTransFaqLanguage' => $translationLanguage, 'captchaFieldset' => PMF_Helper_Captcha::getInstance()->renderFieldset($PMF_LANG['msgCaptcha'], $captcha->printCaptcha('translate')), 'msgNewTranslationSubmit' => $PMF_LANG['msgNewTranslationSubmit'], 'tinyMCELanguage' => PMF_Language::isASupportedTinyMCELanguage($LANGCODE) ? $LANGCODE : 'en'));
$tpl->includeTemplate('writeContent', 'index');
示例#26
0
// }}}
// {{{ Functions
function printHTTPStatus404()
{
    if ('cgi' == substr(php_sapi_name(), 0, 3) || isset($_SERVER['ALL_HTTP'])) {
        header('Status: 404 Not Found');
    } else {
        header('HTTP/1.0 404 Not Found');
    }
    exit;
}
// }}}
PMF_Init::cleanRequest();
session_name(PMF_COOKIE_NAME_AUTH . trim($faqconfig->get('main.phpMyFAQToken')));
session_start();
$oFaq = new PMF_Faq();
// Load the faq
$items = $oFaq->getTopTenData(PMF_SITEMAP_YAHOO_MAX_URLS - 1);
$sitemap = '';
// 1st entry: the faq server itself
$sitemap .= PMF_Link::getSystemUri('/sitemap.yahoo.php') . PMF_SITEMAP_YAHOO_END_OF_LINE;
// nth entry: each faq
foreach ($items as $item) {
    // a. We use plain PMF urls w/o any SEO schema
    $link = str_replace($_SERVER['PHP_SELF'], '/index.php', $item['url']);
    // b. We use SEO PMF urls
    if (PMF_SITEMAP_YAHOO_USE_SEO) {
        if (isset($item['thema'])) {
            $oL = new PMF_Link($link);
            $oL->itemTitle = $item['thema'];
            $link = $oL->toString();
示例#27
0
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
if (!$faqConfig->get('main.enableRssFeeds')) {
    exit;
}
$category_id = PMF_Filter::filterInput(INPUT_GET, 'category_id', FILTER_VALIDATE_INT);
$category = new PMF_Category($faqConfig);
$category->setUser($current_user);
$category->setGroups($current_groups);
$faq = new PMF_Faq($faqConfig);
$faq->setUser($current_user);
$faq->setGroups($current_groups);
$records = $faq->getAllRecordPerCategory($category_id, $faqConfig->get('records.orderby'), $faqConfig->get('records.sortby'));
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', $faqConfig->get('main.titleFAQ') . ' - ');
$rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription')));
$rss->writeElement('link', $faqConfig->get('main.referenceURL'));
if (is_array($records)) {
    foreach ($records as $item) {
示例#28
0
    if ($user->perm instanceof PMF_Perm_Medium) {
        $current_groups = $user->perm->getUserGroups($current_user);
    } else {
        $current_groups = array(-1);
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
$currentCategory = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT);
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$getAll = PMF_Filter::filterInput(INPUT_GET, 'getAll', FILTER_VALIDATE_BOOLEAN, false);
$faq = new PMF_Faq($faqConfig);
$faq->setUser($current_user);
$faq->setGroups($current_groups);
$category = new PMF_Category($faqConfig, $current_groups, true);
$category->setUser($current_user);
$pdf = new PMF_Export_Pdf($faq, $category, $faqConfig);
if (true === $getAll) {
    $category->buildTree();
}
$tags = new PMF_Tags($faqConfig);
session_cache_limiter('private');
if (true === $getAll && $user->perm->checkRight($user->getUserId(), 'export')) {
    $filename = 'FAQs.pdf';
    $pdfFile = $pdf->generate(0, true, $lang);
} elseif (is_null($currentCategory) || is_null($id)) {
    Response::create('Wrong HTTP GET parameters values.', 403)->send();
示例#29
0
文件: rss.php 项目: atlcurling/tkt
        $current_groups = $user->perm->getUserGroups($current_user);
    } else {
        $current_groups = array(-1);
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
//
// Initalizing static string wrapper
//
PMF_String::init($LANGCODE);
$faq = new PMF_Faq($current_user, $current_groups);
$rssData = $faq->getTopTenData(PMF_NUMBER_RECORDS_TOPTEN);
$num = count($rssData);
$rss = new XMLWriter();
$rss->openMemory();
$rss->setIndent(true);
$rss->startDocument('1.0', 'utf-8');
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', $faqconfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgTopTen']);
$rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription')));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/topten/rss.php'));
if ($num > 0) {
    $i = 0;
    foreach ($rssData as $item) {
示例#30
0
 * @since     2005-11-02
 */
if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
//
// GET Parameters Syntax:
//   export.file.php?
//          type={pdf|xhtml|xml}
//      [&dispos={inline|attachment}], default: attachment
//       [&catid=NN[&downwards=1]], default: all, downwards
//
$categoryId = PMF_Filter::filterInput(INPUT_POST, 'catid', FILTER_VALIDATE_INT);
$downwards = PMF_Filter::filterInput(INPUT_POST, 'downwards', FILTER_VALIDATE_BOOLEAN, false);
$inlineDisposition = PMF_Filter::filterInput(INPUT_POST, 'dispos', FILTER_SANITIZE_STRING);
$type = PMF_Filter::filterInput(INPUT_POST, 'type', FILTER_SANITIZE_STRING, 'none');
$faq = new PMF_Faq();
$faq->setLanguage($lang);
$category = new PMF_Category();
$category->buildTree();
$tags = new PMF_Tags($db, $Language);
$export = PMF_Export::create($faq, $category, $type);
$content = $export->generate($categoryId, $downwards);
// Stream the file content
$oHttpStreamer = new PMF_HttpStreamer($type, $content);
if ('inline' == $inlineDisposition) {
    $oHttpStreamer->send(PMF_HttpStreamer::HTTP_CONTENT_DISPOSITION_INLINE);
} else {
    $oHttpStreamer->send(PMF_HttpStreamer::HTTP_CONTENT_DISPOSITION_ATTACHMENT);
}