예제 #1
0
파일: Relation.php 프로젝트: noon/phpMyFAQ
 /**
  * Verlinkt einen Artikel dynamisch mit der Suche �ber die �bergebenen Schl�sselw�rter
  *
  * @param    string     $strHighlight
  * @param    string     $strSource
  * @param    integer    $intCount
  * @return   string
  * @author   Marco Enders <*****@*****.**>
  * @author   Thorsten Rinne <*****@*****.**>
  */
 public function setRelationLinks($strHighlight, $strSource, $intCount = 0)
 {
     global $in_content;
     $x = 0;
     $arrMatch = array();
     PMF_String::preg_match_all('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', $strSource, $arrMatch);
     $strSource = PMF_String::preg_replace('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', '~+*# replaced html #*+~', $strSource);
     $x = $x + PMF_String::preg_match('/(' . preg_quote($strHighlight) . ')/ims', $strSource);
     $strSource = PMF_String::preg_replace('/(' . preg_quote($strHighlight) . ')/ims', '<a href="index.php?action=search&search=' . $strHighlight . '" title="Insgesamt ' . $intCount . ' Artikel zu diesem Schlagwort (' . $strHighlight . ') vorhanden. Jetzt danach suchen..." class="relation">$1</a>', $strSource);
     foreach ($arrMatch[0] as $html) {
         $strSource = PMF_String::preg_replace('/' . preg_quote('~+*# replaced html #*+~') . '/', $html, $strSource, 1);
     }
     if ($x == 0) {
         $in_content = false;
     } else {
         $in_content = true;
     }
     return $strSource;
 }
