示例#1
0
 /**
  * This function sends a query to the database.
  *
  * @param string  $query
  * @param integer $offset
  * @param integer $rowcount
  *
  * @return PDOStatement $statement
  */
 public function query($query, $offset = 0, $rowcount = 0)
 {
     if (DEBUG) {
         $this->sqllog .= PMF_Utils::debug($query);
     }
     try {
         return $this->conn->query($query);
     } catch (PDOException $e) {
         $this->sqllog .= $e->getMessage();
     }
 }
示例#2
0
文件: Faq.php 项目: noon/phpMyFAQ
 /**
  * Prepares and returns the sticky records for the frontend
  * 
  * @return array
  */
 public function getStickyRecords()
 {
     $result = $this->getStickyRecordsData();
     $output = array();
     if (count($result) > 0) {
         foreach ($result as $row) {
             $shortTitle = PMF_Utils::makeShorterText($row['thema'], 8);
             $output['title'][] = $shortTitle;
             $output['url'][] = $row['url'];
         }
     } else {
         $output['error'] = $this->pmf_lang['err_noTopTen'];
     }
     return $output;
 }
示例#3
0
        ?>
</td>
                        <td><?php 
        echo $data['lang'];
        ?>
</td>
                        <td>
                            <a href="<?php 
        echo $url;
        ?>
" title="<?php 
        echo $question;
        ?>
">
                                <?php 
        echo PMF_Utils::makeShorterText($question, 14);
        ?>
                            </a>
                        </td>
                        <td><?php 
        echo $data['usr'];
        ?>
