Пример #1
0
 static function urlnicify($url, $id = '')
 {
     if ('' == $url) {
         return $url;
     }
     $url = trim($url);
     $url = strip_tags($url);
     $url = filter_text($url);
     $temp = explode("/", $url);
     $url = $temp[count($temp) - 1];
     $url = preg_replace('|[^a-z0-9-~+_. #=&;,/:]|i', '', $url);
     $url = str_replace('/', '', $url);
     $url = str_replace(' ', '-', $url);
     $url = str_replace('&', '', $url);
     $url = str_replace("'", "", $url);
     $url = str_replace(';//', '://', $url);
     $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);
     $url = strtolower($url);
     //Últims canvis
     $url = trim(mb_eregi_replace("[^ A-Za-z0-9_-]", "", $url));
     $url = mb_eregi_replace("[ \t\n\r]+", "-", $url);
     $url = mb_eregi_replace("[ -]+", "-", $url);
     $url = trim($url, '-');
     if ($id == '') {
         return $url;
     }
     return $url . "-" . $id;
 }
function display_text($string)
{
    $string = mb_eregi_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=_blank>\\0</a>", $string);
    $string = mb_eregi_replace("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@([0-9a-z](-?[0-9a-z])*\\.)+[a-z]{2}([zmuvtg]|fo|me)?\$", "<a href=\"mailto:\\0\" target=_blank>\\0</a>", $string);
    $string = mb_eregi_replace("\n", "<br>", $string);
    return $string;
}
Пример #3
0
 function do_inline($page, $param1, $param2)
 {
     $id = htmlspecialchars(trim($param1));
     $html = convert_inline($param2, $page->getpagename());
     $str = mb_eregi_replace('(?:<a\\s.*?>|</a>)', '', $html);
     return "<a href=\"#{$id}\">" . $str . '</a>';
 }
/**
 * If access to the WFS conf is restricted, modify the filter.
 * TODO: this function is also in mod_wfs_result!! Maybe merge someday.
 */
function checkAccessConstraint($filter, $wfs_conf_id)
{
    /* wfs_conf_element */
    $sql = "SELECT * FROM wfs_conf_element ";
    $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
    $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = \$1 ";
    $sql .= "ORDER BY wfs_conf_element.f_respos";
    $v = array($wfs_conf_id);
    $t = array('i');
    $res = db_prep_query($sql, $v, $t);
    while ($row = db_fetch_array($res)) {
        if (!empty($row["f_auth_varname"])) {
            $auth_varname = $row["f_auth_varname"];
            $element_name = $row["element_name"];
        }
    }
    if (!empty($auth_varname)) {
        if (isValidVarName($auth_varname)) {
            $user = eval("return " . $auth_varname . ";");
            if ($user) {
                $pattern = "(<ogc:Filter[^>]*>)(.*)(</ogc:Filter>)";
                $replacement = "\\1<And>\\2<ogc:PropertyIsEqualTo><ogc:PropertyName>" . $element_name . "</ogc:PropertyName><ogc:Literal>" . $user . "</ogc:Literal></ogc:PropertyIsEqualTo></And>\\3";
                $filter = mb_eregi_replace($pattern, $replacement, $filter);
            } else {
                $e = new mb_exception("mod_wfsGazetteerEditor_server: checkAccessConstraint: invalid value of variable containing user information!");
            }
        } else {
            $e = new mb_exception("mod_wfsGazetteerEditor_server: checkAccessConstraint: var name is not valid! (" . $auth_varname . ")");
        }
    }
    return $filter;
}
 public function onCompress(CompressionEvent $event)
 {
     if (!$event->isSafeToContinue()) {
         return;
     }
     $event->setContent(mb_eregi_replace($this->getPattern(), '\\1\\2', $event->getContent()));
 }
