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

PHP base_convert函数代码示例

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

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



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

示例1: create

 /** Creates directory or throws exception on fail
  * @param string $pathname
  * @param int    $mode     Mode in octal
  * @return bool
  */
 public static function create($pathname, $mode = self::MOD_DEFAULT)
 {
     if (strpos($pathname, '/') !== false) {
         $pathname = explode('/', $pathname);
     }
     if (is_array($pathname)) {
         $current_dir = '';
         $create = array();
         do {
             $current_dir = implode('/', $pathname);
             if (is_dir($current_dir)) {
                 break;
             }
             $create[] = array_pop($pathname);
         } while (any($pathname));
         if (any($create)) {
             $create = array_reverse($create);
             $current_dir = implode('/', $pathname);
             foreach ($create as $dir) {
                 $current_dir .= '/' . $dir;
                 if (!is_dir($current_dir)) {
                     if (!($action = @mkdir($current_dir, $mode))) {
                         throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $current_dir, base_convert($mode, 10, 8)));
                     }
                 }
             }
         }
     } else {
         if (!($action = @mkdir($pathname, $mode, true))) {
             throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $pathname, base_convert($mode, 10, 8)));
         }
     }
     return $action;
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:39,代码来源:directory.php


示例2: load

 public function load(ObjectManager $manager)
 {
     // Obtener todas las ciudades de la base de datos
     $ciudades = $manager->getRepository('CiudadBundle:Ciudad')->findAll();
     $i = 1;
     foreach ($ciudades as $ciudad) {
         $numeroTiendas = rand(2, 5);
         for ($j = 1; $j <= $numeroTiendas; $j++) {
             $tienda = new Tienda();
             $tienda->setNombre($this->getNombre());
             $tienda->setLogin('tienda' . $i);
             $tienda->setSalt(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36));
             $passwordEnClaro = 'tienda' . $i;
             $encoder = $this->container->get('security.encoder_factory')->getEncoder($tienda);
             $passwordCodificado = $encoder->encodePassword($passwordEnClaro, $tienda->getSalt());
             $tienda->setPassword($passwordCodificado);
             $tienda->setDescripcion($this->getDescripcion());
             $tienda->setDireccion($this->getDireccion($ciudad));
             $tienda->setCiudad($ciudad);
             $manager->persist($tienda);
             $i++;
         }
     }
     $manager->flush();
 }
开发者ID:adripanico,项目名称:cupon,代码行数:25,代码来源:Tiendas.php


示例3: twofactor_genkey

/**
 * Generate Secret Key
 * @return string
 */
function twofactor_genkey()
{
    global $base32_enc;
    // RFC 4226 recommends 160bits Secret Keys, that's 20 Bytes for the lazy ones.
    $crypto = false;
    $raw = "";
    $x = -1;
    while ($crypto == false || ++$x < 10) {
        $raw = openssl_random_pseudo_bytes(20, $crypto);
    }
    // RFC 4648 Base32 Encoding without padding
    $len = strlen($raw);
    $bin = "";
    $x = -1;
    while (++$x < $len) {
        $bin .= str_pad(base_convert(ord($raw[$x]), 10, 2), 8, '0', STR_PAD_LEFT);
    }
    $bin = str_split($bin, 5);
    $ret = "";
    $x = -1;
    while (++$x < sizeof($bin)) {
        $ret .= $base32_enc[base_convert(str_pad($bin[$x], 5, '0'), 2, 10)];
    }
    return $ret;
}
开发者ID:samyscoub,项目名称:librenms,代码行数:29,代码来源:twofactor.lib.php