예제 #2
0
 /**
  * 
  * @param unknown_type $text
  */
 private function search_vars($text)
 {
     if (DEBUG) {
         $pattern = "/{(?!meta|baseHref|phpmyfaqversion)\\w+}/msi";
     } else {
         $pattern = "/{(?!debug|meta|baseHref|phpmyfaqversion)\\w+}/msi";
     }
     if (PMF_String::preg_match($pattern, $text)) {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
파일: String.php 프로젝트: noon/phpMyFAQ
 /**
  * 
  * Match a regexp
  * @param string $pattern
  * @param string $subject
  * @param array &$matches
  * @param int $flags
  * @param int $offset
  * 
  * @return int
  */
 public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
 {
     return self::$instance->preg_match($pattern, $subject, $matches, $flags, $offset);
 }
 /**
  * Returns the current page URL
  *
  * @param string $url URL
  *
  * @return integer
  */
 protected function getCurrentPageFromUrl($url)
 {
     $page = 1;
     if (!empty($url)) {
         $match = array();
         if (PMF_String::preg_match('$&(amp;|)' . $this->pageParamName . '=(\\d+)$', $url, $match)) {
             $page = isset($match[2]) ? $match[2] : $page;
         }
     }
     return $page;
 }
예제 #5
0
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
$faqsession->userTracking('sendmail_send2friend', 0);
$captcha = new PMF_Captcha($db, $Language);
$captcha->setSessionId($sids);
$name = PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$mailfrom = PMF_Filter::filterInput(INPUT_POST, 'mailfrom', FILTER_VALIDATE_EMAIL);
$mailto = PMF_Filter::filterInputArray(INPUT_POST, array('mailto' => array('filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_REQUIRE_ARRAY | FILTER_NULL_ON_FAILURE)));
$link = PMF_Filter::filterInput(INPUT_POST, 'link', FILTER_VALIDATE_URL);
$attached = PMF_Filter::filterInput(INPUT_POST, 'zusatz', FILTER_SANITIZE_STRIPPED);
$code = PMF_Filter::filterInput(INPUT_POST, 'captcha', FILTER_SANITIZE_STRING);
if (!is_null($name) && !is_null($mailfrom) && is_array($mailto) && IPCheck($_SERVER['REMOTE_ADDR']) && checkBannedWord(PMF_String::htmlspecialchars($attached)) && $captcha->checkCaptchaCode($code)) {
    // Backward compatibility: extract article info from the link, no template change required
    $cat = $id = $artlang = null;
    PMF_String::preg_match('`index\\.php\\?action=artikel&cat=(?<cat>[\\d]+)&id=(?<id>[\\d]+)&artlang=(?<artlang>[^$]+)$`', $link, $matches);
    if (isset($matches['cat'])) {
        $cat = (int) $matches['cat'];
    }
    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;
    }
예제 #6
0
파일: Template.php 프로젝트: noon/phpMyFAQ
 /**
  * This function reads the block
  *
  * @param  string $tpl Block to read
  * @return string
  */
 private function _readBlocks($tpl)
 {
     $tmpBlocks = array();
     // read all blocks into $tmpBlocks
     PMF_String::preg_match_all('/\\[.+\\]\\s*[\\W\\w\\s\\{\\}\\<\\>\\=\\"\\/]*?\\s*\\[\\/.+\\]/', $tpl, $tmpBlocks);
     $unblocked = $tpl;
     if (isset($tmpBlocks)) {
         $blockCount = count($tmpBlocks[0]);
         for ($i = 0; $i < $blockCount; $i++) {
             $name = '';
             //find block name
             PMF_String::preg_match('/\\[.+\\]/', $tmpBlocks[0][$i], $name);
             $name = PMF_String::preg_replace('/[\\[\\[\\/\\]]/', '', $name);
             //remove block tags from block
             $res = str_replace('[' . $name[0] . ']', '', $tmpBlocks[0][$i]);
             $res = str_replace('[/' . $name[0] . ']', '', $res);
             $tplBlocks[$name[0]] = $res;
             //unblocked content
             $unblocked = str_replace($tplBlocks[$name[0]], '', $unblocked);
             $unblocked = str_replace('[' . $name[0] . ']', '', $unblocked);
             $unblocked = str_replace('[/' . $name[0] . ']', '', $unblocked);
         }
         $hits = array();
         PMF_String::preg_match_all('/\\{.+?\\}/', $unblocked, $hits);
         $tplBlocks['unblocked'] = $hits[0];
     } else {
         // no blocks defined
         $tplBlocks = $tpl;
     }
     return $tplBlocks;
 }
예제 #7
0
파일: Sitemap.php 프로젝트: atlcurling/tkt
 /**
  * Returns all available first letters
  *
  * @return array
  * @since  2007-03-30
  * @author Thorsten Rinne <*****@*****.**>
  */
 public function getAllFirstLetters()
 {
     global $sids;
     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);
     }
     $writeLetters = '<p id="sitemapletters">';
     switch ($this->type) {
         case 'db2':
         case 'sqlite':
             $query = sprintf("\n                    SELECT\n                        DISTINCT UPPER(SUBSTR(fd.thema, 1, 1)) AS letters\n                    FROM\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.lang = '%s'\n                    AND\n                        fd.active = 'yes'\n                    AND\n                        %s\n                    ORDER BY\n                        letters", SQLPREFIX, SQLPREFIX, SQLPREFIX, $this->language, $permPart);
             break;
         default:
             $query = sprintf("\n                    SELECT\n                        DISTINCT UPPER(SUBSTRING(fd.thema, 1, 1)) AS letters\n                    FROM\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.lang = '%s'\n                    AND\n                        fd.active = 'yes'\n                    AND\n                        %s\n                    ORDER BY\n                        letters", SQLPREFIX, SQLPREFIX, SQLPREFIX, $this->language, $permPart);
             break;
     }
     $result = $this->db->query($query);
     while ($row = $this->db->fetch_object($result)) {
         $letters = PMF_String::strtoupper($row->letters);
         if (PMF_String::preg_match("/^[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]/i", $letters)) {
             $url = sprintf('%saction=sitemap&amp;letter=%s&amp;lang=%s', $sids, $letters, $this->language);
             $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
             $oLink->text = (string) $letters;
             $writeLetters .= $oLink->toHtmlAnchor() . ' ';
         }
     }
     $writeLetters .= '</p>';
     return $writeLetters;
 }
예제 #8
0
 /**
  * Check if we can ignore a value while comparing. Actually
  * catching empty and non alphanumeric strings
  * 
  * @param string $val Value
  * 
  * @return boolean
  */
 public function isValIgnorable($val)
 {
     return PMF_String::preg_match('/^[^a-z0-9]*$/i', $val);
 }
예제 #9
0
 protected function getCurrentPageFromUrl($url)
 {
     $retval = 1;
     if (!empty($url)) {
         $match = array();
         switch ($this->urlStyle) {
             case self::URL_STYLE_REWRITE:
                 $pattern = '$/(' . $this->pageParamName . ')/(\\d+)$';
                 break;
             case self::URL_STYLE_DEFAULT:
             default:
                 $pattern = '$&(amp;|)' . $this->pageParamName . '=(\\d+)$';
                 break;
         }
         if (PMF_String::preg_match($pattern, $url, $match)) {
             $retval = isset($match[2]) ? $match[2] : $retval;
         }
     }
     return $retval;
 }
예제 #10
0
파일: Sitemap.php 프로젝트: ae120/phpMyFAQ
 /**
  * Returns all available first letters
  *
  * @return array
  * @since  2007-03-30
  * @author Thorsten Rinne <*****@*****.**>
  */
 public function getAllFirstLetters()
 {
     global $sids;
     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);
     }
     $writeLetters = '<ul class="nav">';
     if ($this->_config->getDb() instanceof PMF_DB_Sqlite || $this->_config->getDb() instanceof PMF_DB_Sqlite3) {
         $query = sprintf("\n                    SELECT\n                        DISTINCT UPPER(SUBSTR(fd.thema, 1, 1)) AS letters\n                    FROM\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.lang = '%s'\n                    AND\n                        fd.active = 'yes'\n                    AND\n                        %s\n                    ORDER BY\n                        letters", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $this->_config->getLanguage()->getLanguage(), $permPart);
     } else {
         $query = sprintf("\n                    SELECT\n                        DISTINCT UPPER(SUBSTRING(fd.thema, 1, 1)) AS letters\n                    FROM\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.lang = '%s'\n                    AND\n                        fd.active = 'yes'\n                    AND\n                        %s\n                    ORDER BY\n                        letters", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $this->_config->getLanguage()->getLanguage(), $permPart);
     }
     $result = $this->_config->getDb()->query($query);
     while ($row = $this->_config->getDb()->fetchObject($result)) {
         $letters = PMF_String::strtoupper($row->letters);
         if (PMF_String::preg_match("/^[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]/i", $letters)) {
             $url = sprintf('%s?%saction=sitemap&amp;letter=%s&amp;lang=%s', PMF_Link::getSystemRelativeUri(), $sids, $letters, $this->_config->getLanguage()->getLanguage());
             $oLink = new PMF_Link($url, $this->_config);
             $oLink->text = (string) $letters;
             $writeLetters .= '<li>' . $oLink->toHtmlAnchor() . '</li>';
         }
     }
     $writeLetters .= '</ul>';
     return $writeLetters;
 }
예제 #11
0
파일: Docbook.php 프로젝트: noon/phpMyFAQ
 /**
  * schreiben eines Textes
  *
  * Diese Funktion schreibt einen Text
  *
  * @param   string $textString
  * @return  string $textString
  * @author  David Sauer <*****@*****.**>
  * @since   2005-07-21
  */
 function text(&$textString)
 {
     if (PMF_String::preg_match('/((<)(.*)(>)?)/', $textString, $matches)) {
         if (PMF_String::preg_match('/^((?!<)(.*?))((<(\\/?(.*)?)>)+)/', $textString, $matches) == true) {
             $textStringPart = PMF_String::substr($textString, 0, PMF_String::strlen($matches[1]));
             $textString = PMF_String::substr($textString, PMF_String::strlen($matches[1]));
         } else {
             $match = PMF_String::preg_match('/^(<\\/?(.*)>)/', $textString, $matchesRemainder);
             if ($match) {
                 $textString = PMF_String::substr($textString, PMF_String::strlen($matchesRemainder[0]));
                 $textStringPart = '';
             } else {
                 $textStringPart = '';
                 $textString = PMF_String::substr($textString, PMF_String::strlen($textString));
             }
         }
     } else {
         $textStringPart = $textString;
         $textString = PMF_String::substr($textString, PMF_String::strlen($textString));
     }
     if (!empty($textStringPart)) {
         $this->xmlContent .= '<para>';
         $this->xmlContent .= $textStringPart;
         $this->xmlContent .= '</para>';
     }
 }
예제 #12
0
 /**
  * The actual decoding algorithm
  * @param string
  * @return mixed
  */
 private function _decode($encoded)
 {
     $decoded = array();
     // find the Punycode prefix
     if (!PMF_String::preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
         $this->_error('This is not a punycode string');
         return false;
     }
     $encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded);
     // If nothing left after removing the prefix, it is hopeless
     if (!$encode_test) {
         $this->_error('The given encoded string was empty');
         return false;
     }
     // Find last occurence of the delimiter
     $delim_pos = strrpos($encoded, '-');
     if ($delim_pos > strlen($this->_punycode_prefix)) {
         for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
             $decoded[] = ord($encoded[$k]);
         }
     }
     $deco_len = count($decoded);
     $enco_len = strlen($encoded);
     // Wandering through the strings; init
     $is_first = true;
     $bias = $this->_initial_bias;
     $idx = 0;
     $char = $this->_initial_n;
     for ($enco_idx = $delim_pos ? $delim_pos + 1 : 0; $enco_idx < $enco_len; ++$deco_len) {
         for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) {
             $digit = $this->_decode_digit($encoded[$enco_idx++]);
             $idx += $digit * $w;
             $t = $k <= $bias ? $this->_tmin : ($k >= $bias + $this->_tmax ? $this->_tmax : $k - $bias);
             if ($digit < $t) {
                 break;
             }
             $w = (int) ($w * ($this->_base - $t));
         }
         $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
         $is_first = false;
         $char += (int) ($idx / ($deco_len + 1));
         $idx %= $deco_len + 1;
         if ($deco_len > 0) {
             // Make room for the decoded char
             for ($i = $deco_len; $i > $idx; $i--) {
                 $decoded[$i] = $decoded[$i - 1];
             }
         }
         $decoded[$idx++] = $char;
     }
     return $this->_ucs4_to_utf8($decoded);
 }
예제 #13
0
 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";
 }