示例#1
0
 public function upload()
 {
     //上传文件
     $this->files = $this->upload->save();
     //设置错误
     if ($this->upload->error()) {
         $this->error($this->upload->error(), $this->upload->msg());
     }
     if (is_array($this->files)) {
         //保存文件
         $ip = ip::current();
         $userid = $this->_user['id'];
         $description = (array) $this->description;
         foreach ($this->files as $key => $file) {
             if (!$this->isExist($this->_key, $file['id'])) {
                 $image = $this->info($file['path']);
                 $file['id'] = $file['id'];
                 $file['parentid'] = $file['id'];
                 $file['globalid'] = $this->globalid;
                 $file['folderid'] = $this->folderid;
                 $file['field'] = $this->field;
                 $file['type'] = 'image';
                 $file['width'] = $image['width'];
                 $file['height'] = $image['height'];
                 $file['description'] = empty($description[$key]) ? $file['description'] : $description[$key];
                 $file['userid'] = $userid;
                 $file['createip'] = $ip;
                 $file['createtime'] = TIME;
                 $this->insert($file);
             }
         }
         return $this->files;
     }
     return array();
 }
示例#2
0
 public static function init()
 {
     self::$timestamp = time();
     self::$ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
     if (isset($_SERVER['REMOTE_ADDR'])) {
         self::$realip = $_SERVER['REMOTE_ADDR'];
         self::$packed_realip = ip::type(self::$realip, self::$realip_type, self::$realip2);
         if (!self::$packed_realip) {
             die('IP Address Error');
         }
         self::$ip = ip::get_ip();
         self::$packed_ip = ip::type(self::$ip, self::$ip_type, self::$ip2);
         if (isset($_SERVER['HTTP_HOST'])) {
             $hosts = explode(':', $_SERVER['HTTP_HOST']);
             $num = count($hosts) - 1;
             if ($hosts[$num] == $_SERVER['SERVER_PORT']) {
                 unset($hosts[$num]);
             }
             $host = implode(':', $hosts);
         } else {
             $host = $_SERVER['SERVER_ADDR'];
         }
         $port = self::$ssl ? $_SERVER['SERVER_PORT'] == 443 ? 0 : $_SERVER['SERVER_PORT'] : ($_SERVER['SERVER_PORT'] == 80 ? 0 : $_SERVER['SERVER_PORT']);
         self::$base_url = 'http' . (self::$ssl ? 's' : '') . '://' . $host . ($port ? ':' . $port : '');
     }
 }
示例#3
0
 /**
  * 登录
  */
 public function login()
 {
     if (!IS_POST) {
         $this->error("页面不存在!");
     }
     $username = Q("post.username");
     $pwd = Q("post.pwd", null, "md5");
     $user = K("user")->where(array("username" => $username))->field("password,userlock,uid,uuid,usergroup")->find();
     if (empty($user)) {
         $this->error("用户不存在!");
     }
     if ($pwd != $user["password"]) {
         $this->error("用户名或者密码错误!");
     }
     if ($user["userlock"]) {
         $this->error("您已经被锁定,请联系管理员!");
     }
     //$this->eve_exp($user["uid"]);
     $loginData = array("logintime" => time(), "loginip" => ip::getClientIp());
     $qqau = Q("post.qqau");
     if ($qqau) {
         $loginData["qqau"] = $qqau;
     }
     M("user")->where(array("uid" => $user["uid"]))->save($loginData);
     // p($_POST);
     $auto = Q("post.auto");
     if ($auto == "on") {
         setcookie(session_name(), session_id(), C("COOKIE_TIME"), "/");
     }
     session("username", $username);
     session("uid", $user["uid"]);
     session("uuid", $user["uuid"]);
     session("usergroup", $user["usergroup"]);
     $this->success("登录成功!正在跳转...");
 }
示例#4
0
 /**
  * 返回登录
  */
 public function callback()
 {
     require_once COMMON_LIB_PATH . "QqConnect/API/qqConnectAPI.php";
     $qc = new QC();
     $callback = $qc->qq_callback();
     $openid = $qc->get_openid();
     $user = K("user")->field("uid,username,password,qqau,userlock,uuid,usergroup")->where(array("qqau" => $openid))->find();
     session("qqau", $openid);
     if (empty($user["qqau"])) {
         //首次登录或没有绑定账号
         $qc = new QC($callback, $openid);
         $arr = $qc->get_user_info();
         session("UserInfo", $arr["nickname"]);
         go("Passport/Qqlogin/index");
     } elseif ($user["qqau"] == $openid) {
         //数据库比对正确
         if ($user["userlock"] == 1) {
             $this->error("您已经被锁定,请联系管理员!");
         }
         //$this->eve_exp($user["uid"]);
         $loginData = array("logintime" => time(), "loginip" => ip::getClientIp(), "qqau" => $openid);
         M("user")->where(array("uid" => $user["uid"]))->save($loginData);
         // p($_POST);
         session("username", $user["username"]);
         session("uid", $user["uid"]);
         session("uuid", $user["uuid"]);
         session("usergroup", $user["usergroup"]);
         $this->success("登录成功!正在跳转...", U(__WEB__));
     }
 }
