• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP hexdec函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中hexdec函数的典型用法代码示例。如果您正苦于以下问题:PHP hexdec函数的具体用法?PHP hexdec怎么用?PHP hexdec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了hexdec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  *	Génère l'avatar
  */
 public function run()
 {
     //On créer l'image avec les dimentions données
     $image = imagecreate($this->_size, $this->_size);
     //On créer la couleur en fonction du hash de la chaine de caractères
     $color = imagecolorallocate($image, hexdec(substr($this->_color, 0, 2)), hexdec(substr($this->_color, 2, 2)), hexdec(substr($this->_color, 4, 2)));
     //on défini le fond de l'image (blanc)
     $bg = imagecolorallocate($image, 255, 255, 255);
     //nombre de blocs à placer dans l'image (taille de l'image/taille des blocs)
     $c = $this->_size / $this->_blockSize;
     for ($x = 0; $x < ceil($c / 2); $x++) {
         for ($y = 0; $y < $c; $y++) {
             // Si le nombre est pair $pixel vaut true sinon $pixel vaut false
             $pixel = hexdec($this->_hash[(int) ($x * ceil($c / 2)) + $y]) % 2 == 0;
             if ($pixel) {
                 $pixelColor = $color;
             } else {
                 $pixelColor = $bg;
             }
             // On place chaque bloc de l'image
             //imagefilledrectangle($image, $x*$this->_blockSize, $y*$this->_blockSize, ($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             //imagefilledrectangle($image, $this->_size-$x*$this->_blockSize, $y*$this->_blockSize, $this->_size-($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $x * $this->_blockSize, $y * $this->_blockSize, ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $this->_size - $x * $this->_blockSize, $y * $this->_blockSize, $this->_size - ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
         }
     }
     ob_start();
     imagepng($image);
     //on place l'image en mémoire
     $this->_image = ob_get_contents();
     ob_clean();
 }
开发者ID:JulienCoutault,项目名称:Web,代码行数:35,代码来源:RandomAvatar.php


示例2: wpcom_static_url

 function wpcom_static_url($file)
 {
     $i = hexdec(substr(md5($file), -1)) % 2;
     $http = is_ssl() ? 'https' : 'http';
     $url = $http . '://s' . $i . '.wp.com' . $file;
     return $url;
 }
开发者ID:moscarar,项目名称:cityhow,代码行数:7,代码来源:notes.php


