function compress($str, $xmlsafe = false)
{
    $dico = array();
    $skipnum = $xmlsafe ? 5 : 0;
    for ($i = 0; $i < 256; $i++) {
        $dico[chr($i)] = $i;
    }
    if ($xmlsafe) {
        $dico["<"] = 256;
        $dico[">"] = 257;
        $dico["&"] = 258;
        $dico["\""] = 259;
        $dico["'"] = 260;
    }
    $res = "";
    $splitStr = str_split($str);
    //print_r($splitStr);
    $length = count($splitStr);
    $nbChar = 256 + $skipnum;
    $buffer = "";
    for ($i = 0; $i <= $length; $i++) {
        $current = $splitStr[$i];
        if ($dico[$buffer . $current] !== NULL && $current != "") {
            //echo $buffer . ":" . $current . "<br>";
            $buffer .= $current;
        } else {
            $res .= unichr($dico[$buffer]);
            //echo $dico[$buffer] . ": " . unichr($dico[$buffer]) . "<br>";
            $dico[$buffer . $current] = $nbChar;
            $nbChar++;
            $buffer = $current;
        }
    }
    return $res;
}
Example #2
0
 /**
  * Verifies if a username is valid or invalid.
  *
  * @param boolean True when valid, false when invalid.
  */
 function verify_username()
 {
     global $mybb;
     $username =& $this->data['username'];
     require_once MYBB_ROOT . 'inc/functions_user.php';
     // Fix bad characters
     $username = trim_blank_chrs($username);
     $username = str_replace(array(unichr(160), unichr(173), unichr(0xca), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);
     // Remove multiple spaces from the username
     $username = preg_replace("#\\s{2,}#", " ", $username);
     // Check if the username is not empty.
     if ($username == '') {
         $this->set_error('missing_username');
         return false;
     }
     // Check if the username belongs to the list of banned usernames.
     if (is_banned_username($username, true)) {
         $this->set_error('banned_username');
         return false;
     }
     // Check for certain characters in username (<, >, &, commas and slashes)
     if (strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false)) {
         $this->set_error("bad_characters_username");
         return false;
     }
     // Check if the username is of the correct length.
     if ($mybb->settings['maxnamelength'] != 0 && my_strlen($username) > $mybb->settings['maxnamelength'] || $mybb->settings['minnamelength'] != 0 && my_strlen($username) < $mybb->settings['minnamelength']) {
         $this->set_error('invalid_username_length', array($mybb->settings['minnamelength'], $mybb->settings['maxnamelength']));
         return false;
     }
     return true;
 }