示例4: decode

 public static function decode($input)
 {
     if (empty($input)) {
         return;
     }
     $paddingCharCount = substr_count($input, self::$map[32]);
     $allowedValues = array(6, 4, 3, 1, 0);
     if (!in_array($paddingCharCount, $allowedValues)) {
         return false;
     }
     for ($i = 0; $i < 4; $i++) {
         if ($paddingCharCount == $allowedValues[$i] && substr($input, -$allowedValues[$i]) != str_repeat(self::$map[32], $allowedValues[$i])) {
             return false;
         }
     }
     $input = str_replace('=', '', $input);
     $input = str_split($input);
     $binaryString = "";
     for ($i = 0; $i < count($input); $i = $i + 8) {
         $x = "";
         if (!in_array($input[$i], self::$map)) {
             return false;
         }
         for ($j = 0; $j < 8; $j++) {
             $x .= str_pad(base_convert(@self::$flippedMap[@$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
         }
         $eightBits = str_split($x, 8);
         for ($z = 0; $z < count($eightBits); $z++) {
             $binaryString .= ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ? $y : "";
         }
     }
     return $binaryString;
 }
开发者ID:kraczo,项目名称:pracowniapizzy,代码行数:33,代码来源:base32.php


示例5: __construct

 /**
  * Конструктор
  *
  * @param mixed $value Число (0xFFEEDD), массив (array(0xFF, 0xEE, 0xDD)), либо строка ('#FFEEDD' или название web-цвета)
  */
 function __construct($value)
 {
     /**
      * Если число сохраняем
      */
     if (is_int($value)) {
         $this->RGB = $value;
     } else {
         if (is_array($value) && count($value) == 3) {
             $temp = array_values($value);
             $this->RGB = ($temp[0] & 0xff) << 16 | ($temp[1] & 0xff) << 8 | $temp[2] & 0xff;
         } else {
             if (is_string($value)) {
                 if ($value[0] == '#') {
                     $this->RGB = intval(base_convert(trim($value, '# '), 16, 10)) & 0xffffff;
                 } else {
                     if (isset(self::$webColors[$temp = strtolower($value)])) {
                         $this->RGB = self::$webColors[$temp];
                     }
                 }
             }
         }
     }
     /**
      * Иначе выдаём ошибку
      */
     if ($this->RGB === FALSE) {
         triggerError(sprintf(Open_Text::getInstance()->dget('errors', 'The value "<b>%s</b>" cannot be converted to color'), $value), E_USER_WARNING);
     }
 }
开发者ID:paveli,项目名称:OpenStructPHP,代码行数:35,代码来源:Color.php


示例6: hex2arr

 /**
  * 递归从左到右处理每一个字节 把非法的字节替换成?
  *  GBK定义 如果单个字节的第8个BIT是0(高位),則这个字节是一个字符
  *          如果是1  则和后面的一个字节合成一个字符,后面的这个字节的第8个BIT也必须是1
  *          第二个字节范围 x40 64 xFE 254
  * 字符有一字节和双字节编码,00–7F范围内是一位,和ASCII保持一致
  * 双字节中,第一字节的范围是81–FE(也就是不含80和FF),第二字节的一部分领域在40–FE
  * @access public
  * @param mixed $str
  * @return void
  * @author 刘建辉
  * @修改日期 2013-02-21 17:28:28
  */
 public static function hex2arr($str)
 {
     $arr = array();
     $i = 0;
     $len = strlen($str);
     while ($i < $len) {
         $firstStr = substr($str, $i, 2);
         $firstStrdec = base_convert($firstStr, 16, 10);
         if ($firstStrdec > 128 && $firstStrdec < 255) {
             //双字节字符
             $secondStr = base_convert(substr($str, $i + 2, 2), 16, 10);
             if ($secondStr > 63 && $secondStr < 255) {
                 $arr[] = substr($str, $i, 4);
             } else {
                 $arr[] = '3f';
             }
             $i += 4;
         } else {
             //单字节字符
             $arr[] = $firstStrdec > 33 && $firstStrdec < 126 ? $firstStr : '3f';
             $i += 2;
         }
     }
     return $arr;
 }
开发者ID:tianyunchong,项目名称:php,代码行数:38,代码来源:StringHelper.php


示例7: login

 public function login($username, $password, $hash = true)
 {
     if (empty($username) || empty($password)) {
         return false;
     }
     if ($hash) {
         $password = md5($password);
     }
     $query = $this->db->query("SELECT `password` FROM `" . DB_PREFIX . "user` WHERE `username` = '" . $this->db->escape($username) . "'");
     list($pass, $suffix) = explode(':', $query->row['password']);
     if (!$suffix) {
         $suffix = md5(base_convert(rand(1.0E+17, 1.0E+21), 10, 36) . time());
         $this->db->query("UPDATE `" . DB_PREFIX . "user` SET \n              `password`    = '" . $this->db->escape(md5($password . $suffix) . ':' . $suffix) . "' \n              WHERE `username` = '" . $this->db->escape($username) . "'");
     }
     $user_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "user` " . "WHERE username = '" . $this->db->escape($username) . "' " . "AND password = '" . $this->db->escape(md5($password . $suffix) . ':' . $suffix) . "'");
     if ($user_query->num_rows) {
         $this->session->set('user_id', $user_query->row['user_id']);
         $utoken = $this->session->has('utoken') ? $this->session->get('utoken') : md5(date('d-m-Y') . mt_rand(1000000000, 9999999999));
         $this->session->set('utoken', $utoken);
         $this->ukey = md5($this->key) . ":" . $this->session->get('utoken') . "_" . $user_query->row['user_id'];
         $this->session->set('token', $this->ukey);
         $this->session->set('nttoken', $this->key . $this->session->get('utoken'));
         $this->session->set('ukey', $this->ukey);
         $this->user_id = $user_query->row['user_id'];
         $this->username = $user_query->row['username'];
         $user_group_query = $this->db->query("SELECT permission FROM " . DB_PREFIX . "user_group WHERE user_group_id = '" . (int) $user_query->row['user_group_id'] . "'");
         foreach (unserialize($user_group_query->row['permission']) as $key => $value) {
             $this->permissions[$key] = $value;
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:josueaponte7,项目名称:necotienda_standalone,代码行数:34,代码来源:user.php


示例8: testPerformanceCreateAction

 public function testPerformanceCreateAction()
 {
     $this->request('/admin/Performance/create', 'GET', 302);
     $this->request('/admin/Performance/create' . base_convert(md5(uniqid()), 11, 10), 'GET', 404);
     $this->logIn();
     $this->request('/admin/Performance/create', 'GET', 200);
 }
开发者ID:0TshELn1ck,项目名称:CheTheatre,代码行数:7,代码来源:AdminPerformanceControllerTest.php


示例9: saveMIDItoFile

 public function saveMIDItoFile()
 {
     $this->filename = base_convert(mt_rand(), 10, 36);
     $this->filepath = $this->saveDir.$this->filename;
     $this->midi->saveMidFile($this->filepath.'.mid', 0666);
     return true;
 }
开发者ID:niieani,项目名称:nandu,代码行数:7,代码来源:class.MIDIfy.php


示例10: make_seccode

 public static function make_seccode($seccode = '')
 {
     global $_G;
     if (!$seccode) {
         $seccode = random(6, 1);
         $seccodeunits = '';
         if ($_G['setting']['seccodedata']['type'] == 1) {
             $lang = lang('seccode');
             $len = strtoupper(CHARSET) == 'GBK' ? 2 : 3;
             $code = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
             $seccode = '';
             for ($i = 0; $i < 2; $i++) {
                 $seccode .= substr($lang['chn'], $code[$i] * $len, $len);
             }
         } elseif ($_G['setting']['seccodedata']['type'] == 3) {
             $s = sprintf('%04s', base_convert($seccode, 10, 20));
             $seccodeunits = 'CEFHKLMNOPQRSTUVWXYZ';
         } else {
             $s = sprintf('%04s', base_convert($seccode, 10, 24));
             $seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
         }
         if ($seccodeunits) {
             $seccode = '';
             for ($i = 0; $i < 4; $i++) {
                 $unit = ord($s[$i]);
                 $seccode .= $unit >= 0x30 && $unit <= 0x39 ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57];
             }
         }
     }
     self::_create('code', $seccode);
     return $seccode;
 }
开发者ID:MCHacker,项目名称:discuz-docker,代码行数:32,代码来源:helper_seccheck.php


示例11: get_subscribed_forum_func

function get_subscribed_forum_func()
{
    global $config, $db, $user, $auth, $mobiquo_config, $phpbb_home;
    $user->setup('ucp');
    if (!$user->data['is_registered']) {
        trigger_error('LOGIN_EXPLAIN_UCP');
    }
    $forum_list = array();
    if ($config['allow_forum_notify']) {
        $forbidden_forums = $auth->acl_getf('!f_read', true);
        $forbidden_forums = array_unique(array_keys($forbidden_forums));
        if (isset($mobiquo_config['hide_forum_id'])) {
            $forbidden_forums = array_unique(array_merge($forbidden_forums, $mobiquo_config['hide_forum_id']));
        }
        $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_WATCH_TABLE => 'fw', FORUMS_TABLE => 'f'), 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
                AND f.forum_id = fw.forum_id
                AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true), 'ORDER_BY' => 'left_id');
        if ($config['load_db_lastread']) {
            $sql_array['LEFT_JOIN'] = array(array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'));
            $sql_array['SELECT'] .= ', ft.mark_time ';
        } else {
            $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
            $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
        }
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        $forum_list = array();
        while ($row = $db->sql_fetchrow($result)) {
            $forum_id = $row['forum_id'];
            if ($config['load_db_lastread']) {
                $forum_check = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
            } else {
                $forum_check = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
            }
            $unread_forum = $row['forum_last_post_time'] > $forum_check ? true : false;
            $logo_url = '';
            if (file_exists("./forum_icons/{$forum_id}.png")) {
                $logo_url = $phpbb_home . $config['tapatalkdir'] . "/forum_icons/{$forum_id}.png";
            } else {
                if (file_exists("./forum_icons/{$forum_id}.jpg")) {
                    $logo_url = $phpbb_home . $config['tapatalkdir'] . "/forum_icons/{$forum_id}.jpg";
                } else {
                    if (file_exists("./forum_icons/default.png")) {
                        $logo_url = $phpbb_home . $config['tapatalkdir'] . "/forum_icons/default.png";
                    } else {
                        if ($row['forum_image']) {
                            $logo_url = $phpbb_home . $row['forum_image'];
                        }
                    }
                }
            }
            $xmlrpc_forum = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(html_entity_decode($row['forum_name']), 'base64'), 'icon_url' => new xmlrpcval($logo_url), 'is_protected' => new xmlrpcval($row['forum_password'] ? true : false, 'boolean'), 'sub_only' => new xmlrpcval($row['forum_type'] == FORUM_POST ? false : true, 'boolean'), 'new_post' => new xmlrpcval($unread_forum, 'boolean')), 'struct');
            $forum_list[] = $xmlrpc_forum;
        }
        $db->sql_freeresult($result);
    }
    $forum_num = count($forum_list);
    $response = new xmlrpcval(array('total_forums_num' => new xmlrpcval($forum_num, 'int'), 'forums' => new xmlrpcval($forum_list, 'array')), 'struct');
    return new xmlrpcresp($response);
}
开发者ID:danielgospodinow,项目名称:GamingZone,代码行数:60,代码来源:get_subscribed_forum.php


