Пример #1
0
 /**
  * Log In
  */
 public function action_login()
 {
     Auth::check() and Reponse::redirect('admin');
     $data['username'] = null;
     if (Input::post('login')) {
         if (Auth::instance()->login()) {
             Session::set_flash('notice', __('Welcome back!'));
             Response::redirect('admin');
         }
         Session::set_flash('notice', __('Wrong username/password combo. Try again.'));
         $data['username'] = Input::post('username');
     }
     $this->template->title = __('Log In');
     $this->template->content = View::forge('admin/login', $data);
 }
 public function postIndex()
 {
     $user = Auth::getUser();
     $friendUser = null;
     if (Input::has('id')) {
         $friendUser = $this->meService->getUser(Input::get('id'));
         if ($friendUser === null) {
             return Reponse::error('User id not found');
         }
     } else {
         if (Input::has('facebook_uid')) {
             $facebook_uid = Input::get('facebook_uid');
             $friendUser = $this->registerService->preRegisterFacebookId($facebook_uid);
         } else {
             if (Input::has('email')) {
                 $email = Input::get('email');
                 $friendUser = $this->registerService->inviteByEmail($email, $user);
             } else {
                 return Response::error('Missing parameters');
             }
         }
     }
     if ($user->id === $friendUser->id) {
         return Response::error('Invited same user');
     }
     $friend = $this->meService->addFriend($user, $friendUser);
     if ($friend === null) {
         return Response::error('Failed to add friend');
     } else {
         return Response::json(['message' => 'Added new friend']);
     }
 }
Пример #3
0
 /**
  * Api function for get currency and listing by 7 days data.
  *
  * @param number $currencyId
  * @return boolean|Response
  */
 public function getCurrenciesById($currencyId = 0)
 {
     $data = get();
     $default = array('currency_id' => $currencyId);
     // Validator input params.
     $valids = Validator::make($default, ['currency_id' => 'required|numeric|min:1'], EXRHelper::getMessage());
     // Check fails.
     if ($valids->fails()) {
         return Reponse::json(array('status' => 'error', 'data' => $valids->messages()), 500);
     }
     $cacheId = 'currency_detail_' . $currencyId;
     if (!Cache::has($cacheId)) {
         $records = CurrencyDaily::whereRaw('currency_id = ? AND created_at >= NOW() - INTERVAL ? WEEK', array($currencyId, DLN_LIMIT_WEEK))->orderBy('updated_at', 'ASC')->with('currency')->get();
         $newRecords = array();
         if (count($records)) {
             foreach ($records as $record) {
                 switch ($record->type) {
                     case 'gold':
                         $multiple = 100000;
                         break;
                     default:
                         $multiple = 1;
                         break;
                 }
                 $record->buy = intval($record->buy * $multiple);
                 $record->transfer = intval($record->transfer * $multiple);
                 $record->sell = intval($record->sell * $multiple);
                 $record->min_buy = intval($record->min_buy * $multiple);
                 $record->max_buy = intval($record->max_buy * $multiple);
                 $record->min_sell = intval($record->min_sell * $multiple);
                 $record->max_sell = intval($record->max_sell * $multiple);
                 $record->buy_change = intval($record->buy_change * $multiple);
                 $record->sell_change = intval($record->sell_change * $multiple);
                 $newRecords[] = $record;
             }
         }
         Cache::put($cacheId, json_encode($newRecords), EXR_CACHE_MINUTE);
     } else {
         $records = json_decode(Cache::get($cacheId, null));
     }
     return Response::json(array('status' => 'success', 'data' => $records));
 }
Пример #4
0
 public function statistiques($action, $id, $vars)
 {
     switch ($action) {
         /**** GET ****/
         case 'get':
             $vars['titrePage'] = 'Statistiques';
             // <h1> de la page
             $vars['visites'] = Visite::getStat();
             $vars['membres'] = Membre::getStat();
             $vars['technotes'] = Technote::getStat();
             $vars['commentaires'] = Commentaire::getStat();
             $vars['questions'] = Question::getStat();
             $vars['reponses'] = Reponse::getStat();
             $vars['motsCles'] = MotCle::getStat();
             $this->vue->display('admin/statistiques.twig', $vars);
             exit;
         default:
             $this->vue->display('404.twig', $vars);
             exit;
     }
 }
Пример #5
0
 public function reponses($action, $id, $vars)
 {
     switch ($action) {
         case 'add':
             if (!empty($_POST)) {
                 // Si le formulaire est valide au niveau faille CSRF
                 if (!empty($_POST['jetonCSRF']) && $_POST['jetonCSRF'] == $_SESSION['jetonCSRF']) {
                     // On essaye d'enregistrer la réponse
                     $res = Reponse::addReponse($_POST);
                     if ($res->success) {
                         $res->add['reponse'] = $this->vue->render('templates/reponse.twig', array('reponses' => $res->add));
                     }
                     echo json_encode($res);
                 }
             }
             exit;
         case 'edit':
             if (!empty($_POST)) {
                 // Si le formulaire est valide au niveau faille CSRF
                 if (!empty($_POST['jetonCSRF']) && $_POST['jetonCSRF'] == $_SESSION['jetonCSRF']) {
                     // On essaye d'enregistrer le commentaire
                     $res = Reponse::editReponse($_POST, $id);
                     echo json_encode($res);
                 }
             }
             exit;
         case 'drop':
             if (!empty($_POST)) {
                 // Si le formulaire est valide au niveau faille CSRF
                 if (!empty($_POST['jetonCSRF']) && $_POST['jetonCSRF'] == $_SESSION['jetonCSRF']) {
                     // On essaye d'enregistrer le commentaire
                     $res = Reponse::dropReponse($_POST, $id);
                     echo json_encode($res);
                 }
             }
             exit;
         default:
             $this->vue->display('404.twig', $vars);
             exit;
     }
 }
Пример #6
0
 /**
  * 上传文件
  * @return string
  */
 public function uploadFile()
 {
     if ($this->checkError() && $this->checkSize() && $this->checkExt() && $this->checkMime() && $this->checkTrueImg() && $this->checkHTTPPost()) {
         $this->checkUploadPath();
         $this->uniName = $this->getUniName();
         $this->destination = $this->uploadPath . '/' . $this->uniName . '.' . $this->ext;
         if (@move_uploaded_file($this->fileInfo['tmp_name'], $this->destination)) {
             return $this->destination;
         } else {
             Reponse::show(716, 'move file error');
             //$this->error='文件移动失败';
             //$this->showError();
         }
     }
     //else{
     //	$this->showError();
     //}
 }