Example #3
0
function get_category_status_chars($category)
{
    $chars = "";
    if (!$category['exposed']) {
        $chars .= unichr(CONST_CHAR_CROSS);
    }
    if (!is_visible($category['available_from'], $category['available_until'])) {
        $chars .= unichr(CONST_CHAR_CLOCK);
    }
    return $chars;
}
 private function make_counter($n, $type, $pad = null)
 {
     $n = intval($n);
     $text = "";
     $uppercase = false;
     switch ($type) {
         case "decimal-leading-zero":
         case "decimal":
         case "1":
             if ($pad) {
                 $text = str_pad($n, $pad, "0", STR_PAD_LEFT);
             } else {
                 $text = $n;
             }
             break;
         case "upper-alpha":
         case "upper-latin":
         case "A":
             $uppercase = true;
         case "lower-alpha":
         case "lower-latin":
         case "a":
             $text = chr($n % 26 + ord('a') - 1);
             break;
         case "upper-roman":
         case "I":
             $uppercase = true;
         case "lower-roman":
         case "i":
             $text = dec2roman($n);
             break;
         case "lower-greek":
             $text = unichr($n + 944);
             break;
     }
     if ($uppercase) {
         $text = strtoupper($text);
     }
     return "{$text}.";
 }
 function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal")
 {
     $type = mb_strtolower($type);
     if ($id === "page") {
         $value = $this->get_dompdf()->get_canvas()->get_page_number();
     } elseif (!isset($this->_counters[$id])) {
         $this->_counters[$id] = 0;
         $value = 0;
     } else {
         $value = $this->_counters[$id];
     }
     switch ($type) {
         default:
         case "decimal":
             return $value;
         case "decimal-leading-zero":
             return str_pad($value, 2, "0");
         case "lower-roman":
             return dec2roman($value);
         case "upper-roman":
             return mb_strtoupper(dec2roman($value));
         case "lower-latin":
         case "lower-alpha":
             return chr($value % 26 + ord('a') - 1);
         case "upper-latin":
         case "upper-alpha":
             return chr($value % 26 + ord('A') - 1);
         case "lower-greek":
             return unichr($value + 944);
         case "upper-greek":
             return unichr($value + 912);
     }
 }
 function code2utf($number)
 {
     if ($number < 0) {
         return FALSE;
     }
     if ($number < 128) {
         return chr($number);
     }
     // Removing / Replacing Windows Illegals Characters
     if ($number < 160) {
         if ($number == 128) {
             $number = 8364;
         } elseif ($number == 129) {
             $number = 160;
         } elseif ($number == 130) {
             $number = 8218;
         } elseif ($number == 131) {
             $number = 402;
         } elseif ($number == 132) {
             $number = 8222;
         } elseif ($number == 133) {
             $number = 8230;
         } elseif ($number == 134) {
             $number = 8224;
         } elseif ($number == 135) {
             $number = 8225;
         } elseif ($number == 136) {
             $number = 710;
         } elseif ($number == 137) {
             $number = 8240;
         } elseif ($number == 138) {
             $number = 352;
         } elseif ($number == 139) {
             $number = 8249;
         } elseif ($number == 140) {
             $number = 338;
         } elseif ($number == 141) {
             $number = 160;
         } elseif ($number == 142) {
             $number = 381;
         } elseif ($number == 143) {
             $number = 160;
         } elseif ($number == 144) {
             $number = 160;
         } elseif ($number == 145) {
             $number = 8216;
         } elseif ($number == 146) {
             $number = 8217;
         } elseif ($number == 147) {
             $number = 8220;
         } elseif ($number == 148) {
             $number = 8221;
         } elseif ($number == 149) {
             $number = 8226;
         } elseif ($number == 150) {
             $number = 8211;
         } elseif ($number == 151) {
             $number = 8212;
         } elseif ($number == 152) {
             $number = 732;
         } elseif ($number == 153) {
             $number = 8482;
         } elseif ($number == 154) {
             $number = 353;
         } elseif ($number == 155) {
             $number = 8250;
         } elseif ($number == 156) {
             $number = 339;
         } elseif ($number == 157) {
             $number = 160;
         } elseif ($number == 158) {
             $number = 382;
         } elseif ($number == 159) {
             $number = 376;
         }
     }
     //if
     if ($number < 2048) {
         return unichr(($number >> 6) + 192) . unichr(($number & 63) + 128);
     }
     if ($number < 65536) {
         return unichr(($number >> 12) + 224) . unichr(($number >> 6 & 63) + 128) . unichr(($number & 63) + 128);
     }
     if ($number < 2097152) {
         return unichr(($number >> 18) + 240) . unichr(($number >> 12 & 63) + 128) . unichr(($number >> 6 & 63) + 128) . chr(($number & 63) + 128);
     }
     return FALSE;
 }
}
$entity_files = array();
while (($file = readdir($dh)) !== false) {
    if (@$file[0] === '.') {
        continue;
    }
    if (substr(strrchr($file, "."), 1) !== 'ent') {
        continue;
    }
    $entity_files[] = $file;
}
closedir($dh);
if (!$entity_files) {
    exit("Fatal Error: No entity files to parse.\n");
}
$entity_table = array();
$regexp = '/<!ENTITY\\s+([A-Za-z0-9]+)\\s+"&#(?:38;#)?([0-9]+);">/';
foreach ($entity_files as $file) {
    $contents = file_get_contents($entity_dir . $file);
    $matches = array();
    preg_match_all($regexp, $contents, $matches, PREG_SET_ORDER);
    foreach ($matches as $match) {
        $entity_table[$match[1]] = unichr($match[2]);
    }
}
$output = serialize($entity_table);
$fh = fopen($output_file, 'w');
fwrite($fh, $output);
fclose($fh);
echo "Completed successfully.";
// vim: et sw=4 sts=4
 /**
  * Function for handling the {{\#fromcodepoint }} parser function.
  */
 public static function doFromCodepoint($parser, $codepoint, $base = 10)
 {
     if (!is_numeric($base)) {
         $base = 10;
     }
     $value = intval($codepoint, $base);
     if ($value < 1) {
         $error_msg = array('Invalid codepoint', $codepoint);
         return smwfEncodeMessages($error_msg);
     }
     return unichr($value);
 }
 * @license   LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link      http://www.ar-php.org 
 */
/**
 * Function to convert the code points to entites.
 *  
 * @param integer $u HTML entity number for Arabic character
 *                    
 * @return string Returns convert Arabic character encoding 
 *                from HTML entities to UTF-8
 */
function unichr($u)
{
    return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}
/**
 * A map of Arabic attached forms of characters to original characters
 */
