本文整理汇总了PHP中long2ip函数的典型用法代码示例。如果您正苦于以下问题:PHP long2ip函数的具体用法?PHP long2ip怎么用?PHP long2ip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了long2ip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: my_inet_ntop
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;
}
示例2: form_subnet
function form_subnet()
{
global $db, $vars, $lang;
$form_subnet = new form(array('FORM_NAME' => 'form_subnet'));
$form_subnet->db_data('subnets.ip_start, subnets.ip_end, subnets.type, subnets.link_id, subnets.client_node_id');
$links = $db->get('links.id AS value, links.type, links.ssid, nodes.name, links.peer_node_id, "" AS output', "links\n\t\t\t\t\t\t\tLEFT JOIN nodes ON links.peer_node_id = nodes.id", "(links.type = 'ap' OR links.type = 'p2p') AND node_id = " . intval(get('node')), "", "links.type ASC, links.date_in ASC");
foreach ((array) $links as $key => $value) {
$links[$key]['output'] .= $lang['db']['links__type-' . $value['type']] . ' - ';
if ($value['type'] == 'ap') {
$links[$key]['output'] .= $links[$key]['ssid'];
}
if ($value['type'] == 'p2p') {
$links[$key]['output'] .= $links[$key]['name'] . ' (#' . $links[$key]['peer_node_id'] . ')';
}
}
$form_subnet->db_data_enum('subnets.link_id', $links);
$clients = $db->get('cl_n.id AS value, ap_l.ssid, cl_n.name, cl_n.id, "" AS output', "links AS cl_l " . "LEFT JOIN links AS ap_l ON cl_l.peer_ap_id = ap_l.id\n\t\t\t\t\t\t\tLEFT JOIN nodes AS ap_n ON ap_l.node_id = ap_n.id " . "LEFT JOIN nodes AS cl_n ON cl_l.node_id = cl_n.id", "cl_l.type = 'client' AND ap_l.type = 'ap' AND ap_l.node_id = " . intval(get('node')), "", "ap_l.date_in ASC, cl_l.date_in ASC");
foreach ((array) $clients as $key => $value) {
$clients[$key]['output'] = '[' . $lang['db']['links__type-ap'] . ' ' . $clients[$key]['ssid'] . '] - ' . $clients[$key]['name'] . ' (#' . $clients[$key]['id'] . ')';
}
$form_subnet->db_data_enum('subnets.client_node_id', $clients);
$form_subnet->db_data_values("subnets", "id", get('subnet'));
if (get('subnet') != 'add') {
$form_subnet->data[0]['value'] = long2ip($form_subnet->data[0]['value']);
$form_subnet->data[1]['value'] = long2ip($form_subnet->data[1]['value']);
}
return $form_subnet;
}
示例3: fn_settings_actions_addons_access_restrictions_admin_reverse_ip_access
/**
* Reverse IP filter
*/
function fn_settings_actions_addons_access_restrictions_admin_reverse_ip_access(&$new_value, $old_value)
{
$ip = fn_get_ip(true);
if ($new_value == 'Y') {
$ip_data = db_get_row("SELECT item_id, status FROM ?:access_restriction WHERE ip_from = ?i AND ip_to = ?i AND type IN ('aas', 'aab', 'aar')", $ip['host'], $ip['host']);
if (empty($ip_data) || empty($ip_data['item_id'])) {
// Add IP
$restrict_ip = array('ip_from' => $ip['host'], 'ip_to' => $ip['host'], 'type' => 'aas', 'timestamp' => TIME, 'expires' => '0', 'status' => 'A');
$__data = array();
$__data['item_id'] = db_query("REPLACE INTO ?:access_restriction ?e", $restrict_ip);
$__data['type'] = 'aas';
foreach (fn_get_translation_languages() as $__data['lang_code'] => $_v) {
$__data['reason'] = __('store_admin', '', $__data['lang_code']);
db_query("REPLACE INTO ?:access_restriction_reason_descriptions ?e", $__data);
}
fn_set_notification('W', __('warning'), __('your_ip_added', array('[ip]' => long2ip($ip['host']))));
} elseif (empty($ip_data['status']) || $ip_data['status'] != 'A') {
// Change IP status to available
db_query("UPDATE ?:access_restriction SET ?u WHERE item_id = ?i", array('status' => 'A'), $ip_data['item_id']);
fn_set_notification('W', __('warning'), __('your_ip_enabled', array('[ip]' => long2ip($ip['host']))));
}
} else {
// Delete IP
$ips_data = db_get_array("SELECT item_id, type FROM ?:access_restriction WHERE ip_from <= ?i AND ip_to >= ?i AND type IN ('aas', 'aab', 'aar')", $ip['host'], $ip['host']);
if (!empty($ips_data)) {
foreach ($ips_data as $ip_data) {
db_query("DELETE FROM ?:access_restriction WHERE item_id = ?i", $ip_data['item_id']);
db_query("DELETE FROM ?:access_restriction_reason_descriptions WHERE item_id = ?i AND type = ?s", $ip_data['item_id'], $ip_data['type']);
}
fn_set_notification('W', __('warning'), __('your_ip_removed', array('[ip]' => long2ip($ip['host']))));
}
}
return true;
}
示例4: testValidDataConversion
/**
* Valid conversion should complete with no
* exception thrown.
*
*
* @group validconversion
*/
public function testValidDataConversion()
{
$data = json_decode(json_encode($this->validSubmission));
$data->data->cookie = md5(time());
$data->data->domain = 'phptest' . time() . '.com';
$data->data->domain_name = 'tsetphp' . time() . '.com';
$data->data->registrant_ip = long2ip(time());
$data->data->max_to_expiry = strtotime('-1 week');
$data->data->min_to_expiry = strtotime('-2 years');
$data->data->page = '10';
$data->data->limit = '100';
$data->data->type = md5(serialize($data));
$shouldMatchNewDataObject = new \stdClass();
$shouldMatchNewDataObject->cookie = $data->data->cookie;
$shouldMatchNewDataObject->attributes = new \stdClass();
$shouldMatchNewDataObject->attributes->domain = $data->data->domain;
$shouldMatchNewDataObject->attributes->domain_name = $data->data->domain_name;
$shouldMatchNewDataObject->attributes->registrant_ip = $data->data->registrant_ip;
$shouldMatchNewDataObject->attributes->max_to_expiry = $data->data->max_to_expiry;
$shouldMatchNewDataObject->attributes->min_to_expiry = $data->data->min_to_expiry;
$shouldMatchNewDataObject->attributes->page = $data->data->page;
$shouldMatchNewDataObject->attributes->limit = $data->data->limit;
$shouldMatchNewDataObject->attributes->type = $data->data->type;
$ns = new GetDomain();
$newDataObject = $ns->convertDataObject($data);
$this->assertTrue($newDataObject == $shouldMatchNewDataObject);
}
示例5: index
/**
* [index 管理员列表]
* @return [type] [description]
*/
public function index()
{
if (IS_AJAX) {
$draw = I('draw', 1, 'intval');
//排序设置
$mycolumns = I('mycolumns', '');
$myorder = I('order', '');
if (empty($myorder) || empty($mycolumns)) {
$order = 'id desc';
} else {
foreach ($myorder as $key => $v) {
$order .= $mycolumns[$v['column']] . ' ' . $v['dir'] . ' ,';
}
$order = rtrim($order, ',');
}
$db = D('UsersView');
$lists = $db->where(true)->order($order)->select();
foreach ($lists as $key => $v) {
$lists[$key]['loginTime'] = $v['loginTime'] ? date('Y/m/d H:i:s', $v['loginTime']) : '';
$lists[$key]['loginIp'] = $v['loginIp'] ? long2ip($v['loginIp']) : '';
if ($v['status']) {
$lists[$key]['status'] = '正常';
} else {
$lists[$key]['status'] = '禁用';
}
}
$result['draw'] = $draw;
$result['recordsTotal'] = $db->where(true)->count();
$result['recordsFiltered'] = $result['recordsTotal'];
$result['data'] = $lists;
$this->ajaxReturn($result);
} else {
$this->display();
}
}
示例6: get_data
public function get_data()
{
$data = $this->input->stream();
$page = isset($data['page']) ? $data['page'] : 1;
$page--;
$where = '1=1 AND ';
if (isset($data['start_time']) && !empty($data['start_time'])) {
$where .= "opera_time >= " . strtotime($data['start_time']) . " AND ";
}
if (isset($data['end_time']) && !empty($data['end_time'])) {
$where .= "opera_time <= " . strtotime($data['end_time']) . " AND ";
}
if (isset($data['user']) && !empty($data['user'])) {
$where .= "user like '%{$data['user']}%' AND ";
}
$where = rtrim($where, 'AND ');
$logs = $this->log_model->get_limit_length($page, self::PAGELENGTH, $where);
$total_pages = $this->log_model->get_pages($where, self::PAGELENGTH);
if ($logs) {
array_walk($logs, function (&$item) {
$item['ip'] = long2ip($item['ip']);
$item['opera_time'] = date('Y-m-d H:i:s', $item['opera_time']);
});
}
die(json_encode(array('code' => 200, 'message' => '获取成功', 'data' => array('data' => $logs, 'total_pages' => $total_pages, 'current_page' => $page + 1))));
}
示例7: getRandomIp
function getRandomIp()
{
$ip_long = array(array('607649792', '608174079'), array('1038614528', '1039007743'), array('1783627776', '1784676351'), array('2035023872', '2035154943'), array('2078801920', '2079064063'), array('-1950089216', '-1948778497'), array('-1425539072', '-1425014785'), array('-1236271104', '-1235419137'), array('-770113536', '-768606209'), array('-569376768', '-564133889'));
$rand_key = mt_rand(0, 9);
$ip = long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
return $ip;
}
示例8: isSpam
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
{
if (!$ip || long2ip(ip2long($ip)) != $ip) {
return;
}
$urls = $this->getLinks($content);
array_unshift($urls, $site);
foreach ($urls as $u) {
$b = parse_url($u);
if (!isset($b['host']) || !$b['host']) {
continue;
}
$domain = preg_replace('/^[\\w]{2,6}:\\/\\/([\\w\\d\\.\\-]+).*$/', '$1', $b['host']);
$domain_elem = explode(".", $domain);
$i = count($domain_elem) - 1;
if ($i == 0) {
// "domain" is 1 word long, don't check it
return null;
}
$host = $domain_elem[$i];
do {
$host = $domain_elem[$i - 1] . '.' . $host;
$i--;
if (substr(gethostbyname($host . '.' . $this->server), 0, 3) == "127") {
$status = substr($domain, 0, 128);
return true;
}
} while ($i > 0);
}
}
示例9: shop_match_network
function shop_match_network($nets, $ip, $first = false)
{
$return = false;
if (!is_array($nets)) {
$nets = array($nets);
}
foreach ($nets as $net) {
if ($rev = $net[0] == '!') {
$net = substr($net, 1);
}
$ip_arr = explode('/', $net);
$net_long = ip2long($ip_arr[0]);
$x = ip2long($ip_arr[1]);
$mask = long2ip($x) == $ip_arr[1] ? $x : 4294967295.0 << 32 - $ip_arr[1];
$ip_long = ip2long($ip);
if ($rev) {
if (($ip_long & $mask) == ($net_long & $mask)) {
return false;
}
} else {
if (($ip_long & $mask) == ($net_long & $mask)) {
$return = true;
}
if ($first && $return) {
return true;
}
}
}
return $return;
}
示例10: userOneDetail
/**
* 用户个人信息,收货信息
* 收货人,收货手机,收货地址,邮编
*/
public function userOneDetail()
{
$this->V(['user_id' => ['egNum', null, true]]);
$id = intval($_POST['user_id']);
$address = $this->table('user_address')->where(['is_on' => 1, 'user_id' => $id, 'is_default' => 1])->get(['id'], true);
if (!$address) {
$userinfo = $this->table('user')->where(['is_on' => 1, 'id' => $id])->get(null, true);
$userinfo['add_time'] = date('Y-m-d H:i:s', $userinfo['add_time']);
$userinfo['update_time'] = date('Y-m-d H:i:s', $userinfo['update_time']);
$userinfo['last_ip'] = long2ip($userinfo['last_ip']);
$userinfo['last_login'] = date('Y-m-d H:i:s', $userinfo['last_login']);
$this->R(['userinfo' => $userinfo]);
}
$where = 'A.id=' . $id . ' and A.is_on = 1 and B.is_default = 1 and B.is_on = 1';
$dataClass = $this->H('UserInfo');
$userinfo = $dataClass->getUserInfo($where);
if (!$userinfo) {
$this->R('', 70009);
}
$userinfo['last_ip'] = long2ip($userinfo['last_ip']);
$userinfo['last_login'] = date('Y-m-d H:i:s', $userinfo['last_login']);
$userinfo['add_time'] = date('Y-m-d H:i:s', $userinfo['add_time']);
$userinfo['update_time'] = date('Y-m-d H:i:s', $userinfo['update_time']);
//返回数据,参见System/BaseClass.class.php方法
$this->R(['userinfo' => $userinfo]);
}
示例11: dump
/**
* @param Query $query
* @param $filename
* @return array
*/
private function dump(Query $query, $filename)
{
$result = [];
if (count($query) > 0) {
$this->stdout("dump {$filename}:\n", Console::FG_GREEN);
$total = count($query);
Console::startProgress(0, $total);
$n = 0;
$time = Query::time();
foreach ($query as $ip => $division) {
if (is_integer($division)) {
$division = $query->divisionById($division);
}
$result[long2ip($ip)] = $division;
$n++;
if ($time < Query::time()) {
Console::updateProgress($n, $total);
$time = Query::time();
}
}
Console::updateProgress($total, $total);
Console::endProgress();
$this->stdout(" completed!\n", Console::FG_GREEN);
}
return $result;
}
示例12: main
protected function main()
{
inc_lib('news/news_exists');
$count_news_existe = news_exists($_GET['id']);
if ($count_news_existe == false && (is_logged_in() && !check_auth('view_histo_all_news'))) {
redir(Nw::$lang['news']['news_not_exist'], false, './');
}
inc_lib('news/get_info_news');
$donnees_news = get_info_news($_GET['id']);
$this->set_title(Nw::$lang['news']['historique_news'] . ' | ' . $donnees_news['n_titre']);
$this->set_tpl('news/log_news.html');
$this->add_css('code.css');
// Fil ariane
if ($count_news_existe) {
$this->set_filAriane(array(Nw::$lang['news']['news_section'] => array('news-70.html'), $donnees_news['c_nom'] => array($donnees_news['c_rewrite'] . '/'), $donnees_news['n_titre'] => array($donnees_news['c_rewrite'] . '/' . rewrite($donnees_news['n_titre']) . '-' . $_GET['id'] . '/'), Nw::$lang['news']['historique_news'] => array('')));
} else {
$this->set_filAriane(array(Nw::$lang['news']['news_section'] => array('news-70.html'), Nw::$lang['news']['historique_news'] => array('')));
}
/**
* Affichage du logo
**/
inc_lib('news/get_news_logs');
$donnees_logs = get_news_logs('l_id_news = ' . intval($_GET['id']), 'l_date DESC');
foreach ($donnees_logs as $donnees) {
Nw::$tpl->setBlock('log', array('ACTION' => $donnees['l_action'], 'ACTION_LOG' => isset(Nw::$lang['news']['log_news_' . $donnees['l_action']]) ? Nw::$lang['news']['log_news_' . $donnees['l_action']] : '', 'TEXTE' => nl2br($donnees['l_texte']), 'TITRE' => $donnees['l_titre'], 'DATE' => date_sql($donnees['date'], $donnees['heures_date'], $donnees['jours_date']), 'AUTEUR' => $donnees['u_pseudo'], 'AUTEUR_ID' => $donnees['u_id'], 'AUTEUR_AVATAR' => $donnees['u_avatar'], 'AUTEUR_ALIAS' => $donnees['u_alias'], 'IP' => long2ip($donnees['l_ip'])));
}
Nw::$tpl->set(array('ID' => $_GET['id'], 'TITRE' => $donnees_news['n_titre']));
}
示例13: start
/**
* 应用程序初始化
* @access public
* @return void
*/
public static function start()
{
// 设定错误和异常处理
register_shutdown_function(array('Think', 'fatalError'));
set_error_handler(array('Think', 'appError'));
set_exception_handler(array('Think', 'appException'));
// 注册AUTOLOAD方法
spl_autoload_register(array('Think', 'autoload'));
//[RUNTIME]
Think::buildApp();
// 预编译项目
//[/RUNTIME]
// 运行应用
$_SERVER['ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$cdn_ips = array('182.140.245.*', '58.49.105.*', '61.147.103.*', '61.147.79.*', '61.158.240.*', '61.244.110.*', '210.209.122.*', '64.32.4.*', '69.28.51.*', '111.161.72.*', '112.253.3.*', '112.64.18.*', '113.31.80.*', '113.31.82.*', '117.34.91.*', '118.144.86.*', '119.97.153.*', '120.197.85.*', '121.11.83.*', '121.12.119.*', '121.14.212.*', '122.200.77.*', '122.225.36.*', '123.129.209.*', '123.150.187.*', '124.95.164.*', '182.118.12.*', '182.118.38.*', '183.232.29.*', '202.102.85.*', '202.105.176.*', '203.171.228.*', '220.181.135.*', '223.202.2.*', '211.155.80.*', '61.164.211.*');
foreach ($cdn_ips as $cdnip) {
if ($_SERVER['ip'] == $cdnip || strrchr($cdnip, '.') == '.*' && ($pre = substr($cdnip, 0, -2)) && $pre == substr($_SERVER['ip'], 0, strlen($pre))) {
$realip = $_SERVER['HTTP_X_FORWARDED_FOR'];
empty($realip) && ($realip = $_SERVER['HTTP_CLIENT_IP']);
if (preg_match('#^\\d+(\\.\\d+){3}$#', $realip)) {
$_SERVER['REMOTE_ADDR'] = long2ip(ip2long($realip));
}
}
}
App::run();
return;
}
示例14: index
public function index()
{
echo $_POST['keyword'];
//搜索
if (!empty($_GET['keyword'])) {
if ($_GET['searchtype'] == 'uid') {
$condition_user['uid'] = $_GET['keyword'];
} else {
if ($_GET['searchtype'] == 'nickname') {
$condition_user['nickname'] = array('like', '%' . $_GET['keyword'] . '%');
} else {
if ($_GET['searchtype'] == 'phone') {
$condition_user['phone'] = array('like', '%' . $_GET['keyword'] . '%');
}
}
}
}
$database_user = D('User');
$count_user = $database_user->where($condition_user)->count();
import('@.ORG.system_page');
$p = new Page($count_user, 15);
$user_list = $database_user->field(true)->where($condition_user)->order('`uid` DESC')->limit($p->firstRow . ',' . $p->listRows)->select();
if (!empty($user_list)) {
import('ORG.Net.IpLocation');
$IpLocation = new IpLocation();
foreach ($user_list as &$value) {
$last_location = $IpLocation->getlocation(long2ip($value['last_ip']));
$value['last_ip_txt'] = iconv('GBK', 'UTF-8', $last_location['country']);
}
}
$this->assign('user_list', $user_list);
$pagebar = $p->show();
$this->assign('pagebar', $pagebar);
$this->display();
}
示例15: get_IP
public static function get_IP()
{
/**
* Si PHP est derrière un reverse proxy ou un load balancer, REMOTE_ADDR peut contenir l'ip du proxy.
* Normalement, le proxy doit renseigner HTTP_X_REAL_IP, ou HTTP_X_FORWARDED_FOR.
* Au CITIC, REMOTE_ADDR est correct, et chez OVH aussi (avec apache derrière nginx ou pas).
*/
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_REAL_IP']))
{
$ip = $_SERVER['HTTP_X_REAL_IP'];
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$forwarded = $_SERVER['HTTP_X_FORWARDED_FOR'];
// on s'arrête à la 1re virgule si on en trouve une
$tab_forwarded = preg_split("/,| /",$forwarded);
$ip_candidate = $tab_forwarded[0];
$ip_composantes = explode('.', $ip_candidate);
// On vérifie que ça ressemble à une ip (au cas où on aurait une chaîne bizarre ou vide on garde notre REMOTE_ADDR)
if ( (count($ip_composantes)==4) && (min($ip_composantes)>=0) && (max($ip_composantes)<256) && (max($ip_composantes)>0) )
{
$ip = $ip_candidate;
}
}
// petit truc pour s'assurer d'avoir une IP valide
return ($ip == long2ip(ip2long($ip))) ? $ip : '' ;
}