Ejemplo n.º 1
0
 /**
  * 获取用户及空间信息
  * @return array
  */
 public function getProfile()
 {
     $data = array();
     $data['id'] = $this->user['id'];
     $data['display_name'] = $this->user['nick'];
     $data['user_name'] = $this->user['user_name'];
     $data['avatar'] = $this->user['avatar'];
     $data['nick'] = $this->user['nick'];
     $data['email'] = $this->user['email'];
     $data['space'] = $this->user['space'];
     $data['usedSpace'] = $this->user['usedSpace'];
     $data['used_space'] = $this->user['usedSpace'];
     $data['email'] = $this->user['email'];
     $data['phone'] = $this->user['phone'];
     //这里的信息比较冗余,把站点的逻辑融入到用户信息获得的地方,是为了不让PC客户端发送多次请求
     //打印用户是否是管理员
     $info = array("success" => $this->user["is_admin"]);
     $data['is_admin'] = $info;
     //输出服务器时间
     $info = array("time" => time());
     $data['time'] = $info;
     //获得站点信息
     $app = new SiteService();
     $data['app_info'] = $app->info();
     //是否系统只有默认账号
     $data['only_default_account'] = $app->onlyDefaultAccount();
     //获得授权码信息
     $code = MiniOption::getInstance()->getOptionValue("code");
     if (empty($code)) {
         $code = "";
     }
     $data['code'] = $code;
     return $data;
 }
 public function execute($parameters = [])
 {
     if (!isset($parameters['action'])) {
         $result = ['Result' => 'ERROR', 'Message' => 'Faltan parámetros'];
         return json_encode($result);
     }
     switch ($parameters['action']) {
         case 'emailExists':
             if (isset($parameters['email'])) {
                 return json_encode($this->emailExists($parameters['email']));
             } else {
                 return json_encode(SiteService::MissingParameters());
             }
         case 'logout':
             return json_encode(User::logOut());
             break;
         case 'login':
             extract($parameters);
             $password = $pass;
             //  Válido que el correo exista en la base de datos
             if ($this->usernameExists($user)) {
                 $login = User::loginNormal($user, $password);
                 return json_encode($this->processLoginResult($login));
             }
             $result = ['Result' => 'ERROR', 'Message' => 'El correo electrónico no existe'];
             return $result;
             break;
         case 'password-recovery':
             $email = $parameters['email'];
             break;
         default:
             $result = [];
             $result['Result'] = 'ERROR';
             $result['Message'] = 'Acción no definida';
             return json_encode($result);
     }
 }
Ejemplo n.º 3
0
 /**
  * 判断是否是默认账号
  * @return array|null
  */
 public function defaultAccount()
 {
     $app = new SiteService();
     return $app->onlyDefaultAccount();
 }
Ejemplo n.º 4
0
<?php

/**
 * Created by PhpStorm.
 * User: Poka
 * Date: 2/12/2016
 * Time: 1:36 PM
 */
require_once __DIR__ . '/../../services/SiteService.php';
$app->get('/admin/site/get-site-data/{catName}', function ($request, $response, $args) {
    $contact = new SiteService();
    $catName = $args['catName'];
    $result = $contact->getSiteInfo($catName);
    $error = null;
    if (!$result) {
        $error = 'Unable fetch data';
    }
    //TODO: Detail error for client
    return AppCore::JsonResponse($response, $result, 200, $error);
});