$ligature_map = array(unichr(0xfe80) => unichr(0x621), unichr(0xfe81) => unichr(0x622), unichr(0xfe82) => unichr(0x622), unichr(0xfe83) => unichr(0x623), unichr(0xfe84) => unichr(0x623), unichr(0xfe85) => unichr(0x624), unichr(0xfe86) => unichr(0x624), unichr(0xfe87) => unichr(0x625), unichr(0xfe88) => unichr(0x625), unichr(0xfe89) => unichr(0x626), unichr(0xfe8b) => unichr(0x626), unichr(0xfe8c) => unichr(0x626), unichr(0xfe8a) => unichr(0x626), unichr(0xfe8d) => unichr(0x627), unichr(0xfe8e) => unichr(0x627), unichr(0xfe8f) => unichr(0x628), unichr(0xfe91) => unichr(0x628), unichr(0xfe92) => unichr(0x628), unichr(0xfe90) => unichr(0x628), unichr(0xfe93) => unichr(0x629), unichr(0xfe94) => unichr(0x629), unichr(0xfe95) => unichr(0x62a), unichr(0xfe97) => unichr(0x62a), unichr(0xfe98) => unichr(0x62a), unichr(0xfe96) => unichr(0x62a), unichr(0xfe99) => unichr(0x62b), unichr(0xfe9b) => unichr(0x62b), unichr(0xfe9c) => unichr(0x62b), unichr(0xfe9a) => unichr(0x62b), unichr(0xfe9d) => unichr(0x62c), unichr(0xfe9f) => unichr(0x62c), unichr(0xfea0) => unichr(0x62c), unichr(0xfe9e) => unichr(0x62c), unichr(0xfea1) => unichr(0x62d), unichr(0xfea3) => unichr(0x62d), unichr(0xfea4) => unichr(0x62d), unichr(0xfea2) => unichr(0x62d), unichr(0xfea5) => unichr(0x62e), unichr(0xfea7) => unichr(0x62e), unichr(0xfea8) => unichr(0x62e), unichr(0xfea6) => unichr(0x62e), unichr(0xfea9) => unichr(0x62f), unichr(0xfeaa) => unichr(0x62f), unichr(0xfeab) => unichr(0x630), unichr(0xfeac) => unichr(0x630), unichr(0xfead) => unichr(0x631), unichr(0xfeae) => unichr(0x631), unichr(0xfeaf) => unichr(0x632), unichr(0xfeb0) => unichr(0x632), unichr(0xfeb1) => unichr(0x633), unichr(0xfeb3) => unichr(0x633), unichr(0xfeb4) => unichr(0x633), unichr(0xfeb2) => unichr(0x633), unichr(0xfeb5) => unichr(0x634), unichr(0xfeb7) => unichr(0x634), unichr(0xfeb8) => unichr(0x634), unichr(0xfeb6) => unichr(0x634), unichr(0xfeb9) => unichr(0x635), unichr(0xfebb) => unichr(0x635), unichr(0xfebc) => unichr(0x635), unichr(0xfeba) => unichr(0x635), unichr(0xfebd) => unichr(0x636), unichr(0xfebf) => unichr(0x636), unichr(0xfec0) => unichr(0x636), unichr(0xfebe) => unichr(0x636), unichr(0xfec1) => unichr(0x637), unichr(0xfec3) => unichr(0x637), unichr(0xfec4) => unichr(0x637), unichr(0xfec2) => unichr(0x637), unichr(0xfec5) => unichr(0x638), unichr(0xfec7) => unichr(0x638), unichr(0xfec8) => unichr(0x638), unichr(0xfec6) => unichr(0x638), unichr(0xfec9) => unichr(0x639), unichr(0xfecb) => unichr(0x639), unichr(0xfecc) => unichr(0x639), unichr(0xfeca) => unichr(0x639), unichr(0xfecd) => unichr(0x63a), unichr(0xfecf) => unichr(0x63a), unichr(0xfed0) => unichr(0x63a), unichr(0xfece) => unichr(0x63a), unichr(0x640) => unichr(0x640), unichr(0xfed1) => unichr(0x641), unichr(0xfed3) => unichr(0x641), unichr(0xfed4) => unichr(0x641), unichr(0xfed2) => unichr(0x641), unichr(0xfed5) => unichr(0x642), unichr(0xfed7) => unichr(0x642), unichr(0xfed8) => unichr(0x642), unichr(0xfed6) => unichr(0x642), unichr(0xfed9) => unichr(0x643), unichr(0xfedb) => unichr(0x643), unichr(0xfedc) => unichr(0x643), unichr(0xfeda) => unichr(0x643), unichr(0xfedd) => unichr(0x644), unichr(0xfedf) => unichr(0x644), unichr(0xfee0) => unichr(0x644), unichr(0xfede) => unichr(0x644), unichr(0xfee1) => unichr(0x645), unichr(0xfee3) => unichr(0x645), unichr(0xfee4) => unichr(0x645), unichr(0xfee2) => unichr(0x645), unichr(0xfee5) => unichr(0x646), unichr(0xfee7) => unichr(0x646), unichr(0xfee8) => unichr(0x646), unichr(0xfee6) => unichr(0x646), unichr(0xfee9) => unichr(0x647), unichr(0xfeeb) => unichr(0x647), unichr(0xfeec) => unichr(0x647), unichr(0xfeea) => unichr(0x647), unichr(0xfeed) => unichr(0x648), unichr(0xfeee) => unichr(0x648), unichr(0xfeef) => unichr(0x649), unichr(0xfef0) => unichr(0x649), unichr(0xfef1) => unichr(0x64a), unichr(0xfef3) => unichr(0x64a), unichr(0xfef4) => unichr(0x64a), unichr(0xfef2) => unichr(0x64a));
/**
 * Arabic unicode code points
 **/