Пример #6
0
function do_translit($st)
{
    $replacement = array("й" => "i", "ц" => "c", "у" => "u", "к" => "k", "е" => "e", "н" => "n", "г" => "g", "ш" => "sh", "щ" => "sh", "з" => "z", "х" => "x", "ъ" => "\\'", "ф" => "f", "ы" => "i", "в" => "v", "а" => "a", "п" => "p", "р" => "r", "о" => "o", "л" => "l", "д" => "d", "ж" => "zh", "э" => "ie", "ё" => "e", "я" => "ya", "ч" => "ch", "с" => "c", "м" => "m", "и" => "i", "т" => "t", "ь" => "\\'", "б" => "b", "ю" => "yu", "Й" => "I", "Ц" => "C", "У" => "U", "К" => "K", "Е" => "E", "Н" => "N", "Г" => "G", "Ш" => "SH", "Щ" => "SH", "З" => "Z", "Х" => "X", "Ъ" => "\\'", "Ф" => "F", "Ы" => "I", "В" => "V", "А" => "A", "П" => "P", "Р" => "R", "О" => "O", "Л" => "L", "Д" => "D", "Ж" => "ZH", "Э" => "IE", "Ё" => "E", "Я" => "YA", "Ч" => "CH", "С" => "C", "М" => "M", "И" => "I", "Т" => "T", "Ь" => "\\'", "Б" => "B", "Ю" => "YU");
    foreach ($replacement as $i => $u) {
        $st = mb_eregi_replace($i, $u, $st);
    }
    return $st;
}
Пример #7
0
function FirstLetters($string)
{
    $n = preg_split('/[ -]/', $string);
    foreach ($n as &$v) {
        $v = mb_eregi_replace('^(.).+', '\\1', $v);
    }
    return implode('', $n);
}
Пример #8
0
 /**
  * Translit text from cyrillic to latin letters.
  * @static
  * @param string $text the text being translit.
  * @return string
  */
 protected static function cyrillicToLatin($text)
 {
     $matrix = array("й" => "i", "ц" => "c", "у" => "u", "к" => "k", "е" => "e", "н" => "n", "г" => "g", "ш" => "sh", "щ" => "sh", "з" => "z", "х" => "h", "ъ" => "\\'", "ф" => "f", "ы" => "i", "в" => "v", "а" => "a", "п" => "p", "р" => "r", "о" => "o", "л" => "l", "д" => "d", "ж" => "zh", "э" => "ie", "ё" => "e", "я" => "ya", "ч" => "ch", "с" => "s", "м" => "m", "и" => "i", "т" => "t", "ь" => "\\'", "б" => "b", "ю" => "yu", "Й" => "I", "Ц" => "C", "У" => "U", "К" => "K", "Е" => "E", "Н" => "N", "Г" => "G", "Ш" => "SH", "Щ" => "SH", "З" => "Z", "Х" => "X", "Ъ" => "\\'", "Ф" => "F", "Ы" => "I", "В" => "V", "А" => "A", "П" => "P", "Р" => "R", "О" => "O", "Л" => "L", "Д" => "D", "Ж" => "ZH", "Э" => "IE", "Ё" => "E", "Я" => "YA", "Ч" => "CH", "С" => "S", "М" => "M", "И" => "I", "Т" => "T", "Ь" => "\\'", "Б" => "B", "Ю" => "YU", "«" => "", "»" => "", " " => "_");
     foreach ($matrix as $from => $to) {
         $text = mb_eregi_replace($from, $to, $text);
     }
     return $text;
 }
Пример #9
0
function _strs($string) {	#Conversion charactere à la con =>pour req sql
	$string=str_replace('\\', '\\\\', $string);		 #caractere protégé \\
    #$string=eregi_replace("'", "\\'", $string);       #caractere protégé \'
    #$string=eregi_replace('"', "\\'", $string);       #caractere protégé \"
    $string=mb_eregi_replace("'", "\\'", $string);       #caractere protégé \'
    $string=mb_eregi_replace('"', "\\'", $string);       #caractere protégé \"
 	return $string; 
}
Пример #10
0
 public function SlugHelperUrl($text)
 {
     $matrix = array("й" => "i", "ц" => "c", "у" => "u", "к" => "k", "е" => "e", "н" => "n", "г" => "g", "ш" => "sh", "щ" => "sh", "з" => "z", "х" => "h", "ъ" => "\\'", "ф" => "f", "ы" => "i", "в" => "v", "а" => "a", "п" => "p", "р" => "r", "о" => "o", "л" => "l", "д" => "d", "ж" => "zh", "э" => "ie", "ё" => "e", "я" => "ya", "ч" => "ch", "с" => "s", "м" => "m", "и" => "i", "т" => "t", "ь" => "\\'", "б" => "b", "ю" => "yu", "і" => "i", "ї" => "i", "Й" => "I", "Ц" => "C", "У" => "U", "К" => "K", "Е" => "E", "Н" => "N", "Г" => "G", "Ш" => "SH", "Щ" => "SH", "З" => "Z", "Х" => "X", "Ъ" => "\\'", "Ф" => "F", "Ы" => "I", "В" => "V", "А" => "A", "П" => "P", "Р" => "R", "О" => "O", "Л" => "L", "Д" => "D", "Ж" => "ZH", "Э" => "IE", "Ё" => "E", "Я" => "YA", "Ч" => "CH", "С" => "S", "М" => "M", "И" => "I", "Т" => "T", "Ь" => "\\'", "Б" => "B", "Ю" => "YU", "І" => "I", "Ї" => "I", "«" => "", "»" => "", " " => "-");
     foreach ($matrix as $from => $to) {
         $text = mb_eregi_replace($from, $to, $text);
     }
     $text = preg_replace('/[^A-Za-z0-9_\\-]/', '', $text);
     return trim(strtolower($text));
 }
Пример #11
0
 public static function getSharedModelUploads($model, $primary, $key)
 {
     $files = self::getModelUploads($model, $primary, $key);
     $len = mb_strlen(DOCROOT);
     foreach ($files as $key => $file) {
         $files[$key] = DIRECTORY_SEPARATOR . mb_substr($file, $len);
         $files[$key] = mb_eregi_replace('\\\\', '/', $files[$key]);
     }
     return $files;
 }
Пример #12
0
 function do_inline($page, $param1, $param2)
 {
     $url = SCRIPTURL . '?' . htmlspecialchars($param1);
     if (trim($param2) == '') {
         $alias = htmlspecialchars($url);
     } else {
         $alias = mb_eregi_replace('(?:<a\\s.*?>|</a>)', '', convert_inline($param2, $page->getpagename()));
     }
     return "<a href=\"{$url}\">{$alias}</a>";
 }