示例12: doSynlogin

 protected function doSynlogin($request, $get, $post)
 {
     if (!API_SYNLOGIN) {
         return API_RETURN_FORBIDDEN;
     }
     $partnerUser = uc_get_user($get['uid'], 1);
     $bind = $this->getUserService()->getUserBindByTypeAndFromId('discuz', $get['uid']);
     if (UC_CHARSET == 'gbk') {
         $get['username'] = iconv('gb2312', 'UTF-8', $get['username']);
     }
     if (empty($bind)) {
         $registration = array('nickname' => $get['username'], 'email' => $partnerUser[2], 'password' => substr(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36), 0, 8), 'createdTime' => $get['time'], 'createdIp' => $request->getClientIp(), 'token' => array('userId' => $get['uid']));
         if (!$this->getAuthService()->isRegisterEnabled()) {
             return API_RETURN_FORBIDDEN;
         }
         $user = $this->getUserService()->register($registration, 'discuz');
     } else {
         $user = $this->getUserService()->getUser($bind['toId']);
         if (empty($user)) {
             return API_RETURN_SUCCEED;
         }
     }
     $this->authenticateUser($user);
     return API_RETURN_SUCCEED;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:25,代码来源:PartnerDiscuzController.php


示例13: generateChecksum

 /**
  * @param string $input
  * @return string
  * @throws \InvalidArgumentException
  */
 protected function generateChecksum($input)
 {
     $invalidChars = array();
     foreach (str_split($input) as $char) {
         if (!in_array($char, $this->characterMap)) {
             $invalidChars[] = $char;
         }
     }
     if (count($invalidChars)) {
         throw new \InvalidArgumentException("Argument 1 contains the following characters not in the character map: " . implode(" ", $invalidChars));
     }
     $base = count($this->characterMap);
     $factor = 2;
     $total = 0;
     for ($i = strlen($input) - 1; $i >= 0; $i--) {
         $codePoint = array_search(substr($input, $i, 1), $this->characterMap);
         $add = base_convert($codePoint * $factor, 10, $base);
         if ($add > 9) {
             $add = array_sum(str_split($add));
         }
         $total = $total + $add;
         $factor = $factor == 2 ? 1 : 2;
     }
     return $this->characterMap[$base - $total % $base];
 }