$char_names = array('COMMA' => unichr(0x60c), 'SEMICOLON' => unichr(0x61b), 'QUESTION' => unichr(0x61f), 'HAMZA' => unichr(0x621), 'ALEF_MADDA' => unichr(0x622), 'ALEF_HAMZA_ABOVE' => unichr(0x623), 'WAW_HAMZA' => unichr(0x624), 'ALEF_HAMZA_BELOW' => unichr(0x625), 'YEH_HAMZA' => unichr(0x626), 'ALEF' => unichr(0x627), 'BEH' => unichr(0x628), 'TEH_MARBUTA' => unichr(0x629), 'TEH' => unichr(0x62a), 'THEH' => unichr(0x62b), 'JEEM' => unichr(0x62c), 'HAH' => unichr(0x62d), 'KHAH' => unichr(0x62e), 'DAL' => unichr(0x62f), 'THAL' => unichr(0x630), 'REH' => unichr(0x631), 'ZAIN' => unichr(0x632), 'SEEN' => unichr(0x633), 'SHEEN' => unichr(0x634), 'SAD' => unichr(0x635), 'DAD' => unichr(0x636), 'TAH' => unichr(0x637), 'ZAH' => unichr(0x638), 'AIN' => unichr(0x639), 'GHAIN' => unichr(0x63a), 'TATWEEL' => unichr(0x640), 'FEH' => unichr(0x641), 'QAF' => unichr(0x642), 'KAF' => unichr(0x643), 'LAM' => unichr(0x644), 'MEEM' => unichr(0x645), 'NOON' => unichr(0x646), 'HEH' => unichr(0x647), 'WAW' => unichr(0x648), 'ALEF_MAKSURA' => unichr(0x649), 'YEH' => unichr(0x64a), 'MADDA_ABOVE' => unichr(0x653), 'HAMZA_ABOVE' => unichr(0x654), 'HAMZA_BELOW' => unichr(0x655), 'ZERO' => unichr(0x660), 'ONE' => unichr(0x661), 'TWO' => unichr(0x662), 'THREE' => unichr(0x663), 'FOUR' => unichr(0x664), 'FIVE' => unichr(0x665), 'SIX' => unichr(0x666), 'SEVEN' => unichr(0x667), 'EIGHT' => unichr(0x668), 'NINE' => unichr(0x669), 'PERCENT' => unichr(0x66a), 'DECIMAL' => unichr(0x66b), 'THOUSANDS' => unichr(0x66c), 'STAR' => unichr(0x66d), 'MINI_ALEF' => unichr(0x670), 'ALEF_WASLA' => unichr(0x671), 'FULL_STOP' => unichr(0x6d4), 'BYTE_ORDER_MARK' => unichr(0xfeff), 'FATHATAN' => unichr(0x64b), 'DAMMATAN' => unichr(0x64c), 'KASRATAN' => unichr(0x64d), 'FATHA' => unichr(0x64e), 'DAMMA' => unichr(0x64f), 'KASRA' => unichr(0x650), 'SHADDA' => unichr(0x651), 'SUKUN' => unichr(0x652), 'SMALL_ALEF' => unichr(0x670), 'SMALL_WAW' => unichr(0x6e5), 'SMALL_YEH' => unichr(0x6e6), 'LAM_ALEF' => unichr(0xfefb), 'LAM_ALEF_HAMZA_ABOVE' => unichr(0xfef7), 'LAM_ALEF_HAMZA_BELOW' => unichr(0xfef9), 'LAM_ALEF_MADDA_ABOVE' => unichr(0xfef5), 'simple_LAM_ALEF' => unichr(0x644) . unichr(0x64e) . unichr(0x627), 'simple_LAM_ALEF_HAMZA_ABOVE' => unichr(0x644) . unichr(0x623), 'simple_LAM_ALEF_HAMZA_BELOW' => unichr(0x644) . unichr(0x625), 'simple_LAM_ALEF_MADDA_ABOVE' => unichr(0x644) . unichr(0x621) . unichr(0x64e) . unichr(0x627));
/**
 * Arabic char groups
 **/
