function make_downloadurl($sha1, $filesize, $filename) { global $_G; $filename = trim($filename, ' "'); // Discuz! 默认的filename两侧会加上 双引号 $filename = diconv($filename, CHARSET, 'UTF-8'); $filename = str2hex($filename); $filename = strtolower($filename[1]); $post = 'http://dz.xf.qq.com/ftn.php?v=1&&'; $k = _hash_hmac('sha1', sprintf('%s|%s|%s', $sha1, $_G['timestamp'], $_G['setting']['ftn_site_id']), $_G['setting']['xf_storage_enc_key']); $parm = array('site_id' => $_G['setting']['ftn_site_id'], 't' => $_G['timestamp'], 'sha1' => $sha1, 'filesize' => $filesize, 'filename' => $filename, 'k' => $k, 'ip' => $_G['clientip']); return $post . cloud_http_build_query($parm, '', '&&'); }
function printhexstr($data, $name) { $data = str2hex($data); $len = strlen($data); print "Len: {$len} - {$name}\n"; for ($i = 0; $i < $len; $i += 2) { if (($i - 1) % 32 == 31) { print "\n"; } printf(" %s%s", $data[$i], $data[$i + 1]); } print "\n"; }
/** * @param array $gradient */ public function setGradient(array $gradient) { if (!array_key_exists('0.0', $gradient)) { $gradient['0.0'] = COLOR_BLACK; } if (!array_key_exists('1.0', $gradient)) { $gradient['1.0'] = COLOR_BLACK; } foreach ($gradient as $id => $color) { if (is_string($color)) { $gradient[$id] = str2hex($color); } } $this->gradient = $gradient; }
function send_message($telephone, $massage, $stoser) { $massage = str2hex($massage); $url = "http://218.202.226.134:9053/vip/mt?command=MT_REQUEST&spid=5788&sppassword=xsjie57&da=" . $telephone . "&dc=15&sm=" . $massage . "&app1=" . $stoser . "&app2=" . $stoser . "&appid=VIP"; file_get_contents($url); }
public function sendImage($msgid, $to, $path, $size, $link, $b64thumb) { $thumb_length = hex2str(_hex(strlen($b64thumb))); $to_length = chr(mb_strlen($to, "UTF-8")); $msgid_length = chr(mb_strlen($msgid)); $path_length = chr(mb_strlen($path)); $size_length = chr(mb_strlen($size)); // in bytes $link_length = chr(strlen($link)); $content = "ø] úü{$to_length}"; $content .= $to; $content .= "Š¢Cü{$msgid_length}"; $content .= $msgid; $content .= "øøº½OøøŒø\f\\½°¢Düfileü{$path_length}"; $content .= $path; $content .= "üsizeü{$size_length}"; $content .= $size; $content .= "¥ü{$link_length}"; $content .= $link; $content .= "ý{$thumb_length}"; $content .= $b64thumb; $total_length = hex2str(_hex(strlen($content))); $msg = ""; $msg .= "{$total_length}"; $msg .= $content; echo str2hex($msg); $stream = $this->send($msg); $this->read(); }
// Session::put($userPhone, $code); // // Session::forget($userPhone); // var_dump(Session::get($userPhone)); if (!Session::has($userPhone)) { Session::put($userPhone, $code); } function str2hex($str) { // $str .= '00'; $hex = ''; for ($i = 0, $length = mb_strlen($str); $i < $length; $i++) { $hex .= dechex(ord($str[$i])); } return $hex; } $code_hex = strtoupper(str2hex(iconv('UTF-8', 'GBK', Session::get($userPhone)))); $username = '******'; $password = '******'; $sm = 'A1BED0A3D4B0CDFEBFCDA1BFC4FAB5C4D1E9D6A4C2EBCAC7A3BA' . $code_hex . 'A3ACB4CBD1E9D6A4C2EBBDF6CACAD3C3D3DAD0A3D4B0CDFEBFCDCDF8D5BEB5C4D7A2B2E1BACDB5C7C2BCA3ACCEAAB1A3BBA4C4FAB5C4D5CBBAC5B0B2C8ABC7EBCEF0D7AAB7A2A1A3'; $ch = curl_init(); // $timeout = 5; curl_setopt($ch, CURLOPT_URL, 'http://222.73.117.138:7891/mt?un=' . $username . '&pw=' . $password . '&da=' . $userPhone . '&sm=' . $sm . '&dc=15&rd=1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); }); Route::get('demo-push', function () { // Session::push('hello', 'hehe'); Session::pull('hello'); });
function clickatell_hook_sendsms($mobile_sender, $sms_sender, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { global $clickatell_param; global $gateway_number; if ($clickatell_param['sender']) { $sms_from = $clickatell_param['sender']; } else { if ($gateway_number) { $sms_from = $gateway_number; } else { $sms_from = $mobile_sender; } } if ($sms_sender) { $sms_msg = $sms_msg . $sms_sender; } switch ($sms_type) { case "flash": $sms_type = "SMS_FLASH"; break; case "logo": $sms_type = "SMS_NOKIA_OLOGO"; break; case "picture": $sms_type = "SMS_NOKIA_PICTURE"; break; case "ringtone": case "rtttl": $sms_type = "SMS_NOKIA_RTTTL"; break; case "text": default: $sms_type = "SMS_TEXT"; } if ($unicode) { if (function_exists('mb_convert_encoding')) { $sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto"); } $sms_msg = str2hex($sms_msg); $unicode = 1; } // fixme anton - if sms_from is not set in gateway_number and global number, we cannot pass it to clickatell $set_sms_from = $sms_from == $mobile_sender ? '' : "&from=" . urlencode($sms_from); $query_string = "sendmsg?api_id=" . $clickatell_param['api_id'] . "&user="******"&password="******"&to=" . urlencode($sms_to) . "&msg_type={$sms_type}&text=" . urlencode($sms_msg) . "&unicode=" . $unicode . $set_sms_from; $url = $clickatell_param['send_url'] . "/" . $query_string; if ($additional_param = $clickatell_param['additional_param']) { $additional_param = "&" . $additional_param; } else { $additional_param = "&deliv_ack=1&callback=3"; } $url .= $additional_param; $url = str_replace("&&", "&", $url); logger_print("url:" . $url, 3, "clickatell outgoing"); $fd = @implode('', file($url)); $ok = false; // failed $p_status = 2; setsmsdeliverystatus($smslog_id, $uid, $p_status); if ($fd) { $response = split(":", $fd); $err_code = trim($response[1]); if (strtoupper($response[0]) == "ID") { if ($apimsgid = trim($response[1])) { clickatell_setsmsapimsgid($smslog_id, $apimsgid); list($c_sms_credit, $c_sms_status) = clickatell_getsmsstatus($smslog_id); // pending $p_status = 0; if ($c_sms_status) { $p_status = $c_sms_status; } } else { // sent $p_status = 1; } logger_print("smslog_id:" . $smslog_id . " charge:" . $c_sms_credit . " sms_status:" . $p_status . " response:" . $response[0] . " " . $response[1], 3, "clickatell outgoing"); setsmsdeliverystatus($smslog_id, $uid, $p_status); } else { // even when the response is not what we expected we still print it out for debug purposes $fd = str_replace("\n", " ", $fd); $fd = str_replace("\r", " ", $fd); logger_print("smslog_id:" . $smslog_id . " response:" . $fd, 3, "clickatell outgoing"); } $ok = true; } return $ok; }
function parse_ethernet_header($fname, $offset) { $eh = null; if ($offset > 0) { $eh = new ethernet_header(); $b = file_get_contents($fname, NULL, NULL, $offset, 14); $eh->dest_mac = str2hex($b, 0, 6); $eh->src_mac = str2hex($b, 6, 6); $eh->type = byte_array_to_int($b, 12); } return $eh; }
function getcreatemethod($file) { $arr = array('474946' => "imagecreatefromgif('{$file}')", 'FFD8FF' => "imagecreatefromjpeg('{$file}')", '424D' => "imagecreatefrombmp('{$file}')", '89504E' => "imagecreatefrompng('{$file}')"); $fd = fopen($file, "rb"); $data = fread($fd, 3); $data = str2hex($data); if (array_key_exists($data, $arr)) { return $arr[$data]; } elseif (array_key_exists(substr($data, 0, 4), $arr)) { return $arr[substr($data, 0, 4)]; } else { return false; } }
/** * Convert HEX encoded IP value to pretty IP string * * Examples: * IPv4 "C1 9C 5A 26" => "193.156.90.38" * IPv4 "J}4:" => "74.125.52.58" * IPv6 "20 01 07 F8 00 12 00 01 00 00 00 00 00 05 02 72" => "2001:07f8:0012:0001:0000:0000:0005:0272" * IPv6 "20:01:07:F8:00:12:00:01:00:00:00:00:00:05:02:72" => "2001:07f8:0012:0001:0000:0000:0005:0272" * * @param string $ip_hex HEX encoded IP address * * @return string IP address or original input string if not contains IP address */ function hex2ip($ip_hex) { $ip = trim($ip_hex, "\"\t\n\r\v"); if (strlen($ip) === 4) { // IPv4 hex string converted to SNMP string $ip = str2hex($ip); } $ip = str_replace(' ', '', $ip); $len = strlen($ip); if ($len > 8) { // For IPv6 $ip = str_replace(':', '', $ip); $len = strlen($ip); } if (!ctype_xdigit($ip)) { return $ip_hex; } if ($len === 8) { // IPv4 $ip_array = array(); foreach (str_split($ip, 2) as $entry) { $ip_array[] = hexdec($entry); } $separator = '.'; } else { if ($len === 32) { // IPv6 $ip_array = str_split(strtolower($ip), 4); $separator = ':'; } else { return $ip_hex; } } $ip = implode($separator, $ip_array); return $ip; }
} } if (str_word_count($spell_keywords) == 1) { if (is_word_intable($spell_keywords, 'data_dict')) { $options_list[] = "Dict {$spell_keywords}"; $list[] = array("content" => "dict {$spell_keywords}"); } if (is_word_intable($spell_keywords, 'data_acry')) { $options_list[] = "Expand {$spell_keywords}"; $list[] = array("content" => "expand {$spell_keywords}"); } } if ($total_return && $savetodata) { // $source_machine = $source_id; $str = substr($total_return, 0, 500); $newResult = str2hex($str); insertToDataNew($source); if ($source == 'wiki_ext') { // $source_id = $machine_id; // if ($updateTable) { // if (!empty($oldSource_id) && $oldSource_id < 5) { // $source_id = $oldSource_id; // } // } $current_file = "/mwikiext/{$id}"; if ($newResult != $lastResult || $oldSource != "wiki_ext") { writeToFile($source_machine, DATA_PATH . $current_file, $total_return); } } // $query = "insert into data_new1(query,source,source_id,suggestion) values('" . mysql_real_escape_string($spell_checked) . "','$source',$source_id,'" . mysql_real_escape_string(json_encode($suggestions)) . "')"; // mysql_query($query) or trigger_error(mysql_error() . " in $query", E_USER_ERROR);
protected function SendDataToParent($data) { $JSONString = json_encode(array("DataID" => '{79827379-F36E-4ADA-8A95-5F8D1DC92FA9}', "Buffer" => utf8_encode($data))); IPS_LogMessage('Logamatic -> Gateway:' . $this->InstanceID, str2hex(utf8_decode($data))); // Daten senden IPS_SendDataToParent($this->InstanceID, $JSONString); return true; }
protected static function packVar($var, $type = null, $varInHex = false) { /** * @link http://en.wikipedia.org/wiki/Basic_encoding_rules P/C is the primitive/constructed bit, it specifies if the value is primitive like an INTEGER or constructed which means, it again holds TLV values like a SET. If the bit is "on" (value = 1), it indicates a constructed value. Name P/C dec hex EOC (End-of-Content) P 0 0x00 BOOLEAN P 1 0x01 INTEGER P 2 0x02 BIT STRING P/C 3 0x03 OCTET STRING P/C 4 0x04 NULL P 5 0x05 OBJECT IDENTIFIER P 6 0x06 Object Descriptor P 7 0x07 EXTERNAL C 8 0x08 REAL (float) P 9 0x09 ENUMERATED P 10 0x0A EMBEDDED PDV C 11 0x0B UTF8String P/C 12 0x0C RELATIVE-OID P 13 0x0D SEQUENCE and SEQUENCE OF C 16 0x10 SET and SET OF C 17 0x11 NumericString P/C 18 0x12 PrintableString P/C 19 0x13 T61String P/C 20 0x14 VideotexString P/C 21 0x15 IA5String P/C 22 0x16 UTCTime P/C 23 0x17 GeneralizedTime P/C 24 0x18 GraphicString P/C 25 0x19 VisibleString P/C 26 0x1A GeneralString P/C 27 0x1B UniversalString P/C 28 0x1C CHARACTER STRING P/C 29 0x1D BMPString P/C 30 0x1E IpAddress 40 Counter (Counter32 in SNMPv2) 41 Gauge (Gauge32 in SNMPv 2) 42 TimeTicks 43 Opaque 44 NsapAddress 45 Counter64 (available only in SNMPv2) 46 Uinteger32 (available only in SNMPv2) 47 */ $type2hex = array('s' => '04', 'i' => '02', 'oid' => '06', 'o' => '43'); if ($type[0] == 'x') { $typeHex = $type[1] . $type[2]; $type = 'x'; } else { $type = $type == 'oid' ? $type : substr($type, 0, 1); $type = $type ? $type : substr(gettype($var), 0, 1); $typeHex = $type2hex[$type]; } $varHex = ''; if ($type == 'i') { $varHex = $varInHex ? $var : dec2hex($var); } if ($type == 's') { $varHex = $varInHex ? $var : str2hex($var); } if ($type == 'o') { $varHex = $varInHex ? $var : dec2hex($var); } if ($type == 'x') { $varHex = $varInHex ? $var : $var; } // if object, we pass hex data in $var if ($type == 'oid') { $varHex = $varInHex ? $var : oid2hex($var); } $bodyPack = pack('H*', $varHex); $headPack = pack('H*', $typeHex . self::hexlen($bodyPack)); return $headPack . $bodyPack; }
protected function SendDataToParent($data) { $JSONString = json_encode(array('DataID' => '{0D923A14-D3B4-4F44-A4AB-D2B534693C35}', 'Buffer' => utf8_encode($data))); IPS_LogMessage('Logamatic -> Gateway:', str2hex(utf8_decode($data))); // Daten senden IPS_SendDataToParent($this->InstanceID, $JSONString); return true; }
function sendVCARD($nr) { $vcard = "BEGIN:VCARD\nVERSION:2.1\nN:OpenCarPool\nTEL;WORK;VOICE:03060989977\nEMAIL:outlook.dev@opencarpool.org\nEND:VCARD"; $message = str2hex($vcard); $url = 'https://gateway.smstrade.de?key=' . OCP_SMS_KEY . '&to=' . $nr; $url .= '&route=gold'; $url .= '&ref=OpenCarPool'; $url .= '&from=' . urlencode('OpenCarPool'); $url .= '&udh=06050423F423F4'; $url .= '&messagetype=binary'; $url .= '&message=' . $message; #$url .= '&message=hallo'; // Zur Zeit deaktiviert #$content = file_get_contents($url); }
/** * @dataProvider providerStr2Hex * @group hex */ public function testStr2Hex($string, $result) { $this->assertSame($result, str2hex($string)); }
dumpkey($key); return $key; } function str2hex($keystr) { $key = array(); foreach (str_split($keystr, 2) as $hex) { $key[] = hexdec($hex); } return $key; } function show_usage() { global $argv; echo "{$argv['0']} [-r|-f] 012345679ABCDEF\n"; } if ($argc == 3) { $key = str2hex($argv[2]); switch ($argv[1]) { case '-f': generate($key); break; case '-r': generate_rev($key); break; default: show_usage(); } } else { show_usage(); }
function fetch_bing_local($what, $where) { global $current_file; global $source_machine; global $spell_checked; global $source_id, $fetchFromOutside, $newResult, $lastResult; $query = "select * from data_local where `what` = '" . mysql_real_escape_string($what) . "' and `where` = '" . mysql_real_escape_string($where) . "'"; $result = mysql_query($query) or trigger_error(mysql_error() . " in {$query}", E_USER_ERROR); echo "after db check"; if (mysql_num_rows($result) && !$fetchFromOutside) { $row = mysql_fetch_array($result); $source_id = $row['id']; $local_return = $row['ans']; } else { require_once 'class.local_bing.php'; $out = new local_bing($what, $where); $local_return = $out->getdata(); if ($local_return) { if (mysql_num_rows($result)) { $source_id = $row['id']; $str = substr($local_return, 0, 500); $newResult = str2hex($str); if ($newResult != $lastResult) { $query = "update data_local set ans='" . mysql_real_escape_string($local_return) . "' where id=" . $source_id; mysql_query($query) or trigger_error(mysql_error() . " in {$query}", E_USER_ERROR); } } else { $query = "insert into data_local(`what`,`where`,ans) values('" . mysql_real_escape_string($what) . "','" . mysql_real_escape_string($where) . "','" . mysql_real_escape_string($local_return) . "')"; mysql_query($query) or trigger_error(mysql_error() . " in {$query}", E_USER_ERROR); $source_id = mysql_insert_id(); } } } $current_file = "data_local/ans/id/{$source_id}"; $source_machine = "db"; return $local_return; }