Example #1
0
 public function sRender()
 {
     $uid = $_SESSION['admin']['id'];
     $userApi = new KUser_userApi();
     $logininfo = $userApi->getUser($uid);
     $app = new KOperation_App();
     $head = new Ko_View_Smarty();
     $head->vAssignHtml('IMG_DOMAIN', IMG_DOMAIN);
     $head->vAssignHtml('WWW_DOMAIN', WWW_DOMAIN);
     $head->vAssignHtml('PASSPORT_DOMAIN', PASSPORT_DOMAIN);
     $head->vAssignHtml('logininfo', $logininfo);
     list($top_menus, $cur_menu, $left_nav_html) = $app->aGetNavData();
     $head->vAssignHtml('__top_menus', $top_menus);
     $head->vAssignHtml('__cur_menus', $cur_menu);
     $head->vAssignRaw('__admin_nav', $left_nav_html);
     $head->vAssignRaw('is_super', !!in_array($logininfo['id'], KOperation_Conf::$super_users));
     $headHtml = $head->sFetch('operation/common/header.html');
     //		$head = new Ko_View_Render_Smarty;
     //		$head->oSetTemplate('operation/common/header.html')
     //			->oSetData('IMG_DOMAIN', IMG_DOMAIN)
     //			->oSetData('WWW_DOMAIN', WWW_DOMAIN)
     //			->oSetData('PASSPORT_DOMAIN', PASSPORT_DOMAIN)
     //			->oSetData('logininfo', $logininfo);
     $tail = new Ko_View_Render_Smarty();
     $tail->oSetTemplate('operation/common/footer.html')->oSetData('IMG_DOMAIN', IMG_DOMAIN)->oSetData('WWW_DOMAIN', WWW_DOMAIN)->oSetData('PASSPORT_DOMAIN', PASSPORT_DOMAIN);
     return $headHtml . parent::sRender() . $tail->sRender();
 }
Example #2
0
 public function post($update, $after = null, $post_style)
 {
     $api = new KUser_loginApi();
     if ($post_style == 'default') {
         $uid = $api->iLogin($update['username'], $update['passwd'], $errno);
         if (!$uid) {
             if (Ko_Mode_User::E_LOGIN_USER == $errno) {
                 throw new Exception('用户名不存在', 1);
             }
             if (Ko_Mode_User::E_LOGIN_PASS == $errno) {
                 throw new Exception('密码错误', 2);
             }
             throw new Exception('登录失败,请重试', 2);
         }
         $userApi = new KUser_userApi();
         $userApi->doAfterLogin($uid);
     } elseif ($post_style == 'register') {
         $userApi = new KUser_userApi();
         $insert = array('username' => $update['username']);
         $uid = $userApi->addUser($insert);
         if (!$uid) {
             throw new Exception('注册失败,请重试');
         }
         $ret = $api->bRegisterUid($uid, $update['username'], $update['passwd'], $errno);
         if (!$uid) {
             switch ($errno) {
                 case 3:
                     throw new Exception('用户名已存在', 1);
                     break;
             }
         }
     }
     return array('key' => $uid);
 }
Example #3
0
<?php

/**
 * Created by JetBrains PhpStorm.
 * User: Jichen Zhou
 * Date: 2015年12月22日
 * Time: 下午5:31
 */
Ko_Web_Event::On('ko.dispatch', 'before', function () {
    $uri = Ko_Web_Request::SRequestUri();
    $script = Ko_Web_Request::SScriptName();
    $userApi = new KUser_userApi();
    if ($uri == '/user/login/index') {
        echo "hook logout" . chr(10);
        //		$userApi->logoutAdminAuth();
    } elseif ($uri == '/rest/user/login/') {
    } else {
        if (!$userApi->checkLogin()) {
            $url = 'http://' . WWW_DOMAIN . '/user/login/index';
            header('Location:' . $url);
            exit;
        }
    }
});