</td>
                        <td>
                            <?php 
        if (round($data['num'] * 20) > 75) {
            $progressBar = 'success';
        } elseif (round($data['num'] * 20) < 25) {
            $progressBar = 'danger';
        } else {
            $progressBar = 'info';
示例#4
0
    $metaDescription = $faqconfig->get('main.metaDescription');
}
//
// found a solution ID?
//
$solution_id = PMF_Filter::filterInput(INPUT_GET, 'solution_id', FILTER_VALIDATE_INT);
if (!is_null($solution_id)) {
    $title = ' -  powered by phpMyFAQ ' . $faqconfig->get('main.currentVersion');
    $keywords = '';
    $faqData = $faq->getIdFromSolutionId($solution_id);
    if (is_array($faqData)) {
        $id = $faqData['id'];
        $lang = $faqData['lang'];
        $title = ' - ' . $faq->getRecordTitle($id);
        $keywords = ',' . $faq->getRecordKeywords($id);
        $metaDescription = PMF_Utils::makeShorterText(strip_tags($faqData['content']), 12);
    }
}
//
// Handle the Tagging ID
//
$tag_id = PMF_Filter::filterInput(INPUT_GET, 'tagging_id', FILTER_VALIDATE_INT);
if (!is_null($tag_id)) {
    $title = ' - ' . $oTag->getTagNameById($tag_id);
    $keywords = '';
}
//
// Handle the SiteMap
//
$letter = PMF_Filter::filterInput(INPUT_GET, 'letter', FILTER_SANITIZE_STRIPPED);
if (!is_null($letter) && 1 == PMF_String::strlen($letter)) {
示例#5
0
 /**
  * Returns date from out of time
  *
  * @return string
  */
 public static function getNeverExpireDate()
 {
     // Unix: 13 Dec 1901 20:45:54 -> 19 Jan 2038 03:14:07, signed 32 bit
     // Windows: 1 Jan 1970 -> 19 Jan 2038.
     // So we will use: 1 Jan 2038 -> 2038-01-01, 00:00:01
     return PMF_Utils::getPMFDate(mktime(0, 0, 1, 1, 1, 2038));
 }
示例#6
0
        ?>
</td>
        <td><a href="../index.php?action=artikel&amp;cat=<?php 
        print $data['category_id'];
        ?>
&amp;id=<?php 
        print $data['id'];
        ?>
&amp;artlang=<?php 
        print $data['lang'];
        ?>
" title="<?php 
        print PMF_String::htmlspecialchars(trim($data['question']), ENT_QUOTES, 'utf-8');
        ?>
"><?php 
        print PMF_Utils::makeShorterText(PMF_htmlentities(trim($data['question']), ENT_QUOTES, 'utf-8'), 14);
        ?>
</a></td>
        <td><?php 
        print $data['usr'];
        ?>
</td>
        <td style="width: 50px;"><img src="stat.bar.php?num=<?php 
        print $data['num'];
        ?>
" border="0" alt="<?php 
        print round($data['num'] * 20);
        ?>
 %" width="50" height="15" title="<?php 
        print round($data['num'] * 20);
        ?>
示例#7
0
 $showcat = PMF_Filter::filterInput(INPUT_POST, 'showcat', FILTER_SANITIZE_STRING);
 // translate an existing category
 if (!is_null($showcat) && $showcat == 'yes') {
     $categoryData = array('id' => PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT), 'lang' => PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING), 'parent_id' => PMF_Filter::filterInput(INPUT_POST, 'parent_id', FILTER_VALIDATE_INT), 'name' => PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING), 'description' => PMF_Filter::filterInput(INPUT_POST, 'description', FILTER_SANITIZE_STRING), 'user_id' => PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT));
     // translate.category only returns non-existent languages to translate too
     if ($categoryNode->create($categoryData)) {
         printf('<p>%s</p>', $PMF_LANG['ad_categ_translated']);
     } else {
         printf('<p>%s</p>', $db->error());
     }
 }
 print "\n\n<table>\n";
 print "<tr>\n";
 print "    <th>" . $currentLanguage . "</th>\n";
 // get languages in use for all categories
 $allLanguages = PMF_Utils::languageAvailable(0, $table = 'faqcategories');
 asort($allLanguages);
 foreach ($allLanguages as $language) {
     if ($languageCodes[strtoupper($language)] != $currentLanguage) {
         print "    <th>" . $languageCodes[strtoupper($language)] . "</th>\n";
     }
 }
 $categoryDataProvider = new PMF_Category_Tree_DataProvider_SingleQuery();
 $categoryTreeHelper = new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryDataProvider));
 $categoryHelper = new PMF_Category_Helper();
 foreach ($categoryTreeHelper as $categoryId => $categoryName) {
     $indent = str_repeat('&nbsp;', $categoryTreeHelper->indent);
     $categoryLang = $categoryTreeHelper->getInnerIterator()->current()->getLanguage();
     if ($categoryLang == $LANGCODE) {
         print "</tr>\n";
         print "<tr>\n";
 /**
  * Create the headers of the email.
  *
  * @return void     
  */
 private function _createHeaders()
 {
     // Cleanup headers
     $this->headers = array();
     // Check if the message consists of just a "plain" single item
     if (false === strpos($this->contentType, 'multipart')) {
         // Content-Disposition: inline
         $this->headers['Content-Disposition'] = $this->contentDisposition;
         // Content-Type
         $this->headers['Content-Type'] = $this->contentType . '; format=flowed; charset="' . $this->charset . '"';
         // Content-Transfer-Encoding: 7bit
         $this->headers['Content-Transfer-Encoding'] = '7bit';
     } else {
         // Content-Type
         $this->headers['Content-Type'] = $this->contentType . '; boundary="' . $this->boundary . '"';
     }
     // Date
     $this->headers['Date'] = self::getDate(self::getTime());
     // Disposition-Notification-To, RFC 3798
     $notifyTos = array();
     foreach ($this->_notifyTo as $address => $name) {
         $notifyTos[] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
     }
     $notifyTo = implode(',', $notifyTos);
     if (!empty($notifyTo)) {
         $this->headers['Disposition-Notification-To'] = $notifyTo;
     }
     // From
     foreach ($this->_from as $address => $name) {
         $this->headers['From'] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
     }
     // CC
     foreach ($this->_cc as $address => $name) {
         $this->headers['CC'] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
     }
     // BCC
     foreach ($this->_bcc as $address => $name) {
         $this->headers['BCC'] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
     }
     // Message-Id
     $this->headers['Message-ID'] = $this->messageId;
     // MIME-Version: 1.0
     $this->headers['MIME-Version'] = '1.0';
     // Reply-To
     $this->headers['Reply-To'] = $this->headers['From'];
     foreach ($this->_replyTo as $address => $name) {
         $this->headers['Reply-To'] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
     }
     // Return-Path
     foreach ($this->_from as $address => $name) {
         $this->headers['Return-Path'] = '<' . $address . '>';
     }
     foreach ($this->_returnPath as $address => $name) {
         $this->headers['Return-Path'] = '<' . $address . '>';
     }
     // Sender
     $this->headers['Sender'] = $this->headers['From'];
     foreach ($this->_sender as $address => $name) {
         $this->headers['Sender'] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
     }
     // Subject. Note: it must be RFC 2047 compliant
     // TODO: wrap mb_encode_mimeheader() to add other content encodings
     $this->headers['Subject'] = PMF_Utils::resolveMarkers(html_entity_decode($this->subject, ENT_COMPAT, 'UTF-8'), $this->_config);
     // X-Mailer
     $this->headers['X-Mailer'] = $this->_mailer;
     // X-MSMail-Priority
     if (isset($this->priorities[(int) $this->priority])) {
         $this->headers['X-MSMail-Priority'] = $this->priorities[(int) $this->priority];
     }
     // X-Originating-IP
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $this->headers['X-Originating-IP'] = $_SERVER['REMOTE_ADDR'];
     }
     // X-Priority
     $this->headers['X-Priority'] = $this->priority;
 }
示例#9
0
文件: rss.php 项目: nosch/phpMyFAQ
$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['msgOpenQuestions']);
$rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription')));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/openquestions/rss.php'));
if ($num > 0) {
    $counter = 0;
    foreach ($rssData as $item) {
        if ($counter < PMF_RSS_OPENQUESTIONS_MAX) {
            $counter++;
            $rss->startElement('item');
            $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item->question), 8) . " (" . $item->username . ")");
            $rss->startElement('description');
            $rss->writeCdata($item->question);
            $rss->endElement();
            $rss->writeElement('link', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER["PHP_SELF"]) . "?action=open#openq_" . $item->id);
            $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item->date, true));
            $rss->endElement();
        }
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
示例#10
0
 /**
  * This function sends a query to the database.
  *
  * @param string  $query
  * @param integer $offset
  * @param integer $rowcount
  *
  * @return  mixed $result
  */
 public function query($query, $offset = 0, $rowcount = 0)
 {
     if (DEBUG) {
         $this->sqllog .= PMF_Utils::debug($query);
     }
     if (0 < $rowcount) {
         $query .= sprintf(' OFFSET %d ROWS FETCH NEXT %d ROWS ONLY', $offset, $rowcount);
     }
     $result = mssql_query($query, $this->conn);
     if (!$result) {
         $this->sqllog .= $this->error();
     }
     return $result;
 }
