/** * Parse language file and get vars it does contain * * @param string $filepath Filepath * * @return array */ public function getVars($filepath) { $retval = array(); if (file_exists($filepath) && is_readable($filepath)) { $orig = file($filepath); while (list(, $line) = each($orig)) { $line = rtrim($line); /** * Bypass all but variable definitions */ if (strlen($line) && '$' == $line[0]) { /** * $PMF_LANG["key"] = "val"; * or * $PMF_LANG["key"] = array(0 => "something", 1 => ...); * turns to something like array('$PMF_LANG["key"]', '"val";') */ $m = explode("=", $line, 2); $key = str_replace(array('["', '"]', '[\'', '\']'), array('[', ']', '[', ']'), PMF_String::substr(trim($m[0]), 1)); $tmp = trim(@$m[1]); if (0 === PMF_String::strpos($tmp, 'array')) { $retval[$key] = PMF_String::substr($tmp, 0, -1); } else { $retval[$key] = stripslashes(PMF_String::substr($tmp, 1, -2)); } } } } return $retval; }
function printHTTPStatus404() { if ('cgi' == PMF_String::substr(php_sapi_name(), 0, 3) || isset($_SERVER['ALL_HTTP'])) { header('Status: 404 Not Found'); } else { header('HTTP/1.0 404 Not Found'); } exit; }
/** * Gets the main categories and write them in an array * * @param string $categories Array of parent category ids * @param boolean $parent_id Only top level categories? * * @return array */ public function getCategories($categories, $parent_id = true) { $_query = ''; $query = sprintf(' SELECT id, lang, parent_id, name, description, user_id FROM %sfaqcategories WHERE ', PMF_Db::getTablePrefix()); if (true == $parent_id) { $query .= 'parent_id = 0'; } foreach (explode(',', $categories) as $cats) { $_query .= ' OR parent_id = ' . $cats; } if (false == $parent_id && 0 < PMF_String::strlen($_query)) { $query .= PMF_String::substr($_query, 4); } if (isset($this->language) && preg_match("/^[a-z\\-]{2,}\$/", $this->language)) { $query .= " AND lang = '" . $this->language . "'"; } $query .= " ORDER BY id"; $result = $this->_config->getDb()->query($query); while ($row = $this->_config->getDb()->fetchArray($result)) { $this->categories[$row['id']] = $row; } return $this->categories; }
} if (!is_null($username) && !is_null($usermail) && !is_null($thema) && !is_null($content) && IPCheck($_SERVER['REMOTE_ADDR']) && checkBannedWord(PMF_String::htmlspecialchars($thema)) && checkBannedWord(PMF_String::htmlspecialchars($content)) && $captcha->checkCaptchaCode($code) && (is_null($faqid) && !is_null($categories) || !is_null($faqid) && !is_null($faqlanguage) && PMF_Language::isASupportedLanguage($faqlanguage))) { $isNew = true; if (!is_null($faqid)) { $isNew = false; $faqsession->userTracking('save_new_translation_entry', 0); } else { $faqsession->userTracking('save_new_entry', 0); } $isTranslation = false; if (!is_null($faqlanguage)) { $isTranslation = true; $newLanguage = $faqlanguage; } if (PMF_String::substr($contentlink, 7) != "") { $content = $content . "<br />" . $PMF_LANG["msgInfo"] . "<a href=\"http://" . PMF_String::substr($contentlink, 7) . "\" target=\"_blank\">" . $contentlink . "</a>"; } $newData = array('lang' => $isTranslation == true ? $newLanguage : $LANGCODE, 'thema' => $thema, 'active' => FAQ_SQL_ACTIVE_NO, 'sticky' => 0, 'content' => $content, 'keywords' => $keywords, 'author' => $username, 'email' => $usermail, 'comment' => FAQ_SQL_YES, 'date' => date('YmdHis'), 'dateStart' => '00000000000000', 'dateEnd' => '99991231235959', 'linkState' => '', 'linkDateCheck' => 0); $categoryNode = new PMF_Category_Node(); $categoryRelation = new PMF_Category_Relations(); $faqRecord = new PMF_Faq_Record(); if ($isNew) { $newData['id'] = null; $categories = $categoryNode->fetchAll($categories['rubrik']); } else { $newData['id'] = $faqid; foreach ($categoryRelation->fetchAll() as $relation) { if ($relation->record_id == $newData['id']) { $categories[] = $relation; } }
/** * This function converts relative uri into absolute uri using specific reference point. * For example, * $relativeuri = "test/foo.html" * $referenceuri = "http://example.com:8000/sample/index.php" * will generate "http://example.com:8000/sample/test/foo.html" * * @param string $relativeuri * @param string $message * @return string $result * @access private * @author Minoru TODA <*****@*****.**> * @since 2005-08-01 */ function makeAbsoluteURL($relativeuri = "", $referenceuri = "") { // If relativeuri is protocol we don't want to handle, don't process it. foreach ($this->invalid_protocols as $_protocol => $_message) { if (PMF_String::strpos($relativeuri, $_protocol) === 0) { return $relativeuri; } } // If relativeuri is absolute URI, don't process it. foreach (array("http://", "https://") as $_protocol) { if (PMF_String::strpos($relativeuri, $_protocol) === 0) { return $relativeuri; } } // Split reference uri into parts. $pathparts = parse_url($referenceuri); // If port is specified in reference uri, prefix with ":" if (isset($pathparts['port']) && $pathparts['port'] != "") { $pathparts['port'] = ":" . $pathparts['port']; } else { $pathparts['port'] = ""; } // If path is not specified in reference uri, set as blank if (isset($pathparts['path'])) { $pathparts['path'] = str_replace("\\", "/", $pathparts['path']); $pathparts['path'] = preg_replace("/^.*(\\/)\$/i", "", $pathparts['path']); } else { $pathparts['path'] = ""; } // Recombine urls if (PMF_String::substr($relativeuri, 0, 1) == "/") { return $pathparts['scheme'] . "://" . $pathparts['host'] . $pathparts['port'] . $relativeuri; } else { return $pathparts['scheme'] . "://" . $pathparts['host'] . $pathparts['port'] . $pathparts['path'] . "/" . $relativeuri; } }
function quoted_printable_encode($return = '') { // Ersetzen der lt. RFC 1521 noetigen Zeichen $return = PMF_String::preg_replace('/([^\\t\\x20\\x2E\\041-\\074\\076-\\176])/ie', "sprintf('=%2X',ord('\\1'))", $return); $return = PMF_String::preg_replace('!=\\ ([A-F0-9])!', '=0\\1', $return); // Einfuegen von QP-Breaks (=\r\n) if (PMF_String::strlen($return) > 75) { $length = PMF_String::strlen($return); $offset = 0; do { $step = 76; $add_mode = $offset + $step < $length ? 1 : 0; $auszug = PMF_String::substr($return, $offset, $step); if (PMF_String::preg_match('!\\=$!', $auszug)) { $step = 75; } if (PMF_String::preg_match('!\\=.$!', $auszug)) { $step = 74; } if (PMF_String::preg_match('!\\=..$!', $auszug)) { $step = 73; } $auszug = PMF_String::substr($return, $offset, $step); $offset += $step; $schachtel .= $auszug; if (1 == $add_mode) { $schachtel .= '=' . "\r\n"; } } while ($offset < $length); $return = $schachtel; } $return = PMF_String::preg_replace('!\\.$!', '. ', $return); return PMF_String::preg_replace('!(\\r\\n|\\r|\\n)$!', '', $return) . "\r\n"; }
* @subpackage Frontend * @author Thomas Zeithaml <*****@*****.**> * @author Thorsten Rinne <*****@*****.**> * @since 2005-08-21 * @version SVN: $Id$ * @copyright 2005-2009 phpMyFAQ Team * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. */ if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } $faqsession->userTracking('sitemap', 0); $letter = PMF_Filter::filterInput(INPUT_GET, 'letter', FILTER_SANITIZE_STRIPPED); if (!is_null($letter) && 1 == PMF_String::strlen($letter)) { $currentLetter = strtoupper($db->escape_string(PMF_String::substr($letter, 0, 1))); } else { $currentLetter = 'A'; } $sitemap = new PMF_Sitemap($current_user, $current_groups); $tpl->processTemplate('writeContent', array('writeLetters' => $sitemap->getAllFirstLetters(), 'writeMap' => $sitemap->getRecordsFromLetter($currentLetter), 'writeCurrentLetter' => $currentLetter)); $tpl->includeTemplate('writeContent', 'index');
?> '<?php print str_replace("\"", "´", $record['title']); ?> '"><?php print $record['title']; ?> </a> <?php if (isset($numCommentsByFaq[$record['id']])) { print " (" . $numCommentsByFaq[$record['id']] . " " . $PMF_LANG["ad_start_comments"] . ")"; } ?> </td> <td class="list" style="width: 48px;"><?php print PMF_String::substr($record['date'], 0, 10); ?> </td> <td class="list" style="width: 96px;"><?php print $linkverifier->getEntryStateHTML($record['id'], $record['lang']); ?> </td> <td class="list" style="width: 16px;"> <a href="#" onclick="javascript:deleteRecord(<?php print $record['id']; ?> , '<?php print $record['lang']; ?> ');" title="<?php print $PMF_LANG["ad_user_delete"];
/** * Generates a result based on search a search string. * * This function generates a result set based on a search string. * FIXME: can extend to handle operands like google * * @access public * @author Tom Rochester <*****@*****.**> * @author Matteo scaramuccia <*****@*****.**> * @since 2005-02-21 */ public function search($table, array $assoc, $joinedTable = '', array $joinAssoc = array(), $match = array(), $string = '', array $cond = array(), array $orderBy = array()) { $string = $this->escape_string(trim($string)); $fields = ""; $joined = ""; $where = ""; foreach ($assoc as $field) { if (empty($fields)) { $fields = $field; } else { $fields .= ", " . $field; } } if (isset($joinedTable) && $joinedTable != '') { $joined .= ' LEFT JOIN ' . $joinedTable . ' ON '; } if (is_array($joinAssoc)) { foreach ($joinAssoc as $joinedFields) { $joined .= $joinedFields . ' AND '; } $joined = PMF_String::substr($joined, 0, -4); } foreach ($cond as $field => $data) { if (empty($where)) { $where .= $field . " = " . $data; } else { $where .= " AND " . $field . " = " . $data; } } $match = implode(",", $match); if (is_numeric($string)) { $query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE " . $match . " = " . $string; } else { $query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE MATCH (" . $match . ") AGAINST ('" . $string . "' IN BOOLEAN MODE)"; } if (!empty($where)) { $query .= " AND (" . $where . ")"; } $firstOrderBy = true; foreach ($orderBy as $field) { if ($firstOrderBy) { $query .= " ORDER BY " . $field; $firstOrderBy = false; } else { $query .= ", " . $field; } } return $this->query($query); }
/** * Wandlung Timestamp * * Diese Funktion wandelt einen Timestamp in ein Datum * * @param string $date * @return string $timestamp * @author David Sauer <*****@*****.**> * @since 2005-07-21 */ function aktually_date($date) { $offset = 0; $current = strtotime(PMF_String::substr($date, 0, 4) . "-" . PMF_String::substr($date, 4, 2) . "-" . PMF_String::substr($date, 6, 2) . " " . PMF_String::substr($date, 8, 2) . ":" . PMF_String::substr($date, 10, 2)); $timestamp = $current + $offset; return date("Y-m-d H:i", $timestamp); }
/** * Returns all FAQ record IDs where all tags are included * * @param array $arrayOfTags Array of Tags * @return array */ public function getRecordsByUnionTags($arrayOfTags) { if (!is_array($arrayOfTags)) { return false; } $query = sprintf("\n SELECT\n d.record_id AS record_id\n FROM\n %sfaqdata_tags d, %sfaqtags t\n WHERE\n t.tagging_id = d.tagging_id\n AND\n (t.tagging_name IN ('%s'))\n GROUP BY\n d.record_id", SQLPREFIX, SQLPREFIX, PMF_String::substr(implode("', '", $arrayOfTags), 0, -2)); $records = array(); $result = $this->db->query($query); while ($row = $this->db->fetchObject($result)) { $records[] = $row->record_id; } return $records; }
/** * 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&cat=%d&id=%d&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; }
/** * Returns a HTTP status header * * @param integer $code HTTP status code * * @return void */ public function sendStatus($code) { switch ($code) { case 301: header('HTTP/1.1 301 Moved Permanently'); break; case 403: header('HTTP/1.1 403 Forbidden'); break; case 404: if ('cgi' == PMF_String::substr(PHP_SAPI, 0, 3) || isset($_SERVER['ALL_HTTP'])) { header('Status: 404 Not Found'); } else { header('HTTP/1.0 404 Not Found'); } break; } exit; }
* obtain one at http://mozilla.org/MPL/2.0/. * * @category phpMyFAQ * @package Frontend * @author Thomas Zeithaml <*****@*****.**> * @author Thorsten Rinne <*****@*****.**> * @copyright 2005-2015 phpMyFAQ Team * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 * @link http://www.phpmyfaq.de * @since 2005-08-21 */ if (!defined('IS_VALID_PHPMYFAQ')) { $protocol = 'http'; if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') { $protocol = 'https'; } header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } $faqsession->userTracking('sitemap', 0); $letter = PMF_Filter::filterInput(INPUT_GET, 'letter', FILTER_SANITIZE_STRIPPED); if (!is_null($letter) && 1 == PMF_String::strlen($letter)) { $currentLetter = strtoupper(PMF_String::substr($letter, 0, 1)); } else { $currentLetter = ''; } $sitemap = new PMF_Sitemap($faqConfig); $sitemap->setUser($current_user); $sitemap->setGroups($current_groups); $tpl->parse('writeContent', array('writeLetters' => $sitemap->getAllFirstLetters(), 'writeMap' => $sitemap->getRecordsFromLetter($currentLetter), 'writeCurrentLetter' => empty($currentLetter) ? $PMF_LANG['msgSitemap'] : $currentLetter)); $tpl->merge('writeContent', 'index');
$mquery[] = 'DELETE FROM ' . $tbl[$h]; } $ok = 1; } if ($ok == 1) { $table_prefix = ''; printf("<p>%s</p>\n", $PMF_LANG['ad_csv_prepare']); while ($dat = fgets($handle, 65536)) { $dat = trim($dat); $backup_prefix_pattern = "-- pmftableprefix:"; $backup_prefix_pattern_len = PMF_String::strlen($backup_prefix_pattern); if (PMF_String::substr($dat, 0, $backup_prefix_pattern_len) == $backup_prefix_pattern) { $table_prefix = trim(PMF_String::substr($dat, $backup_prefix_pattern_len)); } if (PMF_String::substr($dat, 0, 2) != '--' && $dat != '') { $mquery[] = trim(PMF_String::substr($dat, 0, -1)); } } $k = 0; $g = 0; printf("<p>%s</p>\n", $PMF_LANG['ad_csv_process']); $num = count($mquery); $kg = ''; for ($i = 0; $i < $num; $i++) { $mquery[$i] = alignTablePrefix($mquery[$i], $table_prefix, SQLPREFIX); $kg = $db->query($mquery[$i]); if (!$kg) { printf('<div style="font-size: 9px;"><strong>Query</strong>: "%s" <span style="color: red;">failed (Reason: %s)</span></div>%s', PMF_String::htmlspecialchars($mquery[$i], ENT_QUOTES, 'utf-8'), $db->error(), "\n"); $k++; } else { printf('<!-- <div style="font-size: 9px;"><strong>Query</strong>: "%s" <span style="color: green;">okay</span></div> -->%s', PMF_String::htmlspecialchars($mquery[$i], ENT_QUOTES, 'utf-8'), "\n");
/** * Generates a result based on search a search string. * * @param string $table Table for search * @param array $assoc Associative array with columns for the resulset * @param string $joinedTable Table to do a JOIN, e.g. for faqcategoryrelations * @param array $joinAssoc Associative array with comlumns for the JOIN * @param string $string Search term * @param array $cond Conditions * @param array $orderBy ORDER BY columns * @return mixed */ public function search($table, array $assoc, $joinedTable = '', array $joinAssoc = array(), $match = array(), $string = '', array $cond = array(), array $orderBy = array()) { $string = trim($string); $fields = ''; $join = ''; $joined = ''; $where = ''; foreach ($assoc as $field) { if (empty($fields)) { $fields = $field; } else { $fields .= ", " . $field; } } if (isset($joinedTable) && $joinedTable != '') { $joined .= ' LEFT JOIN ' . $joinedTable . ' ON '; } if (is_array($joinAssoc)) { foreach ($joinAssoc as $joinedFields) { $join .= $joinedFields . ' AND '; } $joined .= PMF_String::substr($join, 0, -4); } $keys = PMF_String::preg_split("/\\s+/", $string); $numKeys = count($keys); $numMatch = count($match); for ($i = 0; $i < $numKeys; $i++) { if (strlen($where) != 0) { $where = $where . " OR"; } $where = $where . " ("; for ($j = 0; $j < $numMatch; $j++) { if ($j != 0) { $where = $where . " OR "; } $where = $where . $match[$j] . " LIKE '%" . $keys[$i] . "%'"; } $where .= ")"; } foreach ($cond as $field => $data) { if (empty($where)) { $where .= $field . " = " . $data; } else { $where .= " AND " . $field . " = " . $data; } } $query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE"; if (!empty($where)) { $query .= " (" . $where . ")"; } if (is_numeric($string)) { $query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE " . $match . " = " . $string; } $firstOrderBy = true; foreach ($orderBy as $field) { if ($firstOrderBy) { $query .= " ORDER BY " . $field; $firstOrderBy = false; } else { $query .= ", " . $field; } } return $this->query($query); }
</th> <th><?php echo $PMF_LANG['msgTransToolWritable']; ?> </th> <th><?php echo $PMF_LANG['msgTransToolPercent']; ?> </th> </tr> </thead> <tbody> <?php $sortedLangList = array(); foreach ($transDir as $file) { if ($file->isFile() && '.php' == PMF_String::substr($file, -4) && 'bak' != PMF_String::substr($file, -7, -4)) { $lang = str_replace(array('language_', '.php'), '', $file); /** * English is our exemplary language which won't be changed */ if ('en' == $lang) { continue; } $sortedLangList[] = $lang; } } sort($sortedLangList); while (list(, $lang) = each($sortedLangList)) { $isLangFileWritable = is_writable($langDir . DIRECTORY_SEPARATOR . "language_{$lang}.php"); $showActions = $isTransDirWritable && $isLangFileWritable; ?>
/** * Get a part of string * * @param string $str String * @param integer $start Start * @param integer $length Length * * @return string */ public static function substr($str, $start, $length = null) { return self::$instance->substr($str, $start, $length); }
$record_ids = $tagging->getRecordsByTagId($inputTag); $printResult = $faq->showAllRecordsByIds($record_ids); } // // Handle the full text search stuff // if (!is_null($inputSearchTerm) || !is_null($search)) { if (!is_null($inputSearchTerm)) { $inputSearchTerm = $db->escape_string(strip_tags($inputSearchTerm)); } if (!is_null($search)) { $inputSearchTerm = $db->escape_string(strip_tags($search)); } $printResult = searchEngine($inputSearchTerm, $inputCategory, $allLanguages); $inputSearchTerm = stripslashes($inputSearchTerm); $faqsearch->logSearchTerm($inputSearchTerm); } // Change a little bit the $searchCategory value; $inputCategory = '%' == $inputCategory ? 0 : $inputCategory; $faqsession->userTracking('fulltext_search', $inputSearchTerm); $category->buildTree(); $openSearchLink = sprintf('<a class="searchplugin" href="#" onclick="window.external.AddSearchProvider(\'%s/opensearch.php\');">%s</a>', PMF_Link::getSystemUri('/index.php'), $PMF_LANG['opensearch_plugin_install']); $mostPopularSearches = ''; $mostPopularSearchData = $faqsearch->getMostPopularSearches(); foreach ($mostPopularSearchData as $searchItem) { $mostPopularSearches .= sprintf('<a href="?search=%s&submit=Search&action=search">%s</a> (%dx), ', urlencode($searchItem['searchterm']), $searchItem['searchterm'], $searchItem['number']); } $helper = PMF_Helper_Category::getInstance(); $helper->setCategory($category); $tpl->processTemplate('writeContent', array('msgSearch' => $tagSearch ? $PMF_LANG['msgTagSearch'] : $PMF_LANG['msgSearch'], 'searchString' => PMF_htmlentities($inputSearchTerm, ENT_QUOTES, $PMF_LANG['metaCharset']), 'searchOnAllLanguages' => $PMF_LANG['msgSearchOnAllLanguages'], 'checkedAllLanguages' => $allLanguages ? ' checked="checked"' : '', 'selectCategories' => $PMF_LANG['msgSelectCategories'], 'allCategories' => $PMF_LANG['msgAllCategories'], 'printCategoryOptions' => $helper->renderCategoryOptions($inputCategory), 'writeSendAdress' => '?' . $sids . 'action=search', 'msgSearchWord' => $PMF_LANG['msgSearchWord'], 'printResult' => $printResult, 'openSearchLink' => $openSearchLink, 'msgMostPopularSearches' => $PMF_LANG['msgMostPopularSearches'], 'printMostPopularSearches' => PMF_String::substr($mostPopularSearches, 0, -2))); $tpl->includeTemplate('writeContent', 'index');
} if (!is_null($name) && !empty($name) && !is_null($email) && !empty($email) && !is_null($question) && !empty($question) && checkBannedWord(PMF_String::htmlspecialchars($question)) && !is_null($answer) && !empty($answer) && checkBannedWord(PMF_String::htmlspecialchars($answer)) && (is_null($faqid) && !is_null($categories['rubrik']) || !is_null($faqid) && !is_null($faqlanguage) && PMF_Language::isASupportedLanguage($faqlanguage))) { $isNew = true; if (!is_null($faqid)) { $isNew = false; $faqsession->userTracking('save_new_translation_entry', 0); } else { $faqsession->userTracking('save_new_entry', 0); } $isTranslation = false; if (!is_null($faqlanguage)) { $isTranslation = true; $newLanguage = $faqlanguage; } if (PMF_String::substr($contentlink, 7) != "") { $answer = sprintf('%s<br /><div id="newFAQContentLink">%s<a href="http://%s" target="_blank">%s</a></div>', $answer, $PMF_LANG['msgInfo'], PMF_String::substr($contentlink, 7), $contentlink); } $autoActivate = PMF_Configuration::getInstance()->get('records.defaultActivation'); $newData = array('lang' => $isTranslation == true ? $newLanguage : $languageCode, 'thema' => $question, 'active' => $autoActivate ? FAQ_SQL_ACTIVE_YES : FAQ_SQL_ACTIVE_NO, 'sticky' => 0, 'content' => nl2br($answer), 'keywords' => $keywords, 'author' => $name, 'email' => $email, 'comment' => FAQ_SQL_YES, 'date' => date('YmdHis'), 'dateStart' => '00000000000000', 'dateEnd' => '99991231235959', 'linkState' => '', 'linkDateCheck' => 0); if ($isNew) { $categories = $categories['rubrik']; } else { $newData['id'] = $faqid; $categories = $category->getCategoryIdsFromArticle($newData['id']); } $recordId = $faq->addRecord($newData, $isNew); $faq->addCategoryRelations($categories, $recordId, $newData['lang']); // Activate visits $visits = PMF_Visits::getInstance(); $visits->add($recordId, $newData['lang']); if ($autoActivate) {
/** * Returns the timestamp of a tracking file * * @param string $file Filename * @param boolean $endOfDay End of day? * * @return integer */ public static function getTrackingFileDate($file, $endOfDay = false) { if (PMF_String::strlen($file) >= 16) { $day = PMF_String::substr($file, 8, 2); $month = PMF_String::substr($file, 10, 2); $year = PMF_String::substr($file, 12, 4); if (!$endOfDay) { $time = mktime(0, 0, 0, $month, $day, $year); } else { $time = mktime(23, 59, 59, $month, $day, $year); } return $time; } else { return -1; } }
/** * Returns a 404 header * * @return void */ public function printHTTPStatus404() { if ('cgi' == PMF_String::substr(PHP_SAPI, 0, 3) || isset($_SERVER['ALL_HTTP'])) { header('Status: 404 Not Found'); } else { header('HTTP/1.0 404 Not Found'); } exit; }
/** * Generates a result based on search a search string. * * @access public * @author Thorsten Rinne <*****@*****.**> * @author Matteo scaramuccia <*****@*****.**> * @since 2005-09-20 */ public function search($table, array $assoc, $joinedTable = '', array $joinAssoc = array(), $match = array(), $string = '', array $cond = array(), array $orderBy = array()) { $string = addslashes(trim($string)); $fields = ""; $joined = ""; $where = ""; foreach ($assoc as $field) { if (empty($fields)) { $fields = $field; } else { $fields .= ", " . $field; } } if (isset($joinedTable) && $joinedTable != '') { $joined .= ' LEFT JOIN ' . $joinedTable . ' ON '; } if (is_array($joinAssoc)) { foreach ($joinAssoc as $joinedFields) { $joined .= $joinedFields . ' AND '; } $joined = PMF_String::substr($joined, 0, -4); } foreach ($cond as $field => $data) { if (empty($where)) { $where = $field . " = '" . addslashes($data) . "'"; } else { $where .= "AND " . $field . " ='" . addslashes($data) . "'"; } } $match = implode(",", $match); $query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE " . $match . " LIKE ('%" . $string . "%')"; if (!empty($where)) { $query .= " AND (" . $where . ")"; } $firstOrderBy = true; foreach ($orderBy as $field) { if ($firstOrderBy) { $query .= " ORDER BY " . $field; $firstOrderBy = false; } else { $query .= ", " . $field; } } $query .= ";"; return $this->query($query); }
$switchLanguage .= "</select>\n"; $switchLanguage .= " \n"; $switchLanguage .= "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"" . $PMF_LANG["msgLangaugeSubmit"] . "\" />\n"; $switchLanguage .= "</fieldset>\n"; $switchLanguage .= "</form>\n"; $switchLanguage .= "</p>\n"; } // List all faq attachments if ($faqconfig->get('main.disableAttachments') && 'yes' == $faq->faqRecord['active']) { $attList = PMF_Attachment_Factory::fetchByRecordId($record_id); $outstr = ""; while (list(, $att) = each($attList)) { $outstr .= sprintf('<a href="%s">%s</a>, ', $att->buildUrl(), $att->getFilename()); } if (count($attList) > 0) { $content .= '<p>' . $PMF_LANG['msgAttachedFiles'] . ' ' . PMF_String::substr($outstr, 0, -2) . '</p>'; } } // List all categories for this faq $writeMultiCategories = ''; $multiCategories = array(); $categoryRelations = new PMF_Category_Relations(); foreach ($categoryRelations->fetchAll() as $relation) { if ($relation->record_id == $record_id) { $multiCategories[] = $relation->category_id; } } if (count($multiCategories) > 1) { $writeMultiCategories .= ' <div id="article_categories">'; $writeMultiCategories .= ' <fieldset>'; $writeMultiCategories .= ' <legend>' . $PMF_LANG['msgArticleCategories'] . '</legend>';
/** * Align the prefix of the table name used in the PMF backup file, * from the (old) value of the system upon which the backup was performed * to the (new) prefix of the system upon which the backup will be restored. * This alignment will be perfomed ONLY upon those given SQL queries starting * with the given pattern. * * @param string $query * @param string $startPattern * @param string $oldValue * @param string $newValue * * @return string */ private static function alignTablePrefixByPattern($query, $startPattern, $oldValue, $newValue) { $return = $query; $matches = []; PMF_String::preg_match_all("/^" . $startPattern . "\\s+(\\w+)(\\s+|\$)/i", $query, $matches); if (isset($matches[1][0])) { $oldTableFullName = $matches[1][0]; $newTableFullName = $newValue . PMF_String::substr($oldTableFullName, PMF_String::strlen($oldValue)); $return = str_replace($oldTableFullName, $newTableFullName, $query); } return $return; }
/** * Adds a image * * @param string path to the image * @return void * @access private */ function AddImage($image) { // Check, if image is stored locally or not if ('http' != PMF_String::substr($image, 0, 4)) { // Please note that the image must be accessible by HTTP NOT ONLY by HTTPS $image = 'http://' . EndSlash($_SERVER['HTTP_HOST']) . $image; } // Set a friendly User Agent $ua = ini_get('user_agent'); ini_set('user_agent', 'phpMyFAQ PDF Builder'); if (!($info = getimagesize($image))) { return; } if ($info[0] > 555) { $w = $info[0] / 144 * 25.4; $h = $info[1] / 144 * 25.4; } else { $w = $info[0] / 72 * 25.4; $h = $info[1] / 72 * 25.4; } // Check for the fpdf image type support if (isset($this->mimetypes[$info[2]])) { $type = $this->mimetypes[$info[2]]; } else { return; } $hw_ratio = $h / $w; $this->Write(5, ' '); if ($info[0] > $this->wPt) { $info[0] = $this->wPt - $this->lMargin - $this->rMargin; if ($w > $this->w) { $w = $this->w - $this->lMargin - $this->rMargin; $h = $w * $hw_ratio; } } $x = $this->GetX(); if ($this->GetY() + $h > $this->h) { $this->AddPage(); } $y = $this->GetY(); $this->Image($image, $x, $y, $w, $h, $type); $this->Write(5, ' '); $y = $this->GetY(); $this->Image($image, $x, $y, $w, $h, $type); if ($y + $h > $this->hPt) { $this->AddPage(); } else { if ($info[1] > 20) { $this->SetY($y + $h); } $this->SetX($x + $w); } // Unset the friendly User Agent restoring the original UA ini_set('user_agent', $ua); }
/** * Macht an den String nen / dran, falls keiner da ist * @@ Bastian, 2002-01-06 */ function EndSlash($string) { if (PMF_String::substr($string, PMF_String::strlen($string) - 1, 1) != "/") { $string .= "/"; } return $string; }
/** * Returns the part of the SQL query with the columns for the join * * @return string */ public function getJoinedColumns() { $joinedColumns = ''; foreach ($this->joinedColumns as $column) { $joinedColumns .= $column . ' AND '; } return PMF_String::substr($joinedColumns, 0, -4); }
/** * Bastelt aus den Dateinamen des Tracking einen Timestamp | @@ Bastian, 2002-01-05 * Last Update: @@ Thorsten, 2002-09-19 * Last Update: @@ Matteo, 2006-06-13 */ function FileToDate($file, $endOfDay = false) { if (PMF_String::strlen($file) >= 16) { $tag = PMF_String::substr($file, 8, 2); $mon = PMF_String::substr($file, 10, 2); $yea = PMF_String::substr($file, 12, 4); if (!$endOfDay) { $tim = mktime(0, 0, 0, $mon, $tag, $yea); } else { $tim = mktime(23, 59, 59, $mon, $tag, $yea); } return $tim; } else { return -1; } }