当前位置: 首页>>代码示例>>PHP>>正文


PHP ip函数代码示例

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


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

示例1: avatar

 public function avatar()
 {
     if ($_POST['dosubmit']) {
         $_POST['id'] = $this->_userid;
         if (!$this->dao->create($_POST)) {
             $this->error($this->dao->getError());
         }
         $this->dao->update_time = time();
         $this->dao->last_ip = ip();
         $result = $this->dao->save();
         if (false !== $result) {
             if ($_POST['aid']) {
                 foreach ($_POST['aid'] as $r) {
                     $aids[] = intval($r);
                 }
                 $Attachment = M('Attachment');
                 $aids = implode(',', $aids);
                 $data['userid'] = $this->_userid;
                 $data['catid'] = 0;
                 $data['status'] = '1';
                 $Attachment->where("aid in (" . $aids . ")")->save($data);
             }
             $this->success(L('do_success'));
         } else {
             $this->error(L('do_error'));
         }
         exit;
     }
     $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS') . $_SERVER['HTTP_USER_AGENT']);
     $yourphp_auth = authcode('0-1-0-1-jpeg,jpg,png,gif-0.2-0', 'ENCODE', $yourphp_auth_key);
     $this->assign('yourphp_auth', $yourphp_auth);
     $this->display();
 }
开发者ID:bossyuetao,项目名称:yuephp,代码行数:33,代码来源:IndexAction.class.php

示例2: check_ip

 /**
  * 
  * IP禁止判断接口,供外部调用 ...
  */
 public function check_ip()
 {
     $ip_array = array();
     //当前IP
     $ip = ip();
     //加载IP禁止缓存
     $ipbanned_cache = getcache('ipbanned', 'commons');
     if (!empty($ipbanned_cache)) {
         foreach ($ipbanned_cache as $data) {
             $ip_array[$data['ip']] = $data['ip'];
             //是否是IP段
             if (strpos($data['ip'], '*')) {
                 $ip_min = $this->convert_ip("min", $data['ip']);
                 $ip_max = $this->convert_ip("max", $data['ip']);
                 $result = $this->ipforbidden($ip, $ip_min, $ip_max);
                 if ($result == 0 && $data['expires'] > SYS_TIME) {
                     //被封
                     showmessage('你在IP禁止段内,所以禁止你访问');
                 }
             } else {
                 //不是IP段,用绝对匹配
                 if ($ip == $data['ip'] && $data['expires'] > SYS_TIME) {
                     showmessage('IP地址绝对匹配,禁止你访问');
                 }
             }
         }
     }
 }
开发者ID:ahmatjan,项目名称:huluphp,代码行数:32,代码来源:ipbanned_model.class.php

示例3: info

function info($data, $top)
{
    global $protocols;
    echo ' ', ip($data, 12), ' > ', ip($data, 16), ' protocol=';
    if (!isset($protocols[$data[9]])) {
        echo 'unknown(', $data[9], ')';
        return;
    }
    echo $protocols[$data[9]];
    if ($data[9] == 1) {
        // ICMP
        info_icmp(array_slice($data, 20));
        if ($data[9] == 1 && $data[20] == 3) {
            // ICMP Destination Unreachable
            echo "\n\tdata: ";
            // Print into on the contained packet
            info(array_slice($data, 28), false);
        }
    } else {
        if ($data[9] == 6) {
            // TCP
            info_tcp(array_slice($data, 20));
        } else {
            if ($data[9] == 17) {
                // UDP
                info_udp(array_slice($data, 20));
            }
        }
    }
}
开发者ID:dinamic,项目名称:php-net-tools,代码行数:30,代码来源:icmpdump.php

示例4: checklogin

 public function checklogin()
 {
     $seccode = md5($_POST['seccode']);
     if ($_SESSION['verify'] !== $seccode) {
         $this->error(L('VERIFYERROR'), 'index');
     }
     $username = $_POST['username'];
     $pwd = md5($_POST['password']);
     $DB = M('admin');
     $list = $DB->where("user='" . $username . "'")->find();
     if ($list) {
         if ($pwd != $list['pwd']) {
             $this->error(L('LogError'), 'index');
         }
         $_SESSION['USER'] = $username;
         $_SESSION['STATUS'] = true;
         $_SESSION['LANGID'] = 1;
         $logtime = time();
         $logip = ip();
         $data = array('logtime' => $logtime, 'logip' => $logip);
         $DB->where(array('id' => $list['id']))->save($data);
         $this->redirect('Index/index');
     } else {
         $this->error(L('LogError'), 'index');
     }
 }
