本文整理汇总了PHP中HexDec函数的典型用法代码示例。如果您正苦于以下问题:PHP HexDec函数的具体用法?PHP HexDec怎么用?PHP HexDec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HexDec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Query
public function Query()
{
$Length = StrLen($this->ServerIP);
$Data = Pack('cccca*', HexDec($Length), 0, 0x4, $Length, $this->ServerIP) . Pack('nc', $this->ServerPort, 0x1);
Socket_Send($this->Socket, $Data, StrLen($Data), 0);
// handshake
Socket_Send($this->Socket, "", 2, 0);
// status ping
$Length = $this->ReadVarInt();
// full packet length
if ($Length < 10) {
return FALSE;
}
Socket_Read($this->Socket, 1);
// packet type, in server ping it's 0
$Length = $this->ReadVarInt();
// string length
$Data = Socket_Read($this->Socket, $Length, PHP_NORMAL_READ);
// and finally the json string
if ($Data === FALSE) {
throw new MinecraftPingException('Server didn\'t return any data');
}
$Data = JSON_Decode($Data, true);
if (JSON_Last_Error() !== JSON_ERROR_NONE) {
if (Function_Exists('json_last_error_msg')) {
throw new MinecraftPingException(JSON_Last_Error_Msg());
} else {
throw new MinecraftPingException('JSON parsing failed');
}
return FALSE;
}
return $Data;
}
示例2: Bytes_Trim
function Bytes_Trim($String)
{
/****************************************************************************/
$__args_types = array('string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
return DecHex(HexDec($String));
}
示例3: Captcha
function Captcha($text, $font, $color)
{
$C = HexDec($color);
$R = floor($C / pow(256, 2));
$G = floor($C % pow(256, 2) / pow(256, 1));
$B = floor($C % pow(256, 2) % pow(256, 1) / pow(256, 0));
$fsize = 32;
$bound = array();
$bound = imageTTFBbox($fsize, 0, $font, $text);
$this->image = imageCreateTrueColor($bound[4] + 5, abs($bound[5]) + 15);
imageFill($this->image, 0, 0, ImageColorAllocate($this->image, 255, 255, 255));
imagettftext($this->image, $fsize, 0, 2, abs($bound[5]) + 5, ImageColorAllocate($this->image, $R, $G, $B), $font, $text);
}
示例4: SNAC_Create
function SNAC_Create($FamilyID, $SubTypeID, $Data = '')
{
/****************************************************************************/
$__args_types = array('integer', 'integer', 'string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
$Result = Bytes_I2B(WORD, HexDec($FamilyID)) . Bytes_I2B(WORD, HexDec($SubTypeID)) . Bytes_I2B(BUTE, 0) . Bytes_I2B(BUTE, 0) . Bytes_I2B(DWORD, Rand(1, 65025));
# Номер запроса
#-----------------------------------------------------------------------------
$Result .= $Data;
# Сам пакет
#-----------------------------------------------------------------------------
return $Result;
}
示例5: ColorChangeIntensity
function ColorChangeIntensity($color, $intensity_offset)
{
if (eregi('^#([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})$', $color, $components) != 7) {
return $color;
}
if (($red = intval(HexDec($components[1]) * (100 + $intensity_offset) / 100)) > 255) {
$red = 255;
}
if (($green = intval(HexDec($components[2]) * (100 + $intensity_offset) / 100)) > 255) {
$green = 255;
}
if (($blue = intval(HexDec($components[3]) * (100 + $intensity_offset) / 100)) > 255) {
$blue = 255;
}
return sprintf('#%02X%02X%02X', $red, $green, $blue);
}
示例6: couleur_inverse
function couleur_inverse($c_orig)
{
$a = substr($c_orig, 0, 1);
$b = substr($c_orig, 1, 1);
$c = substr($c_orig, 2, 1);
$d = substr($c_orig, 3, 1);
$e = substr($c_orig, 4, 1);
$f = substr($c_orig, 5, 1);
$ai = DecHex(15 - HexDec($a));
$bi = DecHex(15 - HexDec($b));
$ci = DecHex(15 - HexDec($c));
$di = DecHex(15 - HexDec($d));
$ei = DecHex(15 - HexDec($e));
$fi = DecHex(15 - HexDec($f));
$c_inv = $ai . $bi . $ci . $di . $ei . $fi;
return $c_inv;
}
示例7: mf_str_conv
function mf_str_conv($str_or)
{
$str_or = stripslashes($str_or);
if (!preg_match("/unescape\\(\\W([0-9a-f]+)\\W\\);\\w+=([0-9]+);[^\\^]+\\)([0-9\\^]+)?\\)\\);eval/", $str_or, $match)) {
return $str_or;
}
$match[3] = $match[3] ? $match[3] : "";
for ($i = 0; $i < $match[2]; $i++) {
$c = HexDec(substr($match[1], $i * 2, 2));
eval("\$c = \$c" . $match[3] . ";");
$str_re .= chr($c);
}
$str_re = str_replace($match[0], stripslashes($str_re), $str_or);
if (preg_match("/unescape\\(\\W([0-9a-f]+)\\W\\);\\w+=([0-9]+);[^\\^]+\\)([0-9\\^]+)?\\)\\);eval/", $str_re, $dummy)) {
$str_re = mf_str_conv($str_re);
}
return $str_re;
}
示例8: TVL_Explode
function TVL_Explode($String, &$Array = array())
{
/****************************************************************************/
$__args_types = array('string', 'array');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
$Length = HexDec(Bytes_Get($String, 02, WORD));
#-----------------------------------------------------------------------------
$Array[Bytes_Get($String, 00, WORD)] = SubStr($String, 04, $Length);
#-----------------------------------------------------------------------------
if (StrLen($String = SubStr($String, 04 + $Length)) > 0) {
TVL_Explode($String, $Array);
}
#-----------------------------------------------------------------------------
return $Array;
}
示例9: query
/**
* Make a new query to the NTP server
* @param string $timeserver
* @param integer $port
* @param integer $timeout
* @return object
*/
public static function query($timeserver, $port, $timeout = 2)
{
$err = null;
$errstr = null;
$fp = @fsockopen($timeserver, $port, $err, $errstr, $timeout);
if ($fp) {
fputs($fp, "\n");
$timeread = fread($fp, 49);
$timevalue = bin2hex($timeread);
$timevalue = abs(HexDec('7fffffff') - HexDec($timevalue) - HexDec('7fffffff'));
$timestamp = $timevalue - 2208988800.0;
# convert to UNIX epoch timestamp
fclose($fp);
$result = (object) array('timezone' => date_default_timezone_get(), 'timestamp' => $timestamp, 'datetime' => date('Y-m-d H:i:s', $timestamp));
} else {
$result = null;
}
return (object) array('result' => $result, 'error-code' => $err, 'error-text' => $errstr);
}
示例10: BuildItemDesc
function BuildItemDesc($file)
{
print " * Loading multis config file...\n";
$cfg_file = ReadConfigFile($file);
if ($cfg_file == FALSE) {
print "Cant open {$file} ({$php_errormsg}). Blame Stephen Donald.\n";
exit;
}
print " * Purging itemdesc.cfg for new write...\n";
$handle = FOpen("itemdesc.cfg", "w");
FClose($handle);
$handle = FOpen("itemdesc.cfg", "a");
print " * Finding elem names...";
$elem_names = GetConfigStringKeys($cfg_file, CLASS_LABELS_ON);
print "(" . Count($elem_names) . ")\n";
foreach ($elem_names as $elem_name) {
if (!Preg_Match("/^House\\s+/i", $elem_name)) {
continue;
}
$multi_id = Preg_Replace("/^House\\s+/i", "", $elem_name);
$objtype = HexDec($multi_id);
$objtype += 16384;
// 0x4000
$objtype = "0x" . DecHex($objtype);
FWrite($handle, "House {$objtype}\n");
FWrite($handle, "{\n");
FWrite($handle, "\t// Main Stuff\n");
FWrite($handle, "\tName\t\tHouse{$objtype}\n");
FWrite($handle, "\tGraphic\t\t{$objtype}\n");
FWrite($handle, "\n");
FWrite($handle, "\t// Multi Info\n");
FWrite($handle, "\tMultiID\t\t{$multi_id}\n");
FWrite($handle, "}\n\n");
}
FClose($handle);
return 1;
}
示例11: Tag
#-------------------------------------------------------------------------------
$Table = new Tag('TABLE', array('class' => 'Standard', 'cellspacing' => 0, 'cellpadding' => 0));
#-------------------------------------------------------------------------------
$Gradetion = $Palette['Gradetion'];
#-------------------------------------------------------------------------------
foreach ($Palette['Colors'] as $Color) {
#-----------------------------------------------------------------------------
$Tr = new Tag('TR');
#-----------------------------------------------------------------------------
for ($i = 1; $i < ($Count = $Gradetion['Count']) * 2; $i++) {
#---------------------------------------------------------------------------
$IsLeft = $i >= $Count;
#---------------------------------------------------------------------------
$Shift = ($IsLeft ? $i - $Count : $Count - $i) * $Gradetion['Step'];
#---------------------------------------------------------------------------
$Shifted = Color_Shift(HexDec($Color), $IsLeft ? 0xffffff : 0x0, $Shift);
#---------------------------------------------------------------------------
$Colors[] = $Shifted;
#---------------------------------------------------------------------------
$Td = new Tag('TD', array('align' => 'center', 'bgcolor' => $Shifted, 'height' => 50, 'width' => 50), $Shifted);
#---------------------------------------------------------------------------
if ($i == $Count) {
$Td->AddAttribs(array('style' => 'border:1px solid #DCDCDC;'));
}
#---------------------------------------------------------------------------
$Tr->AddChild($Td);
}
#-----------------------------------------------------------------------------
$Table->AddChild($Tr);
}
#-------------------------------------------------------------------------------
示例12: watermark
public function watermark($file, $desfile)
{
$suffx = substr($file, strlen($file) - 4, 4);
if ($suffx == ".jpg" || $suffx == "jpeg" || $suffx == ".png") {
$text = str_replace("[date]", date($this->_wmdatfmt), $this->_wmtext);
if ($suffx == ".jpg" || $suffx == "jpeg") {
$image = imagecreatefromjpeg($file);
} elseif ($suffx == ".png") {
$image = imagecreatefrompng($file);
} else {
return false;
}
$rgbtext = HexDec($this->_wmrgbtext);
$txtr = floor($rgbtext / pow(256, 2));
$txtg = floor($rgbtext % pow(256, 2) / pow(256, 1));
$txtb = floor($rgbtext % pow(256, 2) % pow(256, 1) / pow(256, 0));
$rgbtsdw = HexDec($this->_wmrgbtsdw);
$tsdr = floor($rgbtsdw / pow(256, 2));
$tsdg = floor($rgbtsdw % pow(256, 2) / pow(256, 1));
$tsdb = floor($rgbtsdw % pow(256, 2) % pow(256, 1) / pow(256, 0));
$coltext = imagecolorallocate($image, $txtr, $txtg, $txtb);
$coltsdw = imagecolorallocate($image, $tsdr, $tsdg, $tsdb);
if ($this->_wmhotspot != 0) {
$ix = imagesx($image);
$iy = imagesy($image);
$tsw = strlen($text) * $this->_wmfont_size / imagefontwidth($this->_wmfont) * 3;
$tsh = $this->_wmfont_size / imagefontheight($this->_wmfont);
switch ($this->_wmhotspot) {
case 1:
$txp = $this->_wmtxp;
$typ = $tsh * $tsh + imagefontheight($this->_wmfont) * 2 + $this->_wmtyp;
break;
case 2:
$txp = floor(($ix - $tsw) / 2);
$typ = $tsh * $tsh + imagefontheight($this->_wmfont) * 2 + $this->_wmtyp;
break;
case 3:
$txp = $ix - $tsw - $this->_wmtxp;
$typ = $tsh * $tsh + imagefontheight($this->_wmfont) * 2 + $this->_wmtyp;
break;
case 4:
$txp = $this->_wmtxp;
$typ = floor(($iy - $tsh) / 2);
break;
case 5:
$txp = floor(($ix - $tsw) / 2);
$typ = floor(($iy - $tsh) / 2);
break;
case 6:
$txp = $ix - $tsw - $this->_wmtxp;
$typ = floor(($iy - $tsh) / 2);
break;
case 7:
$txp = $this->_wmtxp;
$typ = $iy - $tsh - $this->_wmtyp;
break;
case 8:
$txp = floor(($ix - $tsw) / 2);
$typ = $iy - $tsh - $this->_wmtyp;
break;
case 9:
$txp = $ix - $tsw - $this->_wmtxp;
$typ = $iy - $tsh - $this->_wmtyp;
break;
default:
return false;
}
} else {
$txp = 0;
$typ = 0;
}
imagettftext($image, $this->_wmfont_size, 0, $txp + 1, $typ + 1, $coltsdw, $this->_wmfont, $text);
imagettftext($image, $this->_wmfont_size, 0, $txp, $typ, $coltext, $this->_wmfont, $text);
if ($suffx == ".jpg" || $suffx == "jpeg") {
imagejpeg($image, $desfile, $this->_JPEGquality);
} elseif ($suffx == ".png") {
imagepng($image, $desfile);
}
imagedestroy($image);
return true;
} else {
return false;
}
}
示例13: Mark53
function Mark53($AccountNo, $BLZ)
{
$Significance = '4216379A5842';
if (strlen($AccountNo) == 10) {
if (substr($AccountNo, 0, 1) == '9') {
$Correct = $this->Mark20($AccountNo);
}
} else {
$Help = 0;
$Rest = 0;
$AltKonto = substr($BLZ, -4, 2) . substr($AccountNo, 1, 1) . substr($BLZ, -1) . substr($AccountNo, 0, 1) . substr($AccountNo, 2, 1);
$AccountNo = Substr($AccountNo, 3);
while (substr($AccountNo, 0, 1) == '0') {
$AccountNo = Substr($AccountNo, 1);
}
$AltKonto = $AltKonto . $AccountNo;
while (strlen($AltKonto) < 12) {
$AltKonto = "0" . $AltKonto;
}
$Checksum = substr($AltKonto, 5, 1);
$AltKonto = substr($AltKonto, 0, 5) . '0' . substr($AltKonto, 6);
$Laenge = strlen($AltKonto);
for ($Run = 0; $Run < $Laenge; $Run++) {
$Help += substr($AltKonto, $Run, 1) * HexDec(substr($Significance, $Run, 1));
}
$Rest = $Help % 11;
$Gewicht = HexDec(substr($Significance, 5, 1));
$PZ = -1;
do {
$PZ++;
$Help2 = $Rest + $PZ * $Gewicht;
} while ($Help2 % 11 != 10 or $PZ > 9);
if ($Help2 % 11 == 10) {
if ($PZ == $Checksum) {
$Correct = 0;
} else {
$Correct = 1;
}
} else {
$Correct = 1;
}
}
return $Correct;
}
示例14: _hexdecBcmath
/**
* hex decode using bcmath extension
*/
function _hexdecBcmath($hex)
{
$dec = '0';
for ($i = 0; $i < strlen($hex); $i += 4) {
$dec = bcadd(bcmul($dec, 65536), HexDec(substr($hex, $i, 4)));
}
return $dec;
}
示例15: _decodeModKtai
/**
* mod_ktai コードをデコード (サブ関数) by nao-pon
*
* @param string $match
* @return string
*/
function _decodeModKtai($match)
{
if ($match[1]) {
if ($this->to !== 'COMMON' && strtolower(substr($match[1], 0, 9)) === '<textarea') {
$carrier = '';
switch ($this->to) {
case MPC_TO_FOMA:
$carrier = MPC_FROM_FOMA;
break;
case MPC_TO_EZWEB:
$carrier = MPC_FROM_EZWEB;
break;
case MPC_TO_SOFTBANK:
$carrier = MPC_FROM_SOFTBANK;
break;
}
if ($carrier) {
$mpc = MobilePictogramConverter::factory($match[1], $carrier, $this->from_charset, MPC_FROM_OPTION_MODKTAI);
return $mpc->autoConvert();
}
}
return $match[0];
}
if (isset($match[4])) {
$emj_table = 'emj2i_table';
$match[2] = 'i';
if (!empty($match[5])) {
switch (strtolower($match[5])) {
case 'sb':
$emj_table = 'emj2s_table';
$match[2] = 's';
break;
case 'ez':
$emj_table = 'e2icon_table';
$match[2] = 'e';
break;
default:
$emj_table = 'emj2i_table';
$match[2] = 'i';
}
}
if (empty($this->{$emj_table})) {
require 'map/' . $emj_table . '.php';
}
$_table = $this->{$emj_table};
if (!isset($_table[$match[4]])) {
return $match[0];
}
$match[3] = $match[2] === 'e' ? dechex($_table[$match[4]]) : $_table[$match[4]];
/*
if ($this->emj_to === 's') {
if (empty($this->i2s_table)) {
require 'map/i2s_table.php';
}
$match[2] = 's';
$match[3] = dechex($this->i2s_table[hexdec($match[3])]);
} else if ($this->emj_to === 'e') {
if (empty($this->i2e_table)) {
require 'map/i2e_table.php';
}
if (empty($this->e2icon_table)) {
require 'map/e2icon_table.php';
}
$match[2] = 'e';
$match[3] = dechex($this->e2icon_table[$this->i2e_table[hexdec($match[3])]]);
}
*/
}
$mode = strtolower($match[2]);
if ($mode === 'v') {
$mode = 's';
}
// ezweb convert to icon number
$dec = HexDec($match[3]);
if ($mode === 'e') {
if (empty($this->e2icon_table)) {
require 'map/e2icon_table.php';
}
$dec = intval(array_search($dec, $this->e2icon_table));
}
$_dec = $dec;
//exists check
switch ($mode) {
case 'i':
$table = $mode . '2e_table';
break;
case 's':
$table = $mode . '2e_table';
break;
case 'e':
$table = $mode . '2s_table';
break;
}
if (empty($this->{$table})) {
//.........这里部分代码省略.........