示例#5
0
 /**
  * 后台会员登录
  */
 public function login()
 {
     if (!IS_POST) {
         $this->error("页面不存在!");
     }
     $username = Q("post.username");
     $code = Q("post.verify", null, array("htmlspecialchars", "strtoupper"));
     if ($code != Q("session.code")) {
         $this->error("验证码错误!");
     }
     $db = M("admin");
     $user = $db->where(array("username" => $username))->field("password,userlock,aid")->find();
     if ($user["userlock"] == 1) {
         $this->error("您已经被锁定,请联系管理员");
     }
     $password = Q("password", null, "md5");
     if ($password != $user["password"]) {
         $this->error("用户名或者密码错误!");
     }
     $data = array("logintime" => time(), "loginip" => ip::getClientIp());
     $db->where(array("username" => $username))->save($data);
     session("adminname", $username);
     session("aid", $user["aid"]);
     $this->success("登录成功!正在为您跳转.....", "Admin/Index/index");
 }
示例#6
0
 function test_process_simple_ips_list()
 {
     $ip_list = $this->ip->process_ip_range('192.168.0.1, 192.168.0.2, 192.168.0.3');
     $this->assertEqual($ip_list[0], ip::encode_ip('192.168.0.1'));
     $this->assertEqual($ip_list[1], ip::encode_ip('192.168.0.2'));
     $this->assertEqual($ip_list[2], ip::encode_ip('192.168.0.3'));
 }
 function _set_ip_filter()
 {
     if (!isset($_REQUEST['stats_ip'])) {
         return;
     }
     $ip_list = ip::process_ip_range($_REQUEST['stats_ip']);
     $this->stats_event_report->set_ip_filter($ip_list);
 }
示例#8
0
文件: user.php 项目: dalinhuang/zotop
 /**
  * 刷新用户状态,包括登录时间以及登录次数等
  *
  */
 public function refresh($id = '')
 {
     $id = empty($id) ? $this->id : $id;
     if (empty($id)) {
         return false;
     }
     $result = $this->update(array('id' => (int) $id, 'logintime' => TIME, 'loginnum' => array('loginnum', '+', 1), 'loginip' => ip::current()));
     return $result;
 }
 function test_same_host_wrong_day()
 {
     $date1 = new date();
     $ip = ip::encode_ip('192.168.0.5');
     $this->stats_ip->setReturnValue('get_client_ip', $ip);
     $this->stats_ip->is_new_host($date1);
     $date2 = new date();
     $date2->set_by_days($date1->date_to_days() - 2);
     $this->stats_ip->setReturnValueAt(1, 'get_client_ip', $ip);
     $this->assertFalse($this->stats_ip->is_new_host($date2));
     $this->_check_stats_ip_record($total_records = 1, $ip, $date1);
 }
示例#10
0
 /**
  * 添加服务器
  * @param $server 服务器名称
  * @param $ip 地址
  * @param $port 端口
  * @param $os 操作系统
  * @param $security_name snmp用户名
  * @param $pass_phrase snmp密码
  * @param $auth_protocol snmp身份验证加密方式
  * @param $priv_protocol 加密/解密协议
  */
 public static function add($server, $ip, $port, $os, $security_name, $pass_phrase, $auth_protocol, $priv_protocol)
 {
     $data['name'] = $server;
     $data['ip'] = ip::ip_to_long($ip);
     $data['port'] = $port;
     $data['type'] = $os;
     $data['security_name'] = $security_name;
     $data['pass_phrase'] = $pass_phrase;
     $data['auth_protocol'] = $auth_protocol;
     $data['priv_protocol'] = $priv_protocol;
     // 加密
     $data['security_name'] = self::encode_security_name($data);
     $data['pass_phrase'] = self::encode_pass_phrase($data);
     self::$db->insert('server', $data);
 }