开发者ID:rust1989,项目名称:cms,代码行数:26,代码来源:LoginAction.class.php

示例5: gravalog

function gravalog($numero, $texto, $pagina = null, $linha = null, $contexto = null)
{
    $ddf = fopen(DIR_LOGS . "/" . date('Y.M.d') . ".log", 'a');
    if ($ddf) {
        $datalog = date('d.m.Y H:i:s');
        $txt = "::[" . $datalog . "]--|" . ip() . "|----------------------\n";
        $txt .= "(" . $numero . ") " . $texto . "\n";
        if (!is_null($pagina)) {
            $txt .= "Pagina: " . $pagina . "\n";
        }
        if (!is_null($linha)) {
            $txt .= "Linha: " . $linha . "\n";
        }
        $txt .= "\n";
        if (PROFILER) {
            if (class_exists("Console")) {
                $e = new ErrorException($texto, 0, $numero, $pagina, $linha);
                Console::logError($e, $texto);
            }
        }
        if (fwrite($ddf, $txt)) {
            return true;
            if (DEBUG) {
                alert('Arquivo gravado com sucesso', false);
            }
        }
    } else {
        if (DEBUG) {
            alert('Erro ao gravar arquivo', false);
        }
    }
    fclose($ddf);
}
开发者ID:patrix,项目名称:oraculum,代码行数:33,代码来源:logs.php

示例6: post

 function post($nickname, $message)
 {
     global $prefs;
     if ($this->banned(ip())) {
         return false;
     }
     if (!$this->validate($message, $prefs['messageLength'])) {
         return false;
     }
     if (!$this->validate($nickname, $prefs['nicknameLength'])) {
         return false;
     }
     $message = trim(clean($message));
     $nickname = trim(clean($nickname));
     if ($message == '') {
         return false;
     }
     if ($nickname == '') {
         return false;
     }
     $timestamp = ts();
     $message = $this->censor($message);
     $nickname = $this->censor($nickname);
     $post = array('nickname' => $nickname, 'message' => $message, 'timestamp' => $timestamp, 'admin' => $this->admin, 'uid' => md5($timestamp . ' ' . $nickname), 'adminInfo' => array('ip' => ip()));
     $s = $this->storage->open(true);
     $s['posts'][] = $post;
     if (sizeof($s['posts']) > $prefs['history']) {
         $this->truncate($s['posts']);
     }
     $s['info']['latestTimestamp'] = $post['timestamp'];
     $this->storage->close($s);
     $this->postProcess($post);
     return $post;
 }
开发者ID:ericmuyser,项目名称:bndb,代码行数:34,代码来源:yshout.class.php

示例7: save_data

 /**
  * 信息保存到附件表的数据组装
  */
 public function save_data()
 {
     if (empty($this->res_data)) {
         return false;
     }
     /*图片信息保存到数据*/
     $pic_data['realname'] = $this->res_data['client_name'];
     $pic_data['filename'] = $this->res_data['file_name'];
     $pic_data['fileext'] = $this->res_data['file_ext'];
     $base_path = str_replace('\\', '/', FCPATH);
     $pic_data['filepath'] = str_replace($base_path, '', $this->res_data['full_path']);
     $pic_data['filesize'] = $this->res_data['file_size'];
     $pic_data['img_spec'] = $this->res_data['image_width'] . 'x' . $this->res_data['image_height'];
     $pic_data['shop_id'] = $this->shop_id;
     $pic_data['aclass_id'] = $this->class_id;
     $pic_data['isadmin'] = $this->isadmin;
     $pic_data['upload_ip'] = ip();
     $pic_data['upload_time'] = time();
     $pic_data['sts'] = $this->sts;
     if (!isset($this->CI)) {
         $this->CI =& get_instance();
     }
     $this->CI->load->model('m_uploadfile_model');
     $id = $this->CI->m_uploadfile_model->save_uploadfile($pic_data);
     return $id;
 }
