public function step3()
 {
     if (session('step') != 3) {
         $this->redirect('step2');
     }
     $this->display();
     //连接数据库
     $dbconfig = session('db_config');
     $db = Db::getInstance($dbconfig);
     //创建数据表
     create_tables($db, $dbconfig['DB_PREFIX']);
     //注册创始人帐号
     $auth = build_auth_key();
     $admin = session('admin_info');
     register_administrator($db, $dbconfig['DB_PREFIX'], $admin, $auth);
     //创建初始编辑号
     register_editor($db, $dbconfig['DB_PREFIX'], $auth);
     //创建配置文件
     $conf = write_config($dbconfig, $auth);
     session('config_file', $conf);
     if (session('error')) {
         //show_msg();
     } else {
         session('step', 3);
         $this->redirect('Index/complete');
     }
 }
 /**
  * 自动登录用户
  * @param  integer $user 用户信息数组
  */
 private function autoLogin($user, $remember = false, $role_id = 0)
 {
     /* 更新登录信息 */
     $data = array('uid' => $user['uid'], 'login' => array('exp', '`login`+1'), 'last_login_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), 'last_login_role' => $user['last_login_role']);
     $this->save($data);
     //判断角色用户是否审核
     $map['uid'] = $user['uid'];
     $map['role_id'] = $user['last_login_role'];
     $audit = M('UserRole')->where($map)->getField('status');
     //判断角色用户是否审核 end
     /* 记录登录SESSION和COOKIES */
     $auth = array('uid' => $user['uid'], 'username' => get_username($user['uid']), 'last_login_time' => $user['last_login_time'], 'role_id' => $user['last_login_role'], 'audit' => $audit);
     session('user_auth', $auth);
     session('user_auth_sign', data_auth_sign($auth));
     if ($remember) {
         $user1 = M('user_token')->where('uid=' . $user['uid'])->find();
         $token = $user1['token'];
         if ($user1 == null) {
             $token = build_auth_key();
             $data['token'] = $token;
             $data['time'] = time();
             $data['uid'] = $user['uid'];
             M('user_token')->add($data);
         }
     }
     if (!$this->getCookieUid() && $remember) {
         $expire = 3600 * 24 * 7;
         cookie('OX_LOGGED_USER', $this->jiami($this->change() . ".{$user['uid']}.{$token}"), $expire);
     }
 }
Exemplo n.º 3
0
 /**
  * 自动登录用户
  * @param  integer $user 用户信息数组
  */
 private function autoLogin($user, $remember = false)
 {
     /* 更新登录信息 */
     $data = array('uid' => $user['uid'], 'login' => array('exp', '`login`+1'), 'last_login_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1));
     $this->save($data);
     /* 记录登录SESSION和COOKIES */
     $auth = array('uid' => $user['uid'], 'username' => get_username($user['uid']), 'last_login_time' => $user['last_login_time']);
     session('user_auth', $auth);
     session('user_auth_sign', data_auth_sign($auth));
     if ($remember) {
         $token = build_auth_key();
         $user1 = D('user_token')->where('uid=' . $user['uid'])->find();
         $data1['token'] = $token;
         $data1['time'] = time();
         if ($user1 == null) {
             $data1['uid'] = $user['uid'];
             D('user_token')->add($data1);
         } else {
             D('user_token')->where('uid=' . $user['uid'])->save($data1);
         }
     }
     if (!$this->getCookieUid() && $remember) {
         $expire = 3600 * 24 * 7;
         cookie('ZS_LOGGED_USER', $this->jiami($this->change() . ".{$user['uid']}.{$token}"), $expire);
     }
 }
 public function step3()
 {
     /* if(session('step') != 2){
            $this->redirect('step2');
        }*/
     $this->display();
     //连接数据库
     $dbconfig = cookie('db_config');
     $db = Db::getInstance($dbconfig);
     //创建数据表
     create_tables($db, $dbconfig['DB_PREFIX']);
     //注册创始人帐号
     $auth = build_auth_key();
     $admin = session('admin_info');
     register_administrator($db, $dbconfig['DB_PREFIX'], $admin, $auth);
     //创建配置文件
     $conf = write_config($dbconfig, $auth);
     session('config_file', $conf);
     if (session('error')) {
         //show_msg();
     } else {
         session('step', 3);
         echo "<script type=\"text/javascript\">setTimeout(function(){location.href='" . U('Index/complete') . "'},5000)</script>";
         ob_flush();
         flush();
         //$this->redirect('Index/complete');
     }
 }
Exemplo n.º 5
0
 /**
  * 执行安装
  */
 public function finish_done()
 {
     $charset = C('DEFAULT_CHARSET');
     header('Content-type:text/html;charset=' . $charset);
     $temp_info = F('temp_data');
     $conn = mysql_connect($temp_info['db_host'] . ':' . $temp_info['db_port'], $temp_info['db_user'], $temp_info['db_pass']);
     $version = mysql_get_server_info();
     $charset = str_replace('-', '', $charset);
     if ($version > '4.1') {
         if ($charset != 'latin1') {
             mysql_query("SET character_set_connection={$charset}, character_set_results={$charset}, character_set_client=binary", $conn);
         }
         if ($version > '5.0.1') {
             mysql_query("SET sql_mode=''", $conn);
         }
     }
     $selected_db = mysql_select_db($temp_info['db_name'], $conn);
     //开始创建数据表
     $this->_show_process(L('create_table_begin'));
     $sqls = $this->_get_sql(APP_PATH . 'Install/sqldata/create_table.sql');
     foreach ($sqls as $sql) {
         //替换前缀
         $sql = str_replace('`cs_', '`' . $temp_info['db_prefix'], $sql);
         //获得表名
         $run = mysql_query($sql, $conn);
         if (substr($sql, 0, 12) == 'CREATE TABLE') {
             $table_name = $temp_info['db_prefix'] . preg_replace("/CREATE TABLE IF NOT EXISTS `" . $temp_info['db_prefix'] . "([a-z0-9_]+)` .*/is", "\\1", $sql);
             $this->_show_process(sprintf(L('create_table_successed'), $table_name));
         }
     }
     //开始导入数据
     $this->_show_process(L('insert_initdate_begin'));
     $sqls = $this->_get_sql(APP_PATH . 'Install/sqldata/initdata.sql');
     $weburl = $_SERVER["HTTP_HOST"];
     foreach ($sqls as $sql) {
         //替换前缀
         $sql = str_replace('`cs_', '`' . $temp_info['db_prefix'], $sql);
         $sql = str_replace('127.0.0.1', $weburl, $sql);
         $run = mysql_query($sql, $conn);
         //获得表名
         if (substr($sql, 0, 11) == 'INSERT INTO') {
             $table_name = $temp_info['db_prefix'] . preg_replace("/INSERT INTO `" . $temp_info['db_prefix'] . "([a-z0-9_]+)` .*/is", "\\1", $sql);
             $this->_show_process(sprintf(L('insert_initdate_successed'), $table_name));
         }
     }
     $sqls = $this->_get_sql(APP_PATH . 'Install/sqldata/area.sql');
     foreach ($sqls as $sql) {
         //替换前缀
         $sql = str_replace('`cs_', '`' . $temp_info['db_prefix'], $sql);
         $run = mysql_query($sql, $conn);
         //获得表名
         if (substr($sql, 0, 11) == 'INSERT INTO') {
             $table_name = $temp_info['db_prefix'] . preg_replace("/INSERT INTO `" . $temp_info['db_prefix'] . "([a-z0-9_]+)` .*/is", "\\1", $sql);
             $this->_show_process(sprintf(L('insert_initdate_successed'), $table_name));
         }
     }
     $this->_show_process('注册创始人帐号');
     //注册创始人帐号
     //修改配置文件
     $auth = build_auth_key();
     $config_data['DB_TYPE'] = $temp_info['db_type'];
     $config_data['DB_HOST'] = $temp_info['db_host'];
     $config_data['DB_NAME'] = $temp_info['db_name'];
     $config_data['DB_USER'] = $temp_info['db_user'];
     $config_data['DB_PWD'] = $temp_info['db_pass'];
     $config_data['DB_PORT'] = $temp_info['db_port'];
     $config_data['DB_PREFIX'] = $temp_info['db_prefix'];
     $db = Db::getInstance($config_data);
     $config_data['WEB_MD5'] = $auth;
     $conf = write_config($config_data);
     register_administrator($db, $temp_info['db_prefix'], $temp_info, $auth);
     $this->_show_process('注册创始人帐号成功');
     //锁定安装程序
     touch('./Data/install.lock');
     //$password = hash ( 'md5', $temp_info['admin_pass'] );
     //$sqls[] = "INSERT INTO `" . $temp_info['db_prefix'] . "user` VALUES " .
     //  "('1', '" . $temp_info['admin_user'] . "', '管理员', '" . $password . "', '', '". NOW_TIME."', '".get_client_ip(1)."', 1, 8888, '" . $temp_info['admin_email'] . "', '', '". NOW_TIME."', '". NOW_TIME."', 1, 0, '', 0)";
     //安装完毕
     $this->_show_process(L('install_successed'), 'parent.install_successed();');
     //创建配置文件
     return false;
 }