コード例 #1
1
ファイル: function_home.php プロジェクト: upyun/discuz-plugin
function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $bbcode = 0, $html = 0)
{
    global $_G;
    $string = trim($string);
    $sppos = strpos($string, chr(0) . chr(0) . chr(0));
    if ($sppos !== false) {
        $string = substr($string, 0, $sppos);
    }
    if ($in_slashes) {
        $string = dstripslashes($string);
    }
    $string = preg_replace("/\\[hide=?\\d*\\](.*?)\\[\\/hide\\]/is", '', $string);
    if ($html < 0) {
        $string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string);
    } elseif ($html == 0) {
        $string = dhtmlspecialchars($string);
    }
    if ($length) {
        $string = cutstr($string, $length);
    }
    if ($bbcode) {
        require_once DISCUZ_ROOT . './source/class/class_bbcode.php';
        $bb =& bbcode::instance();
        $string = $bb->bbcode2html($string, $bbcode);
    }
    if ($out_slashes) {
        $string = daddslashes($string);
    }
    return trim($string);
}
コード例 #2
1
function wsOnMessage($clientID, $message, $messageLength, $binary)
{
    global $Server;
    $ip = long2ip($Server->wsClients[$clientID][6]);
    // check if message length is 0
    if ($messageLength == 0) {
        $Server->wsClose($clientID);
        return;
    }
    //The speaker is the only person in the room. Don't let them feel lonely.
    if (sizeof($Server->wsClients) == 1) {
        $Server->wsSend($clientID, "There isn't anyone else in the room, but I'll still listen to you. --Your Trusty Server");
    } else {
        //Send the message to everyone but the person who said it
        foreach ($Server->wsClients as $id => $client) {
            if ($id != $clientID) {
                $Server->wsSend($id, "{$message}");
            }
        }
    }
    //and to arduino forst decoding mesage and sending only one byte
    if ("{$message}" == "arduino1") {
        `mode com4: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
        $fp = fopen("com4", "w+");
        fwrite($fp, chr(0x1));
        fclose($fp);
    }
}
コード例 #3
1
ファイル: BatchInsert.php プロジェクト: brienomatty/elmsln
 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
  * @param array $fields array of unquoted field names
  * @param array $values array of data to be inserted
  * @param bool $throwException Whether to throw an exception that was caught while trying
  *                                LOAD DATA INFILE, or not.
  * @throws Exception
  * @return bool  True if the bulk LOAD was used, false if we fallback to plain INSERTs
  */
 public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
 {
     $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
     $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
     $loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
     if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
         try {
             $fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
                 return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
             }, 'eol' => "\r\n", 'null' => 'NULL');
             // hack for charset mismatch
             if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
                 $fileSpec['charset'] = 'latin1';
             }
             self::createCSVFile($filePath, $fileSpec, $values);
             if (!is_readable($filePath)) {
                 throw new Exception("File {$filePath} could not be read.");
             }
             $rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
             if ($rc) {
                 unlink($filePath);
                 return true;
             }
         } catch (Exception $e) {
             Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
             if ($throwException) {
                 throw $e;
             }
         }
     }
     // if all else fails, fallback to a series of INSERTs
     @unlink($filePath);
     self::tableInsertBatchIterate($tableName, $fields, $values);
     return false;
 }
コード例 #4
1
ファイル: FdfFile.php プロジェクト: aviddv1/php-pdftk
 /**
  * Constructor
  *
  * @param array $data the form data as name => value
  * @param string|null $suffix the optional suffix for the tmp file
  * @param string|null $suffix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
  * @param string|null $directory directory where the file should be created. Autodetected if not provided.
  * @param string|null $encoding of the data. Default is 'UTF-8'.
  */
 public function __construct($data, $suffix = null, $prefix = null, $directory = null, $encoding = 'UTF-8')
 {
     if ($directory === null) {
         $directory = self::getTempDir();
     }
     $suffix = '.fdf';
     $prefix = 'php_pdftk_fdf_';
     $this->_fileName = tempnam($directory, $prefix);
     $newName = $this->_fileName . $suffix;
     rename($this->_fileName, $newName);
     $this->_fileName = $newName;
     $fields = '';
     foreach ($data as $key => $value) {
         // Create UTF-16BE string encode as ASCII hex
         // See http://blog.tremily.us/posts/PDF_forms/
         $utf16Value = mb_convert_encoding($value, 'UTF-16BE', $encoding);
         /* Also create UTF-16BE encoded key, this allows field names containing
          * german umlauts and most likely many other "special" characters.
          * See issue #17 (https://github.com/mikehaertl/php-pdftk/issues/17)
          */
         $utf16Key = mb_convert_encoding($key, 'UTF-16BE', $encoding);
         // Escape parenthesis
         $utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
         $fields .= "<</T(" . chr(0xfe) . chr(0xff) . $utf16Key . ")/V(" . chr(0xfe) . chr(0xff) . $utf16Value . ")>>\n";
     }
     // Use fwrite, since file_put_contents() messes around with character encoding
     $fp = fopen($this->_fileName, 'w');
     fwrite($fp, self::FDF_HEADER);
     fwrite($fp, $fields);
     fwrite($fp, self::FDF_FOOTER);
     fclose($fp);
 }
コード例 #5
0
ファイル: Converter.php プロジェクト: robertboloc/zf2
 /**
  * Converts all Hex expressions ("\HEX") to their original ASCII characters
  *
  * @see    Net_LDAP2_Util::hex2asc() from Benedikt Hallinger <*****@*****.**>,
  *         heavily based on work from DavidSmith@byu.net
  * @link   http://pear.php.net/package/Net_LDAP2
  * @author Benedikt Hallinger <*****@*****.**>, heavily based on work from DavidSmith@byu.net
  *
  * @param string $string String to convert
  * @return string
  */
 public static function hex32ToAsc($string)
 {
     $string = preg_replace_callback('/\\\\([0-9A-Fa-f]{2})/', function ($matches) {
         return chr(hexdec($matches[1]));
     }, $string);
     return $string;
 }
コード例 #6
0
ファイル: complete.php プロジェクト: armoving/nayaritenlinea
function sendNotificationIOS()
{
    // Put your device token here (without spaces):
    $deviceToken = '87d4477b81a7f8f7ba80b3f5f043d83dec3c9b0940c708d24f803ef67600966f';
    // Put your private key's passphrase here:
    $passphrase = 'pushchat';
    // Put your alert message here:
    $message = 'My first push notification!';
    ////////////////////////////////////////////////////////////////////////////////
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
    stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
    // Open a connection to the APNS server
    $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
    if (!$fp) {
        exit("Failed to connect: {$err} {$errstr}" . PHP_EOL);
    }
    echo 'Connected to APNS' . PHP_EOL;
    // Create the payload body
    $body['aps'] = array('alert' => $message, 'sound' => 'default');
    // Encode the payload as JSON
    $payload = json_encode($body);
    // Build the binary notification
    $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
    // Send it to the server
    $result = fwrite($fp, $msg, strlen($msg));
    if (!$result) {
        echo 'Message not delivered' . PHP_EOL;
    } else {
        echo 'Message successfully delivered' . PHP_EOL;
    }
    // Close the connection to the server
    fclose($fp);
}
コード例 #7
0
ファイル: unicodeTest.php プロジェクト: nlegoff/Phraseanet
 /**
  * @covers \unicode::substituteCtrlCharacters
  */
 public function testSubstituteCtrlCharacters()
 {
     $string = 'Hello' . chr(30) . 'World !';
     $this->assertEquals('Hello+World !', $this->object->substituteCtrlCharacters($string, '+'));
     $string = 'Hello' . chr(9) . 'World !';
     $this->assertEquals($string, $this->object->substituteCtrlCharacters($string, '+'));
 }
コード例 #8
0
 function u2utf8($c)
 {
     $str = '';
     if ($c < 0x80) {
         $str .= $c;
     } else {
         if ($c < 0x800) {
             $str .= chr(0xc0 | $c >> 6);
             $str .= chr(0x80 | $c & 0x3f);
         } else {
             if ($c < 0x10000) {
                 $str .= chr(0xe0 | $c >> 12);
                 $str .= chr(0x80 | $c >> 6 & 0x3f);
                 $str .= chr(0x80 | $c & 0x3f);
             } else {
                 if ($c < 0x200000) {
                     $str .= chr(0xf0 | $c >> 18);
                     $str .= chr(0x80 | $c >> 12 & 0x3f);
                     $str .= chr(0x80 | $c >> 6 & 0x3f);
                     $str .= chr(0x80 | $c & 0x3f);
                 }
             }
         }
     }
     return $str;
 }
コード例 #9
0
 protected function setUp()
 {
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineOrmTestCase::createTestEntityManager();
     parent::setUp();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::ENTITY_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $ids = range(1, 300);
     foreach ($ids as $id) {
         $name = 65 + chr($id % 57);
         $this->em->persist(new SingleIdentEntity($id, $name));
     }
     $this->em->flush();
 }
コード例 #10
0
ファイル: RunLength.php プロジェクト: rapsli/404crawler
 /**
  * Encode data
  *
  * @param string $data
  * @param array $params
  * @return string
  * @throws Zend_Pdf_Exception
  */
 public static function encode($data, $params = null)
 {
     $output = '';
     $chainStartOffset = 0;
     $offset = 0;
     while ($offset < strlen($data)) {
         // Do not encode 2 char chains since they produce 2 char run sequence,
         // but it takes more time to decode such output (because of processing additional run)
         if (($repeatedCharChainLength = strspn($data, $data[$offset], $offset + 1, 127) + 1) > 2) {
             if ($chainStartOffset != $offset) {
                 // Drop down previouse (non-repeatable chars) run
                 $output .= chr($offset - $chainStartOffset - 1) . substr($data, $chainStartOffset, $offset - $chainStartOffset);
             }
             $output .= chr(257 - $repeatedCharChainLength) . $data[$offset];
             $offset += $repeatedCharChainLength;
             $chainStartOffset = $offset;
         } else {
             $offset++;
             if ($offset - $chainStartOffset == 128) {
                 // Maximum run length is reached
                 // Drop down non-repeatable chars run
                 $output .= "" . substr($data, $chainStartOffset, 128);
                 $chainStartOffset = $offset;
             }
         }
     }
     if ($chainStartOffset != $offset) {
         // Drop down non-repeatable chars run
         $output .= chr($offset - $chainStartOffset - 1) . substr($data, $chainStartOffset, $offset - $chainStartOffset);
     }
     $output .= "€";
     return $output;
 }
コード例 #11
0
ファイル: rc4Encrypt.php プロジェクト: sourcefabric/newscoop
function rc4($key, $text)
{
    $kl = strlen($key);
    $s = array();
    for ($i = 0; $i < 256; $i++) {
        $s[$i] = $i;
    }
    $y = 0;
    for ($j = 0; $j < 2; $j++) {
        for ($x = 0; $x < 256; $x++) {
            $y = (ord($key[$x % $kl]) + $s[$x] + $y) % 256;
            $t = $s[$x];
            $s[$x] = $s[$y];
            $s[$y] = $t;
        }
    }
    $z = '';
    for ($x = 0; $x < strlen($text); $x++) {
        $x2 = $x & 255;
        $y = $s[$x2] + $y & 255;
        $t = $s[$x2];
        $s[$x2] = $s[$y];
        $s[$y] = $t;
        $z .= chr(ord($text[$x]) ^ $s[($s[$x2] + $s[$y]) % 256]);
    }
    return $z;
}
コード例 #12
0
/**
 * UTF8::from_unicode
 *
 * @package    JsonApiApplication
 * @author     JsonApiApplication Team
 * @copyright  (c) 2007-2012 JsonApiApplication Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _from_unicode($arr)
{
    ob_start();
    $keys = array_keys($arr);
    foreach ($keys as $k) {
        // ASCII range (including control chars)
        if ($arr[$k] >= 0 and $arr[$k] <= 0x7f) {
            echo chr($arr[$k]);
        } elseif ($arr[$k] <= 0x7ff) {
            echo chr(0xc0 | $arr[$k] >> 6);
            echo chr(0x80 | $arr[$k] & 0x3f);
        } elseif ($arr[$k] == 0xfeff) {
            // nop -- zap the BOM
        } elseif ($arr[$k] >= 0xd800 and $arr[$k] <= 0xdfff) {
            // Found a surrogate
            throw new UTF8_Exception("UTF8::from_unicode: Illegal surrogate at index: ':index', value: ':value'", array(':index' => $k, ':value' => $arr[$k]));
        } elseif ($arr[$k] <= 0xffff) {
            echo chr(0xe0 | $arr[$k] >> 12);
            echo chr(0x80 | $arr[$k] >> 6 & 0x3f);
            echo chr(0x80 | $arr[$k] & 0x3f);
        } elseif ($arr[$k] <= 0x10ffff) {
            echo chr(0xf0 | $arr[$k] >> 18);
            echo chr(0x80 | $arr[$k] >> 12 & 0x3f);
            echo chr(0x80 | $arr[$k] >> 6 & 0x3f);
            echo chr(0x80 | $arr[$k] & 0x3f);
        } else {
            throw new UTF8_Exception("UTF8::from_unicode: Codepoint out of Unicode range at index: ':index', value: ':value'", array(':index' => $k, ':value' => $arr[$k]));
        }
    }
    $result = ob_get_contents();
    ob_end_clean();
    return $result;
}
コード例 #13
0
ファイル: moduleFunctions.php プロジェクト: dpredster/core
function num2alpha($n)
{
    for ($r = ""; $n >= 0; $n = intval($n / 26) - 1) {
        $r = chr($n % 26 + 0x41) . $r;
    }
    return $r;
}
コード例 #14
0
ファイル: auth.php プロジェクト: anggasap/saribhakti
 function do_login($username, $password, $jenis_kantor, $tgl, $dt, $nama_kantor)
 {
     $username = strtoupper($username);
     $password = strtoupper($password);
     $nama_lkm = $nama_kantor;
     $tgl = $tgl;
     $dt = $dt;
     // cek di database, ada ga?
     $this->CI->db->from('nasabah');
     $this->CI->db->where('nasabah_id', $username);
     $result = $this->CI->db->get();
     if ($result->num_rows() == 1) {
         $hasil = $result->result();
         foreach ($hasil as $row) {
             $arr = array('usr' => $row->nasabah_id, 'namaNasabah' => $row->nama_nasabah, 'pwd' => $row->password);
         }
         $m = '';
         $split_password = str_split($arr['pwd']);
         foreach ($split_password as $value) {
             $x = ord($value);
             $x = $x - 5;
             $x = chr($x);
             $m = $m . $x;
         }
         //$m = passowor dr sql
         if ($password == $m) {
             if ($m == '111111') {
                 $this->CI->load->helper('cookie');
                 $cookie1 = array('name' => 'userId', 'value' => $arr['usr'], 'expire' => time() + 86500);
                 set_cookie($cookie1);
                 $cookie2 = array('name' => 'namaUser', 'value' => $arr['namaNasabah'], 'expire' => time() + 86500);
                 set_cookie($cookie1);
                 $cookie3 = array('name' => 'namaLKM', 'value' => $nama_lkm, 'expire' => time() + 86500);
                 $cookie4 = array('name' => 'tglD', 'value' => $tgl, 'expire' => time() + 86500);
                 $cookie5 = array('name' => 'tglY', 'value' => $dt, 'expire' => time() + 86500);
                 set_cookie($cookie1);
                 set_cookie($cookie2);
                 set_cookie($cookie3);
                 set_cookie($cookie4);
                 set_cookie($cookie5);
                 redirect('main/vResetPassword');
             } else {
                 // end if $m=='111111'
                 $session_data = array('user_id' => $arr['usr'], 'nama' => $arr['namaNasabah'], 'level' => 2, 'tglD' => $tgl, 'tglY' => $dt, 'nama_lkm' => $nama_lkm);
                 // buat session
                 $this->CI->session->set_userdata($session_data);
                 $data_auth = array('pesan' => "Anda berhasil login.", 'bool' => true);
                 return $data_auth;
             }
         } else {
             //if($password==$m){
             $data_auth = array('pesan' => "Password anda salah.", 'bool' => false);
             return $data_auth;
             //  die("Maaf, Anda tidak berhak untuk mengakses halaman ini.");
         }
     } else {
         //end if($result->num_rows() == 1){
         return false;
     }
 }
コード例 #15
0
function cloudaddons_check()
{
    if (!function_exists('gzuncompress')) {
        cpmsg('cloudaddons_check_gzuncompress_error', '', 'error');
    }
    if (dfsockopen(CLOUDADDONS_WEBSITE_URL . '/image/logo.png', 4, '', '', false, CLOUDADDONS_DOWNLOAD_IP, 60) !== chr(0x89) . 'PNG') {
        cpmsg('cloudaddons_check_url_fopen_error', '', 'error');
    }
    if (dfsockopen(CLOUDADDONS_CHECK_URL . '/logo.png', 4, '', '', false, CLOUDADDONS_CHECK_IP, 60) !== chr(0x89) . 'PNG') {
        cpmsg('cloudaddons_check_url_fopen_error', '', 'error');
    }
    foreach (array('download', 'addonmd5') as $path) {
        $tmpdir = DISCUZ_ROOT . './data/' . $path . '/' . random(5);
        $tmpfile = $tmpdir . '/index.html';
        dmkdir($tmpdir, 0777);
        if (!is_dir($tmpdir) || !file_exists($tmpfile)) {
            cpmsg('cloudaddons_check_write_error', '', 'error');
        }
        @unlink($tmpfile);
        @rmdir($tmpdir);
        if (is_dir($tmpdir) || file_exists($tmpfile)) {
            cpmsg('cloudaddons_check_write_error', '', 'error');
        }
    }
}
コード例 #16
0
function enjumble($data)
{
    for ($i = 0; $i < strlen($data); $i++) {
        $data[$i] = chr(ord($data[$i]) + 1);
    }
    return base64_encode(gzdeflate($data, 9));
}
コード例 #17
0
 /**
  * Escape strings for safe use in an LDAP filter or DN
  *
  * @see RFC2254 define how string search filters must be represented
  * @see For PHP >= 5.6.0, ldap_escape() is a core function
  *
  * @author Chris Wright
  * @see https://github.com/DaveRandom/LDAPi/blob/master/src/global_functions.php
  *
  * @return String
  */
 private function escape($value, $ignore = '', $flags = 0)
 {
     if (function_exists('ldap_escape')) {
         return ldap_escape($value, $ignore, $flags);
     }
     $value = (string) $value;
     $ignore = (string) $ignore;
     $flags = (int) $flags;
     if ($value === '') {
         return '';
     }
     $char_list = array();
     if ($flags & self::LDAP_ESCAPE_FILTER) {
         $char_list = array("\\", "*", "(", ")", "");
     }
     if ($flags & self::LDAP_ESCAPE_DN) {
         $char_list = array_merge($char_list, array("\\", ",", "=", "+", "<", ">", ";", "\"", "#"));
     }
     if (!$char_list) {
         for ($i = 0; $i < 256; $i++) {
             $char_list[] = chr($i);
         }
     }
     $char_list = array_flip($char_list);
     for ($i = 0; isset($ignore[$i]); $i++) {
         unset($char_list[$ignore[$i]]);
     }
     foreach ($char_list as $k => &$v) {
         $v = sprintf('\\%02x', ord($k));
     }
     return strtr($value, $char_list);
 }
コード例 #18
0
ファイル: Encry.class.php プロジェクト: hdbaiyu/HDPHP
 /**
  * 位加密或解密
  * @param $string 加密或解密内容
  * @param $type 类型:1加密 2解密
  * @param $key
  * @return mixed|string
  */
 private static function cry($string, $type, $key)
 {
     self::createKey($key);
     $string = $type == 2 ? base64_decode($string) : substr(md5(self::$auth_key . $string), 0, 8) . $string;
     $str_len = strlen($string);
     $data = array();
     $auth_key_length = strlen(self::$auth_key);
     for ($i = 0; $i <= 256; $i++) {
         $data[$i] = ord(self::$auth_key[$i % $auth_key_length]);
     }
     $tmp = '';
     for ($i = $j = 1; $i < 256; $i++) {
         $j = $data[($i + $data[$i]) % 256];
         $tmp = $data[$i];
         $data[$i] = ord($data[$j]);
         $data[$j] = $tmp;
     }
     $code = '';
     $s = '';
     for ($n = $i = $j = 0; $i < $str_len; $i++) {
         $tmp = ($i + $i % 256) % 256;
         $j = $data[$tmp] % 256;
         $n = ($tmp + $j) % 256;
         $code = $data[($data[$j] + $data[$n]) % 256];
         $s .= chr(ord($string[$i]) ^ $code);
     }
     if ($type == 1) {
         return str_replace("=", "", base64_encode($s));
     } else {
         if (substr(md5(self::$auth_key . substr($s, 8)), 0, 8) == substr($s, 0, 8)) {
             return substr($s, 8);
         }
         return '';
     }
 }
コード例 #19
0
 /**
  * Convert character code to UTF-8 character
  *
  * @param int $charCode
  *
  * @return string
  */
 public static function toUTF8Character($charCode)
 {
     switch ($charCode) {
         case 0:
             $char = chr(0);
             break;
         case !($charCode & 0xffffff80):
             // 7 bit
             $char = chr($charCode);
             break;
         case !($charCode & 0xfffff800):
             // 11 bit
             $char = chr(0xc0 | $charCode >> 6 & 0x1f) . chr(0x80 | $charCode & 0x3f);
             break;
         case !($charCode & 0xffff0000):
             // 16 bit
             $char = chr(0xe0 | $charCode >> 12 & 0xf) . chr(0x80 | $charCode >> 6 & 0x3f) . chr(0x80 | $charCode & 0x3f);
             break;
         case !($charCode & 0xffe00000):
             // 21 bit
             $char = chr(0xf0 | $charCode >> 18 & 0x7) . chr(0x80 | $charCode >> 12 & 0x3f) . chr(0x80 | $charCode >> 6 & 0x3f) . chr(0x80 | $charCode & 0x3f);
             break;
         case !($charCode & 0xfc000000):
             // 26 bit
             $char = chr(0xf8 | $charCode >> 24 & 0x3) . chr(0x80 | $charCode >> 18 & 0x3f) . chr(0x80 | $charCode >> 12 & 0x3f) . chr(0x80 | $charCode >> 6 & 0x3f) . chr(0x80 | $charCode & 0x3f);
             break;
         default:
             // 31 bit
             $char = chr(0xfc | $charCode >> 30 & 0x1) . chr(0x80 | $charCode >> 24 & 0x3f) . chr(0x80 | $charCode >> 18 & 0x3f) . chr(0x80 | $charCode >> 12 & 0x3f) . chr(0x80 | $charCode >> 6 & 0x3f) . chr(0x80 | $charCode & 0x3f);
     }
     return $char;
 }
コード例 #20
0
 public function dataForTestSerialize()
 {
     $data = array();
     $data[] = array(array("aaa"), "aaa\n");
     // single plain value
     $data[] = array(array("aaa", "bbb", "ccc"), "aaa\tbbb\tccc\n");
     // multiple plain values
     $data[] = array(array("aaa", null, null), "aaa\t\\N\t\\N\n");
     // null values
     $data[] = array(array("aaa", chr(0), "13"), "aaa\t\\0\t13\n");
     // special char: null
     $data[] = array(array("aaa", chr(9), "13"), "aaa\t\\\t\t13\n");
     // special char: tab
     $data[] = array(array("aaa", chr(10), "13"), "aaa\t\\\n\t13\n");
     // special char: newline
     $data[] = array(array("aaa", '\\' . chr(10), "13"), "aaa\t\\\\\\\n\t13\n");
     // special char: \ before newline
     $data[] = array(array("aaa", '\\\\' . chr(10), "13"), "aaa\t\\\\\\\\\\\n\t13\n");
     // special char: \\ before newline
     $data[] = array(array("aaa", '\\\\\\' . chr(10), "13"), "aaa\t\\\\\\\\\\\\\\\n\t13\n");
     // special char: \\\ before newline
     $data[] = array(array("aaa", '\\' . chr(10) . 'ok' . chr(10), "13"), "aaa\t\\\\\\\nok\\\n\t13\n");
     // special char: \ before newline
     $data[] = array(array("aaa", '\\', "13"), "aaa\t\\\\\t13\n");
     // special char: backslash (escape char)
     $data[] = array(array("\\", '\\n\\r\\0\\N', "13"), "\\\\\t\\\\n\\\\r\\\\0\\\\N\t13\n");
     // false escaping
     return $data;
 }
コード例 #21
0
function this_callback($str)
{
    foreach ($str as $match) {
        $ret .= chr(hexdec(str_replace("%", "", $match)));
    }
    return $ret;
}
コード例 #22
0
ファイル: AddEmail.php プロジェクト: duynhan07/elink
 function on_submit()
 {
     $email_list = Url::get('email_list');
     $count = 0;
     if ($email_list) {
         $arr = explode("\n", $email_list);
         $arr_tmp = array();
         $email_list = '';
         if ($arr) {
             foreach ($arr as $email) {
                 $email = str_replace(array(chr(13), chr(10)), '', stripslashes($email));
                 if (eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,6}\$", $email) && !isset($arr_tmp[$email])) {
                     $email_list .= ($email_list ? "\n" : '') . $email;
                     $arr_tmp[$email] = 1;
                     $count++;
                 }
             }
         }
     }
     $this->email_list = array('email_list' => addslashes($email_list), 'time' => TIME_NOW, 'time_modify' => TIME_NOW);
     $this->checkFormInput('Danh sách email', 'email_list', $email_list, 'str', true, '', 1);
     if ($count > 50) {
         $this->setFormError('', "Bạn đã nhập vào {$count} email, số mail nhập vào phải <=50!");
     }
     if (!$this->errNum) {
         $id = DB::insert('spam_mail', $this->email_list);
         if ($id) {
             Url::redirect_current(array('cmd' => 'email_list'));
         } else {
             $this->setFormError('', 'Không cập nhật được CSDL!');
         }
     }
 }
コード例 #23
0
ファイル: TXT.php プロジェクト: ookwudili/chisimba
 function Net_DNS_RR_TXT(&$rro, $data, $offset = '')
 {
     $this->name = $rro->name;
     $this->type = $rro->type;
     $this->class = $rro->class;
     $this->ttl = $rro->ttl;
     $this->rdlength = $rro->rdlength;
     $this->rdata = $rro->rdata;
     if ($offset) {
         if ($this->rdlength > 0) {
             $maxoffset = $this->rdlength + $offset;
             while ($maxoffset > $offset) {
                 list($text, $offset) = Net_DNS_Packet::label_extract($data, $offset);
                 $this->text[] = $text;
             }
         }
     } else {
         $data = str_replace('\\\\', chr(1) . chr(1), $data);
         /* disguise escaped backslash */
         $data = str_replace('\\"', chr(2) . chr(2), $data);
         /* disguise \" */
         ereg('("[^"]*"|[^ \\t]*)[ \\t]*$', $data, $regs);
         $regs[1] = str_replace(chr(2) . chr(2), '\\"', $regs[1]);
         $regs[1] = str_replace(chr(1) . chr(1), '\\\\', $regs[1]);
         $regs[1] = stripslashes($regs[1]);
         $this->text = $regs[1];
     }
 }
コード例 #24
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     jimport('joomla.filesystem.folder');
     // path to images directory
     $path = JPATH_ROOT . DS . $node->attributes('directory');
     $filter = $node->attributes('filter');
     $exclude = $node->attributes('exclude');
     $recursive = $node->attributes('recursive') == 1 ? true : false;
     $folders = JFolder::folders($path, $filter, $recursive);
     $folders = $this->recursive_listdir($path, $node);
     $options = array();
     foreach ($folders as $key => $folder) {
         if ($exclude) {
             if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
                 continue;
             }
         }
         $options[] = JHTML::_('select.option', $key, $folder);
     }
     if (!$node->attributes('hide_none')) {
         array_unshift($options, JHTML::_('select.option', '-1', '- ' . JText::_('Do not use') . ' -'));
     }
     if (!$node->attributes('hide_default')) {
         array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Use default') . ' -'));
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $options, $fullName, 'class="inputbox"', 'value', 'text', $value, "params{$name}");
 }
コード例 #25
0
ファイル: backups.php プロジェクト: pojok-webdev/pattimura
 function do_backup($table)
 {
     $fields = $this->obj->db->list_fields($table);
     $column_array = array();
     $c = 0;
     foreach ($fields as $field) {
         $column_array[$c] = $field;
         $c++;
     }
     $columns = implode(',', $column_array);
     $query = 'select ' . $columns . ' from ' . $table;
     $result = $this->obj->db->query($query);
     $text = '';
     foreach ($result->result() as $row) {
         $row_array = array();
         $c = 0;
         foreach ($column_array as $column) {
             $row_array[$c] = '"' . $row->{$column} . '"';
             $c++;
         }
         $rows = implode(',', $row_array);
         $text .= 'insert into ' . $table . '(' . $columns . ') values (' . $rows . ');' . chr(13);
     }
     return $text;
 }
コード例 #26
0
ファイル: base32.php プロジェクト: kraczo/pracowniapizzy
 public static function decode($input)
 {
     if (empty($input)) {
         return;
     }
     $paddingCharCount = substr_count($input, self::$map[32]);
     $allowedValues = array(6, 4, 3, 1, 0);
     if (!in_array($paddingCharCount, $allowedValues)) {
         return false;
     }
     for ($i = 0; $i < 4; $i++) {
         if ($paddingCharCount == $allowedValues[$i] && substr($input, -$allowedValues[$i]) != str_repeat(self::$map[32], $allowedValues[$i])) {
             return false;
         }
     }
     $input = str_replace('=', '', $input);
     $input = str_split($input);
     $binaryString = "";
     for ($i = 0; $i < count($input); $i = $i + 8) {
         $x = "";
         if (!in_array($input[$i], self::$map)) {
             return false;
         }
         for ($j = 0; $j < 8; $j++) {
             $x .= str_pad(base_convert(@self::$flippedMap[@$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
         }
         $eightBits = str_split($x, 8);
         for ($z = 0; $z < count($eightBits); $z++) {
             $binaryString .= ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ? $y : "";
         }
     }
     return $binaryString;
 }
コード例 #27
0
ファイル: rcon.class.php プロジェクト: pentyum/WebEssentials
 function run($command)
 {
     $str = '';
     $num = 0;
     $h = 0;
     $buffer = chr(strlen($command) + 10) . chr(0) . chr(0) . chr(0) . chr($this->t) . chr(0) . chr(0) . chr(0) . chr(2) . chr(0) . chr(0) . chr(0) . $command . chr(0) . chr(0);
     fwrite($this->sock, $buffer);
     while ($h == 0) {
         $h = ord(fgetc($this->sock));
     }
     //echo $h;
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     fgetc($this->sock);
     while ($num < $h - 10) {
         $str = $str . fgetc($this->sock);
         $num++;
     }
     $this->t++;
     return $str;
 }
コード例 #28
0
function bassAckwards($input)
{
    $length = strlen($input);
    $commaDeLim = chr(44);
    //ascii value for ','
    $answer = "";
    $x = 0;
    $y = 0;
    $i = 0;
    while ($i < $length) {
        while ($input[$i] != $commaDeLim) {
            $i++;
            if ($i == $length) {
                break;
            }
        }
        $y = $i + 1;
        while ($i >= $x) {
            if ($input[$i] != $commaDeLim) {
                $answer .= $input[$i];
            }
            $i--;
        }
        $x = $y;
        $i = $y;
        if ($i < $length) {
            $answer .= chr(44);
        }
    }
    return $answer;
}
コード例 #29
0
ファイル: VuFindSitemap.php プロジェクト: grharry/vufind
 /**
  * Load metadata about an HTML document using Aperture.
  *
  * @param string $htmlFile File on disk containing HTML.
  *
  * @return array
  */
 protected static function getApertureFields($htmlFile)
 {
     $xmlFile = tempnam('/tmp', 'apt');
     $cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler');
     exec($cmd);
     // If we failed to process the file, give up now:
     if (!file_exists($xmlFile)) {
         throw new \Exception('Aperture failed.');
     }
     // Extract and decode the full text from the XML:
     $xml = str_replace(chr(0), ' ', file_get_contents($xmlFile));
     @unlink($xmlFile);
     preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches);
     $final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Extract the title from the XML:
     preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches);
     $title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Extract the keywords from the XML:
     preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches);
     $keywords = [];
     if (isset($matches[1])) {
         foreach ($matches[1] as $current) {
             $keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8'));
         }
     }
     // Extract the description from the XML:
     preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches);
     $description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Send back the extracted fields:
     return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final];
 }
コード例 #30
0
 function uploadImageData($db, $file, $currentPictureId, $table, $id)
 {
     // insert the new record into the media's table and load the
     // corresponding blob with the media's data
     // (we use oracle's pseudo column rowid which identifies a row
     // within a table (but not within a database) to refer to the
     // right record later on)
     $sql = "DECLARE\n                        obj ORDSYS.ORDImage;\n                        iblob BLOB;\n                BEGIN\n                        SELECT image INTO obj FROM {$table}\n                        WHERE {$id} = {$currentPictureId} FOR UPDATE;\n\n                        iblob := obj.source.localData;\n                        :extblob := iblob;\n\n                        UPDATE {$table} SET image = obj WHERE {$id} = {$currentPictureId};\n                END;";
     // the function OCINewDescriptor allocates storage to hold descriptors or
     // lob locators.
     // see http://www.php.net/manual/en/function.ocinewdescriptor.php
     $blob = OCINewDescriptor($db, OCI_D_LOB);
     $sql = strtr($sql, chr(13) . chr(10), " ");
     $stmt = OCIParse($db, $sql);
     // the function OCIBindByName binds a PHP variable to a oracle placeholder
     // (whether the variable will be used for input or output will be determined
     // run-time, and the necessary storage space will be allocated)
     // see http://www.php.net/manual/en/function.ocibindbyname.php
     OCIBindByName($stmt, ':extblob', $blob, -1, OCI_B_BLOB);
     echo "{$this->log} - {$sql} <br />";
     OCIExecute($stmt, OCI_DEFAULT);
     // read the files data and load it into the blob
     $blob->savefile($file);
     OCIFreeStatement($stmt);
     $blob->free();
 }