开发者ID:choccybiccy,项目名称:algorithms,代码行数:30,代码来源:LuhnModN.php


示例14: getId

 /**
  * Get unique identifier
  */
 public function getId()
 {
     if (!isset($this->options['id'])) {
         $this->options['id'] = isset($this->options['name']) ? $this->options['name'] . '-form' : base_convert(uniqid(), 16, 36);
     }
     return $this->options['id'];
 }
开发者ID:sachsy,项目名称:formbuilder,代码行数:10,代码来源:Form.php


示例15: generate

 /**
  * {@inheritdoc}
  */
 public function generate()
 {
     // Obtain a random string of 32 hex characters.
     $hex = bin2hex(Crypt::randomBytes(16));
     // The variable names $time_low, $time_mid, $time_hi_and_version,
     // $clock_seq_hi_and_reserved, $clock_seq_low, and $node correlate to
     // the fields defined in RFC 4122 section 4.1.2.
     //
     // Use characters 0-11 to generate 32-bit $time_low and 16-bit $time_mid.
     $time_low = substr($hex, 0, 8);
     $time_mid = substr($hex, 8, 4);
     // Use characters 12-15 to generate 16-bit $time_hi_and_version.
     // The 4 most significant bits are the version number (0100 == 0x4).
     // We simply skip character 12 from $hex, and concatenate the strings.
     $time_hi_and_version = '4' . substr($hex, 13, 3);
     // Use characters 16-17 to generate 8-bit $clock_seq_hi_and_reserved.
     // The 2 most significant bits are set to one and zero respectively.
     $clock_seq_hi_and_reserved = base_convert(substr($hex, 16, 2), 16, 10);
     $clock_seq_hi_and_reserved &= 0b111111;
     $clock_seq_hi_and_reserved |= 0b10000000;
     // Use characters 18-19 to generate 8-bit $clock_seq_low.
     $clock_seq_low = substr($hex, 18, 2);
     // Use characters 20-31 to generate 48-bit $node.
     $node = substr($hex, 20);
     // Re-combine as a UUID. $clock_seq_hi_and_reserved is still an integer.
     $uuid = sprintf('%s-%s-%s-%02x%s-%s', $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $clock_seq_low, $node);
     return $uuid;
 }