$char_groups = array('LETTER' => array('ALEF', 'BEH', 'TEH', 'TEH_MARBUTA', 'THEH', 'JEEM', 'HAH', 'KHAH', 'DAL', 'THAL', 'REH', 'ZAIN', 'SEEN', 'SHEEN', 'SAD', 'DAD', 'TAH', 'ZAH', 'AIN', 'GHAIN', 'FEH', 'QAF', 'KAF', 'LAM', 'MEEM', 'NOON', 'HEH', 'WAW', 'YEH', 'HAMZA', 'ALEF_MADDA', 'ALEF_HAMZA_ABOVE', 'WAW_HAMZA', 'ALEF_HAMZA_BELOW', 'YEH_HAMZA'), 'TASHKEEL' => array('FATHATAN', 'DAMMATAN', 'KASRATAN', 'FATHA', 'DAMMA', 'KASRA', 'SUKUN', 'SHADDA'), 'HARAKAT' => array('FATHATAN', 'DAMMATAN', 'KASRATAN', 'FATHA', 'DAMMA', 'KASRA', 'SUKUN'), 'SHORTHARAKAT' => array('FATHA', 'DAMMA', 'KASRA', 'SUKUN'), 'TANWIN' => array('FATHATAN', 'DAMMATAN', 'KASRATAN'), 'LIGUATURES' => array('LAM_ALEF', 'LAM_ALEF_HAMZA_ABOVE', 'LAM_ALEF_HAMZA_BELOW', 'LAM_ALEF_MADDA_ABOVE'), 'HAMZAT' => array('HAMZA', 'WAW_HAMZA', 'YEH_HAMZA', 'HAMZA_ABOVE', 'HAMZA_BELOW', 'ALEF_HAMZA_BELOW', 'ALEF_HAMZA_ABOVE'), 'ALEFAT' => array('ALEF', 'ALEF_MADDA', 'ALEF_HAMZA_ABOVE', 'ALEF_HAMZA_BELOW', 'ALEF_WASLA', 'ALEF_MAKSURA', 'SMALL_ALEF'), 'WEAK' => array('ALEF', 'WAW', 'YEH', 'ALEF_MAKSURA'), 'YEHLIKE' => array('YEH', 'YEH_HAMZA', 'ALEF_MAKSURA', 'SMALL_YEH'), 'WAWLIKE' => array('WAW', 'WAW_HAMZA', 'SMALL_WAW'), 'TEHLIKE' => array('TEH', 'TEH_MARBUTA'), 'SMALL' => array('SMALL_ALEF', 'SMALL_WAW', 'SMALL_YEH'), 'MOON' => array('HAMZA', 'ALEF_MADDA', 'ALEF_HAMZA_ABOVE', 'ALEF_HAMZA_BELOW', 'ALEF', 'BEH', 'JEEM', 'HAH', 'KHAH', 'AIN', 'GHAIN', 'FEH', 'QAF', 'KAF', 'MEEM', 'HEH', 'WAW', 'YEH'), 'SUN' => array('TEH', 'THEH', 'DAL', 'THAL', 'REH', 'ZAIN', 'SEEN', 'SHEEN', 'SAD', 'DAD', 'TAH', 'ZAH', 'LAM', 'NOON'));
/**
 * Arabic char names
 **/