示例#11
0
        ?>
</td>
        <td><a href="../index.php?action=artikel&amp;cat=<?php 
        print $data['category_id'];
        ?>
&amp;id=<?php 
        print $data['id'];
        ?>
&amp;artlang=<?php 
        print $data['lang'];
        ?>
" title="<?php 
        print PMF_String::htmlspecialchars(trim($data['question']), ENT_QUOTES, 'utf-8');
        ?>
"><?php 
        print PMF_Utils::makeShorterText(PMF_String::htmlspecialchars(trim($data['question']), ENT_QUOTES, 'utf-8'), 14);
        ?>
</a></td>
        <td><?php 
        print $data['usr'];
        ?>
</td>
        <td style="width: 50px;"><img src="stat.bar.php?num=<?php 
        print $data['num'];
        ?>
" border="0" alt="<?php 
        print round($data['num'] * 20);
        ?>
 %" width="50" height="15" title="<?php 
        print round($data['num'] * 20);
        ?>
示例#12
0
文件: rss.php 项目: noon/phpMyFAQ
$rss = new XMLWriter();
$rss->openMemory();
$rss->startDocument('1.0', $PMF_LANG['metaCharset']);
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', utf8_encode($PMF_CONF['main.titleFAQ']) . ' - ' . utf8_encode($PMF_LANG['msgOpenQuestions']));
$rss->writeElement('description', utf8_encode($PMF_CONF['main.metaDescription']));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/openquestions/rss.php'));
if ($num > 0) {
    $counter = 0;
    foreach ($rssData as $item) {
        if ($counter < PMF_RSS_OPENQUESTIONS_MAX) {
            $counter++;
            $rss->startElement('item');
            $rss->writeElement('title', utf8_encode(PMF_Utils::makeShorterText($item['question'], 8) . " (" . $item['user'] . ")"));
            $rss->startElement('description');
            $rss->writeCdata(utf8_encode($item['question']));
            $rss->endElement();
            $rss->writeElement('link', utf8_encode((isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER["PHP_SELF"]) . "?action=open#openq_" . $item['id']));
            $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['date'], false));
            $rss->endElement();
        }
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
示例#13
0
 /**
  * Returns all records from the current first letter
  *
  * @param  string $letter Letter
  * @return array
  * @since  2007-03-30
  * @author Thorsten Rinne <*****@*****.**>
  */
 public function getRecordsFromLetter($letter = 'A')
 {
     global $sids, $PMF_LANG;
     if ($this->groupSupport) {
         $permPart = sprintf("( fdg.group_id IN (%s)\n            OR\n                (fdu.user_id = %d AND fdg.group_id IN (%s)))", implode(', ', $this->groups), $this->user, implode(', ', $this->groups));
     } else {
         $permPart = sprintf("( fdu.user_id = %d OR fdu.user_id = -1 )", $this->user);
     }
     $letter = PMF_String::strtoupper($this->db->escape_string(PMF_String::substr($letter, 0, 1)));
     $writeMap = '';
     switch ($this->type) {
         case 'db2':
         case 'sqlite':
             $query = sprintf("\n                    SELECT\n                        fd.thema AS thema,\n                        fd.id AS id,\n                        fd.lang AS lang,\n                        fcr.category_id AS category_id,\n                        fd.content AS snap\n                    FROM\n                        %sfaqcategoryrelations fcr,\n                        %sfaqdata fd\n                    LEFT JOIN\n                        %sfaqdata_group AS fdg\n                    ON\n                        fd.id = fdg.record_id\n                    LEFT JOIN\n                        %sfaqdata_user AS fdu\n                    ON\n                        fd.id = fdu.record_id\n                    WHERE\n                        fd.id = fcr.record_id\n                    AND\n                        SUBSTR(fd.thema, 1, 1) = '%s'\n                    AND\n                        fd.lang = '%s'\n                    AND\n                        fd.active = 'yes'\n                    AND\n                        %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
             break;
         default:
             $query = sprintf("\n                    SELECT\n                        fd.thema AS thema,\n                        fd.id AS id,\n                        fd.lang AS lang,\n                        fcr.category_id AS category_id,\n                        fd.content AS snap\n                    FROM\n                        %sfaqcategoryrelations fcr,\n                        %sfaqdata fd\n                    LEFT JOIN\n                        %sfaqdata_group AS fdg\n                    ON\n                        fd.id = fdg.record_id\n                    LEFT JOIN\n                        %sfaqdata_user AS fdu\n                    ON\n                        fd.id = fdu.record_id\n                    WHERE\n                        fd.id = fcr.record_id\n                    AND\n                        SUBSTRING(fd.thema, 1, 1) = '%s'\n                    AND\n                        fd.lang = '%s'\n                    AND\n                        fd.active = 'yes'\n                    AND\n                        %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
             break;
     }
     $result = $this->db->query($query);
     $oldId = 0;
     while ($row = $this->db->fetch_object($result)) {
         if ($oldId != $row->id) {
             $title = PMF_String::htmlspecialchars($row->thema, ENT_QUOTES, 'utf-8');
             $url = sprintf('%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
             $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
             $oLink->itemTitle = $row->thema;
             $oLink->text = $title;
             $oLink->tooltip = $title;
             $writeMap .= '<li>' . $oLink->toHtmlAnchor() . '<br />' . "\n";
             $writeMap .= PMF_Utils::chopString(strip_tags($row->snap), 25) . " ...</li>\n";
         }
         $oldId = $row->id;
     }
     $writeMap = empty($writeMap) ? '' : '<ul>' . $writeMap . '</ul>';
     return $writeMap;
 }
示例#14
0
文件: Tags.php 项目: nosch/phpMyFAQ
 /**
  * Returns all tags
  *
  * @param  string  $search Move the returned result set to be the result of a start-with search
  * @param  boolean $limit  Limit the returned result set
  * @return array
  */
 public function getAllTags($search = null, $limit = false)
 {
     global $DB;
     $tags = $allTags = array();
     // Hack: LIKE is case sensitive under PostgreSQL
     switch ($DB['type']) {
         case 'pgsql':
             $like = 'ILIKE';
             break;
         default:
             $like = 'LIKE';
             break;
     }
     $query = sprintf("\n            SELECT\n                tagging_id, tagging_name\n            FROM\n                %sfaqtags\n                %s\n            ORDER BY tagging_name", SQLPREFIX, isset($search) && $search != '' ? "WHERE tagging_name " . $like . " '" . $search . "%'" : '');
     $result = $this->db->query($query);
     if ($result) {
         while ($row = $this->db->fetchObject($result)) {
             $allTags[$row->tagging_id] = $row->tagging_name;
         }
     }
     $numberOfItems = $limit ? PMF_TAGS_CLOUD_RESULT_SET_SIZE : $this->db->numRows($result);
     if (isset($allTags) && $numberOfItems < count($allTags)) {
         $keys = array_keys($allTags);
         shuffle($keys);
         foreach ($keys as $current_key) {
             $tags[$current_key] = $allTags[$current_key];
         }
         $tags = array_slice($tags, 0, $numberOfItems);
     } else {
         $tags = PMF_Utils::shuffleData($allTags);
     }
     return $tags;
 }
示例#15
0
文件: rss.php 项目: noon/phpMyFAQ
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/topten/rss.php'));
if ($num > 0) {
    $i = 0;
    foreach ($rssData as $item) {
        $i++;
        // Get the url
        $link = str_replace($_SERVER['PHP_SELF'], '/index.php', $item['url']);
        if (PMF_RSS_USE_SEO) {
            if (isset($item['thema'])) {
                $oL = new PMF_Link($link);
                $oL->itemTitle = $item['thema'];
                $link = $oL->toString();
            }
        }
        $rss->startElement('item');
        $rss->writeElement('title', utf8_encode(PMF_Utils::makeShorterText($item['thema'], 8) . " (" . $item['visits'] . " " . $PMF_LANG['msgViews'] . ")"));
        $rss->startElement('description');
        $rss->writeCdata(utf8_encode("[" . $i . ".] " . $item['thema'] . " (" . $item['visits'] . " " . $PMF_LANG['msgViews'] . ")"));
        $rss->endElement();
        $rss->writeElement('link', utf8_encode(PMF_Link::getSystemUri('/feed/topten/rss.php') . $link));
        $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['last_visit'], false));
        $rss->endElement();
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
$db->dbclose();
示例#16
0
    $metaDescription = $faqConfig->get('main.metaDescription');
}
//
// found a solution ID?
//
$solutionId = PMF_Filter::filterInput(INPUT_GET, 'solution_id', FILTER_VALIDATE_INT);
if (!is_null($solutionId)) {
    $title = ' -  powered by phpMyFAQ ' . $faqConfig->get('main.currentVersion');
    $keywords = '';
    $faqData = $faq->getIdFromSolutionId($solutionId);
    if (is_array($faqData)) {
        $id = $faqData['id'];
        $lang = $faqData['lang'];
        $title = ' - ' . $faq->getRecordTitle($id);
        $keywords = ',' . $faq->getRecordKeywords($id);
        $metaDescription = str_replace('"', '', PMF_Utils::makeShorterText(strip_tags($faqData['content']), 12));
    }
}
//
// Handle the Tagging ID
//
$tag_id = PMF_Filter::filterInput(INPUT_GET, 'tagging_id', FILTER_VALIDATE_INT);
if (!is_null($tag_id)) {
    $title = ' - ' . $oTag->getTagNameById($tag_id);
    $keywords = '';
}
//
// Handle the SiteMap
//
$letter = PMF_Filter::filterInput(INPUT_GET, 'letter', FILTER_SANITIZE_STRIPPED);
if (!is_null($letter) && 1 == PMF_String::strlen($letter)) {
 $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";
 echo $output;
 $i = 0;
 foreach ($_records as $_r) {
     $i++;
     $output = '';
     $output .= sprintf('%0' . strlen((string) $tot) . 'd', $i) . '/' . $tot . '. Checking ' . $_r['solution_id'] . ' (' . PMF_Utils::makeShorterText(strip_tags($_r['title']), 8) . '):';
     $start = microtime(true);
     if ($oLnk->getEntryState($_r['id'], $_r['lang'], true) === true) {
         $output .= $oLnk->verifyArticleURL($_r['content'], $_r['id'], $_r['lang'], true);
     }
     $end = microtime(true);
     $output .= ' done in ' . round($end - $start, 4) . ' sec.';
     $output .= $isRequestedByWebLocalhost ? '' : "\n";
     if ($isRequestedByWebLocalhost) {
         $output = $output . "\n";
     }
     echo $output;
 }
 $output = '';
 $totEnd = microtime(true);
 $output .= $isRequestedByWebLocalhost ? '' : "\n";
示例#18
0
            $_title = $faq->getRecordTitle($_id, false);
            $_link = substr($_url, 9);
            // Move the link to XHTML
            if (strpos($_url, '&amp;') === false) {
                $_link = str_replace('&', '&amp;', $_link);
            }
            $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . $_link);
            $oLink->itemTitle = $oLink->tooltip = $_title;
            $newFaqPath = $oLink->toString();
            $fixedContent = str_replace($_url, $newFaqPath, $fixedContent);
        }
    }
}
$content = $fixedContent;
// Check for the languages for a faq
$arrLanguage = PMF_Utils::languageAvailable($faq->faqRecord['id']);
$switchLanguage = '';
$check4Lang = '';
$num = count($arrLanguage);
if ($num > 1) {
    foreach ($arrLanguage as $language) {
        $check4Lang .= "<option value=\"" . $language . "\"";
        $check4Lang .= $lang == $language ? ' selected="selected"' : '';
        $check4Lang .= ">" . $languageCodes[strtoupper($language)] . "</option>\n";
    }
    $switchLanguage .= "<p>\n";
    $switchLanguage .= "<fieldset>\n";
    $switchLanguage .= "<legend>" . $PMF_LANG["msgLangaugeSubmit"] . "</legend>\n";
    $switchLanguage .= "<form action=\"" . $changeLanguagePath . "\" method=\"post\" style=\"display: inline;\">\n";
    $switchLanguage .= "<select name=\"artlang\" size=\"1\">\n";
    $switchLanguage .= $check4Lang;
示例#19
0
     // Create user account (login and password)
     // Note: password be automatically generated
     //       and sent by email as soon if admin switch user to "active"
     if (!$user->createUser($user_name, '')) {
         $messages[] = $user->error();
     } else {
         // set user data (realname, email)
         $user->userdata->set(array('display_name', 'email'), array($user_realname, $user_email));
         // set user status
         $user->setStatus($defaultUserStatus);
         $text = sprintf("New user has been registrated:\n\nUsername: %s\nLoginname: %s\n\n" . "To activate this user do please use the administration interface.", $lastname, $loginname);
         $mail = new PMF_Mail();
         $mail->unsetFrom();
         $mail->setFrom($user_email);
         $mail->addTo($faqconfig->get('main.administrationMail'));
         $mail->subject = PMF_Utils::resolveMarkers($PMF_LANG['emailRegSubject']);
         $mail->message = $text;
         $result = $mail->send();
         unset($mail);
         header("Location: index.php?action=thankyou");
         exit;
     }
 }
 // no errors, show list
 if (count($messages) == 0) {
     $userAction = $defaultUserAction;
     // display error messages and show form again
 } else {
     $tpl->processTemplate('writeContent', array('regErrors' => sprintf("<strong>%s</strong> <br /> - %s <br /><br />", $PMF_LANG['msgRegError'], implode("<br />- ", $messages)), 'msgUserData' => $PMF_LANG['msgUserData'], 'login_errorRegistration' => !is_null($loginname) ? $PMF_LANG['errorRegistration'] : '', 'name_errorRegistration' => !is_null($lastname) ? $PMF_LANG['errorRegistration'] : '', 'email_errorRegistration' => !is_null($email) ? $PMF_LANG['errorRegistration'] : '', 'loginname' => $PMF_LANG["ad_user_loginname"], 'lastname' => $PMF_LANG["ad_user_realname"], 'email' => $PMF_LANG["ad_entry_email"], 'loginname_value' => $loginname, 'lastname_value' => $lastname, 'email_value' => $email, 'submitRegister' => $PMF_LANG['submitRegister'], 'captchaFieldset' => printCaptchaFieldset($PMF_LANG['msgCaptcha'], $captcha->printCaptcha('add'), $captcha->caplength, isset($captchaError) ? $captchaError : '')));
     $tpl->includeTemplate('writeContent', 'index');
 }
