示例#1
0
文件: login.php 项目: lryl/Lysine2
 public function POST()
 {
     if (!($user = \Model\User::login(post('email'), post('passwd'), post('remember')))) {
         return $this->render('login', array('message' => '错误的用户名或密码'));
     }
     $url = get('ref') ?: '/';
     return resp()->redirect($url);
 }
示例#2
0
 function ambilFile($nama = '')
 {
     if (file_exists(ROOT . $nama . EXT)) {
         include ROOT . $nama . EXT;
     } else {
         resp(503, 'json', true);
     }
 }
示例#3
0
 protected static function reset()
 {
     $_GET = array();
     $_POST = array();
     $_REQUEST = array();
     $_SERVER = array();
     $_SESSION = \Lysine\Session::getInstance();
     resp()->reset();
 }
示例#4
0
文件: mvc.php 项目: lryl/Lysine2
 public function execute($uri = null, $method = null)
 {
     $method = $method ?: req()->getMethod();
     if (!in_array($method, self::$support_methods)) {
         throw HTTP\Exception::factory(HTTP::NOT_IMPLEMENTED);
     }
     $uri = $uri ?: req()->getRequestURI();
     \Lysine\logger()->debug($method . ' ' . $uri);
     if (!req()->isGET() && ($params = post() ?: put())) {
         \Lysine\logger()->debug('Parameters: ' . http_build_query($params));
     }
     $response = $this->getRouter()->execute($uri, $method);
     return $response instanceof \Lysine\HTTP\Response ? $response : resp()->setBody($response);
 }
示例#5
0
文件: index.php 项目: lryl/Lysine2
function __exception_response($code, $exception)
{
    $resp = resp()->reset()->setCode($code);
    if (DEBUG) {
        foreach (__exception_header($exception) as $header) {
            $resp->setHeader($header);
        }
    }
    if (req()->isAjax()) {
        return $resp;
    }
    $body = \Controller::view()->render('_error', array('exception' => $exception));
    $resp->setBody($body);
    return $resp;
}
 public function anyImage(Request $r)
 {
     // Запрос конкретной картинки
     $img_id = $r->get('img', false);
     if ($img_id !== false) {
         // выбираем картинку
         $img = WallpaperImage::where('category', $img_id)->first();
         return resp($img);
     }
     // получаем id категории
     $cat = $r->get('cat', false);
     $category = intval($cat === false ? rand(1, WallpaperCategoty::max('id')) : $cat);
     // выбираем картинку
     $img = WallpaperImage::where('category', $category)->orderByRaw("RAND()")->first();
     return resp($img);
 }
示例#7
0
文件: index.php 项目: lryl/Lysine2
function __exception_response($code, $exception)
{
    $resp = resp()->reset()->setCode($code);
    if (DEBUG) {
        foreach (__exception_header($exception) as $header) {
            $resp->setHeader($header);
        }
    }
    if (req()->isAjax()) {
        return $resp;
    }
    if ($code == 401) {
        $resp = resp()->redirect('/login?ref=' . urlencode(req()->requestUri()));
    } else {
        $body = \Controller::view()->render('_error', array('exception' => $exception));
        $resp->setBody($body);
    }
    return $resp;
}
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $desc = $request->input('description');
     $select = $request->input('select.id');
     $status = false;
     $gr = GlossaryReq::find($id);
     if (!empty($select)) {
         // описание этого значения уже есть, применим его к запросу
         $gr->glossary_id = $select;
         $status = $gr->save();
     } elseif (!empty($desc)) {
         // такого описания не было, создаем его
         $g = new Glossary();
         $g->word = $gr->word;
         $g->description = $desc;
         if ($g->save()) {
             $gr->glossary_id = $g->id;
             $status = $gr->save();
         }
     }
     return resp($status, "Значение '{$gr->word}' сохранено", 'Не удалось сохранить значение');
 }
