コード例 #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
ファイル: Template.php プロジェクト: jr-ewing/phpMyFAQ
 /**
  * This function checks the content
  *
  * @param  string $content Content to check
  * 
  * @return string
  */
 private function _checkContent($content)
 {
     // Security measure: avoid the injection of php/shell-code
     $search = array('#<\\?php#i', '#\\{$\\{#', '#<\\?#', '#<\\%#', '#`#', '#<script[^>]+php#mi');
     $phppattern1 = "&lt;?php";
     $phppattern2 = "&lt;?";
     $replace = array($phppattern1, '', $phppattern2, '', '');
     // Hack: Backtick Fix
     $content = str_replace('`', '&acute;', $content);
     foreach ($content as $var => $val) {
         if (is_array($val)) {
             foreach ($val as $key => $value) {
                 $content[$var][$key] = PMF_String::preg_replace($search, $replace, $value);
             }
         } else {
             $content[$var] = PMF_String::preg_replace($search, $replace, $val);
         }
     }
     return $content;
 }
コード例 #3
0
ファイル: Utils.php プロジェクト: jr-ewing/phpMyFAQ
 /**
  * Shortens a string for a given number of words
  * 
  * @param  string  $str  String  
  * @param  integer $char Characters
  * 
  * @return string
  * 
  * @todo This function doesn't work with Chinese, Japanese and Korean
  *       because they don't have spaces as word delimiters
  */
 public static function makeShorterText($str, $char)
 {
     $str = PMF_String::preg_replace('/\\s+/u', ' ', $str);
     $arrStr = explode(' ', $str);
     $shortStr = '';
     $num = count($arrStr);
     if ($num > $char) {
         for ($j = 0; $j <= $char; $j++) {
             $shortStr .= $arrStr[$j] . ' ';
         }
         $shortStr .= '...';
     } else {
         $shortStr = $str;
     }
     return $shortStr;
 }
コード例 #4
0
 /**
  * Set an HTML message providing also a plain text alternative message,
  * if not already set using the $messageAlt property.
  * Besides it is possible to put resources as inline attachments
  *
  * @param  string $message     HTML message.
  * @param  bool   $sanitize Strip out potentially unsecured HTML tags. Defaults to false.
  * @param  bool   $inline   Add images as inline attachments. Defaults to false.
  *
  * @return void
  */
 public function setHTMLMessage($message, $sanitize = false, $inline = false)
 {
     // No Javascript at all
     // 1/2. <script blahblahblah>blahblahblah</tag>
     $message = PMF_String::preg_replace('/(<script[^>]*>.*<\\/script>)|<script[^\\/]*\\/>|<script[^\\/]*>/is', '', $message);
     // Cleanup potentially dangerous HTML tags:
     if ($sanitize) {
         // 1/2. <tag blahblahblah>blahblahblah</tag>
         $message = PMF_String::preg_replace('/<(applet|embed|head|meta|object|style|title)[^>]*>.*<\\/\\1>/is', '', $message);
         // 2/2. <tag blahblahblah />
         $message = PMF_String::preg_replace('/<(applet|embed|head|meta|object|style|title)[^\\/]*\\/>/is', '', $message);
     }
     if ($inline) {
         trigger_error("<strong>Mail Class</strong>: inline option is not implemented yet.", E_USER_ERROR);
     }
     // Set the HTML text as the main message
     $this->message = trim($message);
     // If no alternative text has been provided yet, use just
     // the HTML message stripping any HTML tag
     if (empty($this->messageAlt)) {
         $this->messageAlt = trim(strip_tags($this->message));
     }
 }
コード例 #5
0
ファイル: String.php プロジェクト: noon/phpMyFAQ
 /**
  * Search and replace by a regexp
  * @param string|array $pattern
  * @param string|array $replacement
  * @param string|array $subject
  * @param int $limit
  * @param int &$count
  * 
  * @return array|string|null
  */
 public static function preg_replace($pattern, $replacement, $subject, $limit = -1, &$count = 0)
 {
     return self::$instance->preg_replace($pattern, $replacement, $subject, $limit, $count);
 }
コード例 #6
0
 /**
  * Render url for a given page
  *
  * @param string  $url  url
  * @param integer $page page number
  *
  * @return string
  */
 protected function renderUrl($url, $page)
 {
     if ($this->useRewrite) {
         $url = sprintf($this->rewriteUrl, $page);
     } else {
         $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\\d+)$'), '', $url);
         $url = sprintf('%s&amp;%s=%d', $cleanedUrl, $this->pageParamName, $page);
     }
     return $url;
 }