Пример #13
0
function file_upload($options)
{
    if (!isset($_FILES[$options->key])) {
        if ($options->is_critical) {
            throw new Exception("\$_FILES[{$options->key}] isn't set!");
        }
        return;
    }
    $file = $_FILES[$options->key];
    if ($file["error"]) {
        if ($options->is_critical) {
            throw new Exception("<a href=\"http://www.php.net/manual/en/features.file-upload.errors.php\">Error {$file["error"]}!</a>");
        }
        return;
    }
    $pathinfo = pathinfo($file["name"]);
    $filename = $pathinfo["filename"];
    $extension = isset($pathinfo["extension"]) ? $pathinfo["extension"] : "";
    $filename = mb_eregi_replace("[^a-z0-9_\\-]", "-", $filename);
    $extension = strtolower($extension);
    foreach ($options->extensions as &$value) {
        $value = strtolower($value);
    }
    if (!in_array($extension, $options->extensions)) {
        if ($options->is_critical) {
            throw new Exception("Unexpected file extension {$extension}!");
        }
        return;
    }
    if ($options->neoname) {
        $pathinfo = pathinfo($options->neoname);
        $neoname = $pathinfo["filename"];
    } else {
        $neoname = $filename;
    }
    $newname = "{$neoname}.{$extension}";
    if (file_exists($options->dir . $newname)) {
        $suff = 0;
        $newname = "{$neoname}.0.{$extension}";
        while (file_exists($options->dir . $newname)) {
            $suff++;
            $newname = "{$neoname}.{$suff}.{$extension}";
        }
    }
    $uploadfile = $options->dir . $newname;
    if (!move_uploaded_file($file['tmp_name'], $uploadfile)) {
        if ($options->is_critical) {
            throw new Exception("Cannot move uploaded file!");
        }
        return;
    }
    chmod($uploadfile, $options->rights);
    return $newname;
}
Пример #14
0
 /**
  * Generate a URL friendly "slug" from a given Cyrillic string.
  *
  * @param string $title
  * @param string $separator
  * @return string
  */
 function make($title, $separator = '-')
 {
     $matrix = array('ü' => 'ue', 'ö' => 'oe', 'ß' => 'ss', 'ä' => 'ae', 'Ü' => 'Ue', 'Ö' => 'Oe', 'Š' => 'Ss', 'Ä' => 'Ae');
     foreach ($matrix as $from => $to) {
         $title = mb_eregi_replace($from, $to, $title);
     }
     $title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', mb_strtolower($title));
     $flip = $separator == '-' ? '_' : '-';
     $title = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $title);
     $title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
     return trim($title, $separator);
 }
Пример #15
0
 /**
  * Generate a URL friendly "slug" from a given Cyrillic string.
  *
  * @param string $title
  * @param string $separator
  * @return string
  */
 public function make($title, $separator = '-')
 {
     $matrix = array('й' => 'i', 'ц' => 'c', 'у' => 'u', 'к' => 'k', 'е' => 'e', 'н' => 'n', 'г' => 'g', 'ш' => 'sh', 'щ' => 'shch', 'з' => 'z', 'х' => 'h', 'ъ' => '', 'ф' => 'f', 'ы' => 'y', 'в' => 'v', 'а' => 'a', 'п' => 'p', 'р' => 'r', 'о' => 'o', 'л' => 'l', 'д' => 'd', 'ж' => 'zh', 'э' => 'e', 'ё' => 'e', 'я' => 'ya', 'ч' => 'ch', 'с' => 's', 'м' => 'm', 'и' => 'i', 'т' => 't', 'ь' => '', 'б' => 'b', 'ю' => 'yu', 'ү' => 'u', 'қ' => 'k', 'ғ' => 'g', 'ә' => 'e', 'ң' => 'n', 'ұ' => 'u', 'ө' => 'o', 'Һ' => 'h', 'һ' => 'h', 'і' => 'i', 'ї' => 'ji', 'є' => 'je', 'ґ' => 'g', 'Й' => 'I', 'Ц' => 'C', 'У' => 'U', 'Ұ' => 'U', 'Ө' => 'O', 'К' => 'K', 'Е' => 'E', 'Н' => 'N', 'Г' => 'G', 'Ш' => 'SH', 'Ә' => 'E', 'Ң ' => 'N', 'З' => 'Z', 'Х' => 'H', 'Ъ' => '', 'Ф' => 'F', 'Ы' => 'Y', 'В' => 'V', 'А' => 'A', 'П' => 'P', 'Р' => 'R', 'О' => 'O', 'Л' => 'L', 'Д' => 'D', 'Ж' => 'ZH', 'Э' => 'E', 'Ё' => 'E', 'Я' => 'YA', 'Ч' => 'CH', 'С' => 'S', 'М' => 'M', 'И' => 'I', 'Т' => 'T', 'Ь' => '', 'Б' => 'B', 'Ю' => 'YU', 'Ү' => 'U', 'Қ' => 'K', 'Ғ' => 'G', 'Щ' => 'SHCH', 'І' => 'I', 'Ї' => 'YI', 'Є' => 'YE', 'Ґ' => 'G');
     foreach ($matrix as $from => $to) {
         $title = mb_eregi_replace($from, $to, $title);
     }
     $title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', mb_strtolower($title));
     $flip = $separator == '-' ? '_' : '-';
     $title = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $title);
     $title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
     return trim($title, $separator);
 }