开发者ID:318io,项目名称:318-io,代码行数:31,代码来源:Php.php


示例16: __construct

 public function __construct($username, $password)
 {
     $this->username = $username;
     $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
     $this->setPlainPassword($password);
     $this->setRoles(['ROLE_USER', 'ROLE_API']);
 }
开发者ID:drymek,项目名称:fcs-backend,代码行数:7,代码来源:User.php


示例17: load

 public function load(ObjectManager $manager)
 {
     // Obtener todas las ciudades de la base de datos
     $ciudades = $manager->getRepository('CiudadBundle:Ciudad')->findAll();
     for ($i = 1; $i <= 200; $i++) {
         $usuario = new Usuario();
         $usuario->setNombre($this->getNombre());
         $usuario->setApellidos($this->getApellidos());
         $usuario->setEmail('usuario' . $i . '@localhost');
         $usuario->setSalt(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36));
         $passwordEnClaro = 'usuario' . $i;
         $encoder = $this->container->get('security.encoder_factory')->getEncoder($usuario);
         $passwordCodificado = $encoder->encodePassword($passwordEnClaro, $usuario->getSalt());
         $usuario->setPassword($passwordCodificado);
         $ciudad = $ciudades[array_rand($ciudades)];
         $usuario->setDireccion($this->getDireccion($ciudad));
         $usuario->setCiudad($ciudad);
         // El 60% de los usuarios permite email
         $usuario->setPermiteEmail(rand(1, 1000) % 10 < 6);
         $usuario->setFechaAlta(new \DateTime('now - ' . rand(1, 150) . ' days'));
         $usuario->setFechaNacimiento(new \DateTime('now - ' . rand(7000, 20000) . ' days'));
         $dni = substr(rand(), 0, 8);
         $usuario->setDni($dni . substr("TRWAGMYFPDXBNJZSQVHLCKE", strtr($dni, "XYZ", "012") % 23, 1));
         $usuario->setNumeroTarjeta('1234567890123456');
         $manager->persist($usuario);
     }
     $manager->flush();
 }
