public function checkLogin($redirect = true)
 {
     if (strtolower(C("DB_TYPE")) == 'mysql') {
         echo 'ShowDoc does not support mysql any more . http://www.showdoc.cc/help?page_id=31990 ';
         clear_runtime();
         exit;
     }
     if (!session("login_user")) {
         $cookie_token = cookie('cookie_token');
         if ($cookie_token) {
             $ret = D("UserToken")->getToken($cookie_token);
             if ($ret && $ret['token_expire'] > time()) {
                 $login_user = D("User")->where("uid = {$ret['uid']}")->find();
                 unset($ret['password']);
                 session("login_user", $login_user);
                 return $login_user;
             }
         }
         if ($redirect) {
             $this->message("你尚未登录!", U('Home/User/login'));
             exit;
         }
     } else {
         return session("login_user");
     }
 }
Exemple #2
0
function user_sqlite()
{
    clear_runtime();
    //清除缓存
    write_home_config();
    $config = <<<EOD
<?php
return array(
    //'配置项'=>'配置值'
    //使用sqlite数据库
    'DB_TYPE'   => 'Sqlite', 
    'DB_NAME'   => 'Sqlite/showdoc.db.php', 
    //showdoc不再支持mysql http://www.showdoc.cc/help?page_id=31990
    'DB_HOST'   => 'localhost',
    'DB_USER'   => 'showdoc', 
    'DB_PWD'    => 'showdoc123456',
    'DB_PORT'   => 3306, // 端口
    'DB_PREFIX' => '', // 数据库表前缀
    'DB_CHARSET'=> 'utf8', // 字符集
    'DB_DEBUG'  =>  TRUE, // 数据库调试模式 开启后可以记录SQL日志
    'URL_HTML_SUFFIX' => '',//url伪静态后缀
    'URL_MODEL' => 3 ,//URL兼容模式
    'URL_ROUTER_ON'   => true, 
    'URL_ROUTE_RULES'=>array(
        ':id\\d'               => 'Home/Item/show?item_id=:1',
\t\t':domain\\s\$'               => 'Home/Item/show?item_domain=:1',//item的个性域名
        'uid/:id\\d'               => 'Home/Item/showByUid?uid=:1',
        'page/:id\\d'               => 'Home/Page/single?page_id=:1',
    ),
    'URL_CASE_INSENSITIVE'=>true,
    'SHOW_ERROR_MSG'        =>  true,    // 显示错误信息,这样在部署模式下也能显示错误
    'STATS_CODE' =>'',  //可选,统计代码
    'TMPL_CACHE_ON' => false,//禁止模板编译缓存
    'HTML_CACHE_ON' => false,//禁止静态缓存
    //上传文件到七牛的配置
    'UPLOAD_SITEIMG_QINIU' => array(
                    'maxSize' => 5 * 1024 * 1024,//文件大小
                    'rootPath' => './',
                    'saveName' => array ('uniqid', ''),
                    'driver' => 'Qiniu',
                    'driverConfig' => array (
                            'secrectKey' => '', 
                            'accessKey' => '',
                            'domain' => '',
                            'bucket' => '', 
                        )
                    ),
);
EOD;
    $ret = file_put_contents("../Application/Common/Conf/config.php", $config);
    if ($ret) {
        file_put_contents("./install.lock", "http://www.showdoc.cc/");
        ajax_out(L("install_success"));
    } else {
        ajax_out(L("install_config_not_writable"), 10001);
    }
}
Exemple #3
0
function clear_runtime($path = "../Application/Runtime")
{
    //给定的目录不是一个文件夹
    if (!is_dir($path)) {
        return null;
    }
    $fh = opendir($path);
    while (($row = readdir($fh)) !== false) {
        //过滤掉虚拟目录
        if ($row == '.' || $row == '..' || $row == 'index.html') {
            continue;
        }
        if (!is_dir($path . '/' . $row)) {
            unlink($path . '/' . $row);
        }
        clear_runtime($path . '/' . $row);
    }
    //关闭目录句柄,否则出Permission denied
    closedir($fh);
    return true;
}