示例#9
0
文件: Sandbox.php 项目: lryl/Lysine2
 public function request($uri = '/', $method = 'GET', array $params = array())
 {
     resp()->reset();
     $_GET = $_POST = $_REQUEST = $_SERVER = $_COOKIE = array();
     $_SESSION = \Lysine\Session::getInstance();
     $uri = parse_url($uri);
     $this->path = $uri['path'];
     $method = strtoupper($method);
     $_SERVER['REQUEST_URI'] = $uri;
     $_SERVER['REQUEST_METHOD'] = $method;
     if (isset($uri['query'])) {
         $_SERVER['QUERY_STRING'] = $uri['query'];
         parse_str($uri['query'], $_GET);
     }
     if ($method == 'GET') {
         $_GET = $params;
     } else {
         $_POST = $params;
     }
     $this->cookie->apply($this->path);
     $_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
 }
示例#10
0
文件: logout.php 项目: lryl/Lysine2
 public function GET()
 {
     \Model\User::logout();
     return resp()->redirect('/');
 }
示例#11
0
 /**
  * http重定向
  *
  * @param string $url
  * @param int $code
  * @access public
  * @return Lysine\MVC\Response
  */
 public function redirect($url, $code = 303)
 {
     return resp()->setCode($code)->setHeader('Location', $url)->setBody(null);
 }
示例#12
0
<?php