示例#11
0
 function process_ip_range($ip_range)
 {
     $ip_list = array();
     $ip_list_temp = explode(',', $ip_range);
     for ($i = 0; $i < count($ip_list_temp); $i++) {
         if (preg_match('/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})[ ]*\\-[ ]*([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/', trim($ip_list_temp[$i]), $ip_range_explode)) {
             $ip_1_counter = $ip_range_explode[1];
             $ip_1_end = $ip_range_explode[5];
             while ($ip_1_counter <= $ip_1_end) {
                 $ip_2_counter = $ip_1_counter == $ip_range_explode[1] ? $ip_range_explode[2] : 0;
                 $ip_2_end = $ip_1_counter < $ip_1_end ? 254 : $ip_range_explode[6];
                 if ($ip_2_counter == 0 && $ip_2_end == 254) {
                     $ip_2_counter = 255;
                     $ip_2_fragment = 255;
                     $ip_list[] = ip::encode_ip("{$ip_1_counter}.255.255.255");
                 }
                 while ($ip_2_counter <= $ip_2_end) {
                     $ip_3_counter = $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1] ? $ip_range_explode[3] : 0;
                     $ip_3_end = $ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end ? 254 : $ip_range_explode[7];
                     if ($ip_3_counter == 0 && $ip_3_end == 254) {
                         $ip_3_counter = 255;
                         $ip_3_fragment = 255;
                         $ip_list[] = ip::encode_ip("{$ip_1_counter}.{$ip_2_counter}.255.255");
                     }
                     while ($ip_3_counter <= $ip_3_end) {
                         $ip_4_counter = $ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1] ? $ip_range_explode[4] : 0;
                         $ip_4_end = $ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end ? 254 : $ip_range_explode[8];
                         if ($ip_4_counter == 0 && $ip_4_end == 254) {
                             $ip_4_counter = 255;
                             $ip_4_fragment = 255;
                             $ip_list[] = ip::encode_ip("{$ip_1_counter}.{$ip_2_counter}.{$ip_3_counter}.255");
                         }
                         while ($ip_4_counter <= $ip_4_end) {
                             $ip_list[] = ip::encode_ip("{$ip_1_counter}.{$ip_2_counter}.{$ip_3_counter}.{$ip_4_counter}");
                             $ip_4_counter++;
                         }
                         $ip_3_counter++;
                     }
                     $ip_2_counter++;
                 }
                 $ip_1_counter++;
             }
         } elseif (preg_match('/^([0-9\\*]{1,3})\\.([0-9\\*]{1,3})\\.([0-9\\*]{1,3})\\.([0-9\\*]{1,3})$/', trim($ip_list_temp[$i]))) {
             $ip_list[] = ip::encode_ip(str_replace('*', '255', trim($ip_list_temp[$i])));
         }
     }
     return $ip_list;
 }
 function login($login, $password)
 {
     $this->_delete_cookie();
     $user_ip = ip::encode_ip(sys::client_ip());
     $sid = md5(uniqid($user_ip));
     session::set('phpbb_sid', $sid);
     $phpbb_user_data = array();
     $phpbb_user_data['session_user_id'] = user::get_id();
     $phpbb_user_data['session_id'] = $sid;
     $phpbb_user_data['session_ip'] = $user_ip;
     $phpbb_user_data['session_logged_in'] = 1;
     $phpbb_user_data['session_start'] = time();
     $phpbb_user_data['session_time'] = time();
     $db_table =& db_table_factory::create('phpbb_sessions');
     return $db_table->insert($phpbb_user_data);
 }
 function set_ip_filter($ip_string)
 {
     $ip_positive_hex_list = array();
     $ip_negative_hex_list = array();
     $ip_string_list = $this->_parse_input_string($ip_string);
     foreach ($ip_string_list as $ip_piece) {
         if (substr($ip_piece, 0, 1) == '!') {
             $ip_piece = substr($ip_piece, 1);
             $ip_hex_list =& $ip_negative_hex_list;
         } else {
             $ip_hex_list =& $ip_positive_hex_list;
         }
         if (ip::is_valid($ip_piece)) {
             if (strpos($ip_piece, '*') !== false) {
                 $ip_hex_list[] = ip::encode_ip(str_replace('*', '255', $ip_piece));
             } else {
                 $ip_hex_list[] = ip::encode_ip($ip_piece);
             }
         } elseif (preg_match('/^([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})[ ]*\\-[ ]*([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})$/', $ip_piece, $ip_match)) {
             foreach (ip::encode_ip_range($ip_match[1], $ip_match[2]) as $ip_range_hex_item) {
                 $ip_hex_list[] = $ip_range_hex_item;
             }
         }
     }
     $positive_conditions = array();
     foreach ($ip_positive_hex_list as $hex_ip) {
         if (preg_match('/(ff\\.)|(\\.ff)/is', chunk_split($hex_ip, 2, '.'))) {
             $value = str_replace('.', '', preg_replace('/(ff\\.)|(\\.ff)/is', '%', chunk_split($hex_ip, 2, "."))) . "'";
         } else {
             $value = $hex_ip;
         }
         $positive_conditions[] = $this->_build_positive_condition('sslog.ip', $value);
     }
     $negative_conditions = array();
     foreach ($ip_negative_hex_list as $hex_ip) {
         if (preg_match('/(ff\\.)|(\\.ff)/is', chunk_split($hex_ip, 2, '.'))) {
             $value = str_replace('.', '', preg_replace('/(ff\\.)|(\\.ff)/is', '%', chunk_split($hex_ip, 2, "."))) . "'";
         } else {
             $value = $hex_ip;
         }
         $negative_conditions[] = $this->_build_negative_condition('sslog.ip', $value);
     }
     $condition = $this->_combine_positive_negative_conditions($positive_conditions, $negative_conditions);
     if ($condition) {
         $this->filter_conditions[] = ' AND ( ' . $condition . ' ) ';
     }
 }