Пример #16
0
 /**
  * Internal filter used by other name filtering methods in this class
  *
  * @param string $value Value to filter
  * @param array $allowedExtras Additional characters that are allowed in the value
  * @param string 1 character replacement value for invalid characters
  * @param bool $beautify Whether to beautify the string, specify Sanitizer::translate to perform transliteration. 
  * @param int $maxLength
  * @return string
  *
  */
 public function nameFilter($value, array $allowedExtras, $replacementChar, $beautify = false, $maxLength = 128)
 {
     static $replacements = array();
     if (!is_string($value)) {
         $value = $this->string($value);
     }
     $allowed = array_merge($this->allowedASCII, $allowedExtras);
     $needsWork = strlen(str_replace($allowed, '', $value));
     $extras = implode('', $allowedExtras);
     if ($beautify && $needsWork) {
         if ($beautify === self::translate && $this->multibyteSupport) {
             $value = mb_strtolower($value);
             if (empty($replacements)) {
                 $configData = $this->wire('modules')->getModuleConfigData('InputfieldPageName');
                 $replacements = empty($configData['replacements']) ? InputfieldPageName::$defaultReplacements : $configData['replacements'];
             }
             foreach ($replacements as $from => $to) {
                 if (mb_strpos($value, $from) !== false) {
                     $value = mb_eregi_replace($from, $to, $value);
                 }
             }
         }
         $v = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value);
         if ($v) {
             $value = $v;
         }
         $needsWork = strlen(str_replace($allowed, '', $value));
     }
     if (strlen($value) > $maxLength) {
         $value = substr($value, 0, $maxLength);
     }
     if ($needsWork) {
         $value = str_replace(array("'", '"'), '', $value);
         // blank out any quotes
         $value = filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_NO_ENCODE_QUOTES);
         $hyphenPos = strpos($extras, '-');
         if ($hyphenPos !== false && $hyphenPos !== 0) {
             // if hyphen present, ensure it's first (per PCRE requirements)
             $extras = '-' . str_replace('-', '', $extras);
         }
         $chars = $extras . 'a-zA-Z0-9';
         $value = preg_replace('{[^' . $chars . ']}', $replacementChar, $value);
     }
     // remove leading or trailing dashes, underscores, dots
     if ($beautify) {
         if (strpos($extras, $replacementChar) === false) {
             $extras .= $replacementChar;
         }
         $value = trim($value, $extras);
     }
     return $value;
 }
Пример #17
0
 /**
  * @param string $title
  * @return string
  */
 public function make($title)
 {
     $tr = array("А" => "A", "Б" => "B", "В" => "V", "Г" => "G", "Д" => "D", "Е" => "E", "Ё" => "E", "Ж" => "J", "З" => "Z", "И" => "I", "Й" => "Y", "К" => "K", "Л" => "L", "М" => "M", "Н" => "N", "О" => "O", "П" => "P", "Р" => "R", "С" => "S", "Т" => "T", "У" => "U", "Ф" => "F", "Х" => "H", "Ц" => "TS", "Ч" => "CH", "Ш" => "SH", "Щ" => "SCH", "Ъ" => "", "Ы" => "YI", "Ь" => "", "Э" => "E", "Ю" => "YU", "Я" => "YA", "а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "e", "ж" => "j", "з" => "z", "и" => "i", "й" => "y", "к" => "k", "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f", "х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "y", "ы" => "yi", "ь" => "", "э" => "e", "ю" => "yu", "я" => "ya", "«" => "", "»" => "", "№" => "", "Ӏ" => "", "’" => "", "ˮ" => "", "_" => "-", "'" => "", "`" => "", "^" => "", "\\." => "", "," => "", ":" => "", "<" => "", ">" => "", "!" => "");
     //Транслитерация
     foreach ($tr as $ru => $en) {
         $title = mb_eregi_replace($ru, $en, $title);
     }
     //Преобразуем к нижнему регистру
     $title = mb_strtolower($title);
     //пробелы заменяем на -
     $title = str_replace(' ', '-', $title);
     return $title;
 }