コード例 #7
0
ファイル: Pagination.php プロジェクト: atlcurling/tkt
 /**
  * Render url for a given page
  * 
  * @param string  $url  url
  * @param integer $page page number
  * 
  * @return string
  */
 protected function renderUrl($url, $page)
 {
     $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\\d+)$'), '', $url);
     $url = sprintf('%s&amp;%s=%d', $cleanedUrl, $this->pageParamName, $page);
     $link = new PMF_Link($url);
     $link->itemTitle = $this->seoName;
     return $link->toString();
 }
        // show category name in actual language
        print '<td>';
        if ($cat['lang'] != $LANGCODE) {
            // translate category
            printf('<a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s"><span title="%s" class="icon-share"></span></a></a>', $currentLink, $cat['id'], $LANGCODE, $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']);
        }
        printf("&nbsp;%s<strong>%s</strong>", $indent, $catname);
        print "</td>\n";
        // get languages in use for categories
        $id_languages = $category->getCategoryLanguagesTranslated($cat["id"]);
        foreach ($all_lang as $lang => $language) {
            if ($language == $currentLanguage) {
                continue;
            }
            if (array_key_exists($language, $id_languages)) {
                $spokenLanguage = PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]);
                printf('<td title="%s: %s">', $PMF_LANG['ad_categ_titel'], $spokenLanguage);
                printf('<span title="%s: %s" class="label label-success"><i class="icon-check icon-white"></i></span></td>', $PMF_LANG['ad_categ_titel'], $spokenLanguage);
            } else {
                printf('<td><a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s">', $currentLink, $cat['id'], $lang, $PMF_LANG['ad_categ_translate']);
                printf('<span title="%s" class="label label-inverse"><i class="icon-share icon-white"></i></span></a>', $PMF_LANG['ad_categ_translate']);
            }
            print "</td>\n";
        }
        print "</tr>\n";
    }
    ?>
        </tbody>
        </table>
<?php 
    printf('<p>%s</p>', $PMF_LANG['ad_categ_remark_overview']);
コード例 #9
0
ファイル: functions.php プロジェクト: atlcurling/tkt
/**
 * This function returns the passed content with HTML hilighted banned words.
 *
 * @param   string  $content
 * @return  string
 * @access  public
 * @author  Matteo Scaramuccia <*****@*****.**>
 */
function getHighlightedBannedWords($content)
{
    $bannedHTMLHiliWords = array();
    $bannedWords = getBannedWords();
    // Build the RegExp array
    foreach ($bannedWords as $word) {
        $bannedHTMLHiliWords[] = "/(" . quotemeta($word) . ")/ism";
    }
    // Use the CSS "highlight" class to highlight the banned words
    if (count($bannedHTMLHiliWords) > 0) {
        return PMF_String::preg_replace($bannedHTMLHiliWords, "<span class=\"highlight\">\\1</span>", $content);
    } else {
        return $content;
    }
}
コード例 #10
0
ファイル: Pagination.php プロジェクト: nosch/phpMyFAQ
 /**
  * Render url for a given page
  * 
  * @param string  $url  url
  * @param integer $page page number
  * 
  * @return string
  */
 protected function renderUrl($url, $page)
 {
     switch ($this->urlStyle) {
         case self::URL_STYLE_REWRITE:
             $cleanedUrl = PMF_String::preg_replace(array('$/' . $this->pageParamName . '/(\\d+)$', '$//$'), "", $this->baseUrl);
             $url = "{$cleanedUrl}/{$this->pageParamName}/{$page}";
             break;
         case self::URL_STYLE_DEFAULT:
         default:
             $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\\d+)$'), "", $this->baseUrl);
             $url = "{$cleanedUrl}&amp;{$this->pageParamName}={$page}";
             break;
     }
     return $url;
 }
コード例 #11
0
ファイル: Link.php プロジェクト: ae120/phpMyFAQ
 /**
  * Returns a search engine optimized title
  *
  * @param string $title
  *
  * @return string
  */
 public function getSEOItemTitle($title = '')
 {
     if ('' === $title) {
         $title = $this->itemTitle;
     }
     $itemTitle = trim($title);
     // Lower the case (aesthetic)
     $itemTitle = PMF_String::strtolower($itemTitle);
     // Use '_' for some other characters for:
     // 1. avoiding regexp match break;
     // 2. improving the reading.
     $itemTitle = str_replace(array('-', "'", '/', '&#39'), '_', $itemTitle);
     // 1. Remove any CR LF sequence
     // 2. Use a '-' for the words separation
     $itemTitle = PMF_String::preg_replace('/\\s/m', '-', $itemTitle);
     // Hack: remove some chars for having a better readable title
     $itemTitle = str_replace(array('+', ',', ';', ':', '.', '?', '!', '"', '(', ')', '[', ']', '{', '}', '<', '>'), '', $itemTitle);
     // Hack: move some chars to "similar" but plain ASCII chars
     $itemTitle = str_replace(array('à', 'è', 'é', 'ì', 'ò', 'ù', 'ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü', 'č', 'ę', 'ė', 'į', 'š', 'ų', 'ū', 'ž'), array('a', 'e', 'e', 'i', 'o', 'u', 'ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue', 'c', 'e', 'e', 'i', 's', 'u', 'u', 'z'), $itemTitle);
     // Clean up
     $itemTitle = PMF_String::preg_replace('/-[\\-]+/m', '-', $itemTitle);
     return rawurlencode($itemTitle);
 }