示例#20
0
 /**
  * The header of the PDF file
  *
  * @return void
  */
 public function Header()
 {
     $title = $this->category->name . ': ' . $this->question;
     $currentTextColor = $this->TextColor;
     $this->SetTextColor(0, 0, 0);
     $this->SetFont('arialunicid0', 'B', 18);
     $this->MultiCell(0, 9, $title, 0, 'C', 0);
     if ($this->enableBookmarks) {
         $this->Bookmark(PMF_Utils::makeShorterText($this->question, 5));
     }
     $this->TextColor = $currentTextColor;
     $this->SetMargins(PDF_MARGIN_LEFT, $this->getLastH() + 5, PDF_MARGIN_RIGHT);
 }
$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');
$rss->writeAttribute('type', 'application/rss+xml');
$rss->writeAttribute('href', $faqConfig->get('main.referenceURL') . 'feed/openquestions/rss.php');
$rss->endElement();
if ($num > 0) {
    $counter = 0;
    foreach ($rssData as $item) {
        if ($counter < PMF_RSS_OPENQUESTIONS_MAX) {
            $counter++;
            $rss->startElement('item');
            $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item['question'], ENT_COMPAT, 'UTF-8'), 8) . " (" . $item['username'] . ")");
            $rss->startElement('description');
            $rss->writeCdata($item['question']);
            $rss->endElement();
            $rss->writeElement('link', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER['SCRIPT_NAME']) . "?action=open#openq_" . $item['id']);
            $rss->writeElement('guid', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER['SCRIPT_NAME']) . "?action=open#openq_" . $item['id']);
            $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['created'], true));
            $rss->endElement();
        }
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
$headers = array('Content-Type: application/rss+xml', 'Content-Length: ' . strlen($rssData));
$http = new PMF_Helper_Http();
示例#22
0
文件: rss.php 项目: atlcurling/tkt
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/topten/rss.php'));
if ($num > 0) {
    $i = 0;
    foreach ($rssData as $item) {
        $i++;
        // Get the url
        $link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['url']);
        if (PMF_RSS_USE_SEO) {
            if (isset($item['thema'])) {
                $oLink = new PMF_Link($link);
                $oLink->itemTitle = html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8');
                $link = html_entity_decode($oLink->toString(), ENT_COMPAT, 'UTF-8');
            }
        }
        $rss->startElement('item');
        $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8'), 8) . " (" . $item['visits'] . " " . $PMF_LANG['msgViews'] . ")");
        $rss->startElement('description');
        $rss->writeCdata("[" . $i . ".] " . $item['thema'] . " (" . $item['visits'] . " " . $PMF_LANG['msgViews'] . ")");
        $rss->endElement();
        $rss->writeElement('link', PMF_Link::getSystemUri('/feed/topten/rss.php') . $link);
        $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['last_visit'], false));
        $rss->endElement();
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
$db->dbclose();
示例#23
0
            $_title = $faq->getRecordTitle($_id, false);
            $_link = substr($_url, 9);
            // Move the link to XHTML
            if (strpos($_url, '&amp;') === false) {
                $_link = str_replace('&', '&amp;', $_link);
            }
            $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . $_link);
            $oLink->itemTitle = $oLink->tooltip = $_title;
            $newFaqPath = $oLink->toString();
            $fixedContent = str_replace($_url, $newFaqPath, $fixedContent);
        }
    }
}
$content = $fixedContent;
// Check for the languages for a faq
$arrLanguage = PMF_Utils::languageAvailable($record_id);
$switchLanguage = '';
$check4Lang = '';
$num = count($arrLanguage);
if ($num > 1) {
    foreach ($arrLanguage as $language) {
        $check4Lang .= "<option value=\"" . $language . "\"";
        $check4Lang .= $lang == $language ? ' selected="selected"' : '';
        $check4Lang .= ">" . $languageCodes[strtoupper($language)] . "</option>\n";
    }
    $switchLanguage .= "<p>\n";
    $switchLanguage .= "<fieldset>\n";
    $switchLanguage .= "<legend>" . $PMF_LANG["msgLangaugeSubmit"] . "</legend>\n";
    $switchLanguage .= "<form action=\"" . $changeLanguagePath . "\" method=\"post\" style=\"display: inline;\">\n";
    $switchLanguage .= "<select name=\"language\" size=\"1\">\n";
    $switchLanguage .= $check4Lang;
示例#24
0
 /**
  * Create all languagess which can be used for translation as <option>
  *
  * @param  integer $categoryId   Category id
  * @param  string  $selectedLanguage Selected language
  * @return string
  */
 public function renderLanguages($categoryId, $selectedLanguage)
 {
     $existingLanguages = PMF_Utils::languageAvailable($categoryId, 'faqcategories');
     $options = '';
     foreach (PMF_Language::getAvailableLanguages() as $lang => $langname) {
         if (!in_array(strtolower($lang), $existingLanguages)) {
             $options .= sprintf("\t<option value=\"%s\"%s>%s</option>\n", strtolower($lang), $lang == $selectedLanguage ? ' selected="selected"' : '', $langname);
         }
     }
     return $options;
 }
示例#25
0
文件: api.php 项目: atlcurling/tkt
// Handle actions
switch ($action) {
    case 'getVersion':
        $result = array('version' => $faqconfig->get('main.currentVersion'));
        break;
    case 'getApiVersion':
        $result = array('apiVersion' => (int) $faqconfig->get('main.currentApiVersion'));
        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;
示例#26
0
文件: footer.php 项目: nosch/phpMyFAQ
                     onselect : function(value) {
                         var elements = value.split('_');
                         var faqLink  = '<a class="intfaqlink" href="index.php?action=artikel&amp;cat=' + elements[0] + 
                                        '&amp;id=' + elements[1] + 
                                        '&amp;artlang=' + elements[2] + 
                                        '">' + elements[3] + '</a>';
                         tinyMCE.execCommand('mceBeginUndoLevel');
                         tinyMCE.execCommand('mceInsertContent', false, faqLink);
                         tinyMCE.execCommand('mceEndUndoLevel');
                     }
                });