开发者ID:zydj333,项目名称:hualiangcaifu,代码行数:29,代码来源:iupload_lib.php

示例8: gravalog

function gravalog($numero, $texto, $pagina = null, $linha = null, $contexto = null)
{
    $ddf = fopen(DIR_LOGS . date('Y.M.d') . ".log", 'a');
    if ($ddf) {
        $datalog = date('d.m.Y H:i:s');
        $txt = "::[" . $datalog . "]--|" . ip() . "|----------------------\n";
        $txt .= "(" . $numero . ") " . $texto . "\n";
        if (!is_null($pagina)) {
            $txt .= "Pagina: " . $pagina . "\n";
        }
        if (!is_null($linha)) {
            $txt .= "Linha: " . $linha . "\n";
        }
        $txt .= "\n";
        if (fwrite($ddf, $txt)) {
            return true;
            if (DEBUG) {
                alert('Arquivo gravado com sucesso', false);
            }
        }
    } else {
        if (DEBUG) {
            alert('Erro ao gravar arquivo', false);
        }
    }
    fclose($ddf);
}
开发者ID:RivaldoGuimaraes,项目名称:kap-learning,代码行数:27,代码来源:logs.php

示例9: login

 /**
  * 登录
  * @param $username
  * @param $password
  * @param $checkcode
  * @return array
  */
 public function login($username, $password, $checkcode)
 {
     $msg = array('status' => false, 'msg' => '请认真输入');
     if (!isset($_SESSION['code']) || strtolower($checkcode) != $_SESSION['code']) {
         $msg['status'] = false;
         $msg['msg'] = '验证码错误';
         unset($_SESSION['code']);
         return $msg;
     }
     $user = $this->where('username', $this->addslashes($username))->select()->query();
     if (!empty($user)) {
         if (md5($password . $user[0]['encrypt']) != $user[0]['password']) {
             $msg['status'] = false;
             $msg['msg'] = '密码错误';
         } else {
             $msg['status'] = true;
             $_SESSION['adminuser'] = $user[0]['username'];
             $_SESSION['loginKey'] = $this->loginkey($user[0]['username'], $user[0]['password']);
             $update = array('lastloginip' => ip(), 'lastlogintime' => time());
             $this->where('username', $this->addslashes($username))->update($update);
         }
         unset($_SESSION['code']);
         return $msg;
     } else {
         $msg = array('status' => false, 'msg' => '用户名错误');
         unset($_SESSION['code']);
         return $msg;
     }
 }
开发者ID:pgfeng,项目名称:ssy.9icode.club,代码行数:36,代码来源:adminModel.php

示例10: validate_ip

function validate_ip($ip)
{
    if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) {
        return false;
    }
    self::$ip = $ip;
    return true;
}
开发者ID:pasindujw,项目名称:CSEgrades,代码行数:8,代码来源:ipDetect.php

示例11: write

 public function write($sessID, $sessData = '')
 {
     $ip = ip();
     $username = cookie('username') ? cookie('username') : '';
     $groupid = cookie('groupid') ? intval(cookie('groupid')) : 4;
     $sessiondata = array('sessionid' => $sessID, 'userid' => intval(cookie('userid')), 'username' => $username, 'ip' => $ip, 'lastvisit' => time(), 'groupid' => $groupid, 'data' => '');
     return $this->dao->add($sessiondata, '', true);
 }
开发者ID:bossyuetao,项目名称:yuephp,代码行数:8,代码来源:Online.class.php

示例12: host

 public static function host()
 {
     $host = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null;
     if (is_null($host) || $host == "") {
         $host = ip();
     }
     return $host;
 }
开发者ID:patrix,项目名称:oraculum,代码行数:8,代码来源:HTTP.php

示例13: currentCityInfo

 function currentCityInfo()
 {
     $geoObj = bpBase::loadAppClass('geoObj', 'geo', 1);
     $ipGeo = $geoObj->getGeoByIP(ip());
     if (!$ipGeo) {
         $geo_db = bpBase::loadModel('geo_model');
         $defaultChildLocation = $geo_db->getDefaultChildLocation();
         $ipGeo = $defaultChildLocation;
     }
     echo '{"city":[{"name":"' . $ipGeo->name . '","id":"' . $ipGeo->id . '","geoindex":"' . $ipGeo->geoindex . '"}]}';
 }
