当前位置: 首页>>代码示例>>PHP>>正文


PHP hexdec函数代码示例

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


在下文中一共展示了hexdec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 <beni@php.net>,
  *         heavily based on work from DavidSmith@byu.net
  * @link   http://pear.php.net/package/Net_LDAP2
  * @author Benedikt Hallinger <beni@php.net>, 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;
 }
开发者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 <benjamin.balet@gmail.com>
  */
 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


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