Пример #18
0
 public static function convert($title, $separator = '-')
 {
     $matrix = ['й' => 'i', 'ц' => 'c', 'у' => 'u', 'к' => 'k', 'е' => 'e', 'н' => 'n', 'г' => 'g', 'ш' => 'sh', 'щ' => 'shch', 'з' => 'z', 'х' => 'h', 'ъ' => '', 'ф' => 'f', 'ы' => 'y', 'в' => 'v', 'а' => 'a', 'п' => 'p', 'р' => 'r', 'о' => 'o', 'л' => 'l', 'д' => 'd', 'ж' => 'zh', 'э' => 'e', 'ё' => 'e', 'я' => 'ya', 'ч' => 'ch', 'с' => 's', 'м' => 'm', 'и' => 'i', 'т' => 't', 'ь' => '', 'б' => 'b', 'ю' => 'yu', 'ү' => 'u', 'қ' => 'k', 'ғ' => 'g', 'ә' => 'e', 'ң' => 'n', 'ұ' => 'u', 'ө' => 'o', 'Һ' => 'h', 'һ' => 'h', 'і' => 'i', 'ї' => 'ji', 'є' => 'je', 'ґ' => 'g', 'Й' => 'I', 'Ц' => 'C', 'У' => 'U', 'Ұ' => 'U', 'Ө' => 'O', 'К' => 'K', 'Е' => 'E', 'Н' => 'N', 'Г' => 'G', 'Ш' => 'SH', 'Ә' => 'E', 'Ң ' => 'N', 'З' => 'Z', 'Х' => 'H', 'Ъ' => '', 'Ф' => 'F', 'Ы' => 'Y', 'В' => 'V', 'А' => 'A', 'П' => 'P', 'Р' => 'R', 'О' => 'O', 'Л' => 'L', 'Д' => 'D', 'Ж' => 'ZH', 'Э' => 'E', 'Ё' => 'E', 'Я' => 'YA', 'Ч' => 'CH', 'С' => 'S', 'М' => 'M', 'И' => 'I', 'Т' => 'T', 'Ь' => '', 'Б' => 'B', 'Ю' => 'YU', 'Ү' => 'U', 'Қ' => 'K', 'Ғ' => 'G', 'Щ' => 'SHCH', 'І' => 'I', 'Ї' => 'YI', 'Є' => 'YE', 'Ґ' => 'G', 'a' => 'a', 'b' => 'b', 'c' => 'c', 'ç' => 'c', 'd' => 'd', 'e' => 'e', 'f' => 'f', 'g' => 'g', 'ğ' => 'ğ', 'h' => 'h', 'ı' => 'i', 'i' => 'i', 'j' => 'j', 'k' => 'k', 'l' => 'l', 'm' => 'm', 'n' => 'n', 'o' => 'o', 'ö' => 'o', 'p' => 'p', 'r' => 'r', 's' => 's', 'ş' => 's', 't' => 't', 'u' => 'u', 'ü' => 'u', 'v' => 'v', 'y' => 'y', 'z' => 'z', 'x' => 'x', 'w' => 'w', 'A' => 'a', 'B' => 'b', 'C' => 'c', 'Ç' => 'C', 'D' => 'D', 'E' => 'E', 'F' => 'F', 'G' => 'G', 'Ğ' => 'Ğ', 'H' => 'H', 'I' => 'I', 'İ' => 'I', 'J' => 'J', 'K' => 'K', 'L' => 'L', 'M' => 'M', 'N' => 'N', 'O' => 'O', 'Ö' => 'O', 'P' => 'P', 'R' => 'R', 'S' => 'S', 'Ş' => 'S', 'T' => 'T', 'U' => 'U', 'Ü' => 'U', 'V' => 'V', 'Y' => 'Y', 'Z' => 'Z', 'X' => 'X', 'W' => 'W'];
     foreach ($matrix as $from => $to) {
         $title = mb_eregi_replace($from, $to, $title);
     }
     $pattern = '![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u';
     $title = preg_replace($pattern, '', mb_strtolower($title));
     $flip = $separator == '-' ? '_' : '-';
     $title = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $title);
     $title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
     return trim($title, $separator);
 }
/**
 * Take out mailto: from an email value
 *
 * @param a-tidy-node $mf_node
 * @param xmfp->errors $errors passed by reference
 * @param xmfp->base $base
 */

function post_process_clean_email( &$mf_node, &$errors, &$base) {
	if( isset($mf_node['node']['value']) ) {
		//Singular ocurrence
		 $mf_node['node']['value'] = mb_eregi_replace("mailto:", "", $mf_node['node']['value']);
	} else {
		//Multiple Ocurrences
		//Multiple Ocurrences of the element
		$count_nodes = count($mf_node['node']);
		//This is needed instead of a foreach cause we are passing by reference the value.
		for($x=0; $x<$count_nodes; $x++) {
			$mf_node['node'][$x]['value'] = mb_eregi_replace("mailto:", "", $mf_node['node'][$x]['value']);
		}
	}
}
Пример #20
0
 function do_inlinetag($page, $param1, $param2)
 {
     static $list = array('href', 'title', 'target');
     $arg = tagparam2array($param1);
     $array = array();
     foreach ($list as $key) {
         if (isset($arg[$key])) {
             $array[] = htmlspecialchars($key) . '="' . htmlspecialchars($arg[$key]) . '"';
         }
     }
     $html = convert_inline($param2, $page->getpagename());
     $str = mb_eregi_replace('(?:<a\\s.*?>|</a>)', '', $html);
     $attr = join(' ', $array);
     return "<a {$attr}>{$str}</a>";
 }