示例#14
0
 function encode_ip_range($ip_begin, $ip_end)
 {
     $ip_regex = '/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/';
     if (!preg_match($ip_regex, $ip_begin, $ip_begin_range_explode) || !preg_match($ip_regex, $ip_end, $ip_end_range_explode)) {
         return array();
     }
     $ip_list = array();
     $ip_1_counter = $ip_begin_range_explode[1];
     $ip_1_end = $ip_end_range_explode[1];
     while ($ip_1_counter <= $ip_1_end) {
         $ip_2_counter = $ip_1_counter == $ip_begin_range_explode[1] ? $ip_begin_range_explode[2] : 0;
         $ip_2_end = $ip_1_counter < $ip_1_end ? 254 : $ip_end_range_explode[2];
         if ($ip_2_counter == 0 && $ip_2_end == 254) {
             $ip_2_counter = 255;
             $ip_2_fragment = 255;
             $ip_list[] = ip::encode_ip("{$ip_1_counter}.255.255.255");
         }
         while ($ip_2_counter <= $ip_2_end) {
             $ip_3_counter = $ip_2_counter == $ip_begin_range_explode[2] && $ip_1_counter == $ip_begin_range_explode[1] ? $ip_begin_range_explode[3] : 0;
             $ip_3_end = $ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end ? 254 : $ip_end_range_explode[3];
             if ($ip_3_counter == 0 && $ip_3_end == 254) {
                 $ip_3_counter = 255;
                 $ip_3_fragment = 255;
                 $ip_list[] = ip::encode_ip("{$ip_1_counter}.{$ip_2_counter}.255.255");
             }
             while ($ip_3_counter <= $ip_3_end) {
                 $ip_4_counter = $ip_3_counter == $ip_begin_range_explode[3] && $ip_2_counter == $ip_begin_range_explode[2] && $ip_1_counter == $ip_begin_range_explode[1] ? $ip_begin_range_explode[4] : 0;
                 $ip_4_end = $ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end ? 254 : $ip_end_range_explode[4];
                 if ($ip_4_counter == 0 && $ip_4_end == 254) {
                     $ip_4_counter = 255;
                     $ip_4_fragment = 255;
                     $ip_list[] = ip::encode_ip("{$ip_1_counter}.{$ip_2_counter}.{$ip_3_counter}.255");
                 }
                 while ($ip_4_counter <= $ip_4_end) {
                     $ip_list[] = ip::encode_ip("{$ip_1_counter}.{$ip_2_counter}.{$ip_3_counter}.{$ip_4_counter}");
                     $ip_4_counter++;
                 }
                 $ip_3_counter++;
             }
             $ip_2_counter++;
         }
         $ip_1_counter++;
     }
     return $ip_list;
 }
 function set_ip_filter($ip_string)
 {
     $ip_positive_hex_list = array();
     $ip_negative_hex_list = array();
     if (!($ip_string_list = $this->_parse_input_string($ip_string))) {
         return;
     }
     foreach ($ip_string_list as $ip_piece) {
         //we make a temp link with $ip_hex_list
         if (substr($ip_piece, 0, 1) == '!') {
             $ip_piece = substr($ip_piece, 1);
             $ip_hex_list =& $ip_negative_hex_list;
         } else {
             $ip_hex_list =& $ip_positive_hex_list;
         }
         $ip_piece = str_replace('*', '255', $ip_piece);
         if (ip::is_valid($ip_piece)) {
             $ip_hex_list[] = ip::encode_ip($ip_piece);
         } elseif (preg_match('/^([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})[ ]*\\-[ ]*([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})$/', $ip_piece, $ip_match)) {
             foreach (ip::encode_ip_range($ip_match[1], $ip_match[2]) as $ip_range_hex_item) {
                 $ip_hex_list[] = $ip_range_hex_item;
             }
         }
     }
     $positive_conditions = array();
     foreach ($ip_positive_hex_list as $hex_ip) {
         $hex_ip = $this->_process_ip_255_segments($hex_ip);
         $positive_conditions[] = $this->_build_positive_condition('sslog.ip', $hex_ip);
     }
     $negative_conditions = array();
     foreach ($ip_negative_hex_list as $hex_ip) {
         $hex_ip = $this->_process_ip_255_segments($hex_ip);
         $negative_conditions[] = $this->_build_negative_condition('sslog.ip', $hex_ip);
     }
     $condition = $this->_combine_positive_and_negative_conditions($positive_conditions, $negative_conditions);
     if ($condition) {
         $this->filter_conditions[] = ' AND ( ' . $condition . ' ) ';
     }
 }
 function setUp()
 {
     $this->stats_counter = new stats_counter();
     $this->stats_ip = new stats_ip_test_version($this);
     $this->stats_ip->stats_ip();
     $this->stats_ip->setReturnValue('get_client_ip', ip::encode_ip('127.0.0.1'));
     $this->stats_counter = new stats_counter_test_version($this);
     $this->stats_counter->stats_counter();
     $this->stats_referer = new stats_referer_test_version($this);
     $this->stats_referer->stats_referer();
     $this->stats_referer->setReturnValue('get_referer_page_id', 10);
     $this->stats_search_phrase = new stats_search_phrase_test_version($this);
     $this->stats_search_phrase->stats_search_phrase();
     $this->stats_search_phrase->setReturnValue('register', true);
     $this->stats_register = new stats_register_test_version($this);
     $this->stats_register->stats_register();
     $this->stats_register->setReturnReference('_get_ip_register', $this->stats_ip);
     $this->stats_register->setReturnReference('_get_counter_register', $this->stats_counter);
     $this->stats_register->setReturnReference('_get_referer_register', $this->stats_referer);
     $this->stats_register->setReturnReference('_get_search_phrase_register', $this->stats_search_phrase);
     $this->_login_user(10, array());
     $this->_clean_up();
 }
示例#17
0
 public static function area($ip = "", $is_simple = true, $ipfile = '')
 {
     if (!$ip) {
         $ip = self::ip_get_client();
     }
     self::$ipfile = PATH_HD . '/org/dat/tinyipdata.dat';
     $ipfile = self::$ipfile;
     //        $return = '';
     if (!file_exists($ipfile)) {
         $ipfile = '../' . $ipfile;
     }
     if (preg_match("/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/", $ip)) {
         $iparray = explode('.', $ip);
         if ($iparray[0] == 10 || $iparray[0] == 127 || $iparray[0] == 192 && $iparray[1] == 168 || $iparray[0] == 172 && ($iparray[1] >= 16 && $iparray[1] <= 31)) {
             return '局域网';
         } elseif ($iparray[0] > 255 || $iparray[1] > 255 || $iparray[2] > 255 || $iparray[3] > 255) {
             return 'ERR';
         } elseif ($is_simple) {
             return self::change_simply_area(self::convertip_tiny($ip, $ipfile));
         } else {
             return self::convertip_tiny($ip, $ipfile);
         }
     }
 }
示例#18
0
文件: file.php 项目: dalinhuang/zotop
 public function upload()
 {
     //上传文件
     $this->files = $this->upload->save();
     //设置错误
     if ($this->upload->error()) {
         $this->error($this->upload->error(), $this->upload->msg());
     }
     if (is_array($this->files)) {
         //保存文件
         $ip = ip::current();
         $userid = $this->_user['id'];
         $description = (array) $this->description;
         foreach ($this->files as $key => $file) {
             $file['id'] = $file['id'];
             $file['parentid'] = $file['id'];
             $file['globalid'] = $this->globalid;
             $file['groupid'] = $this->folderid;
             $file['field'] = $this->field;
             $file['type'] = file::type($file['path']);
             $file['description'] = empty($description[$key]) ? $file['description'] : $description[$key];
             $file['userid'] = $userid;
             $file['status'] = (int) $this->status;
             $file['createip'] = $ip;
             $file['createtime'] = TIME;
             if ($file['type'] == 'image' || preg_match('/^(jpeg|jpeg|png|gif|bmp|ico|tif|tiff|psd|xbm|xcf)$/', $file['ext'])) {
                 $info = image::info($file['path']);
                 $file['width'] = (int) $info['width'];
                 $file['height'] = (int) $info['height'];
             }
             $this->insert($file);
         }
         return $this->files;
     }
     return array();
 }
  function test_login()
  {
  	$this->_login_user(5, array());
		$this->assertTrue($this->object->login('', ''));
		
		$db_table	=& db_table_factory :: instance('phpbb_sessions');
		
		$conditions['session_user_id'] = 5;
		$rows = $db_table->get_list($conditions, '', null);
		$record = current($rows);
		$this->assertEqual($record['session_ip'], ip :: encode_ip(sys :: client_ip()));
		$this->assertEqual($record['session_logged_in'], 1);
  }
示例#20
0
function wakeup_client_mode_getWakeup($path){
	$f=explode("\n",@file_get_contents($path));
	while (list ($num, $line) = each ($f) ){
		if(preg_match('#wakeup:"([0-9\.]+)#', $line,$re)){
			$ip=$re[1];
			$tcp=new ip();
			if(!$tcp->isValid($ip)){return null;}else{return $ip;}
		}
		
	}
	if($GLOBALS["VERBOSE"]){echo "Starting......: $path no wakeup ip addr\n";}
}
示例#21
0
function ip2area($ip, $type = '')
{
    $area = '';
    if (is_ip($ip)) {
        $tmp = explode('.', $ip);
        if ($tmp[0] == 10 || $tmp[0] == 127 || $tmp[0] == 192 && $tmp[1] == 168 || $tmp[0] == 172 && ($tmp[1] >= 16 && $tmp[1] <= 31)) {
            $area = 'LAN';
        } elseif ($tmp[0] > 255 || $tmp[1] > 255 || $tmp[2] > 255 || $tmp[3] > 255) {
            $area = 'Unknown';
        } else {
            require_once DT_ROOT . '/include/ip.class.php';
            $do = new ip($ip, $type);
            $area = $do->area();
        }
    }
    return $area ? $area : 'Unknown';
}
    </div>
    <div id="login-bottom"> <a href="http://127.0.0.1/hdjob/index.php/index/profile/createNewRes"><em class="fn-hide">写简历</em></a><a href="http://127.0.0.1/hdjob/index.php/register.html"><em class="fn-hide">注册</em></a> </div>
</div>
<!--right-->
<div id="banner-right"> 
    <!--city-list-->
    <div id="city-list" style="position:relative;" class="fn-clear"> <span>城市频道</span>
        <ul>
            <?php 
$db = M('city');
$citys = $db->cache(86400)->field('name,pinyin')->where('is_open=1')->limit(15)->findall();
if (is_array($citys)) {
    foreach ($citys as $city) {
        ?>
            <li <?php 
        if (strpos(ip::area(), $city['name']) !== false) {
            ?>
class="city-active"<?php 
        }
        ?>
><a href="http://127.0.0.1/hdjob/index.php/<?php 
        echo $city['pinyin'];
        ?>
"><?php 
        echo $city['name'];
        ?>
</a></li>
            <?php 
    }
}
?>
示例#23
0
/**
 * 获得客户端IP地址
 * @staticvar type $realip
 * @return type 
 */
function ip_get_client()
{
    return ip::ip_get_client();
}
		<tr>

			<td colspan='2' class="th"><span class="span_people">&nbsp</span>
			欢迎光临爱翻爱许愿墙管理后台</td>
		</tr>
		<tr>
			<td>用户名</td>
			<td><?php 
echo $_SESSION['username'];
?>
</td>
		</tr>
		<tr>
			<td>登录IP</td>
			<td><?php 
echo ip::getClientIp();
?>
</td>
		</tr>
		<tr>
			<td colspan='2' class="th"><span class="span_server" style="float:left">&nbsp</span>服务器信息</td>
		</tr>

		<tr>
			<td>服务器环境</td>
			<td><?php 
echo $_SERVER['SERVER_SOFTWARE'];
?>
</td>
		</tr>
		<tr>
 function get_client_ip()
 {
     return ip::encode_ip(sys::client_ip());
 }
示例#26
0
文件: ip.php 项目: dalinhuang/zotop
 /**
  * 获取当前的ip地址     * 
  *
  */
 public static function location($ip = '')
 {
     return ip::get();
 }
