function getstep(&$id) { global $err; $STEPS = array('locked', 'step1', 'step2', 'step3'); $MAXST = count($STEPS) - 1; $i = 0; $setupid = null; if (!file_exists(LOCKFILE)) { $setupid = setupid(); if (!$setupid) { die('Setup is running'); } if (!file_exists(SETUPTEMP_FILE)) { if (empty($_POST)) { $i = 0; } else { $i = 1; } } else { $x = explode(',', io_load_file(SETUPTEMP_FILE)); if ($x[0] != $setupid) { die('Setup is running: if you are the owner, you can delete ' . SETUPTEMP_FILE . ' to restart'); } $i = intval($x[1]); } @(include "./setup/lib/{$STEPS[$i]}.lib.php"); if (!function_exists('check_step')) { function check_step() { return true; } } if (check_step()) { ++$i; if ($i >= $MAXST) { fs_delete(SETUPTEMP_FILE); io_write_file(LOCKFILE, "locked"); } else { if ($i > 0 && !@io_write_file(SETUPTEMP_FILE, "{$setupid},{$i}")) { $err[] = 'Write error'; } } } } $id = $STEPS[$i]; return $i; }
/** * 登录指定用户 * @param integer $uid 用户ID * @param bool $remember * @param int $role_id 有值代表强制登录这个角色 * @return boolean ture-登录成功,false-登录失败 */ public function login($uid, $remember = false, $role_id = 0) { /* 检测是否在当前应用注册 */ $user = $this->field(true)->find($uid); if ($role_id != 0) { $user['last_login_role'] = $role_id; } else { if (!intval($user['last_login_role'])) { $user['last_login_role'] = $user['show_role']; } } session('temp_login_uid', $uid); session('temp_login_role_id', $user['last_login_role']); if ($user['status'] == 3) { header('Content-Type:application/json; charset=utf-8'); $data['status'] = 1; $data['url'] = U('Ucenter/Member/activate'); if (IS_AJAX) { exit(json_encode($data)); } else { redirect($data['url']); } } if (1 != $user['status']) { $this->error = L('_USERS_ARE_NOT_ACTIVATED_OR_DISABLED_WITH_EXCLAMATION_'); //应用级别禁用 return false; } $step = M('UserRole')->where(array('uid' => $uid, 'role_id' => $user['last_login_role']))->getField('step'); if (!empty($step) && $step != 'finish') { header('Content-Type:application/json; charset=utf-8'); $data['status'] = 1; //执行步骤在start的时候执行下一步,否则执行此步骤 $go = $step == 'start' ? get_next_step($step) : check_step($step); $data['url'] = U('Ucenter/Member/step', array('step' => $go)); if (IS_AJAX) { exit(json_encode($data)); } else { redirect($data['url']); } } /* 登录用户 */ $this->autoLogin($user, $remember); session('temp_login_uid', null); session('temp_login_role_id', null); //记录行为 action_log('user_login', 'member', $uid, $uid); return true; }
public function step() { $aStep = I('get.step', '', 'op_t'); $aUid = session('temp_login_uid'); $aRoleId = session('temp_login_role_id'); if (empty($aUid)) { $this->error('参数错误'); } $userRoleModel = D('UserRole'); $map['uid'] = $aUid; $map['role_id'] = $aRoleId; $step = $userRoleModel->where($map)->getField('step'); if (get_next_step($step) != $aStep) { $aStep = check_step($step); $_GET['step'] = $aStep; $userRoleModel->where($map)->setField('step', $aStep); } $userRoleModel->where($map)->setField('step', $aStep); if ($aStep == 'finish') { D('Member')->login($aUid, false, $aRoleId); } $this->assign('step', $aStep); $this->display('register'); }
if (isset($_GET['get_started'])) { $_SESSION['DE_INSTALL_STEP'] = 1; } elseif (isset($_GET['reinstall'])) { unset($_SESSION['DE_INSTALL_STEP']); } elseif (isset($_SESSION['DE_INSTALL_STEP']) && $_SESSION['DE_INSTALL_STEP'] == 1 && isset($_GET['agree']) || isset($_GET['data']) && isset($_SESSION['DE_INSTALL_STEP']) && $_SESSION['DE_INSTALL_STEP'] > 2) { $_SESSION['DE_INSTALL_STEP'] = 2; } elseif (isset($_SESSION['DE_INSTALL_STEP']) && $_SESSION['DE_INSTALL_STEP'] > 3 && isset($_GET['extra'])) { $_SESSION['DE_INSTALL_STEP'] = 3; } $install_vars['active_welcome'] = $install_vars['active_agree'] = $install_vars['active_data'] = $install_vars['active_extra'] = $install_vars['active_prog'] = $install_vars['active_done'] = 'default'; if (isset($GLOBALS['CHMOD']['REQ_FTP'])) { $step_name = 'ftp_connect'; } elseif (isset($_SESSION['DE_INSTALL_STEP'])) { $step_name = 'install/step_' . $_SESSION['DE_INSTALL_STEP']; $proc = array(10, 20, 30, 30, 10); check_step($_SESSION['DE_INSTALL_STEP'], $install_vars, $step_vars, $errors_list, $done_list); $t_proc = 0; /* if(isset($_SESSION['DE_INSTALL_STEP'])) { for($i=1;$i<=$_SESSION['DE_INSTALL_STEP'];$i++) $t_proc += $proc[$i - 1]; $install_vars['install_step'] = $_SESSION['DE_INSTALL_STEP']; $install_vars['install_proc'] = ($t_proc / 100) * $install_vars['step_max']; } */ } if (!isset($_SESSION['DE_INSTALL_STEP'])) {