Пример #21
0
 /**
  * Translit text from cyrillic to latin letters.
  * @static
  * @param string $text the text being translit.
  * @return string
  */
 public static function latin($text, $toLowCase = TRUE)
 {
     $matrix = array("й" => "i", "ц" => "c", "у" => "u", "к" => "k", "е" => "e", "н" => "n", "г" => "g", "ш" => "sh", "щ" => "shch", "з" => "z", "х" => "h", "ъ" => "", "ф" => "f", "ы" => "y", "в" => "v", "а" => "a", "п" => "p", "р" => "r", "о" => "o", "л" => "l", "д" => "d", "ж" => "zh", "э" => "e", "ё" => "e", "я" => "ya", "ч" => "ch", "с" => "s", "м" => "m", "и" => "i", "т" => "t", "ь" => "", "б" => "b", "ю" => "yu", "Й" => "I", "Ц" => "C", "У" => "U", "К" => "K", "Е" => "E", "Н" => "N", "Г" => "G", "Ш" => "SH", "Щ" => "SHCH", "З" => "Z", "Х" => "X", "Ъ" => "", "Ф" => "F", "Ы" => "Y", "В" => "V", "А" => "A", "П" => "P", "Р" => "R", "О" => "O", "Л" => "L", "Д" => "D", "Ж" => "ZH", "Э" => "E", "Ё" => "E", "Я" => "YA", "Ч" => "CH", "С" => "S", "М" => "M", "И" => "I", "Т" => "T", "Ь" => "", "Б" => "B", "Ю" => "YU", "«" => "", "»" => "", " " => "-", "\"" => "", "\\." => "", "–" => "-", "\\," => "", "\\(" => "", "\\)" => "", "\\?" => "", "\\!" => "", "\\:" => "", '#' => '', '№' => '', ' - ' => '-', '/' => '-', '  ' => '-');
     // Enforce the maximum component length
     $maxlength = 100;
     $text = implode(array_slice(explode('<br>', wordwrap(trim(strip_tags(html_entity_decode($text))), $maxlength, '<br>', false)), 0, 1));
     //$text = substr(, 0, $maxlength);
     foreach ($matrix as $from => $to) {
         $text = mb_eregi_replace($from, $to, $text);
     }
     // Optionally convert to lower case.
     if ($toLowCase) {
         $text = strtolower($text);
     }
     return $text;
 }
Пример #22
0
function getCacheIcon($user_id, $cache_id, $cache_status, $cache_userid, $iconname)
{
    $iconname = mb_eregi_replace("cache/", "", $iconname);
    // for old cache_type table contents
    $iconext = "." . mb_eregi_replace("^.*\\.", "", $iconname);
    $iconname = mb_eregi_replace("\\..*", "", $iconname);
    // add status
    switch ($cache_status) {
        case 1:
            $iconname .= "-s";
            break;
        case 2:
            $iconname .= "-n";
            break;
        case 3:
            $iconname .= "-a";
            break;
        case 4:
            $iconname .= "-a";
            break;
        case 5:
            $iconname .= "-s";
            break;
            // fix for RT ticket #3403
        // fix for RT ticket #3403
        case 6:
            $iconname .= "-a";
            break;
        case 7:
            $iconname .= "-a";
            break;
    }
    // mark if (not) found
    if ($user_id) {
        if ($cache_userid == $user_id) {
            $iconname .= "-owner";
        } else {
            $logtype = sql_value_slave("\n\t\t\t\tSELECT `type`\n\t\t\t\tFROM `cache_logs`\n\t\t\t\tWHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,2,7)\n\t\t\t\tORDER BY `type`\n\t\t\t\tLIMIT 1", 0, $cache_id, $user_id);
            if ($logtype == 1 || $logtype == 7) {
                $iconname .= '-found';
            } elseif ($logtype == 2) {
                $iconname .= '-dnf';
            }
        }
    }
    return $iconname . $iconext;
}
 public static function cleanString($string, $separator = '-', $cleanPunctuation = TRUE, $cleanSlash = TRUE)
 {
     // Default words to ignore
     /*$ignoreWords = array(
           'an', 'as', 'at', 'before', 'but', 'by', 'for', 'from', 'is', 'in',
           'into', 'like', 'of', 'off', 'on', 'onto', 'per', 'since', 'than', 'the',
           'this', 'that', 'to', 'up', 'via', 'with',
       );*/
     $ignoreWords = array();
     $output = $string;
     if ($cleanPunctuation) {
         $punctuation = self::punctuationChars();
         foreach ($punctuation as $name => $details) {
             if (isset($details['value'])) {
                 // Slightly tricky inline if which either replaces with the separator or nothing
                 $output = str_replace($details['value'], $separator, $output);
             }
         }
     }
     // If something is already urlsafe then don't remove slashes
     if ($cleanSlash) {
         $output = str_replace('/', '', $output);
     }
     // Optionally remove accents and transliterate
     $translations = self::$_utf8_accents;
     $output = strtr($output, $translations);
     // Reduce to the subset of ASCII96 letters and numbers
     //$pattern = '/[^a-zA-Z0-9\/]+/ ';
     //$output = preg_replace($pattern, $separator, $output);
     // Get rid of words that are on the ignore list
     $ignoreWords = implode(',', $ignoreWords);
     $ignoreRe = '\\b' . preg_replace('/,/', '\\b|\\b', $ignoreWords) . '\\b';
     if (function_exists('mb_eregi_replace')) {
         $output = mb_eregi_replace($ignoreRe, '', $output);
     } else {
         $output = preg_replace("/{$ignoreRe}/i", '', $output);
     }
     // Always replace whitespace with the separator.
     $output = preg_replace('/\\s+/', $separator, $output);
     // Trim duplicates and remove trailing and leading separators.
     $output = self::cleanSeparators($output, $separator);
     // Enforce the maximum component length
     //$maxlength = 128;
     //$output = substr($output, 0, $maxlength);
     return $output;
 }
Пример #24
0
 public function generateSlug($event)
 {
     if (empty($this->sourceAttributeName) and empty($this->slugAttributeName) and !$this->hardSlug) {
         return false;
     }
     if (empty($this->owner->{$this->slugAttributeName}) or $this->hardSlug) {
         $text = preg_replace('/\\s{2,}/', ' ', $this->owner->{$this->sourceAttributeName});
     } else {
         $text = preg_replace('/\\s{2,}/', ' ', $this->owner->{$this->slugAttributeName});
     }
     $matrix = array("й" => "i", "ц" => "c", "у" => "u", "к" => "k", "е" => "e", "н" => "n", "г" => "g", "ш" => "sh", "щ" => "sh", "з" => "z", "х" => "h", "ъ" => "\\'", "ф" => "f", "ы" => "i", "в" => "v", "а" => "a", "п" => "p", "р" => "r", "о" => "o", "л" => "l", "д" => "d", "ж" => "zh", "э" => "ie", "ё" => "e", "я" => "ya", "ч" => "ch", "с" => "s", "м" => "m", "и" => "i", "т" => "t", "ь" => "\\'", "б" => "b", "ю" => "yu", "і" => "i", "ї" => "i", "Й" => "I", "Ц" => "C", "У" => "U", "К" => "K", "Е" => "E", "Н" => "N", "Г" => "G", "Ш" => "SH", "Щ" => "SH", "З" => "Z", "Х" => "X", "Ъ" => "\\'", "Ф" => "F", "Ы" => "I", "В" => "V", "А" => "A", "П" => "P", "Р" => "R", "О" => "O", "Л" => "L", "Д" => "D", "Ж" => "ZH", "Э" => "IE", "Ё" => "E", "Я" => "YA", "Ч" => "CH", "С" => "S", "М" => "M", "И" => "I", "Т" => "T", "Ь" => "\\'", "Б" => "B", "Ю" => "YU", "І" => "I", "Ї" => "I", "«" => "", "»" => "", " " => "-");
     foreach ($matrix as $from => $to) {
         $text = mb_eregi_replace($from, $to, $text);
     }
     $text = preg_replace('/[^A-Za-z0-9_\\-]/', '', $text);
     $this->owner->{$this->slugAttributeName} = trim(strtolower($text));
 }
Пример #25
0
 protected static function indexContent($arrSet, $pid)
 {
     $objDatabase = \Database::getInstance();
     // Remove quotes
     $strText = $arrSet['title'] . ' ' . $arrSet['text'];
     $strText = str_replace(array('´', '`'), "'", $strText);
     // Remove special characters
     if (function_exists('mb_eregi_replace')) {
         $strText = mb_eregi_replace('[^[:alnum:]\'\\.:,\\+_-]|- | -|\' | \'|\\. |\\.$|: |:$|, |,$', ' ', $strText);
     } else {
         $strText = preg_replace(array('/- /', '/ -/', "/' /", "/ '/", '/\\. /', '/\\.$/', '/: /', '/:$/', '/, /', '/,$/', '/[^\\pN\\pL\'\\.:,\\+_-]/u'), ' ', $strText);
     }
     // Split words
     $arrWords = preg_split('/ +/', utf8_strtolower($strText));
     $arrIndex = array();
     // Index words
     foreach ($arrWords as $strWord) {
         // Strip a leading plus (see #4497)
         if (strncmp($strWord, '+', 1) === 0) {
             $strWord = substr($strWord, 1);
         }
         $strWord = trim($strWord);
         if (!strlen($strWord) || preg_match('/^[\\.:,\'_-]+$/', $strWord)) {
             continue;
         }
         if (preg_match('/^[\':,]/', $strWord)) {
             $strWord = substr($strWord, 1);
         }
         if (preg_match('/[\':,\\.]$/', $strWord)) {
             $strWord = substr($strWord, 0, -1);
         }
         if (isset($arrIndex[$strWord])) {
             $arrIndex[$strWord]++;
             continue;
         }
         $arrIndex[$strWord] = 1;
     }
     // Remove existing index
     $objDatabase->prepare("DELETE FROM tl_search_index WHERE pid=?")->execute($pid);
     // Create new index
     foreach ($arrIndex as $k => $v) {
         $objDatabase->prepare("INSERT INTO tl_search_index (pid, word, relevance, language) VALUES (?, ?, ?, ?)")->execute($pid, $k, $v, $arrSet['language']);
     }
 }
 public function parseTransactionResponse($xml)
 {
     $result = new stdClass();
     $result->success = false;
     $result->message = "";
     $result->xml = $xml;
     $data = mb_eregi_replace("^[^<]*", "", $xml);
     $data = mb_eregi_replace("[^>]*\$", "", $data);
     $resObj = array();
     if (mb_strpos(mb_strtoupper($data), "SUCCESS") !== false) {
         $result->success = true;
         if (mb_ereg("^.*ogc:FeatureId fid=\"(.+)\"/>.*\$", $data)) {
             $fid = mb_ereg_replace("^.*ogc:FeatureId fid=\"(.+)\"/>.*\$", "\\1", $data);
             $result->fid = $fid;
         }
         $result->message = "Success.";
     } else {
         $result->message = "An unknown error occured.";
     }
     return $result;
 }