开发者ID:ailingsen,项目名称:pigcms,代码行数:11,代码来源:widget.php

示例14: __construct

	function __construct() {
		pc_base::load_app_func('global');
		$this->vote = pc_base::load_model('vote_subject_model');//投票标题
		$this->vote_option = pc_base::load_model('vote_option_model');//投票选项
		$this->vote_data = pc_base::load_model('vote_data_model'); //投票统计的数据模型
		$this->username = param::get_cookie('_username');
		$this->userid = param::get_cookie('_userid'); 
		$this->ip = ip();
		
		$siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid();
  		define("SITEID",$siteid);
 	}
开发者ID:hxzyzz,项目名称:ddc,代码行数:12,代码来源:index.php

示例15: login

 function login()
 {
     if (isset($_GET['dosubmit'])) {
         $username = trim($this->input->post('username'));
         $password = trim($this->input->post('password'));
         $code = trim($this->input->post('code'));
         $login_url = $this->admin_url . 'main_index/index/login';
         $this->load->model('a_system_model');
         $r = $this->a_system_model->get_one(array('username' => $username, 'sts' => 0), $this->tb_admini);
         //if ($this->session->userdata('adlogin_verifycode') != strtolower($code)) {//判断验证码
         //$this->showmessage('error',lang('com_verifycode_error'),$login_url);
         //}
         if (!$r) {
             $this->showmessage('goback', lang('password_error'), $login_url);
         }
         $password = md5(md5($password . $r['encrypt']));
         $maxloginfailedtimes = 5;
         $logintime = time() - 7200;
         $rtime = $this->a_system_model->get_one(array('username' => $username, 'isadmin' => 1, 'logintime >' => $logintime), $this->tb_times);
         //			if($rtime && $rtime['times'] > $maxloginfailedtimes) {
         //				$this->showmessage('error',lang('com_login_maxtimes_error'),$login_url);
         //			}
         if ($r['password'] != $password) {
             $ip = ip();
             if ($rtime && $rtime['times'] < $maxloginfailedtimes + 1) {
                 $times = $maxloginfailedtimes - intval($rtime['times']);
                 $this->a_system_model->update_set(array('username' => $username), array('ip' => $ip, 'isadmin' => 1, 'data_set' => array('times' => 'times+1')), $this->tb_times);
             } else {
                 $this->a_system_model->del(array('username' => $username, 'isadmin' => 1), 'sys_times');
                 $this->a_system_model->add(array('username' => $username, 'ip' => $ip, 'isadmin' => 1, 'logintime' => time(), 'times' => 1), $this->tb_times);
                 $times = $maxloginfailedtimes;
             }
             if ($times >= 3) {
                 //密码输入错误小于3次时提示
                 $this->showmessage('error', lang('com_login_error'), $login_url);
             } else {
                 $com_login_error = lang('com_login_times_error');
                 $com_login_error = cc_str_replace($com_login_error, array('times' => $times));
                 $this->showmessage('error', $com_login_error, $login_url);
             }
         }
         $this->a_system_model->del(array('username' => $username, 'isadmin' => 1), $this->tb_times);
         $last_login_time = empty($r['this_login_time']) ? time() : $r['this_login_time'];
         $loghash = random(6, 'abcdefghigklmnopqrstuvwxwyABCDEFGHIGKLMNOPQRSTUVWXWY0123456789');
         $this->a_system_model->update(array('id' => $r['id']), array('last_login_ip' => ip(), 'last_login_time' => $last_login_time, 'this_login_time' => time()), $this->tb_admini);
         $ses_data = array('admin_user_id' => $r['id'], 'admin_username' => $username, 'admin_role_id' => $r['role_id'], 'admin_area_id' => $r['areaids'], 'admin_login' => 'logined', 'loghash' => $loghash);
         $this->session->set_userdata($ses_data);
         redirect($this->admin_url . 'main_index/index/?loghash=' . $loghash);
     }
     $this->cismarty->display('login.html');
 }
开发者ID:zydj333,项目名称:hualiangcaifu,代码行数:51,代码来源:main_index.php


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