if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (z_validate_token()) {
    z_logout();
    resp(1, "退出成功!");
} else {
    resp(0, "Token is incorrect.");
}
示例#13
0
/**
 * 更新认证信息
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$schoolid = isset($_POST['schoolid']) ? trim($_POST['schoolid']) : "";
$name = isset($_POST['name']) ? trim($_POST['name']) : "";
$idcard = isset($_POST['idcard']) ? trim($_POST['idcard']) : "";
$email = isset($_POST['email']) ? trim($_POST['email']) : "";
if ($schoolid == "" || $name == "" || $idcard == "" || $email == "") {
    resp(0, "信息不完整!");
}
$realinfo_obj = new zRealInfo();
if (!$realinfo_obj->isExistID($id)) {
    resp(0, "认证信息不存在!");
}
if ($realinfo_obj->update($id, $schoolid, $name, $idcard, $email)) {
    resp(1, "更新成功!");
} else {
    resp(0, "更新失败!");
}
示例#14
0
 /**
  * получение информации о друзьях
  * @param  Request $r
  * @return
  */
 public function anyFriendsGet(Request $r)
 {
     $res = (new VK())->req('friends.get', $r->all());
     if (is_array($res) && !empty($res['count']) && $r->get('user_id')) {
         Friend::where('vk_id', $r->get('user_id'))->update(['count' => $res['count']]);
         // Список друзей
         $friendList = FriendList::select('vk_id')->where('owner_id', $r->get('user_id'))->where('is_friend', 1)->get()->lists('vk_id')->toArray();
         // список удаленных друзей
         $deletedFriend = FriendList::select('vk_id')->where('owner_id', $r->get('user_id'))->where('is_friend', 0)->get()->lists('vk_id')->toArray();
         $list = [];
         // новый друг которого добавим
         $list_ids = [];
         // id друзей данные с VK
         $flc = count($friendList) > 0;
         // Для ускорения проверки есть ли друзья у проверяемого пользователя
         $all = array_merge($friendList, $deletedFriend);
         // все друзья
         foreach ($res['items'] as $v) {
             $list_ids[] = $v['id'];
             if ($flc && in_array($v['id'], $all)) {
                 continue;
             }
             $list[] = ['owner_id' => $r->get('user_id'), 'vk_id' => $v['id'], 'first_name' => $v['first_name'], 'last_name' => $v['last_name'], 'photo_50' => $v['photo_50'], 'is_friend' => true, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")];
         }
         // удаленные
         $deleted = array_diff($friendList, $list_ids);
         if (count($deleted)) {
             FriendList::where('owner_id', $r->get('user_id'))->where('is_friend', 1)->whereIn('vk_id', $deleted)->update(['is_friend' => false]);
         }
         // вернувшиеся
         $added = array_diff($list_ids, $friendList);
         if (count($added)) {
             FriendList::where('owner_id', $r->get('user_id'))->where('is_friend', 0)->whereIn('vk_id', $added)->update(['is_friend' => true]);
         }
         if (count($list)) {
             FriendList::insert($list);
         }
         return resp(['count' => $res['count'], 'items' => FriendList::where('owner_id', $r->get('user_id'))->orderBy('is_friend')->orderBy('updated_at', 'DESC')->get()]);
     }
     return resp($res, 'Успешно выполнено', 'Запрос завершился ошибкой');
 }
示例#15
0
function set_cookie($name, $value, $expire = 0, $path = '/', $domain = null, $secure = false, $httponly = true)
{
    return resp()->setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
}
示例#16
0
文件: index.php 项目: yeaha/lysine
    }
    if (!req()->isAjax()) {
        require ROOT_DIR . '/view/_error/500.php';
    }
    echo ob_get_clean();
    die(1);
});
try {
    $resp = app()->run();
} catch (Lysine\HttpError $ex) {
    if (req()->isAjax()) {
        throw $ex;
    }
    $code = $ex->getCode();
    if ($code == 404) {
        $resp = resp()->reset()->setCode($code)->setBody(render_view('_error/404', array('exception' => $ex)));
    } else {
        throw $ex;
    }
}
$profiler = Lysine\Utils\Profiler::instance();
$profiler->end(true);
$resp->setHeader('X-Runtime: ' . round($profiler->getRuntime('__MAIN__') ?: 0, 6))->sendHeader();
echo $resp;
// 尽快返回结果给fastcgi,剩下的环境清理工作已经和客户端无关
// php-fpm fastcgi特性
//
// 如果使用FirePHP/FireLogger这种通过header传递数据的调试工具
// 由于这些工具的header输出步骤都是注册到register_shutdown_function()
// 所以会在fastcgi_finish_request()之后才产生,客户端无法拿到调试信息
if (!DEBUG && PHP_SAPI == 'fpm-fcgi') {
示例#17
0
<?php

/**
 * 获取用户详细信息
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$user_obj = new zUser();
if (!$user_obj->isExistID($id)) {
    resp(0, "用户不存在!");
}
$data = array("detail" => $user_obj->getDetail($id), "more" => $user_obj->getMoreDetail($id));
resp(1, "获取成功", $data);
示例#18
0
/**
 * 更新APP
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$name = isset($_POST['name']) ? trim($_POST['name']) : "";
$trust = isset($_POST['trust']) ? intval($_POST['trust']) : -1;
if ($name == "" || $trust == -1) {
    resp(0, "信息不完整!");
}
if ($trust != 0 && $trust != 1) {
    resp(0, "信息错误!");
}
$app_obj = new zApp();
if (!$app_obj->isExistID($id)) {
    resp(0, "app不存在!");
}
if ($app_obj->update($name, $trust, $id)) {
    resp(1, "更改成功!");
} else {
    resp(0, "更改失败!");
}
示例#19
0
<?php

/**
 * 删除认证信息
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$realinfo_obj = new zRealInfo();
if (!$realinfo_obj->isExistID($id)) {
    resp(0, "认证信息不存在!");
}
if ($realinfo_obj->del($id)) {
    resp(1, "删除成功!");
} else {
    resp(0, "删除失败!");
}
示例#20
0
文件: router.php 项目: neoisldl/Onion
 /**
  * 分发请求到对应的controller
  * 执行并返回结果
  *
  * @param string $url
  * @param array $params
  * @access public
  * @return mixed
  */
 public function dispatch($url, array $params = array())
 {
     if (DEBUG) {
         $logger = \Onion\logger('mvc');
     }
     $url = strtolower(rtrim($url, '/'));
     if (DEBUG) {
         $logger->info('Request url:' . req()->requestUri());
     }
     list($class, $args) = $this->match($url);
     if (DEBUG) {
         $logger->debug('Dispatch url to controller: ' . $class);
     }
     if (!$class || !class_exists($class)) {
         throw HttpError::page_not_found(array('controller' => $class));
     }
     if ($params) {
         $args = array_merge($args, $params);
     }
     fire_event($this, BEFORE_DISPATCH_EVENT, array($url, $class, $args));
     $controller = new $class();
     if (method_exists($controller, '__before_run')) {
         // 如果__before_run返回了内容,就直接完成动作
         // 可以在这里进行某些阻断操作
         // 正常的内容不应该通过这里输出
         if ($resp = call_user_func_array(array($controller, '__before_run'), $args)) {
             return $resp instanceof Response ? $resp : resp()->setBody($resp);
         }
     }
     $request = req();
     $method = $request->method();
     // head方法除了不输出数据之外,和get方法没有区别
     if ($method == 'HEAD') {
         $method = 'GET';
     }
     if (DEBUG) {
         $log = 'Call controller [' . $class . '] method [' . $method . ']';
         if ($args) {
             $log .= ' with ' . json_encode($args);
         }
         $logger->info($log);
     }
     // 执行controller动作并返回结果
     // 不检查method是否存在,用is_callable()
     // 保留__call()重载方法的方式
     if (!is_callable(array($controller, $method))) {
         throw HttpError::method_not_allowed(array('url' => $url, 'class' => $class));
     }
     $resp = call_user_func_array(array($controller, $method), $args);
     // 这里有机会对输出结果进行进一步处理
     if (method_exists($controller, '__after_run')) {
         $controller->__after_run($resp);
     }
     fire_event($this, AFTER_DISPATCH_EVENT, array($url, $class, $args, $resp));
     return $resp instanceof Response ? $resp : resp()->setBody($resp);
 }
示例#21
0
<?php

/**
 * 获取认证信息列表
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 0;
$realinfo_obj = new zRealInfoList();
$list = $realinfo_obj->getList($offset, $rows);
if (count($list) <= 0) {
    resp(0, "还没有认证信息!");
} else {
    resp(1, "获取成功", $list);
}
示例#22
0
<?php

/**
 * 添加APP
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$name = isset($_POST['name']) ? trim($_POST['name']) : "";
$trust = isset($_POST['trust']) ? intval($_POST['trust']) : -1;
if ($name == "" || $trust == -1) {
    resp(0, "信息不完整!");
}
if ($trust != 0 && $trust != 1) {
    resp(0, "信息错误!");
}
$app_obj = new zApp();
if ($app_obj->add($name, $trust)) {
    resp(1, "添加成功!");
} else {
    resp(0, "添加失败!");
}
示例#23
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $res = GlossaryReq::find($id);
     return resp($res);
 }
示例#24
0
文件: context.php 项目: lryl/Lysine2
 public function save()
 {
     $token = $this->getToken();
     $data = $this->data ? $this->encode($this->data) : '';
     if (!($expire = (int) $this->getConfig('expire_at'))) {
         $expire = ($ttl = (int) $this->getConfig('ttl')) ? time() + $ttl : 0;
     }
     $path = $this->getConfig('path') ?: '/';
     $domain = $this->getConfig('domain');
     resp()->setCookie($token, $data, $expire, $path, $domain);
     return $data;
 }
示例#25
0
<?php

/**
 * 登录
 */
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
$username = isset($_POST['username']) ? trim($_POST['username']) : "";
$password = isset($_POST['password']) ? trim($_POST['password']) : "";
if ($username == "" || $password == "") {
    resp(0, "帐号或者密码不准为空!");
    exit;
}
$admin_obj = new zAdmin();
if (!$admin_obj->auth($username, $password)) {
    resp(0, "帐号或者密码错误!");
} else {
    z_login($username);
    resp(1, "登录成功!", array("token" => $_SESSION["user"]["token"]));
}
示例#26
0
if (!defined("Z_ENTRANCE")) {
    header("HTTP/1.0 404 Not Found");
    exit;
}
if (!z_is_login()) {
    resp(0, "还未登录!");
}
if (!z_validate_token()) {
    resp(0, "Token is incorrect.");
}
$password = isset($_POST['password']) ? trim($_POST['password']) : "";
$newpassword = isset($_POST['newpassword']) ? trim($_POST['newpassword']) : "";
$confirmpassword = isset($_POST['confirmpassword']) ? trim($_POST['confirmpassword']) : "";
if ($password == "" || $newpassword == "" || $confirmpassword == "") {
    resp(0, "信息不完整!");
}
if (strcmp($newpassword, $confirmpassword) != 0) {
    resp(0, "两次输入密码不同!");
}
if (strlen($newpassword) < 16) {
    resp(0, "密码不能小于16位!");
}
$admin_obj = new zAdmin();
if (!$admin_obj->auth($_SESSION["user"]["name"], $password)) {
    resp(0, "原密码错误!");
}
if ($admin_obj->update($_SESSION["user"]["name"], $newpassword)) {
    resp(1, "更改密码成功!");
} else {
    resp(0, "更改密码失败!");
}