$char_ar_names = array('ALEF' => 'ألف', 'BEH' => 'باء', 'TEH' => 'تاء', 'TEH_MARBUTA' => 'تاء مربوطة', 'THEH' => 'ثاء', 'JEEM' => 'جيم', 'HAH' => 'حاء', 'KHAH' => 'خاء', 'DAL' => 'دال', 'THAL' => 'ذال', 'REH' => 'راء', 'ZAIN' => 'زاي', 'SEEN' => 'سين', 'SHEEN' => 'شين', 'SAD' => 'صاد', 'DAD' => 'ضاد', 'TAH' => 'طاء', 'ZAH' => 'ظاء', 'AIN' => 'عين', 'GHAIN' => 'غين', 'FEH' => 'فاء', 'QAF' => 'قاف', 'KAF' => 'كاف', 'LAM' => 'لام', 'MEEM' => 'ميم', 'NOON' => 'نون', 'HEH' => 'هاء', 'WAW' => 'واو', 'YEH' => 'ياء', 'HAMZA' => 'همزة', 'TATWEEL' => 'تطويل', 'ALEF_MADDA' => 'ألف ممدودة', 'ALEF_MAKSURA' => 'ألف مقصورة', 'ALEF_HAMZA_ABOVE' => 'همزة على الألف', 'WAW_HAMZA' => 'همزة على الواو', 'ALEF_HAMZA_BELOW' => 'همزة تحت الألف', 'YEH_HAMZA' => 'همزة على الياء', 'FATHATAN' => 'فتحتان', 'DAMMATAN' => 'ضمتان', 'KASRATAN' => 'كسرتان', 'FATHA' => 'فتحة', 'DAMMA' => 'ضمة', 'KASRA' => 'كسرة', 'SHADDA' => 'شدة', 'SUKUN' => 'سكون');
Example #10
0
			<th>6</th>
			<th>7</th>
			<th>8</th>
			<th>9</th>
			<th>a</th>
			<th>b</th>
			<th>c</th>
			<th>d</th>
			<th>e</th>
			<th>f</th>';
    }
    if ($mod16 == 0) {
        $floor = floor($i / 16);
        printf('</tr><tr><th class="left">%03s</th>', dechex($floor));
    }
    $chr = unichr($i);
    $entity = htmlentities($chr, ENT_NOQUOTES, 'UTF-8');
    if (!mb_strpos($entity, ';')) {
        $entity = "<span>&#{$i};</span>";
    }
    switch ($chr) {
        case ' ':
            $chr = '<code>[space]</code>';
            break;
        case "\n":
            $chr = '<code>[\\n]</code>';
            break;
        case "\r":
            $chr = '<code>[\\r]</code>';
            break;
        case "\t":
Example #11
0
/**
* A subroutine of make_clickable used with preg_replace
* It places correct HTML around an url, shortens the displayed text
* and makes sure no entities are inside URLs
*/
function make_clickable_callback($type, $whitespace, $url, $relative_url, $class)
{
    $orig_url = $url;
    $orig_relative = $relative_url;
    $append = '';
    $url = htmlspecialchars_decode($url);
    $relative_url = htmlspecialchars_decode($relative_url);
    // make sure no HTML entities were matched
    $chars = array('<', '>', '"');
    $split = false;
    foreach ($chars as $char) {
        $next_split = strpos($url, $char);
        if ($next_split !== false) {
            $split = $split !== false ? min($split, $next_split) : $next_split;
        }
    }
    if ($split !== false) {
        // an HTML entity was found, so the URL has to end before it
        $append = substr($url, $split) . $relative_url;
        $url = substr($url, 0, $split);
        $relative_url = '';
    } else {
        if ($relative_url) {
            // same for $relative_url
            $split = false;
            foreach ($chars as $char) {
                $next_split = strpos($relative_url, $char);
                if ($next_split !== false) {
                    $split = $split !== false ? min($split, $next_split) : $next_split;
                }
            }
            if ($split !== false) {
                $append = substr($relative_url, $split);
                $relative_url = substr($relative_url, 0, $split);
            }
        }
    }
    // if the last character of the url is a punctuation mark, exclude it from the url
    $last_char = $relative_url ? $relative_url[strlen($relative_url) - 1] : $url[strlen($url) - 1];
    switch ($last_char) {
        case '.':
        case '?':
        case '!':
        case ':':
        case ',':
            $append = $last_char;
            if ($relative_url) {
                $relative_url = substr($relative_url, 0, -1);
            } else {
                $url = substr($url, 0, -1);
            }
            break;
            // set last_char to empty here, so the variable can be used later to
            // check whether a character was removed
        // set last_char to empty here, so the variable can be used later to
        // check whether a character was removed
        default:
            $last_char = '';
            break;
    }
    $short_url = utf8_strlen($url) > 55 ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url;
    switch ($type) {
        case MAGIC_URL_DDNET:
            $tag = 'm';
            $text = '';
            $t = 0;
            $i = 0;
            $chars = str_split(preg_replace('#.*?/([^/]*)/?$#', '$1', $url));
            foreach ($chars as $c) {
                if ($t == 0) {
                    if (strcmp($c, '-') == 0) {
                        $t = 1;
                    } else {
                        $text .= $c;
                    }
                } else {
                    if (strcmp($c, '-') == 0) {
                        $text .= unichr($i);
                        $t = 0;
                        $i = 0;
                    } else {
                        $i = $i * 10 + (int) $c;
                    }
                }
            }
            break;
        case MAGIC_URL_LOCAL:
            $tag = 'l';
            $relative_url = preg_replace('/[&?]sid=[0-9a-f]{32}$/', '', preg_replace('/([&?])sid=[0-9a-f]{32}&/', '$1', $relative_url));
            $url = $url . '/' . $relative_url;
            $text = $relative_url;
            // this url goes to http://domain.tld/path/to/board/ which
            // would result in an empty link if treated as local so
            // don't touch it and let MAGIC_URL_FULL take care of it.
            if (!$relative_url) {
                return $whitespace . $orig_url . '/' . $orig_relative;
                // slash is taken away by relative url pattern
            }
            break;
        case MAGIC_URL_FULL:
            $tag = 'm';
            $text = $short_url;
            break;
        case MAGIC_URL_WWW:
            $tag = 'w';
            $url = 'http://' . $url;
            $text = $short_url;
            break;
        case MAGIC_URL_EMAIL:
            $tag = 'e';
            $text = $short_url;
            $url = 'mailto:' . $url;
            break;
    }
    $url = htmlspecialchars($url);
    $text = htmlspecialchars($text);
    $append = htmlspecialchars($append);
    $html = "{$whitespace}<!-- {$tag} --><a{$class} href=\"{$url}\">{$text}</a><!-- {$tag} -->{$append}";
    return $html;
}
Example #12
0
    'MINI_ALEF' => unichr(0x0670),
    'ALEF_WASLA' => unichr(0x0671),
    'FULL_STOP' => unichr(0x06d4),
    'BYTE_ORDER_MARK' => unichr(0xfeff),

    //Diacritics
    'FATHATAN' => unichr(0x064B),
    'DAMMATAN' => unichr(0x064C),
    'KASRATAN' => unichr(0x064D),
    'FATHA' => unichr(0x064E),
    'DAMMA' => unichr(0x064F),
    'KASRA' => unichr(0x0650),
    'SHADDA' => unichr(0x0651),
    'SUKUN' => unichr(0x0652),

    'SMALL_ALEF' => unichr(0x0670),
    'SMALL_WAW' => unichr(0x06E5),
    'SMALL_YEH' => unichr(0x06E6),

    //Ligatures
    'LAM_ALEF' => unichr(0xFEFb),
    'LAM_ALEF_HAMZA_ABOVE' => unichr(0xFEF7),
    'LAM_ALEF_HAMZA_BELOW' => unichr(0xFEF9),
    'LAM_ALEF_MADDA_ABOVE' => unichr(0xFEF5),
    'simple_LAM_ALEF' => unichr(0x0644).unichr(0x064E).unichr(0x0627),
    'simple_LAM_ALEF_HAMZA_ABOVE' => unichr(0x0644).unichr(0x0623),
    'simple_LAM_ALEF_HAMZA_BELOW' => unichr(0x0644).unichr(0x0625),
    'simple_LAM_ALEF_MADDA_ABOVE' => unichr(0x0644).unichr(0x0621).
                                     unichr(0x064E).unichr(0x0627)
);
Example #13
0
 /**
  * Convert a unicode character number to a unicode string. Callback for preg_replace.
  *
  * @param  array					Regular expression match array.
  * @return ~string				Converted data (false: could not convert).
  */
 function unichrm($matches)
 {
     return unichr(intval($matches[1]));
 }