示例3: loadCharset

 function loadCharset($charset)
 {
     $charset = preg_replace(array('/^WINDOWS-*125([0-8])$/', '/^CP-/'), array('CP125\\1', 'CP'), $charset);
     if (isset($aliases[$charset])) {
         $charset = $aliases[$charset];
     }
     $this->charset = $charset;
     if (empty($this->ascMap[$charset])) {
         $file = UTF8_MAP_DIR . '/' . $charset . '.map';
         if (!is_file($file)) {
             $this->onError(ERR_OPEN_MAP_FILE, "Failed to open map file for {$charset}");
             return;
         }
         $lines = file_get_contents($file);
         $lines = preg_replace("/#.*\$/m", "", $lines);
         $lines = preg_replace("/\n\n/", "", $lines);
         $lines = explode("\n", $lines);
         foreach ($lines as $line) {
             $parts = explode('0x', $line);
             if (count($parts) == 3) {
                 $asc = hexdec(substr($parts[1], 0, 2));
                 $utf = hexdec(substr($parts[2], 0, 4));
                 $this->ascMap[$charset][$asc] = $utf;
             }
         }
         $this->utfMap = array_flip($this->ascMap[$charset]);
     }
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:28,代码来源:utf8.class.php


示例4: r_shell

function r_shell($sc)
{
    for ($z = 0; $z < strlen($sc); $z += 2) {
        $exec .= chr(hexdec(substr($sc, $z, 2)));
    }
    return $exec;
}
开发者ID:sasukeuni,项目名称:Python-Exploit-Search-Tool,代码行数:7,代码来源:24492.php


示例5: validate_token

 /**
  * Validates a full token, by calculating the token value for the provided 
  * offset and compares.
  */
 public function validate_token($token)
 {
     $splittedtoken = explode('-', $token);
     $offset = hexdec($splittedtoken[0]);
     $value = $splittedtoken[1];
     return $this->calculate_tokenvalue($offset) === $value;
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:11,代码来源:TimeLimitedToken.php


示例6: from_pronto

 /** PHP version of the Java method in SignalFactory */
 public static function from_pronto($in)
 {
     $res = new self();
     $in = trim($in);
     $pronto = explode(" ", $in);
     foreach ($pronto as $idx => $val) {
         $pronto[$idx] = hexdec($val);
     }
     if ($pronto[0] != 0) {
         return false;
     }
     $freq = (int) (1000000 / ($pronto[1] * 0.241246));
     $bps1 = $pronto[2] * 2;
     $bps2 = $pronto[3] * 2;
     $offset = 4;
     $pattern = array();
     $length = $bps1 + $bps2;
     for ($i = 0; $i < $length; $i++) {
         $pattern[$i] = $pronto[$offset + $i];
         if ($pattern[$i] <= 0) {
             $pattern[$i] = 1;
         }
     }
     $res->frequency = $freq;
     $res->pattern = $pattern;
     return $res;
 }
开发者ID:smdern,项目名称:IRRemote,代码行数:28,代码来源:remotes.inc.php


示例7: hex32ToAsc

 /**
  * Converts all Hex expressions ("\HEX") to their original ASCII characters
  *
  * @see    Net_LDAP2_Util::hex2asc() from Benedikt Hallinger <[email protected]>,
  *         heavily based on work from [email protected]
  * @link   http://pear.php.net/package/Net_LDAP2
  * @author Benedikt Hallinger <[email protected]>, heavily based on work from [email protected]
  *
  * @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;
 }
开发者ID:robertboloc,项目名称:zf2,代码行数:18,代码来源:Converter.php


示例8: import

function import($file, $dlc)
{
    $res = 0;
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    $tb = 'crefs';
    createTable($tb);
    foreach ($c as $t) {
        list($empty, $eid, $ref, $base, $count, $health, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $lock, $key, $link) = explode("|", $t);
        $ref = hexdec($ref);
        $base = hexdec($base);
        $cell = hexdec($cell);
        $flags = hexdec($flags);
        if (!$ref) {
            continue;
        }
        $prep = $db->prepare("insert into {$tb} (editor,refID,baseID,cell,x,y,z,ax,ay,az,flags,dlc) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $db->errorInfo()[2];
            continue;
        }
        $r = $prep->execute(array($eid, $ref, $base, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $dlc));
        if ($r) {
            $res++;
        }
    }
    return $res;
}
开发者ID:rockhowse,项目名称:vaultmp,代码行数:32,代码来源:f3_acre.php


示例9: getkey

function getkey($key1, $key2)
{
    $a = hexdec($key1);
    $b = $a ^ 0xa55aa5a5;
    $b = dechex($b);
    return $key2 . $b;
}
开发者ID:nullog,项目名称:zhanglubao,代码行数:7,代码来源:function.php


示例10: parse

 /**
  * Parses a DNUMBER token like PHP would.
  *
  * @param string $str A string number
  *
  * @return float The parsed number
  */
 public static function parse($str)
 {
     // if string contains any of .eE just cast it to float
     if (false !== strpbrk($str, '.eE')) {
         return (double) $str;
     }
     // otherwise it's an integer notation that overflowed into a float
     // if it starts with 0 it's one of the special integer notations
     if ('0' === $str[0]) {
         // hex
         if ('x' === $str[1] || 'X' === $str[1]) {
             return hexdec($str);
         }
         // bin
         if ('b' === $str[1] || 'B' === $str[1]) {
             return bindec($str);
         }
         // oct
         // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9)
         // so that only the digits before that are used
         return octdec(substr($str, 0, strcspn($str, '89')));
     }
     // dec
     return (double) $str;
 }
开发者ID:ck-1,项目名称:PHP-Parser,代码行数:32,代码来源:DNumber.php


示例11: import

function import($file, $dlc)
{
    $res = 0;
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    foreach ($c as $t) {
        list($tb, $id, $name, $description) = explode("|", $t);
        $id = hexdec($id);
        createTable($tb);
        $prep = $db->prepare("insert into {$tb} (baseID,name,description,dlc) values (?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $name, $description, $dlc));
        if ($r) {
            $res++;
        }
    }
    return $res;
}
开发者ID:rockhowse,项目名称:vaultmp,代码行数:25,代码来源:f3.php


示例12: color_generator

function color_generator($count = 1, $start = '33CCFF', $step = '221133')
{
    $log = vglobal('log');
    $log->debug("Entering color_generator(" . $count . "," . $start . "," . $step . ") method ...");
    // explode color strings to RGB array
    if ($start[0] == "#") {
        $start = substr($start, 1);
    }
    if ($step[0] == "#") {
        $step = substr($step, 1);
    }
    // pad shorter strings with 0
    $start = substr($start . "000000", 0, 6);
    $step = substr($step . "000000", 0, 6);
    $colors = array(hexdec(substr($start, 0, 2)), hexdec(substr($start, 2, 2)), hexdec(substr($start, 4, 2)));
    $steps = array(hexdec(substr($step, 0, 2)), hexdec(substr($step, 2, 2)), hexdec(substr($step, 4, 2)));
    // buils $count colours adding $step to $start
    $result = array();
    for ($i = 1; $i <= $count; $i++) {
        array_push($result, "#" . dechex($colors[0]) . dechex($colors[1]) . dechex($colors[2]));
        for ($j = 0; $j < 3; $j++) {
            $colors[$j] += $steps[$j];
            if ($colors[$j] > 0xff) {
                $colors[$j] -= 0xff;
            }
        }
    }
    $log->debug("Exiting color_generator method ...");
    return $result;
}
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:30,代码来源:GraphUtils.php


示例13: generateRandomString

 /**
  * Generate a random string by using openssl, dev/urandom or random
  * @param int $length optional length of the string
  * @return string random string
  * @author Benjamin BALET <[email protected]>
  */
 private function generateRandomString($length = 10)
 {
     if (function_exists('openssl_random_pseudo_bytes')) {
         $rnd = openssl_random_pseudo_bytes($length, $strong);
         if ($strong === TRUE) {
             return base64_encode($rnd);
         }
     }
     $sha = '';
     $rnd = '';
     if (file_exists('/dev/urandom')) {
         $fp = fopen('/dev/urandom', 'rb');
         if ($fp) {
             if (function_exists('stream_set_read_buffer')) {
                 stream_set_read_buffer($fp, 0);
             }
             $sha = fread($fp, $length);
             fclose($fp);
         }
     }
     for ($i = 0; $i < $length; $i++) {
         $sha = hash('sha256', $sha . mt_rand());
         $char = mt_rand(0, 62);
         $rnd .= chr(hexdec($sha[$char] . $sha[$char + 1]));
     }
     return base64_encode($rnd);
 }
开发者ID:shawnyeh,项目名称:jorani,代码行数:33,代码来源:session.php


示例14: combine

 /**
  *  Create a cache file from the given list of files and return the cache file name
  *  @name   combine
  *  @type   method
  *  @access public
  *  @param  array file list
  *  @return string cache file name
  */
 public function combine($fileList)
 {
     if (count($fileList) > 0) {
         $cacheFile = '';
         $alphabet = array_map('chr', array_merge(range(48, 57), range(97, 122), range(65, 90)));
         //  a lot is going on on this line; first we take the md5 checksums of the files in the list, then this goes into a json blob, which is m5'd on its own and then wordwrapped at every 3rd character and lastly, the result gets exploded on the wordwrap added newlines. Leaving us with a 11 item array.
         $checksum = explode(PHP_EOL, wordwrap(md5(json_encode(array_map('md5_file', $fileList))), 3, PHP_EOL, true));
         while (count($checksum)) {
             $cacheFile .= $alphabet[hexdec(array_shift($checksum)) % count($alphabet)];
         }
         $cacheFile = $this->_cachePath . '/' . $cacheFile . '.' . pathinfo($fileList[0], PATHINFO_EXTENSION);
         //  if the cache file exists, we gently push the modification time to now (this should make removing old obselete files easier to find)
         if (realpath($cacheFile) && touch($cacheFile)) {
             return basename($cacheFile);
         }
         //  as no cache file was found (or we couldn't push the modification time), we need to generate it
         $fp = fopen($cacheFile, 'w+');
         if ($fp) {
             foreach ($fileList as $file) {
                 $source = trim(file_get_contents($file)) . PHP_EOL;
                 if (substr($file, 0, strlen($this->_cachePath)) == $this->_cachePath) {
                     $source = '/*' . basename($file) . '*/' . $source;
                 }
                 fputs($fp, $source);
             }
             return basename($cacheFile);
         }
     }
     return false;
 }
开发者ID:rspieker,项目名称:konsolidate_scaffold,代码行数:38,代码来源:source.class.php


示例15: HEX2RGBA

 static function HEX2RGBA($color)
 {
     $hex = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
     $rgb = array_map('hexdec', $hex);
     $output = 'rgba(' . implode(',', $rgb) . ',' . hexdec($color[6] . $color[7]) / 255 . ')';
     return $output;
 }
开发者ID:phanhoanglong2610,项目名称:anc_gvn,代码行数:7,代码来源:Theme.Color.class.php


示例16: js_unescape

/**
 * Function converts an Javascript escaped string back into a string with
 * specified charset (default is UTF-8).
 * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
 *
 * @param $source String escaped with Javascript's escape() function
 * @param $iconv_to String destination character set will be used as second parameter 
 * in the iconv function. Default is UTF-8.
 * @return string
 */
function js_unescape($source, $iconv_to = 'UTF-8')
{
    $decodedStr = '';
    $pos = 0;
    $len = strlen($source);
    while ($pos < $len) {
        $charAt = substr($source, $pos, 1);
        if ($charAt == '%') {
            $pos++;
            $charAt = substr($source, $pos, 1);
            if ($charAt == 'u') {
                // we got a unicode character
                $pos++;
                $unicodeHexVal = substr($source, $pos, 4);
                $unicode = hexdec($unicodeHexVal);
                $decodedStr .= code2utf($unicode);
                $pos += 4;
            } else {
                // we have an escaped ascii character
                $hexVal = substr($source, $pos, 2);
                $decodedStr .= chr(hexdec($hexVal));
                $pos += 2;
            }
        } else {
            $decodedStr .= $charAt;
            $pos++;
        }
    }
    if ($iconv_to != "UTF-8") {
        $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
    }
    return $decodedStr;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:43,代码来源:AjaxFunctions.php


示例17: unescapeString

 /**
  * Decodes an encoded N-Triples string. Any \-escape sequences are substituted
  * with their decoded value.
  *
  * @param  string $str An encoded N-Triples string.
  * @return The unencoded string.
  **/
 protected function unescapeString($str)
 {
     if (strpos($str, '\\') === FALSE) {
         return $str;
     }
     $mappings = array('t' => chr(0x9), 'b' => chr(0x8), 'n' => chr(0xa), 'r' => chr(0xd), 'f' => chr(0xc), '\\"' => chr(0x22), '\'' => chr(0x27));
     foreach ($mappings as $in => $out) {
         $str = preg_replace('/\\x5c([' . $in . '])/', $out, $str);
     }
     if (stripos($str, '\\u') === FALSE) {
         return $str;
     }
     while (preg_match('/\\\\(U)([0-9A-F]{8})/', $str, $matches) || preg_match('/\\\\(u)([0-9A-F]{4})/', $str, $matches)) {
         $no = hexdec($matches[2]);
         if ($no < 128) {
             $char = chr($no);
         } else {
             if ($no < 2048) {
                 $char = chr(($no >> 6) + 192) . chr(($no & 63) + 128);
             } else {
                 if ($no < 65536) {
                     $char = chr(($no >> 12) + 224) . chr(($no >> 6 & 63) + 128) . chr(($no & 63) + 128);
                 } else {
                     if ($no < 2097152) {
                         $char = chr(($no >> 18) + 240) . chr(($no >> 12 & 63) + 128) . chr(($no >> 6 & 63) + 128) . chr(($no & 63) + 128);
                     } else {
                         $char = '';
                     }
                 }
             }
         }
         $str = str_replace('\\' . $matches[1] . $matches[2], $char, $str);
     }
     return $str;
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:42,代码来源:Ntriples.php


示例18: kfm_decode_unicode_url

function kfm_decode_unicode_url($str)
{
    # this code taken from here: http://php.net/urldecode
    $res = '';
    $i = 0;
    $max = strlen($str) - 6;
    while ($i <= $max) {
        $character = $str[$i];
        if ($character == '%' && $str[$i + 1] == 'u') {
            $value = hexdec(substr($str, $i + 2, 4));
            $i += 6;
            if ($value < 0x80) {
                $character = chr($value);
            } else {
                if ($value < 0x800) {
                    $character = chr(($value & 0x7c0) >> 6 | 0xc0) . chr($value & 0x3f | 0x80);
                } else {
                    $character = chr(($value & 0xf000) >> 12 | 0xe0) . chr(($value & 0xfc0) >> 6 | 0x80) . chr($value & 0x3f | 0x80);
                }
            }
        } else {
            ++$i;
        }
        $res .= $character;
    }
    return $res . substr($str, $i);
}
开发者ID:blumine,项目名称:vunsy,代码行数:27,代码来源:kaejax.php


示例19: rgb2int255

 /**
  * Converte uma cor em RGB para um vetor de decimais
  * @param $rgb uma string contendo uma cor em RGB
  */
 private function rgb2int255($rgb)
 {
     $red = hexdec(substr($rgb, 1, 2));
     $green = hexdec(substr($rgb, 3, 2));
     $blue = hexdec(substr($rgb, 5, 2));
     return array($red, $green, $blue);
 }
开发者ID:jhonleandres,项目名称:crmbf,代码行数:11,代码来源:TTableWriterPDF.class.php


示例20: normalize

 /**
  * Fix up percent-encoding by decoding unreserved characters and normalizing
  * @param $string String to normalize
  */
 function normalize($string)
 {
     if ($string == '') {
         return '';
     }
     $parts = explode('%', $string);
     $ret = array_shift($parts);
     foreach ($parts as $part) {
         $length = strlen($part);
         if ($length < 2) {
             $ret .= '%25' . $part;
             continue;
         }
         $encoding = substr($part, 0, 2);
         $text = substr($part, 2);
         if (!ctype_xdigit($encoding)) {
             $ret .= '%25' . $part;
             continue;
         }
         $int = hexdec($encoding);
         if ($int >= 48 && $int <= 57 || $int >= 65 && $int <= 90 || $int >= 97 && $int <= 122 || $int == 126 || $int == 45 || $int == 46 || $int == 95) {
             $ret .= chr($int) . $text;
             continue;
         }
         $encoding = strtoupper($encoding);
         $ret .= '%' . $encoding . $text;
     }
     return $ret;
 }
开发者ID:hasshy,项目名称:sahana-tw,代码行数:33,代码来源:PercentEncoder.php



注:本文中的hexdec函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP hexec函数代码示例发布时间:2022-05-15
下一篇:
PHP hex2str函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap