Beispiel #1
0
 /**
  * 添加回复
  */
 public static final function append()
 {
     $online = front::online();
     if (!$online->user_id) {
         die('Permission Denied!');
     }
     //需要登录
     $time = time();
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         $post = array('doc_id' => isset($_POST['doc_id']) ? $_POST['doc_id'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : '', 'content' => isset($_POST['content']) ? $_POST['content'] : '', 'ip' => get_onlineip(), 'create_date' => date('Y-m-d', $time), 'create_time' => date('H:i:s', $time));
         //$post['content'] = htmlentities($content , ENT_COMPAT ,'utf-8') ;
         //pecho($post);
         if (!empty($error)) {
             break;
         }
         $doc_remark = new self();
         $doc_remark->doc_remark_id = null;
         $doc_remark->struct($post);
         $doc_remark->insert('', 'doc_remark_id');
         if ($doc_remark->doc_remark_id) {
             $doc = new doc();
             $doc->doc_id = $doc_remark->doc_id;
             $doc->last_remark = date('Y-m-d H:i:s', $time);
             $doc->update();
         }
         //print_r ( $doc_remark);
         header('Location: ?' . $_GET['query']);
         return;
     }
 }
Beispiel #2
0
 public function register()
 {
     //加载form类,为调用错误函数,需view前加载
     $this->load->helper('form');
     $data['title'] = '注册新用户';
     if ($this->auth->is_login()) {
         show_message('已登录,请退出再注册', site_url());
     }
     if ($_POST && $this->form_validation->run() === TRUE) {
         $password = $this->input->post('password', true);
         $salt = get_salt();
         $this->config->load('userset');
         //用户积分
         $data = array('username' => strip_tags($this->input->post('username')), 'password' => password_dohash($password, $salt), 'salt' => $salt, 'email' => $this->input->post('email', true), 'credit' => $this->config->item('credit_start'), 'ip' => get_onlineip(), 'group_type' => 2, 'gid' => 3, 'regtime' => time(), 'is_active' => 1);
         if ($this->user_m->register($data)) {
             $uid = $this->db->insert_id();
             $newdata = array('username' => $data['username'], 'password' => $password);
             $this->user_m->login($newdata);
             //去除验证码session
             $this->session->unset_userdata('yzm');
             //发送注册邮件
             if ($this->config->item('mail_reg') == 'on') {
                 $subject = '欢迎加入' . $this->config->item('site_name');
                 $message = '欢迎来到 ' . $this->config->item('site_name') . ' 论坛<br/>请妥善保管这封信件。您的帐户信息如下所示:<br/>----------------------------<br/>用户名:' . $data['username'] . '<br/>论坛链接: ' . site_url() . '<br/>----------------------------<br/><br/>感谢您的注册!<br/><br/>-- <br/>' . $this->config->item('site_name');
                 send_mail($data['email'], $subject, $message);
                 //echo $this->email->print_debugger();
             }
             $this->db->set('value', $uid, false)->where('item', 'last_uid')->update('site_stats');
             $this->db->set('value', 'value+1', false)->where('item', 'total_users')->update('site_stats');
             redirect();
         }
     } else {
         $data['csrf_name'] = $this->security->get_csrf_token_name();
         $data['csrf_token'] = $this->security->get_csrf_hash();
         $this->load->view('register', $data);
     }
 }
 public function AdminIndex($param)
 {
     $config = $this->getConfig();
     if (extension_loaded('curl')) {
         $url = "http://yershop.com/index.php?s=/Home/Check/check.html";
         $post_data = array('version' => '1.5', 'domain' => $_SERVER['HTTP_HOST'], 'auth' => sha1(C('DATA_AUTH_KEY')), 'ip' => getip(), 'domainip' => get_onlineip());
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         // 我们在POST数据哦!
         curl_setopt($ch, CURLOPT_POST, 1);
         // 把post的变量加上
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
         $data = curl_exec($ch);
         curl_close($ch);
     }
     if (!empty($data) && strlen($data) < 400 && strlen($data) > 3) {
         $config['new_version'] = $data;
     }
     $this->assign('addons_config', $config);
     if ($config['display']) {
         $this->display('widget');
     }
 }
Beispiel #4
0
 /**
  * 安装过程
  */
 public function process()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $data['item']['dbhost'] = $this->input->post('dbhost') ? $this->input->post('dbhost') : 'localhost';
     $data['item']['port'] = $this->input->post('port') ? $this->input->post('port') : '3306';
     $data['item']['dbprefix'] = $this->input->post('dbprefix') ? $this->input->post('dbprefix') : 'stb_';
     $data['item']['username'] = $this->input->post('username') ? $this->input->post('username') : 'admin';
     $data['item']['email'] = $this->input->post('email') ? $this->input->post('email') : '*****@*****.**';
     if ($this->form_validation->run() === TRUE) {
         $dbhost = $this->input->post('dbhost');
         $dbuser = $this->input->post('dbuser');
         $dbpsw = $this->input->post('dbpsw');
         $dbname = $this->input->post('dbname');
         $port = $this->input->post('port');
         $dbprefix = $this->input->post('dbprefix');
         $salt = get_salt();
         $password = password_dohash($this->input->post('password'), $salt);
         $admin = array('group_type' => 0, 'gid' => 1, 'is_active' => 1, 'username' => $this->input->post('username'), 'password' => $password, 'salt' => $salt, 'email' => $this->input->post('email'), 'regtime' => time(), 'ip' => get_onlineip());
         if (function_exists(@mysqli_connect)) {
             $con = mysqli_connect($dbhost, $dbuser, $dbpsw, $dbname, $port);
         } else {
             $con = mysql_connect($dbhost . ':' . $dbport, $dbuser, $dbpsw);
         }
         //检查数据库信息是否正确
         if (!$con) {
             $string = '
             <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
             <script>
             alert("无法访问数据库,请重新安装!");
             top.location="' . site_url('install') . '";
             </script>
             ';
             exit($string);
         }
         //写入数据库配置文件
         $this->_writeDBConfig($dbhost, $dbuser, $dbpsw, $dbname, $port, $dbprefix);
         //创建数据表
         $this->_createTables($dbhost, $dbuser, $dbpsw, $dbname, $port, $dbprefix, $con);
         //禁止安装的文件
         file_put_contents(FCPATH . 'install.lock', time());
         //写入config文件
         $sub_folder = $this->input->post('base_url');
         if ($sub_folder) {
             $this->config->update('myconfig', 'sub_folder', $sub_folder);
         }
         $encryption_key = md5(uniqid());
         if ($encryption_key) {
             $this->config->update('myconfig', 'encryption_key', $encryption_key);
         }
         sleep(1);
         //添加管理员
         $this->load->database();
         $this->load->model('user_m');
         $this->user_m->register($admin);
         //update stats
         $this->db->set('value', 1)->where('item', 'total_users')->update('site_stats');
         $this->db->set('value', 1)->where('item', 'last_uid')->update('site_stats');
         $this->user_m->login($admin);
         $this->load->view('install_done');
     } else {
         $this->load->view('install_process', $data);
     }
 }
Beispiel #5
0
<?php

function get_onlineip()
{
    $onlineip = '';
    if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
        $onlineip = getenv('HTTP_CLIENT_IP');
    } elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
        $onlineip = getenv('HTTP_X_FORWARDED_FOR');
    } elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
        $onlineip = getenv('REMOTE_ADDR');
    } elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
        $onlineip = $_SERVER['REMOTE_ADDR'];
    }
    return $onlineip;
}
echo get_onlineip();
Beispiel #6
0
 function add_session($data)
 {
     $data['ip'] = ip2long(get_onlineip());
     $this->db->insert('session', $data, true);
 }
function Getip()
{
    if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
        $ip = $_SERVER["HTTP_CLIENT_IP"];
    }
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        //获取代理ip
        $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
    }
    if ($ip) {
        $ips = array_unshift($ips, $ip);
    }
    $count = count($ips);
    for ($i = 0; $i < $count; $i++) {
        if (!preg_match("/^(10|172\\.16|192\\.168)\\./i", $ips[$i])) {
            //排除局域网ip
            $ip = $ips[$i];
            break;
        }
    }
    $tip = empty($_SERVER['REMOTE_ADDR']) ? $ip : $_SERVER['REMOTE_ADDR'];
    if ($tip == "127.0.0.1") {
        //获得本地真实IP
        return get_onlineip();
    } else {
        return $tip;
    }
}