Example #14
0
$content = file_get_contents($file_to_convert);
// handle :some_emoji:
$content = preg_replace_callback('/:([a-zA-Z0-9\\+\\-_&.ô’Åéãíç]+):/', function ($match) {
    global $g_emoji_unicode;
    $str_code = $match[1];
    if (!isset($g_emoji_unicode[$str_code])) {
        return ':' . $str_code . ':';
    }
    $unicode_code = $g_emoji_unicode[$str_code];
    $unicode_image_name = ltrim(strtolower($unicode_code), "\\Uu0") . '.png';
    return '<img class="emoji" title=":' . $match[1] . ':" alt=":' . $match[1] . ':" src="' . EMOJI_PNG_ROOT . $unicode_image_name . '" height="20" width="20" align="absmiddle" />';
}, $content);
// handle <unicode character>
// see http://stackoverflow.com/a/10584493/488666
// see https://en.wikipedia.org/wiki/Emoji#Unicode_Blocks
$content = preg_replace_callback('/[' . unichr(0x1f300) . '-' . unichr(0x1f5ff) . unichr(0x1f600) . '-' . unichr(0x1f64f) . unichr(0x1f680) . '-' . unichr(0x1f6f3) . unichr(0x1f910) . '-' . unichr(0x1f918) . unichr(0x1f980) . '-' . unichr(0x1f984) . unichr(0x1f9c0) . unichr(0x2600) . '-' . unichr(0x27bf) . ']/u', function ($match) {
    $unicode_image_name = strtolower(dechex(intval(uniord($match[0])))) . '.png';
    return '<img class="emoji" src="' . EMOJI_PNG_ROOT . $unicode_image_name . '" height="20" width="20" align="absmiddle" />';
}, $content);
file_put_contents($file_to_convert, $content);
// -----------------------------------------
function unichr($i)
{
    return iconv('UCS-4LE', 'UTF-8', pack('V', $i));
}
// found at http://www.php.net/manual/en/function.ord.php
function uniord($string, &$offset = 0)
{
    $code = ord(substr($string, $offset, 1));
    if ($code >= 128) {
        //otherwise 0xxxxxxx
function lzw_decompress($compressed)
{
    // Build the dictionary.
    $dictSize = 256;
    $dictionary = array();
    for ($i = 0; $i < $dictSize; $i++) {
        $dictionary[$i] = unichr($i);
        //$e = new mb_exception('dictionary['.$i.']:'.$dictionary[$i]);
    }
    $w = (string) unichr($compressed[0]);
    $result = $w;
    for ($i = 1; $i < count($compressed); $i++) {
        $entry = "";
        $k = $compressed[$i];
        if (isset($dictionary[$k])) {
            //whats with null?
            $entry = $dictionary[$k];
        } else {
            if ($k == $dictSize) {
                $entry = $w . $w[0];
            } else {
            }
        }
        $result = $result . $entry;
        $dictionary[$dictSize++] = $w . $entry[0];
        //for the first time 256 after that it will be increased
        $w = $entry;
    }
    return $result;
}
Example #16
0
/**
 * strrchr
 */
function _ml_strrchr($haystack, $needle)
{
    global $application;
    if (!$application->multilang_core->_mb_enabled) {
        return strrchr($haystack, $needle);
    }
    if (!is_string($needle)) {
        $needle = unichr(intval($needle));
    }
    $needle = _ml_substr($needle, 0, 1);
    if (_ml_strpos($haystack, $needle) === false) {
        return false;
    }
    $result = explode($needle, $haystack);
    $result = array_pop($result);
    return $needle . $result;
}
Example #17
0
         echo json_encode($lang->complex_password_fails);
     } else {
         // Return nothing but an OK password if passes regex
         echo json_encode("true");
     }
     exit;
 } else {
     if ($mybb->input['action'] == "username_availability") {
         if (!verify_post_check($mybb->get_input('my_post_key'), true)) {
             xmlhttp_error($lang->invalid_post_code);
         }
         require_once MYBB_ROOT . "inc/functions_user.php";
         $username = $mybb->get_input('username');
         // Fix bad characters
         $username = trim_blank_chrs($username);
         $username = str_replace(array(unichr(160), unichr(173), unichr(0xca), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);
         // Remove multiple spaces from the username
         $username = preg_replace("#\\s{2,}#", " ", $username);
         header("Content-type: application/json; charset={$charset}");
         if (empty($username)) {
             echo json_encode($lang->banned_characters_username);
             exit;
         }
         // Check if the username belongs to the list of banned usernames.
         $banned_username = is_banned_username($username, true);
         if ($banned_username) {
             echo json_encode($lang->banned_username);
             exit;
         }
         // Check for certain characters in username (<, >, &, and slashes)
         if (strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false)) {
Example #18
0
    tg_reply(unichr(0x1f44b) . " " . $name);
} elseif (strpos(strtolower($text), 'rael') !== false) {
    tg_reply(unichr(0x1f440) . " @raelga");
} elseif (strpos($text, '/ola') !== false) {
    tg_reply("ola k ase " . $name);
} elseif (strpos(strtolower($text), 'xur') !== false) {
    tg_sendPhoto($xurmap);
} elseif (strpos(strtolower($text), 'tetas') !== false) {
    tg_reply("Se refiere a tetas como parte del cuerpo, libre de connotaciones sexuales. Seguro que " . $name . " siempre piensa en los niños.");
} elseif (strpos(strtolower($text), 'teta') !== false) {
    tg_reply("Se refiere a teta como parte del cuerpo, libre de connotaciones sexuales. Seguro que " . $name . " siempre piensa en los niños.");
} elseif (strpos(strtolower($text), 'windows') !== false) {
    tg_reply("windows es caca");
} elseif (strpos(strtolower($text), 'necraf') !== false) {
    tg_reply("minecraft es caca");
} elseif (strpos(strtolower($text), "nos días") !== false) {
    tg_reply("Buenos días " . $name . "! " . unichr(0x2600));
} elseif (strpos(strtolower($text), "nas tard") !== false) {
    tg_reply("Buenas tardes " . $name . "! " . unichr(0x1f307));
} elseif (strpos(strtolower(preg_replace("/[^a-zA-Z0-9]+/", "", $text)), "nosdias") !== false) {
    tg_reply("Buenos días " . $name . "! " . unichr(0x2600));
} elseif (strpos(strtolower(preg_replace("/[^a-zA-Z0-9]+/", "", $text)), "nasnoches") !== false) {
    tg_reply("Buenas noches " . $name . "! " . unichr(0x1f319));
} elseif (strpos(strtolower($text), 'assassins') !== false) {
    tg_reply("assassins creed caca");
} else {
    $msg = "";
    //tg_reply("[".$text."]");
}
$file = 'file.txt';
file_put_contentS($file, $rdata, FILE_APPEND);