Ejemplo n.º 1
0
 /**
  * 登陆状态检测;并初始化数据状态
  */
 public function loginCheck()
 {
     if (isset($_SESSION['kod_login']) && $_SESSION['kod_login'] === true) {
         define('USER', USER_PATH . $this->user['name'] . '/');
         if (!file_exists(USER)) {
             $this->logout();
             return;
         }
         if ($this->user['role'] == 'root') {
             define('MYHOME', USER . 'home/');
             define('HOME', '');
             $GLOBALS['web_root'] = WEB_ROOT;
             //服务器目录
             $GLOBALS['is_root'] = 1;
         } else {
             define('MYHOME', '/');
             define('HOME', USER . 'home/');
             $GLOBALS['web_root'] = str_replace(WEB_ROOT, '', HOME);
             //从服务器开始到用户目录
             $GLOBALS['is_root'] = 0;
         }
         $this->config['user_fav_file'] = USER . 'data/fav.php';
         // 收藏夹文件存放地址.
         $this->config['user_seting_file'] = USER . 'data/config.php';
         //用户配置文件
         $this->config['user'] = fileCache::load($this->config['user_seting_file']);
         return;
     } else {
         if (in_array(ACT, $this->notCheck)) {
             //不需要判断的action
             return;
         } else {
             if (isset($_COOKIE['kod_name']) && isset($_COOKIE['kod_token'])) {
                 $member = new fileCache($this->config['system_file']['member']);
                 $user = $member->get($_COOKIE['kod_name']);
                 if (!is_array($user) || !isset($user['password'])) {
                     $this->login();
                 }
                 if (md5($user['password'] . get_client_ip()) == $_COOKIE['kod_token']) {
                     session_start();
                     //re start
                     $_SESSION['kod_login'] = true;
                     $_SESSION['kod_user'] = $user;
                     setcookie('kod_name', $_COOKIE['kod_name'], time() + 3600 * 24 * 365);
                     setcookie('kod_token', $_COOKIE['kod_token'], time() + 3600 * 24 * 365);
                     //密码的MD5值再次md5
                     header('location:' . get_url());
                     exit;
                 }
             }
         }
     }
     $this->login();
 }
Ejemplo n.º 2
0
 /**
  * 登陆状态检测;并初始化数据状态
  */
 public function loginCheck()
 {
     $this->authApi();
     //api方式验证
     if ($_SESSION['isLogin'] === true) {
         define('USER', USER_PATH . $this->user['name'] . '/');
         if ($this->user['role'] == 'root') {
             define('MYHOME', USER . 'home/');
             define('HOME', '');
             $GLOBALS['web_root'] = WEB_ROOT;
             //服务器目录
             $GLOBALS['is_root'] = 1;
         } else {
             define('MYHOME', '/');
             define('HOME', USER . 'home/');
             $GLOBALS['web_root'] = str_replace(WEB_ROOT, '', HOME);
             //从服务器开始到用户目录
             $GLOBALS['is_root'] = 0;
         }
         $this->config['user_fav_file'] = USER . 'data/fav.php';
         // 收藏夹文件存放地址.
         $this->config['user_seting_file'] = USER . 'data/config.php';
         //用户配置文件
         $this->config['user'] = fileCache::load($this->config['user_seting_file']);
         return;
     } else {
         if (ACT == 'loginSubmit' || ACT == 'checkCode') {
             //登陆提交判断;或者获取验证码
             return;
         } else {
             if (isset($_COOKIE['kod_name']) && isset($_COOKIE['kod_token'])) {
                 $member = new fileCache($this->config['system_file']['member']);
                 $user = $member->get($_COOKIE['kod_name']);
                 if (md5($user['password'] . get_client_ip()) == $_COOKIE['kod_token']) {
                     $_SESSION['isLogin'] = true;
                     $_SESSION['user'] = $user;
                     setcookie('kod_name', $_COOKIE['kod_name'], time() + 3600 * 24 * 365);
                     setcookie('kod_token', $_COOKIE['kod_token'], time() + 3600 * 24 * 365);
                     //密码的MD5值再次md5
                     header('location:' . get_url());
                     return;
                 }
             }
         }
     }
     $this->login();
 }
