Example #1
0
 private function _login()
 {
     $oauth_url = APF::get_instance()->get_config('oauth_url');
     $oauth_cid = APF::get_instance()->get_config('oauth_cid');
     $oauth_secret = APF::get_instance()->get_config('oauth_secret');
     if (isset($_REQUEST['code']) && $_REQUEST['code']) {
         $data = array("client_id" => $oauth_cid, "client_secret" => $oauth_secret, "grant_type" => 'authorization_code', "code" => $_REQUEST['code']);
         header("HTTP/1.1 302 Found");
         header("Location: " . $oauth_url . '/token.php?' . http_build_query($data));
         exit;
     }
     if (isset($_REQUEST['access_token']) && $_REQUEST['access_token']) {
         $access_token = $_REQUEST['access_token'];
         $data = array("oauth_token" => $access_token);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $oauth_url . "/resource.php");
         curl_setopt($ch, CURLOPT_POST, TRUE);
         curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         $info = curl_exec($ch);
         if ($info) {
             $info = json_decode($info);
             $access_token = $info->access_token;
             $d = $detail = json_decode($this->_get_info_from_ldap($access_token, $oauth_url));
             $user_id = Biz_User::get_instance()->check_user($d->chinese_name, $d->english_name, $d->email);
             setcookie(APF::get_instance()->get_config('cookie_name'), $user_id, time() + 60 * 60 * 24 * 30, '/');
             $this->_response->redirect(PageHelper::get_domain() . '/project/list');
         } else {
             exit;
         }
     }
     exit;
 }
Example #2
0
 private function _save()
 {
     $pid = intval($this->_param['pid']);
     $hostname = trim($this->_param['hostname']);
     $hostname = explode("\n", $hostname);
     $biz = Biz_Host::get_instance();
     $biz->delete_host($pid);
     foreach ($hostname as $h) {
         $biz->insert_host($pid, trim($h));
     }
     $this->_response->redirect(PageHelper::get_domain() . "/project/op?pid={$pid}");
 }
Example #3
0
 private function _save()
 {
     $pid = intval($this->_param['pid']);
     $pattern = trim($this->_param['pattern']);
     $pattern = explode("\n", $pattern);
     $biz = Biz_Exclude::get_instance();
     $biz->delete_exclude($pid);
     foreach ($pattern as $p) {
         $biz->insert_exclude($pid, trim($p));
     }
     $this->_response->redirect(PageHelper::get_domain() . "/project/op?pid={$pid}");
 }
Example #4
0
 private function _delete()
 {
     $pid = intval($this->_param['pid']);
     Biz_Project::get_instance()->delete($pid);
     $url = PageHelper::get_domain() . '/project/list';
     $this->_response->redirect($url);
 }
Example #5
0
 private function _delete()
 {
     $this->_response->redirect(PageHelper::get_domain() . "/project/op?pid={$this->_param['pid']}");
 }
Example #6
0
 private function _switch()
 {
     $pid = intval($this->_param['pid']);
     $param = isset($this->_param['param']) ? trim($this->_param['param']) : '';
     $desc = isset($this->_param['desc']) ? trim($this->_param['desc']) : '';
     $project = Biz_Project::get_instance()->get_info($pid);
     $input = array();
     $input['pid'] = $pid;
     $input['user_id'] = $this->_user->id;
     $input['op'] = 2;
     $input['param'] = $param;
     $input['desc'] = $desc;
     $input['status'] = 0;
     $oplog_id = Biz_OperateLog::get_instance()->insert($input);
     $input['id'] = $oplog_id;
     Biz_Command::get_instance()->insert($input);
     Biz_Project::get_instance()->update($pid, array('pversion' => $project->version, 'version' => $param));
     $this->_response->redirect(PageHelper::get_domain() . '/project/op?pid=' . $pid);
 }
Example #7
0
 public function handle_request_internel()
 {
     $domain = PageHelper::get_domain();
     $this->_response->redirect($domain . '/project/list');
 }