示例#27
0
function server_settings()
{
    $vpn = new openvpn();
    $nic = new networking();
    $sock = new sockets();
    $OpenVpnPasswordCert = $sock->GET_INFO("OpenVpnPasswordCert");
    if ($OpenVpnPasswordCert == null) {
        $OpenVpnPasswordCert = "MyKey";
    }
    //openvpn_access_interface
    $DEV_TYPE = $vpn->main_array["GLOBAL"]["DEV_TYPE"];
    $dev = Field_array_Hash(array("tun" => "{routed_IP_tunnel}", "tap0" => "{ethernet_tunnel}"), "DEV_TYPE", $vpn->main_array["GLOBAL"]["DEV_TYPE"], "OpenVPNChangeServerMode()", null, 0, 'font-size:16px;padding:3px');
    $dev = "{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $vpn->main_array["GLOBAL"]["IP_START"] = "10.8.0.0";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = "255.255.255.0";
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $openvpn_local = null;
    }
    $CLIENT_NAT_PORT = $vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
    if ($CLIENT_NAT_PORT == null) {
        $CLIENT_NAT_PORT = $vpn->main_array["GLOBAL"]["LISTEN_PORT"];
    }
    $vpn->main_array["GLOBAL"]["PUBLIC_IP"];
    $vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
    $vpn->main_array["GLOBAL"]["LISTEN_PORT"];
    $vpn->main_array["GLOBAL"]["LISTEN_PROTO"];
    $vpn->main_array["GLOBAL"]["ENABLE_SERVER"];
    $vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"];
    $vpn->main_array["GLOBAL"]["IP_START"];
    $vpn->main_array["GLOBAL"]["IPTABLES_ETH"];
    if ($vpn->main_array["GLOBAL"]["PUBLIC_IP"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{public_ip_addr}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["LISTEN_PORT"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}:{public_ip_addr}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["LISTEN_PROTO"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{protocol}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong></p>";
    }
    $LDAP_AUTH = "{no}";
    $EnableOpenVPNEndUserPage = "{no}";
    if ($vpn->main_array["GLOBAL"]["LDAP_AUTH"] == 1) {
        $LDAP_AUTH = "{yes}";
    }
    if ($sock->GET_INFO("EnableOpenVPNEndUserPage") == 1) {
        $EnableOpenVPNEndUserPage = "{yes}";
    }
    $wake_up_ip = $vpn->main_array["GLOBAL"]["WAKEUP_IP"];
    $tcp_ip = new ip();
    if (!$tcp_ip->isValid($wake_up_ip)) {
        $wake_up_ip = "{disabled}";
    }
    if (!$tcp_ip->isValid($vpn->main_array["GLOBAL"]["PUBLIC_IP"])) {
        $vpn->main_array["GLOBAL"]["PUBLIC_IP"] = "0.0.0.0";
    }
    $ahref_edit = "<a href=\"javascript:blur();\" OnClick=\"Loadjs('index.openvpn.server.php');\" style='font-size:16px;text-decoration:underline'>";
    $button_edit = button("{change_settings}", "Loadjs('index.openvpn.server.php')", 34);
    if ($vpn->main_array["GLOBAL"]["LOCAL_BIND"] == null) {
        $vpn->main_array["GLOBAL"]["LOCAL_BIND"] = "{none}";
    }
    $openvpn_local = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{openvpn_local}</a>:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["LOCAL_BIND"]}</a></td>\n\t\t\t</tr>";
    $mandatories = "<table style='width:99%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{listen_port}:</a></td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px;width:850px'>{$vpn->main_array["GLOBAL"]["LISTEN_PORT"]}&nbsp;{$vpn->main_array["GLOBAL"]["LISTEN_PROTO"]}</a></td>\n\t\t\t</tr>\n\t\t\t{$openvpn_local}\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{public_ip_addr}</a>:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px;'>{$vpn->main_array["GLOBAL"]["PUBLIC_IP"]}:{$CLIENT_NAT_PORT}</a></td>\n\t\t\t<tr>\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{password}:</a></td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px'>*****</a></td>\n\t\t\t<tr>\n\t\t\t</table>";
    $proxy = "{no}";
    if ($vpn->main_array["GLOBAL"]["USE_RPROXY"] == 1) {
        $proxy = "{$vpn->main_array["GLOBAL"]["PROXYADDR"]}:{$vpn->main_array["GLOBAL"]["PROXYPORT"]}";
    }
    if ($vpn->main_array["GLOBAL"]["IPTABLES_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["IPTABLES_ETH"] = "{no}";
    }
    $mode_tun = "<table style='width:99%'>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{enable_authentication}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px;;width:850px'>{$LDAP_AUTH}</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{EnableOpenVPNEndUserPage}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$EnableOpenVPNEndUserPage}</td>\n\t\t<td>&nbsp;</td>\n\t<tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{reverse_proxy}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$proxy}</td>\n\t<tr>\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{from_ip_address}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["IP_START"]}</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{netmask}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["NETMASK"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{openvpn_access_interface}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{wake_up_ip}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$wake_up_ip}</a></td>\n\t</tr>\t\n\t\n</table>";
    $VPN_SERVER_IP = $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
    $VPN_DHCP_FROM = $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
    $VPN_DHCP_TO = $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
    $tcp = new networking();
    if ($vpn->main_array["GLOBAL"]["BRIDGE_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["BRIDGE_ETH"] = "eth0";
    }
    $array_ip = $tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    if ($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] == null) {
        $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] = $array_ip["IPADDR"];
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = $array_ip["NETMASK"];
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $nics = Field_array_Hash($vpn->virtual_ip_lists(), 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    }
    $mode_tap = "\n\t<div style='width:100%;margin-bottom:5px'>\n\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<div id='nicvpninfo' style='float:right;margin:5px;'>" . ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]) . "</div>\n\t\t\t\t</td>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<div class=explain>{SERVER_MODE_TAP}</div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{BRIDGE_ETH}:</td>\n\t\t<td width=1% nowrap>{$nics}</td>\n\t\t<td align='left' style='font-weight:bold;font-size:20px' width=1% nowrap>" . texttooltip("{add_virtual_ip_address}", "{add_virtual_ip_address}", "Loadjs('system.nic.config.php?js-add-nic=yes')", null, 0, "font-size:16px;padding:3px") . "</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{BRIDGE_ADDR}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap >" . Field_text('BRIDGE_ADDR', $vpn->main_array["GLOBAL"]["BRIDGE_ADDR"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{VPN_DHCP_FROM}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap>" . Field_text('VPN_DHCP_FROM', $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{VPN_DHCP_TO}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap>" . Field_text('VPN_DHCP_TO', $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td colspan=3 align='right'><hr>" . button("{apply}", "SaveServerSettings()") . "</td>\n\t</tr>\t\t\t\t\n</table>\n";
    $mode = $mode_tun;
    if ($vpn->main_array["GLOBAL"]["DEV_TYPE"] == "tap0") {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_SERVER"] != 1) {
        $status = FATAL_ERROR_SHOW_128("<strong style='font-size:22px'>{OPENVPN_NOT_ENABLED}</strong><hr>\n\t\t\t{OPENVPN_NOT_ENABLED_TEXT}\n\t\t\t") . "<center style='margin:30px'>" . button("{enable_service}", "Loadjs('index.openvpn.enable.progress.php')", 42) . "</center>";
    }
    if ($status == null) {
        $button_apply = button("{OPENVPN_APPLY_CONFIG}", "Loadjs('index.openvpn.enable.progress.php')", 34) . "&nbsp;|&nbsp;";
    }
    $html = "\n<div style='font-size:28px;margin-bottom:30px'>{OPENVPN_SERVER_SETTINGS}</div>\n{$status}\n<div style='width:98%' class=form>\n\n\n<div id='OPENVPN_SERVER_SETTINGS'>\n<div style='text-align:right'>{$button_script}</div>\n{$mandatories}\n{$mode}\n<div style='margin-top:15px;text-align:right;font-size:34px'><hr>{$button_apply}{$button_edit}</div>\t\n</div>\n";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
    // openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull
}
示例#28
0
 public static function log($type = '', $data = array())
 {
     if (empty($type)) {
         return zotop::$logs;
     }
     if (is_array($type)) {
         $log = $type;
     }
     if (is_string($data)) {
         $log = array('type' => $type, 'content' => $data);
     }
     if (is_array($data)) {
         $log = array('type' => $type, 'content' => $data);
     }
     if (!empty($log) && is_array($log)) {
         $log = array('type' => $log['type'], 'title' => $log['title'], 'content' => $log['content'], 'description' => $log['description'], 'userid' => zotop::user('id'), 'url' => url::location(), 'createip' => ip::location(), 'createtime' => TIME);
         zotop::$logs[] = $log;
     }
     return zotop::$logs;
 }
示例#29
0
文件: index.php 项目: kansifang/share
    ?>
" class="checkbox">
            </label></td>
          <td align="center"><a href="<?php 
    echo url('view', 'view', 'serverid=' . $s['id']);
    ?>
"><?php 
    echo $s['name'];
    ?>
</a></td>
          <td align="center"><span style="color:#0F0" title="<?php 
    echo SERVER_OK;
    ?>
">■</span><!--/<span style="color:#F00">■</span>--></td>
          <td align="center"><?php 
    echo ip::long_to_ip($s['ip']);
    ?>
</td>
          <td align="center"><?php 
    view::load_img($s['type'] . '.gif');
    ?>
</td>
          <td align="left">[<a href="#"><?php 
    echo MODIFY;
    ?>
</a>]&nbsp;[<a href="#"><?php 
    echo DELETE;
    ?>
</a>]</td>
        </tr>
        <?php 
示例#30
0
function remote_site_save()
{
    $sitename = $_POST["sitename"];
    $IP_START = $_POST["IP_START"];
    $netmask = $_POST["netmask"];
    $siteid = $_POST["siteid"];
    $wakeupip = $_POST["wakeup"];
    $FixedIPAddr = $_POST["FixedIPAddr"];
    $connexion_type = 1;
    if ($sitename == null) {
        $error[] = "{site_name}";
    }
    if ($IP_START == null) {
        $error[] = "{from_ip_address}";
    }
    if ($netmask == null) {
        $error[] = "{netmask}";
    }
    $ip = new ip();
    if (!$ip->isValid($IP_START)) {
        $error[] = "{from_ip_address}";
    }
    if (count($error) > 0) {
        echo "{error}:" . implode("\n", $error) . " =NULL\n";
        exit;
    }
    if ($siteid == 0) {
        $sql = "INSERT INTO vpnclient (sitename,IP_START,netmask,connexion_type,wakeupip,FixedIPAddr) VALUES('{$sitename}','{$IP_START}','{$netmask}',1,'{$wakeupip}','{$FixedIPAddr}')";
    } else {
        $sql = "UPDATE vpnclient SET sitename='{$sitename}',IP_START='{$IP_START}',netmask='{$netmask}',wakeupip='{$wakeupip}',FixedIPAddr='{$FixedIPAddr}' WHERE ID='{$siteid}'";
    }
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?artica-meta-openvpn-sites=yes");
    $sock = new sockets();
    $sock->getFrameWork("services.php?openvpn=yes");
}