コード例 #12
0
            $templateVars['allLanguages'][] = $language;
        }
    }
    foreach ($category->catTree as $cat) {
        $currentRow = array('catname' => $cat['name'], 'indent' => str_repeat('&nbsp;&nbsp;&nbsp;', $cat['indent']), 'translations' => array(), 'renderTranslateButton' => $cat['lang'] != $LANGCODE, 'translateButtonUrl' => sprintf('?action=translatecategory&cat=%s&trlang=%s', $cat['id'], $LANGCODE));
        // category translated in this language?
        if ($cat['lang'] != $LANGCODE) {
            $currentRow['catname'] .= ' (' . $languageCodes[strtoupper($cat['lang'])] . ')';
        }
        // get languages in use for categories
        $id_languages = $category->getCategoryLanguagesTranslated($cat["id"]);
        foreach ($all_lang as $lang => $language) {
            if ($language == $currentLanguage) {
                continue;
            }
            $currentTranslation = array('isTranslated' => false, 'tooltip' => '');
            if (array_key_exists($language, $id_languages)) {
                $currentTranslation['isTranslated'] = true;
                $currentTranslation['tooltip'] = sprintf('%s: %s', $PMF_LANG['ad_categ_titel'], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]));
            } else {
                $currentTranslation['translateButtonUrl'] = sprintf('?action=translatecategory&cat=%s&trlang=%s', $cat['id'], $lang);
                $currentTranslation['tooltip'] = $PMF_LANG['ad_categ_translate'];
            }
            $currentRow['translations'][] = $currentTranslation;
        }
        $templateVars['categoryTable'][] = $currentRow;
    }
    $twig->loadTemplate('category/showstructure.twig')->display($templateVars);
} else {
    require 'noperm.php';
}
コード例 #13
0
ファイル: functions.php プロジェクト: nosch/phpMyFAQ
 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";
 }
コード例 #14
0
        $cat['lang'] == $LANGCODE ? $catname = $cat['name'] : ($catname = $cat['name'] . ' (' . $languageCodes[strtoupper($cat['lang'])] . ')');
        $cat['lang'] == $LANGCODE ? $desc = "sscDesc" : ($desc = "sscDescNA");
        // show category name in actual language
        printf("<td class=\"%s\">", $desc);
        if ($cat['lang'] != $LANGCODE) {
            // translate category
            printf('<a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s"><img src="images/translate2.gif" width="13" height="16" border="0" title="%s" alt="%s" /></a>', $currentLink, $cat['id'], $LANGCODE, $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']);
        }
        printf("&nbsp;%s<strong>&middot; %s</strong>", $indent, $catname);
        print "</td>\n";
        // get languages in use for categories
        $id_languages = $category->getCategoryLanguagesTranslated($cat["id"]);
        foreach ($all_lang as $lang => $language) {
            if ($language == $actual_language) {
                continue;
            }
            if (array_key_exists($language, $id_languages)) {
                printf("<td class=\"sscDesc\" title=\"%s: %s\"><img src=\"images/ok.gif\" width=\"22\" height=\"18\" border=\"0\" title=\"%s: %s\" alt=\"%s: %s\" /></td>\n", $PMF_LANG["ad_categ_titel"], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]), $PMF_LANG["ad_categ_titel"], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]), $PMF_LANG["ad_categ_titel"], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]));
            } else {
                print "<td class=\"sscDescNA\">";
                printf('<a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s"><img src="images/translate2.gif" width="13" height="16" border="0" title="%s" alt="%s" /></a>', $currentLink, $cat['id'], $lang, $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']);
            }
            print "</td>\n";
        }
        print "</tr>\n";
    }
    print "</table>\n";
    printf('<p>%s</p>', $PMF_LANG['ad_categ_remark_overview']);
} else {
    print $PMF_LANG['err_NotAuth'];
}