开发者ID:jaaguilar,项目名称:cuponing,代码行数:28,代码来源:Usuarios.php


示例18: findOneByPublicID

 /**
  * Get it by the public ID
  * @param $id
  * @return bool|\AboutBrowser\Model\Visitor
  */
 public function findOneByPublicID($id)
 {
     $internalID = base_convert($id, 36, 10);
     $dql = "select v from AboutBrowser\\Model\\Visitor v where v.id = {$internalID} and v.createdAt >= DATE_SUB(CURRENT_DATE(), 3, 'day')";
     $result = $this->_em->createQuery($dql)->getResult();
     return $result ? $result[0] : false;
 }
开发者ID:aaronsaray,项目名称:tell-me-about-my-browser,代码行数:12,代码来源:Visitor.php


示例19: __call

 public function __call($method, $params)
 {
     if ($method === __FUNCTION__) {
         return;
     }
     if ($this->_path) {
         $method = $this->_path . '/' . $method;
     }
     $id = base_convert($this->_uniqid++, 10, 36);
     $rpcTimeout = Config::get('rpc.timeout');
     $timeout = $rpcTimeout[$method] ?: $rpcTimeout['default'];
     $this->_header['X-Gini-RPC-Session'] = $_SERVER['HTTP_X_GINI_RPC_SESSION'] ?: $this->_url . '/' . $method;
     $raw_data = $this->post(J(['jsonrpc' => '2.0', 'method' => $method, 'params' => $params, 'id' => $id]), $timeout);
     \Gini\Logger::of('http-jsonrpc')->debug('RPC <= {data}', ['data' => $raw_data]);
     $data = @json_decode($raw_data, true);
     if (!isset($data['result'])) {
         if (isset($data['error'])) {
             $message = sprintf('remote error: %s', $data['error']['message']);
             $code = $data['error']['code'];
             throw IoC::construct('\\Gini\\RPC\\Exception', $message, $code);
         } elseif (is_null($data)) {
             $message = sprintf('unknown error with raw data: %s', $raw_data ?: '(null)');
             throw IoC::construct('\\Gini\\RPC\\Exception', $message, -32400);
         } elseif ($id != $data['id']) {
             $message = 'wrong response id!';
             throw IoC::construct('\\Gini\\RPC\\Exception', $message, -32400);
         }
     }
     return $data['result'];
 }
开发者ID:iamfat,项目名称:gini,代码行数:30,代码来源:RPC.php


示例20: IPv4To6

function IPv4To6($Ip, $expand = false)
{
    static $Mask = '::ffff:';
    // This tells IPv6 it has an IPv4 address
    $IPv6 = strpos($Ip, ':') !== false;
    $IPv4 = strpos($Ip, '.') !== false;
    if (!$IPv4 && !$IPv6) {
        return false;
    }
    if ($IPv6 && $IPv4) {
        $Ip = substr($Ip, strrpos($Ip, ':') + 1);
    } elseif (!$IPv4) {
        return ExpandIPv6Notation($Ip);
    }
    // Seems to be IPv6 already?
    $Ip = array_pad(explode('.', $Ip), 4, 0);
    if (count($Ip) > 4) {
        return false;
    }
    for ($i = 0; $i < 4; $i++) {
        if ($Ip[$i] > 255) {
            return false;
        }
    }
    $Part7 = base_convert($Ip[0] * 256 + $Ip[1], 10, 16);
    $Part8 = base_convert($Ip[2] * 256 + $Ip[3], 10, 16);
    if ($expand) {
        return ExpandIPv6Notation($Mask . $Part7 . ':' . $Part8);
    } else {
        return $Mask . $Part7 . ':' . $Part8;
    }
}
开发者ID:Prescia,项目名称:Prescia,代码行数:32,代码来源:ipv6.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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