function strip_word_html($text, $allowed_tags = '<i><sup><sub><em><strong><u><img>')
{
    mb_regex_encoding('UTF-8');
    $search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
    $replace = array('\'', '\'', '"', '"', '-');
    $text = preg_replace($search, $replace, $text);
    $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
    if (mb_stripos($text, '/*') !== FALSE) {
        $text = mb_eregi_replace('#/\\*.*?\\*/#s', '', $text, 'm');
    }
    $text = preg_replace(array('/<([0-9]+)/'), array('< $1'), $text);
    $text = strip_tags($text, $allowed_tags);
    $text = preg_replace(array('/^\\s\\s+/', '/\\s\\s+$/', '/\\s\\s+/u'), array('', '', ' '), $text);
    $search = array('#<(strong|b)[^>]*>(.*?)</(strong|b)>#isu', '#<(em|i)[^>]*>(.*?)</(em|i)>#isu', '#<u[^>]*>(.*?)</u>#isu');
    $replace = array('<b>$2</b>', '<i>$2</i>', '<u>$1</u>');
    $text = preg_replace($search, $replace, $text);
    $num_matches = preg_match_all("/\\<!--/u", $text, $matches);
    if ($num_matches) {
        $text = preg_replace('/\\<!--(.)*--\\>/isu', '', $text);
    }
    return $text;
}
Пример #28
0
<?
session_cache_limiter("nocache");
session_start();
require("_global.php"); 
#require_once("Lib/libutf8.inc.php"); 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1		pour empecher la mise en cache (cache trop important avec ironie ou FF8) !!!
header('Content-Type: text/html; charset=iso-8859-1'); 								// pour les caractère accentué
require_once("./Config/_sqlconf.php");

//==============================================================================
if ($PG=="") $PG="MH/packMH_parchemin";
iF ((substr($PG, 1, 1)==":")||(substr($PG, 0, 1)=="/")) $PG="FILE://".$PG;
$PG=mb_eregi_replace("\\\'", "'", $PG);       #caractere protégé \'
$PG=mb_eregi_replace('\\\"', '"', $PG);       #caractere protégé \"
$PG=str_replace('\\\\', '\\', $PG);			  #caractere protégé \\

print('<LINK REL="stylesheet" HREF="'.$PG.'/css/MH_Style_Play.css" TYPE="text/css">');
print("<TABLE><TR><TD width=10></TD><TD>");

//==============================================================================
$_SESSION['login']=""; 		// on ferme la session courante si elle était ouverte

If (!isset($ZZ_TID))  { Die("Erreur accès à ZoryaZilla: Mauvais identifiant Troll!"); }
If (!isset($ZZ_PWD))  { Die("Erreur accès à ZoryaZilla: Mauvais password"); }

$TiD=$ZZ_TID;

if ($action=="Autologout") {
	print("Password de <i><b>$TiD</b></i> effacé de Firefox!!");  
	print("<FORM name=FormDlgBox><INPUT TYPE=hidden Name=ZZSession Value=\"\"></FORM>");
	die();
Пример #29
0
 function setTags($tags)
 {
     if (!$tags) {
         return '';
     }
     $tags = pwHtmlspecialchars_decode($tags);
     $tags = stripslashes($tags);
     $tags = function_exists('mb_eregi_replace') ? mb_eregi_replace('/[“|”]/', '"', $tags) : str_replace(array('“', '”'), '"', $tags);
     $tags = preg_replace_callback('/("[^"]+")/', array($this, 'callback'), $tags);
     $this->tags = array_merge($this->tags, explode(" ", str_replace('/\\s+/is', ' ', trim($tags))));
     $this->tags = array_unique($this->tags);
     if (count($this->tags) > 5) {
         return $this->post->showmsg("tags_num_limit");
     }
     foreach ($this->tags as $key => $value) {
         $this->tags[$key] = trim(preg_replace('/&nbsp;/is', ' ', $this->tags[$key]));
         if (!$this->tags[$key]) {
             unset($this->tags[$key]);
             continue;
         }
         if (strlen($this->tags[$key]) > 15 || strlen($this->tags[$key]) < 3) {
             return $this->post->showmsg('tag_length_limit');
         }
     }
     return implode(" ", $this->tags);
 }
Пример #30
0
 private function related()
 {
     $send = $this->line() . $this->html;
     $html = $this->html;
     foreach (array_keys($this->media) as $name) {
         $preg = '/(\\s)(src|href)\\s*=\\s*(["\']?)' . preg_quote($name) . '\\3/';
         $replace = sprintf('\\1\\2=\\3cid:%s\\3', md5($name));
         $html = mb_eregi_replace(substr($preg, 1, -1), $replace, $html);
         $preg = '/url\\(\\s*(["\']?)' . preg_quote($name) . '\\1\\s*\\)/';
         $replace = sprintf('url(\\1cid:%s\\1)', md5($name));
         $html = mb_eregi_replace(substr($preg, 1, -1), $replace, $html);
     }
     if ($html != $this->html) {
         $send = '';
         $send .= $this->line(sprintf('Content-Type: multipart/related; boundary="%s"', $this->boundary['related']));
         $send .= $this->line();
         $send .= $this->line('--' . $this->boundary['related']);
         $send .= $this->meta('html');
         $send .= $this->line();
         $send .= $this->line($this->enc($html));
         foreach ($this->media as $name => $media) {
             $send .= $this->line('--' . $this->boundary['related']);
             $send .= $this->attach_string($media, md5($name));
         }
         $send .= $this->line('--' . $this->boundary['related'] . '--');
     }
     return $send;
 }