Example #1
0
<?php

/**
 * LiveHub Install Application.
 */
use Jasny\MySQL\DB;
require '../common.php';
$app = create_app("LiveHub-Install");
$app->add(new \Slim\Middleware\SessionCookie(array('domain' => null, 'expires' => '2 days', 'name' => 'livehub_session')));
//参考Wordpress或者ThinkSNS
/**
 *-------------------------------------------
 * LiveHub Install Application
 *-------------------------------------------
 */
$app->get('/', function () use($app) {
    $app->log->info("LiveHub Installing...");
    $check = $mysql = true;
    if (PHP_VERSION < "5.3") {
        $check = false;
    }
    if (!extension_loaded('mysql')) {
        $mysql = false;
        $check = false;
    }
    $app->render("install/index.html", array('check' => $check, 'php_version' => PHP_VERSION, 'mysql' => $mysql));
});
function check_file($file)
{
    return file_exists($file);
}
Example #2
0
<?php

/**
 * LiveHub Webim Application.
 */
require_once '../common.php';
require_once ROOT . 'models/model.php';
require_once ROOT . 'lib/Gravatar.php';
$app = create_app("LiveHub-Webim");
$app->hook('slim.before', function () use($app) {
    $app->view()->appendData(array('SITE_URL' => SITE_URL));
});
/**
 * Load or create visitor
 */
class LoadVisitorMiddleWare extends \Slim\Middleware
{
    public function call()
    {
        $app = $this->app;
        $env = $app->environment();
        //login
        if ($app->request()->getPath() === $app->urlFor('webim_login')) {
            $this->next->call();
            return;
        }
        //user, not visitor
        if (isset($_SESSION['uid'])) {
            $this->next->call();
            return;
        }
Example #3
0
<?php

/**
 * LiveHub Console Application.
 */
require_once '../common.php';
require_once ROOT . 'models/model.php';
require_once ROOT . 'src/Slim/Base.php';
require_once ROOT . 'src/Slim/Column.php';
require_once ROOT . 'src/Slim/Table.php';
require_once ROOT . 'src/Slim/Pager.php';
use Jasny\MySQL\DB;
new DB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
\Slim\Admin\Table::conn(DB::conn());
$app = create_app("LiveHub-Console");
class LoginRequiredMiddleware extends \Slim\Middleware
{
    public function call()
    {
        $app = $this->app;
        if (isset($_SESSION['uid'])) {
            $env = $app->environment();
            $env['user'] = ORM::forTable('users')->findOne($_SESSION['uid']);
            $this->next->call();
        } else {
            $app->redirect(SITE_URL . '/login');
        }
    }
}
$app->add(new \LoginRequiredMiddleware());
$app->add(new \Slim\Middleware\SessionCookie(array('domain' => null, 'expires' => '2 days', 'name' => 'livehub_session')));
Example #4
0
<?php

/**
 * LiveHub Application.
 */
require '../common.php';
$app = create_app("LiveHub");
$app->add(new \Slim\Middleware\SessionCookie(array('name' => 'livehub_session')));
$app->hook('slim.before', function () use($app) {
    $app->view()->appendData(array('SITE_URL' => SITE_URL));
});
/**
 *-------------------------------------------
 * Home Page
 *-------------------------------------------
 */
$app->get('/', function () use($app) {
    $app->render("index.html", array());
})->name('/');
$app->get('/tour', function () use($app) {
    $app->render("tour.html");
})->name('tour');
$app->get('/changelog', function () use($app) {
    $log = file_get_contents(dirname(__FILE__) . '/../CHANGELOG');
    $app->render('log.html', array('log' => $log));
})->name('changelog');
/**
 *-------------------------------------------
 * Login, Logout
 *-------------------------------------------
 */