<?php 
            $faq->getAllRecords(FAQ_SORTING_TYPE_FAQID);
            foreach ($faq->faqRecords as $record) {
                $_title = str_replace(array("\n", "\r", "\r\n"), '', '(' . $record['id'] . ') ' . $record['title']);
                printf("flb.add('%s', '%d_%d_%s_%s');\n", str_replace("'", "`", PMF_Utils::makeShorterText($_title, 8)), $record['category_id'], $record['id'], $record['lang'], str_replace("'", "`", $record['title']));
            }
            ?>

                return flb;
        }

        return null;
    }
});

// Register plugin with a short name
tinymce.PluginManager.add('internalfaqlinkbox', tinymce.plugins.internalFaqLinkPlugin);


tinyMCE.init({
示例#27
0
文件: Pdf.php 项目: noon/phpMyFAQ
 /**
  * The header of the PDF file
  *
  * @return void
  */
 public function Header()
 {
     $title = $this->categories[$this->category]['name'] . ': ' . $this->thema;
     $currentTextColor = $this->TextColor;
     $this->SetTextColor(0, 0, 0);
     $this->SetFont('dejavusans', 'B', 18);
     $this->MultiCell(0, 9, $title, 0, 'C', 0);
     if ($this->enableBookmarks) {
         $this->Bookmark(PMF_Utils::makeShorterText($this->thema, 5));
     }
     $this->TextColor = $currentTextColor;
     $this->SetMargins(PDF_MARGIN_LEFT, $this->getLastH() + 5, PDF_MARGIN_RIGHT);
 }
 /**
  * Renders the result page for the main search page
  *
  * @param PMF_Search_Resultset $resultSet   PMF_Search_Resultset object
  * @param integer              $currentPage Current page number
  *
  * @return string
  */
 public function renderSearchResult(PMF_Search_Resultset $resultSet, $currentPage)
 {
     $html = '';
     $confPerPage = $this->_config->get('records.numberOfRecordsPerPage');
     $numOfResults = $resultSet->getNumberOfResults();
     $totalPages = ceil($numOfResults / $confPerPage);
     $lastPage = $currentPage * $confPerPage;
     $firstPage = $lastPage - $confPerPage;
     if ($lastPage > $numOfResults) {
         $lastPage = $numOfResults;
     }
     if (0 < $numOfResults) {
         $html .= sprintf("<p>%s</p>\n", $this->plurals->GetMsg('plmsgSearchAmount', $numOfResults));
         if (1 < $totalPages) {
             $html .= sprintf("<p><strong>%s%d %s %s</strong></p>\n", $this->translation['msgPage'], $currentPage, $this->translation['msgVoteFrom'], $this->plurals->GetMsg('plmsgPagesTotal', $totalPages));
         }
         $html .= "<ul class=\"phpmyfaq-search-results\">\n";
         $counter = $displayedCounter = 0;
         foreach ($resultSet->getResultset() as $result) {
             if ($displayedCounter >= $confPerPage) {
                 break;
             }
             $counter++;
             if ($counter <= $firstPage) {
                 continue;
             }
             $displayedCounter++;
             // Set language for current category to fetch the correct category name
             $this->Category->setLanguage($result->lang);
             $categoryInfo = $this->Category->getCategoriesFromArticle($result->id);
             $question = PMF_Utils::chopString($result->question, 15);
             $answerPreview = PMF_Utils::chopString(strip_tags($result->answer), 25);
             $searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $this->searchterm);
             $searchterm = preg_quote($searchterm, '/');
             $searchItems = explode(' ', $searchterm);
             if (PMF_String::strlen($searchItems[0]) > 1) {
                 foreach ($searchItems as $item) {
                     if (PMF_String::strlen($item) > 2) {
                         $question = PMF_Utils::setHighlightedString($question, $item);
                         $answerPreview = PMF_Utils::setHighlightedString($answerPreview, $item);
                     }
                 }
             }
             // Build the link to the faq record
             $currentUrl = sprintf('%s?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s&amp;highlight=%s', PMF_Link::getSystemRelativeUri(), $this->sessionId, $result->category_id, $result->id, $result->lang, urlencode($searchterm));
             $oLink = new PMF_Link($currentUrl, $this->_config);
             $oLink->text = $question;
             $oLink->itemTitle = $oLink->tooltip = $result->question;
             $html .= "<li>";
             $html .= sprintf("<strong>%s</strong>: %s<br />", $categoryInfo[0]['name'], $oLink->toHtmlAnchor());
             $html .= sprintf("<small class=\"searchpreview\"><strong>%s</strong> %s...</small>\n", $this->translation['msgSearchContent'], $answerPreview);
             $html .= "</li>";
         }
         $html .= "</ul>\n";
         if (1 < $totalPages) {
             $html .= $this->pagination->render();
         }
     } else {
         $html = $this->translation['err_noArticles'];
     }
     return $html;
 }
示例#29
0
文件: Mysqli.php 项目: ae120/phpMyFAQ
 /**
  * This function sends a query to the database.
  *
  * @param string  $query
  * @param integer $offset
  * @param integer $rowcount
  *
  * @return  mixed $result
  */
 public function query($query, $offset = 0, $rowcount = 0)
 {
     if (DEBUG) {
         $this->sqllog .= PMF_Utils::debug($query);
     }
     if (0 < $rowcount) {
         $query .= sprintf(' LIMIT %d,%d', $offset, $rowcount);
     }
     $result = $this->conn->query($query);
     if (!$result) {
         $this->sqllog .= $this->error();
     }
     return $result;
 }
示例#30
0
 /**
  * Adds some fancy HTML if a comment is too long
  *
  * @param integer $id
  * @param string  $comment
  *
  * @return string
  */
 public function showShortComment($id, $comment)
 {
     $words = explode(' ', nl2br($comment));
     $numWords = 0;
     $comment = '';
     foreach ($words as $word) {
         $comment .= $word . ' ';
         if (15 === $numWords) {
             $comment .= '<span class="comment-dots-' . $id . '">... </span>' . '<a onclick="showLongComment(' . $id . ')" class="comment-show-more-' . $id . ' pointer">' . $this->pmfStr['msgShowMore'] . '</a>' . '<span class="comment-more-' . $id . ' hide">';
         }
         $numWords++;
     }
     // Convert URLs to HTML anchors
     return PMF_Utils::parseUrl($comment) . '</span>';
 }