Ejemplo n.º 3
0
function init_setting()
{
    $setting_file = USER_SYSTEM . 'system_setting.php';
    if (!file_exists($setting_file)) {
        //不存在则建立
        $setting = $GLOBALS['config']['setting_system_default'];
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
        fileCache::save($setting_file, $setting);
    } else {
        $setting = fileCache::load($setting_file);
    }
    if (!is_array($setting)) {
        $setting = $GLOBALS['config']['setting_system_default'];
    }
    if (!is_array($setting['menu'])) {
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
    }
    $GLOBALS['app']->setDefaultController($setting['first_in']);
    //设置默认控制器
    $GLOBALS['app']->setDefaultAction('index');
    //设置默认控制器函数
    $GLOBALS['config']['setting_system'] = $setting;
    //全局
    $GLOBALS['L']['kod_name'] = $setting['system_name'];
    $GLOBALS['L']['kod_name_desc'] = $setting['system_desc'];
    if (isset($setting['powerby'])) {
        $GLOBALS['L']['kod_power_by'] = $setting['powerby'];
    }
}
Ejemplo n.º 4
0
 /**
  * 登录状态检测;并初始化数据状态
  */
 public function loginCheck()
 {
     if (ST == 'share') {
         return true;
     }
     //共享页面
     if (in_array(ACT, $this->notCheck)) {
         //不需要判断的action
         return;
     } else {
         if ($_SESSION['kod_login'] === true && $_SESSION['kod_user']['name'] != '') {
             define('USER', USER_PATH . $this->user['name'] . '/');
             define('USER_TEMP', USER . 'data/temp/');
             define('USER_RECYCLE', USER . 'recycle/');
             if (!file_exists(USER)) {
                 $this->logout();
             }
             if ($this->user['role'] == 'root') {
                 define('MYHOME', USER . 'home/');
                 define('HOME', '');
                 $GLOBALS['web_root'] = WEB_ROOT;
                 //服务器目录
                 $GLOBALS['is_root'] = 1;
             } else {
                 define('MYHOME', '/');
                 define('HOME', USER . 'home/');
                 $GLOBALS['web_root'] = str_replace(WEB_ROOT, '', HOME);
                 //从服务器开始到用户目录
                 $GLOBALS['is_root'] = 0;
             }
             $this->config['user_share_file'] = USER . 'data/share.php';
             // 收藏夹文件存放地址.
             $this->config['user_fav_file'] = USER . 'data/fav.php';
             // 收藏夹文件存放地址.
             $this->config['user_seting_file'] = USER . 'data/config.php';
             //用户配置文件
             $this->config['user'] = fileCache::load($this->config['user_seting_file']);
             if ($this->config['user']['theme'] == '') {
                 $this->config['user'] = $this->config['setting_default'];
             }
             return;
         } else {
             if ($_COOKIE['kod_name'] != '' && $_COOKIE['kod_token'] != '') {
                 $member = new fileCache(USER_SYSTEM . 'member.php');
                 $user = $member->get($_COOKIE['kod_name']);
                 if (!is_array($user) || !isset($user['password'])) {
                     $this->logout();
                 }
                 if (md5($user['password'] . get_client_ip()) == $_COOKIE['kod_token']) {
                     session_start();
                     //re start
                     $_SESSION['kod_login'] = true;
                     $_SESSION['kod_user'] = $user;
                     setcookie('kod_name', $_COOKIE['kod_name'], time() + 3600 * 24 * 365);
                     setcookie('kod_token', $_COOKIE['kod_token'], time() + 3600 * 24 * 365);
                     //密码的MD5值再次md5
                     header('location:' . get_url());
                     exit;
                 }
                 $this->logout();
                 //session user数据不存在
             } else {
                 if ($this->config['setting_system']['auto_login'] != '1') {
                     $this->logout();
                     //不自动登录
                 } else {
                     if (!file_exists(USER_SYSTEM . 'install.lock')) {
                         $this->display('install.html');
                         exit;
                     }
                     header('location:./index.php?user/loginSubmit&name=guest&password=guest');
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
function init_setting()
{
    $setting_file = USER_SYSTEM . 'system_setting.php';
    if (!file_exists($setting_file)) {
        //It does not exist
        $setting = $GLOBALS['config']['setting_system_default'];
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
        fileCache::save($setting_file, $setting);
    } else {
        $setting = fileCache::load($setting_file);
    }
    if (!is_array($setting)) {
        $setting = $GLOBALS['config']['setting_system_default'];
    }
    if (!is_array($setting['menu'])) {
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
    }
    $GLOBALS['app']->setDefaultController($setting['first_in']);
    //Set the default controller
    $GLOBALS['app']->setDefaultAction('index');
    //Set the default controller function
    $GLOBALS['config']['setting_system'] = $setting;
    //全局
    $GLOBALS['L']['kod_name'] = $setting['system_name'];
    $GLOBALS['L']['kod_name_desc'] = $setting['system_desc'];
    if (isset($setting['powerby'])) {
        $GLOBALS['L']['kod_power_by'] = $setting['powerby'];
    }
    //Customized load
    $setting_user = BASIC_PATH . 'config/setting_user.php';
    if (file_exists($setting_user)) {
        include $setting_user;
    }
}
Ejemplo n.º 6
0
function init_setting()
{
    $member = new fileCache(USER_SYSTEM . 'member.php');
    // from environment variables
    $username = '******';
    $password = '******';
    $user = array('name' => $username, 'password' => md5($password), 'role' => 'default', 'status' => 0);
    $member->add($username, $user);
    initDaoCloudUser($username);
    $setting_file = USER_SYSTEM . 'system_setting.php';
    if (!file_exists($setting_file)) {
        //不存在则建立
        $setting = $GLOBALS['config']['setting_system_default'];
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
        fileCache::save($setting_file, $setting);
    } else {
        $setting = fileCache::load($setting_file);
    }
    if (!is_array($setting)) {
        $setting = $GLOBALS['config']['setting_system_default'];
    }
    if (!is_array($setting['menu'])) {
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
    }
    $GLOBALS['app']->setDefaultController($setting['first_in']);
    //设置默认控制器
    $GLOBALS['app']->setDefaultAction('index');
    //设置默认控制器函数
    $GLOBALS['config']['setting_system'] = $setting;
    //全局
    $GLOBALS['L']['kod_name'] = $setting['system_name'];
    $GLOBALS['L']['kod_name_desc'] = $setting['system_desc'];
    if (isset($setting['powerby'])) {
        $GLOBALS['L']['kod_power_by'] = $setting['powerby'];
    }
}