function my_inet_ntop($ip) { if (strlen($ip) == 4) { // ipv4 list(, $ip) = unpack('N', $ip); $ip = long2ip($ip); } elseif (strlen($ip) == 16) { // ipv6 $ip = bin2hex($ip); $ip = substr(chunk_split($ip, 4, ':'), 0, -1); $ip = explode(':', $ip); $res = ''; foreach ($ip as $seg) { while ($seg[0] == '0') { $seg = substr($seg, 1); } if ($seg != '') { $res .= ($res == '' ? '' : ':') . $seg; } else { if (strpos($res, '::') === false) { if (substr($res, -1) == ':') { continue; } $res .= ':'; continue; } $res .= ($res == '' ? '' : ':') . '0'; } } $ip = $res; } return $ip; }
function getexif($img) { $imgtype = array("", "GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "TIFF(intel byte order)", "TIFF(motorola byte order)", "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM"); $Orientation = array("", "top left side", "top right side", "bottom right side", "bottom left side", "left side top", "right side top", "right side bottom", "left side bottom"); $ResolutionUnit = exif_lang('resolutionunit'); $YCbCrPositioning = array("", "the center of pixel array", "the datum point"); $ExposureProgram = exif_lang('exposureprogram'); $MeteringMode_arr = exif_lang('meteringmode'); $Lightsource_arr = exif_lang('lightsource'); $Flash_arr = array("0" => "flash did not fire", "1" => "flash fired", "5" => "flash fired but strobe return light not detected", "7" => "flash fired and strobe return light detected"); if (!function_exists('exif_read_data')) { return exif_lang('img_info'); } $exif = @exif_read_data($img, "IFD0"); if ($exif === false) { $new_img_info = exif_lang('img_info'); } else { @($exif = exif_read_data($img, 0, true)); foreach ($exif as $type => $typearr) { foreach ($typearr as $key => $kval) { if (is_array($kval)) { foreach ($kval as $vkey => $value) { $str = dhtmlspecialchars(preg_replace("/[^\\[A-Za-z0-9_\\.\\/:\\s-\\]]/", '', trim($value))); $exif[$type][$key][$vkey] = $str; } } elseif (!in_array($key, array('ComponentsConfiguration', 'FileSource', 'SceneType'))) { $str = dhtmlspecialchars(preg_replace("/[^\\[A-Za-z0-9_\\.\\/:\\s-\\]]/", '', trim($kval))); $exif[$type][$key] = $str; } } } $new_img_info = array(exif_lang('FileName') => $exif[FILE][FileName], exif_lang('FileType') => $imgtype[$exif[FILE][FileType]], exif_lang('MimeType') => $exif[FILE][MimeType], exif_lang('FileSize') => $exif[FILE][FileSize], exif_lang('FileDateTime') => date("Y-m-d H:i:s", $exif[FILE][FileDateTime]), exif_lang('ImageDescription') => $exif[IFD0][ImageDescription], exif_lang('Make') => $exif[IFD0][Make], exif_lang('Model') => $exif[IFD0][Model], exif_lang('Orientation') => $Orientation[$exif[IFD0][Orientation]], exif_lang('XResolution') => $exif[IFD0][XResolution] . $ResolutionUnit[$exif[IFD0][ResolutionUnit]], exif_lang('YResolution') => $exif[IFD0][YResolution] . $ResolutionUnit[$exif[IFD0][ResolutionUnit]], exif_lang('Software') => $exif[IFD0][Software], exif_lang('DateTime') => $exif[IFD0][DateTime], exif_lang('Artist') => $exif[IFD0][Artist], exif_lang('YCbCrPositioning') => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]], exif_lang('Copyright') => $exif[IFD0][Copyright], exif_lang('Photographer') => $exif[COMPUTED][Copyright . Photographer], exif_lang('Editor') => $exif[COMPUTED][Copyright . Editor], exif_lang('ExifVersion') => $exif[EXIF][ExifVersion], exif_lang('FlashPixVersion') => "Ver. " . number_format($exif[EXIF][FlashPixVersion] / 100, 2), exif_lang('DateTimeOriginal') => $exif[EXIF][DateTimeOriginal], exif_lang('DateTimeDigitized') => $exif[EXIF][DateTimeDigitized], exif_lang('Height') => $exif[COMPUTED][Height], exif_lang('Width') => $exif[COMPUTED][Width], exif_lang('ApertureValue') => $exif[EXIF][ApertureValue], exif_lang('ShutterSpeedValue') => $exif[EXIF][ShutterSpeedValue], exif_lang('ApertureFNumber') => $exif[COMPUTED][ApertureFNumber], exif_lang('MaxApertureValue') => "F" . $exif[EXIF][MaxApertureValue], exif_lang('ExposureTime') => $exif[EXIF][ExposureTime], exif_lang('FNumber') => $exif[EXIF][FNumber], exif_lang('MeteringMode') => getimageinfoval($exif[EXIF][MeteringMode], $MeteringMode_arr), exif_lang('LightSource') => getimageinfoval($exif[EXIF][LightSource], $Lightsource_arr), exif_lang('Flash') => getimageinfoval($exif[EXIF][Flash], $Flash_arr), exif_lang('ExposureMode') => $exif[EXIF][ExposureMode] == 1 ? exif_lang('manual') : exif_lang('auto'), exif_lang('WhiteBalance') => $exif[EXIF][WhiteBalance] == 1 ? exif_lang('manual') : exif_lang('auto'), exif_lang('ExposureProgram') => $ExposureProgram[$exif[EXIF][ExposureProgram]], exif_lang('ExposureBiasValue') => $exif[EXIF][ExposureBiasValue] . "EV", exif_lang('ISOSpeedRatings') => $exif[EXIF][ISOSpeedRatings], exif_lang('ComponentsConfiguration') => bin2hex($exif[EXIF][ComponentsConfiguration]) == "01020300" ? "YCbCr" : "RGB", exif_lang('CompressedBitsPerPixel') => $exif[EXIF][CompressedBitsPerPixel] . "Bits/Pixel", exif_lang('FocusDistance') => $exif[COMPUTED][FocusDistance] . "m", exif_lang('FocalLength') => $exif[EXIF][FocalLength] . "mm", exif_lang('FocalLengthIn35mmFilm') => $exif[EXIF][FocalLengthIn35mmFilm] . "mm", exif_lang('UserCommentEncoding') => $exif[COMPUTED][UserCommentEncoding], exif_lang('UserComment') => $exif[COMPUTED][UserComment], exif_lang('ColorSpace') => $exif[EXIF][ColorSpace] == 1 ? "sRGB" : "Uncalibrated", exif_lang('ExifImageLength') => $exif[EXIF][ExifImageLength], exif_lang('ExifImageWidth') => $exif[EXIF][ExifImageWidth], exif_lang('FileSource') => bin2hex($exif[EXIF][FileSource]) == 0x3 ? "digital still camera" : "unknown", exif_lang('SceneType') => bin2hex($exif[EXIF][SceneType]) == 0x1 ? "A directly photographed image" : "unknown", exif_lang('ThumbFileType') => $exif[COMPUTED][Thumbnail . FileType], exif_lang('ThumbMimeType') => $exif[COMPUTED][Thumbnail . MimeType]); } return $new_img_info; }
public function getHexData($chunkSplit = 0, $sep = ' ') { if ($chunkSplit) { return chunk_split(bin2hex($this->_data), (int) $chunkSplit, (string) $sep); } return bin2hex($this->_data); }
public function register() { $this->form_validation->set_rules('first_name', 'First Name', 'required|trim|alpha|min_length[2]'); $this->form_validation->set_rules('last_name', 'Last Name', 'required|trim|alpha|min_length[2]'); $this->form_validation->set_rules('alias', 'Alias', 'required|min_length[3]'); $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email|is_unique[users.email]'); $this->form_validation->set_rules('password', 'Password', 'required|min_length[8]'); $this->form_validation->set_rules('password2', 'Confirm Password', 'required|matches[password]'); $this->form_validation->set_rules('birthdate', 'Birthdate', 'required'); if ($this->form_validation->run() == FALSE) { $this->session->set_flashdata('registration_errors', validation_errors()); redirect(''); } else { $this->load->model('User'); $post = $this->input->post(); $pass = $post['password']; $salt = bin2hex(openssl_random_pseudo_bytes(22)); $hash = crypt($pass, $salt); $post['password'] = $hash; $user = $this->User->register_user($post); if ($user > 0) { $this->session->set_userdata('id', $user); $this->session->set_userdata('name', $post['first_name']); $this->session->set_userdata('loggedin', TRUE); $this->session->set_flashdata('success', 'Thank you for registering, please log in!'); redirect(''); } else { $this->session->set_flashdata('registration_errors', 'There was a system error, plese try again later!'); redirect(''); } } }
public function testHex2binThree() { $data = "וּמִפְּרִ֣י הָעֵץ֮ אֲשֶׁ֣ר בְּתוֹךְ־הַגָּן֒ אָמַ֣ר אֱלֹהִ֗ים לֹ֤א תֹֽאכְלוּ֙ מִמֶּ֔נּוּ וְלֹ֥א תִגְּע֖וּ בּ֑וֹ פֶּן־תְּמֻתֽוּן׃ "; $hex = bin2hex($data); $this->assertEquals($data, hex2bin($hex)); $this->assertEquals($data, Filter_Hex::hex2bin($hex)); }
function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false) { $algorithm = strtolower($algorithm); if (!in_array($algorithm, hash_algos(), true)) { die('PBKDF2 ERROR: Invalid hash algorithm.'); } if ($count <= 0 || $key_length <= 0) { die('PBKDF2 ERROR: Invalid parameters.'); } $hash_length = strlen(hash($algorithm, "", true)); $block_count = ceil($key_length / $hash_length); $output = ""; for ($i = 1; $i <= $block_count; $i++) { // $i encoded as 4 bytes, big endian. $last = $salt . pack("N", $i); // first iteration $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // perform the other $count - 1 iterations for ($j = 1; $j < $count; $j++) { $xorsum ^= $last = hash_hmac($algorithm, $last, $password, true); } $output .= $xorsum; } if ($raw_output) { return substr($output, 0, $key_length); } else { return bin2hex(substr($output, 0, $key_length)); } }
function smarty_modifier_escape($string, $esc_type = 'html') { switch ($esc_type) { case 'html': return htmlspecialchars($string, ENT_QUOTES); case 'htmlall': return htmlentities($string, ENT_QUOTES); case 'url': return urlencode($string); case 'quotes': // escape unescaped single quotes return preg_replace("%(?<!\\\\)'%", "\\'", $string); case 'hex': // escape every character into hex for ($x = 0; $x < strlen($string); $x++) { $return .= '%' . bin2hex($string[$x]); } return $return; case 'hexentity': for ($x = 0; $x < strlen($string); $x++) { $return .= '&#x' . bin2hex($string[$x]) . ';'; } return $return; case 'javascript': // escape quotes and backslashes and newlines return str_replace(array('\\', '\'', "\r", "\n"), array("\\\\", "\\'", '\\r', '\\r'), $string); default: return $string; } }
function getVisitorId() { if (isset($this->details['idvisitor'])) { return bin2hex($this->details['idvisitor']); } return false; }
public function computeSign($sharedSecret) { if (!$this->isValid) { throw new Exception(__METHOD__ . ": Message was not validated."); } try { $bytesHash = sha1($this->GetSignatureBase(), true); $sharedSecret = pack('H*', $sharedSecret); // uprava pre PHP < 5.0 if (strlen($bytesHash) != 20) { $bytes = ""; for ($i = 0; $i < strlen($bytesHash); $i += 2) { $bytes .= chr(hexdec(substr($str, $i, 2))); } $bytesHash = $bytes; } $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_ECB, ""); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($cipher), MCRYPT_RAND); mcrypt_generic_init($cipher, $sharedSecret, $iv); $text = $this->pad(substr($bytesHash, 0, 16), mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB)); $bytesSign = mcrypt_generic($cipher, $text); mcrypt_generic_deinit($cipher); mcrypt_module_close($cipher); $sign = substr(strtoupper(bin2hex($bytesSign)), 0, 32); } catch (Exception $e) { return false; } return $sign; }
/** * Encrypt the given value. * * @param string $value * * @return string */ private function encrypt($value) { if ($this->cipher) { return bin2hex($this->cipher->encrypt($value)); } return $value; }
/** * @covers CryptLib\Key\Derivation\KDF\KDF1 * @dataProvider provideTestDerive * @group slow */ public function testDerive($p, $len, $data, $expect) { $pb = new KDF1(); $actual = $pb->derive($p, $len, $data); $actual = bin2hex($actual); $this->assertEquals($expect, $actual); }
public function login(Request $request) { $input = $request->json()->all(); $validator = Validator::make($input, ['email' => 'required|email', 'password' => 'required', 'deviceId' => 'required']); if ($validator->fails()) { $error = $validator->errors()->all(); return response()->json(['errorMessage' => [$error]], 404); } $deviceId = $input['deviceId']; $result = DB::table('users')->where('email', $input['email'])->first(); if ($result && Hash::check($input['password'], $result->password)) { $res = DB::table('tokens')->where('deviceId', $deviceId)->first(); if ($res) { $token = Token::find($res->id); $token->token = bin2hex(openssl_random_pseudo_bytes(64)); $token->save(); } else { DB::table('tokens')->insert(['token' => bin2hex(openssl_random_pseudo_bytes(64)), 'userId' => $result->id, 'deviceId' => $deviceId]); } $token = DB::table('tokens')->select('token')->where('userId', $result->id)->where('deviceId', $deviceId)->first(); if ($token) { return response()->json($token); } else { return response()->json(['errorMessage' => 'login failed'], 404); } } else { return response()->json(['errorMessage' => 'this user not found'], 404); } }
/** * Smarty escape modifier plugin * * Type: modifier<br> * Name: escape<br> * Purpose: escape string for output * * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @param string $string input string * @param string $esc_type escape type * @param string $char_set character set, used for htmlspecialchars() or htmlentities() * @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities() * @return string escaped input string */ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'UTF-8', $double_encode = true) { switch ($esc_type) { case 'html': return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); case 'url': return rawurlencode($string); case 'urlpathinfo': return str_replace('%2F', '/', rawurlencode($string)); case 'quotes': // escape unescaped single quotes return preg_replace("%(?<!\\\\)'%", "\\'", $string); case 'hex': // escape every byte into hex // Note that the UTF-8 encoded character ä will be represented as %c3%a4 $return = ''; $_length = strlen($string); for ($x = 0; $x < $_length; $x++) { $return .= '%' . bin2hex($string[$x]); } return $return; case 'javascript': // escape quotes and backslashes, newlines, etc. return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/')); default: throw new Exception('Unrecognized escape option "' . $esc_type . '"'); } }
protected function ecryptdString($str,$keys="6461772803150152",$iv="8105547186756005",$cipher_alg=MCRYPT_RIJNDAEL_128){ // // //source_id=xxx&target_id=xxx&type=1 $encrypted_string = bin2hex(mcrypt_encrypt($cipher_alg, $keys, $str, MCRYPT_MODE_CBC,$iv)); return $encrypted_string; }
function Template($Type) { global $Bot; switch ($Type) { case BLOB_ABOUT: $this->AddText("SellBot is a bot developed by Demerzel (RK1: Scottish, RK2: Toxor) "); $this->AddText("designed to enable people to easily create their own personal shop screen. "); $this->AddText("A link to their shop is posted to their selected channel at a specified "); $this->AddText("interval of over five minutes; viewers of the shop can then place offers "); $this->AddText("or reserve items. Auction functions will become available in future versions.<br><br>"); $this->AddText("To download SellBot to use for your own shop, visit: <br>"); $this->AddChatCmd("/start http://code.google.com/p/sellbot/", "http://code.google.com/p/sellbot/"); $this->Render(); break; case BLOB_OPTIONS: $this->Title = "Options"; $this->AddText("To select the channel your shop will be posted on: "); $this->AddChatCmd("/tell " . $Bot->ShopCharacter . " ChanSelect"); $this->Render(); break; case BLOB_CHOOSECHAN: $this->Title = "here."; $this->AddText("Here is a list of all the channels your SellBot can send messages to. Click the one on which you want your shop posted.<br>"); foreach ($Bot->ChatGroups as $GroupId => $Group) { if (substr(bin2hex($Group[0]), 0, 2) == 86) { $this->AddChatCmd("/tell " . $Bot->ShopCharacter . " ChanSelect " . $GroupId, $Group[1]); $this->AddLineBreak(); } } $this->Render(); break; default: $this->Title = "[err: unrecognised blob type {$Type}]"; } }
function getGUID() { $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0xf | 0x40); $data[8] = chr(ord($data[8]) & 0x3f | 0x80); return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); }
function dnpt($ext_ip, $ext_prefix, $int_prefix) { $debug = false; // This is not a complete solution!!!!!!!!!!!!!!!!!!!!!!!!!! $ext_prefix = str_replace(":", "", $ext_prefix); $int_prefix = str_replace(":", "", $int_prefix); // hehe $sauce = hexdec(split(":", $ext_ip)[4]); $ext_c = icmpChecksum(hex2bin($ext_prefix)); $int_c = icmpChecksum(hex2bin($int_prefix)); if ($debug) { print_r(unpack('n', $int_c)); } $diff = unpack('n', $ext_c)[1] - unpack('n', $int_c)[1]; if ($diff < 0) { $diff = 0xffff + $diff; } $diff = $sauce - $diff; if ($debug) { print bin2hex($ext_c); print "\n"; print bin2hex($int_c); print "\n"; print dechex($diff); print "\n"; } $out = split(":", $ext_ip); $out[4] = dechex($diff); $out = join($out, ":"); return $out; }
/** * Generates an RFC 4122-compliant version 4 UUID. * * @return string The string representation of an RFC 4122-compliant, version 4 UUID. * @link http://www.ietf.org/rfc/rfc4122.txt RFC 4122: UUID URN Namespace */ public static function uuid() { $uuid = static::random(16); $uuid[6] = chr(ord($uuid[6]) & static::UUID_CLEAR_VER | static::UUID_VERSION_4); $uuid[8] = chr(ord($uuid[8]) & static::UUID_CLEAR_VAR | static::UUID_VAR_RFC); return join('-', array(bin2hex(substr($uuid, 0, 4)), bin2hex(substr($uuid, 4, 2)), bin2hex(substr($uuid, 6, 2)), bin2hex(substr($uuid, 8, 2)), bin2hex(substr($uuid, 10, 6)))); }
public static function generate() { $token = bin2hex(openssl_random_pseudo_bytes(32)); if (Session::put(Config::get('session_for_csrf_form_token/timestamp_name'), time())) { return Session::put(Config::get('session_for_csrf_form_token/name'), $token); } }
function add_local_user($username, $userdn, $userfullname) { global $config; // generate new random user_password $bytes = openssl_random_pseudo_bytes(50); $user_password = pack('H*', bin2hex($bytes)); foreach ($config['system']['user'] as &$user) { if ($user['name'] == $username && $user['name'] != 'root') { // link local user to remote server by updating user_dn $user['user_dn'] = $userdn; // trash user password when linking to ldap, avoid accidental login // using fall-back local password. User could still reset it's // local password, but only by choice. local_user_set_password($user, $user_password); local_user_set($user); return; } } // new user, add $new_user = array(); $new_user['scope'] = 'user'; $new_user['name'] = $username; $new_user['user_dn'] = $userdn; $new_user['descr'] = $userfullname; local_user_set_password($new_user, $user_password); $new_user['uid'] = $config['system']['nextuid']++; $config['system']['user'][] = $new_user; local_user_set($new_user); }
public function facture() { $em = $this->getDoctrine()->getManager(); $generator = $this->container->get('security.secure_random'); $session = $this->getRequest()->getSession(); $adresse = $session->get('adresse'); $panier = $session->get('panier'); $commande = array(); $totalHT = 0; $totalTVA = 0; $facturation = $em->getRepository('EPEpapetrieBundle:UtilisateursAdresses')->find($adresse['facturation']); $livraison = $em->getRepository('EPEpapetrieBundle:UtilisateursAdresses')->find($adresse['livraison']); $produits = $em->getRepository('EPEpapetrieBundle:Produits')->findArray(array_keys($session->get('panier'))); foreach ($produits as $produit) { $prixHT = $produit->getPrix() * $panier[$produit->getId()]; $prixTTC = $produit->getPrix() * $panier[$produit->getId()] / $produit->getTva()->getMultiplicate(); $totalHT += $prixHT; if (!isset($commande['tva']['%' . $produit->getTva()->getValeur()])) { $commande['tva']['%' . $produit->getTva()->getValeur()] = round($prixTTC - $prixHT, 2); } else { $commande['tva']['%' . $produit->getTva()->getValeur()] += round($prixTTC - $prixHT, 2); } $totalTVA += round($prixTTC - $prixHT, 2); $commande['produit'][$produit->getId()] = array('reference' => $produit->getNom(), 'quantite' => $panier[$produit->getId()], 'prixHT' => round($produit->getPrix(), 2), 'prixTTC' => round($produit->getPrix() / $produit->getTva()->getMultiplicate(), 2)); } $commande['livraison'] = array('prenom' => $livraison->getPrenom(), 'nom' => $livraison->getNom(), 'telephone' => $livraison->getTelephone(), 'adresse' => $livraison->getAdresse(), 'cp' => $livraison->getCp(), 'ville' => $livraison->getVille(), 'pays' => $livraison->getPays(), 'complement' => $livraison->getComplement()); $commande['facturation'] = array('prenom' => $facturation->getPrenom(), 'nom' => $facturation->getNom(), 'telephone' => $facturation->getTelephone(), 'adresse' => $facturation->getAdresse(), 'cp' => $facturation->getCp(), 'ville' => $facturation->getVille(), 'pays' => $facturation->getPays(), 'complement' => $facturation->getComplement()); $commande['prixHT'] = round($totalHT, 2); $commande['prixTTC'] = round($totalHT + $totalTVA, 2); $commande['token'] = bin2hex($generator->nextBytes(20)); return $commande; }
function ___getmime() { $path = trim(func_get_arg(0)); if (func_num_args() >= 2) { $type = trim(func_get_arg(1)); $type = explode(':', $type); } if (!is_file($path)) { return false; } if (!($fp = fopen($path, "rb"))) { return false; } $bsupport = array(array('jpg', 'ffd8ff', 'image/jpeg'), array('png', '89504e47', 'image/png'), array('gif', '47494638', 'image/gif'), array('bmp', '424d', 'image/x-ms-bmp'), array('zip', '504b0304', 'application/zip')); $headstr = bin2hex(fread($fp, 4)); fclose($fp); foreach ($bsupport as $temp) { if (preg_match("/^{$temp['1']}/i", $headstr)) { if (!isset($type)) { return $temp[2]; } elseif (in_array($temp[0], $type)) { return $temp[2]; } } } return false; }
/** * Builds the NoPermission UI * * @access public * @param string $user Username * @param string $gadget The Gadget user is requesting * @param string $action The 'denied' action * @return string XHTML content */ function ShowNoPermission($user, $gadget, $action) { // Load the template $tpl = $this->gadget->template->load('NoPermission.html'); $tpl->SetBlock('NoPermission'); $tpl->SetVariable('nopermission', _t('USERS_NO_PERMISSION_TITLE')); $tpl->SetVariable('description', _t('USERS_NO_PERMISSION_DESC', $gadget, $action)); $tpl->SetVariable('admin_script', BASE_SCRIPT); $tpl->SetVariable('site-name', $this->gadget->registry->fetch('site_name', 'Settings')); $tpl->SetVariable('site-slogan', $this->gadget->registry->fetch('site_slogan', 'Settings')); $tpl->SetVariable('BASE_URL', $GLOBALS['app']->GetSiteURL('/')); $tpl->SetVariable('.dir', _t('GLOBAL_LANG_DIRECTION') == 'rtl' ? '.rtl' : ''); if ($GLOBALS['app']->Session->Logged()) { $tpl->SetBlock('NoPermission/known'); $logoutLink = $this->gadget->urlMap('Logout'); $referLink = empty($_SERVER['HTTP_REFERER']) ? $GLOBALS['app']->getSiteURL('/') : Jaws_XSS::filter($_SERVER['HTTP_REFERER']); $tpl->SetVariable('known_description', _t('USERS_NO_PERMISSION_KNOWN_DESC', $logoutLink, $referLink)); $tpl->ParseBlock('NoPermission/known'); } else { $tpl->SetBlock('NoPermission/anon'); $loginLink = $this->gadget->urlMap('LoginBox', array('referrer' => bin2hex(Jaws_Utils::getRequestURL(false)))); $referLink = empty($_SERVER['HTTP_REFERER']) ? $GLOBALS['app']->getSiteURL('/') : Jaws_XSS::filter($_SERVER['HTTP_REFERER']); $tpl->SetVariable('anon_description', _t('USERS_NO_PERMISSION_ANON_DESC', $loginLink, $referLink)); $tpl->ParseBlock('NoPermission/anon'); } $tpl->ParseBlock('NoPermission'); return $tpl->Get(); }
public function getHash($hexString = true) { if ($hexString) { return bin2hex($this->hash); } return $this->hash; }
/** * Returns a JSON string encoding the encrypted password and the used salt. * * @param string $password The password to encrypt. * @param string $salt Optional. The salt to use. * @return string * @see encryptPassword() * @see verifyPassword() */ public static function getPasswordHash($password, $salt = null) { if ($salt === null) { $salt = bin2hex(mcrypt_create_iv(8, MCRYPT_DEV_URANDOM)) . time(); } return json_encode(array($salt, self::encryptPassword($password, $salt))); }
public function handleRegister() { $registerData = Input::all(); $registerRules = array('name' => 'required|unique:users|alpha_dash|min:4', 'email' => 'required|email|unique:users', 'password' => 'required|alpha_num|min:6', 'comfirmed_password' => 'required|alpha_num|same:password', 'terms' => 'required'); $registerValidator = Validator::make($registerData, $registerRules); if ($registerValidator->passes()) { $user = new User(); $user->name = Input::get('name'); $user->email = Input::get('email'); $user->password = Hash::make(Input::get('password')); $user->activation_key = bin2hex(openssl_random_pseudo_bytes(16)); $user->activation_state = "on"; $user->save(); // send activation link /*$mailData = array( 'name'=> Input::get('name'), 'link'=> $user->activation_key ); Mail::send('emails.activate',$mailData, function($message) { $message->subject("ubexchange account activation"); $message->to(Input::get('email')); } );*/ return Redirect::to('login')->with('alertMessage', "check email, to activate account."); } if ($registerValidator->fails()) { return Redirect::back()->withInput()->withErrors($registerValidator); } }
/** * gbk转utf8 * @param $gbstr */ function gbk_to_utf8($gbstr) { global $CODETABLE; if (empty($CODETABLE)) { $filename = CODETABLEDIR . 'gb-unicode.table'; $fp = fopen($filename, 'rb'); while ($l = fgets($fp, 15)) { $CODETABLE[hexdec(substr($l, 0, 6))] = substr($l, 7, 6); } fclose($fp); } $ret = ''; $utf8 = ''; while ($gbstr) { if (ord(substr($gbstr, 0, 1)) > 0x80) { $thisW = substr($gbstr, 0, 2); $gbstr = substr($gbstr, 2, strlen($gbstr)); $utf8 = ''; @($utf8 = unicode_to_utf8(hexdec($CODETABLE[hexdec(bin2hex($thisW)) - 0x8080]))); if ($utf8 != '') { for ($i = 0; $i < strlen($utf8); $i += 3) { $ret .= chr(substr($utf8, $i, 3)); } } } else { $ret .= substr($gbstr, 0, 1); $gbstr = substr($gbstr, 1, strlen($gbstr)); } } return $ret; }
function get_replay_type($data, $fileExtension) { if (strcasecmp($fileExtension, "cnc4replay") == 0) { return "cnc4replay"; } if (strcasecmp($fileExtension, "ra3replay") == 0) { return "ra3replay"; } if (strcasecmp($fileExtension, "kwreplay") == 0) { return "kwreplay"; } if (strcasecmp($fileExtension, "cnc3replay") == 0) { return "cnc3replay"; } if (strcasecmp($fileExtension, "rep") == 0) { return "rep"; } if (strcasecmp($fileExtension, "rec") == 0) { $hexdata = bin2hex($data); //先判断是否英雄连,第五个字节后为coh $cohToken = substr($hexdata, 8, 6); $cohToken = hex2bin($cohToken); if ($cohToken == "COH") { return "rec"; } //是英雄连 $dowToken = substr($hexdata, 24, 8); $dowToken = hex2bin($dowToken); if ($dowToken == "DOW2") { return "dow2"; } } }
/** * Generates the fingerprint for request. * * @param string $merchantApiLoginId * @param string $merchantTransactionKey * @param string $amount * @param string $fpSequence An invoice number or random number. * @param string $fpTimestamp * @return string The fingerprint. */ public function generateRequestSign($merchantApiLoginId, $merchantTransactionKey, $amount, $currencyCode, $fpSequence, $fpTimestamp) { if (phpversion() >= '5.1.2') { return hash_hmac("md5", $merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode, $merchantTransactionKey); } return bin2hex(mhash(MHASH_MD5, $merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode, $merchantTransactionKey)); }
/** * Generates a URI based on a serial stored in the database. * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @return string * @throws common_UriProviderException */ public function provide() { $returnValue = (string) ''; $modelUri = common_ext_NamespaceManager::singleton()->getLocalNamespace()->getUri(); $uri = $modelUri . uniqid('i') . getmypid() . bin2hex(openssl_random_pseudo_bytes(8)); return (string) $uri; }