コード例 #1
0
 public static function getTwig()
 {
     if (!isset(self::$twig)) {
         //session_start();
         Twig_Autoloader::register();
         $loader = new Twig_Loader_Filesystem('./templates');
         self::$twig = new Twig_Environment($loader);
         if (isset($_SESSION['role'])) {
             self::$twig->addGlobal('role', $_SESSION['role']);
         }
         if (isset($_SESSION['title'])) {
             self::$twig->addGlobal('siteTitle', $_SESSION['title']);
         }
         if (isset($_SESSION['description'])) {
             self::$twig->addGlobal('siteDescription', $_SESSION['description']);
         }
     }
     return self::$twig;
 }
コード例 #2
0
ファイル: config.php プロジェクト: hbattat/my-scripts
define('DBPASS', 'root');
define('BASEURL', 'http://*****:*****@9>WuYHwy3a(2$q{i:3GOwq:buQ@O050R!|fV~}a<g_s}#*W');
date_default_timezone_set('America/Los_Angeles');
/**
 * SlimPHP for all the magic
 * 
 */
require_once COREPATH . 'Slim/Slim.php';
/**
 * TwigView - for templating magic
 */
require_once COREPATH . 'Views/TwigView.php';
// Configure
TwigView::$twigDirectory = COREPATH . '/Twig/lib/Twig/';
/**
 * Idiorm & Paris are light ORM/ActiveRecord that makes 
 * life with the Database lite and easy!
 */
require_once COREPATH . 'libs/idiorm.php';
require_once COREPATH . 'libs/paris.php';
// Configure
ORM::configure('mysql:host=' . DBHOST . ';dbname=' . DBNAME);
ORM::configure('username', DBUSER);
ORM::configure('password', DBPASS);
ORM::configure('logging', true);
// ORM::configure('setting_name', 'value_for_setting');
// ORM::configure('id', 'primary_key');
// ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
/**
コード例 #3
0
ファイル: bootstrap.php プロジェクト: elaOnMars/datawrapper
}
function debug_log($txt)
{
    $h = fopen(ROOT_PATH . 'log.txt', 'a+');
    fwrite($h, microtime(true) . ': ' . $txt . "\n");
    fclose($h);
}
require ROOT_PATH . 'lib/l10n.php';
require ROOT_PATH . 'lib/utils/parse_config.php';
parse_config();
if (!defined('NO_SLIM')) {
    // Initialize Slim app..
    if (ROOT_PATH == '../') {
        // ..either with TwigView for Datawrapper UI,...
        require_once ROOT_PATH . 'vendor/Slim-Extras/Views/TwigView.php';
        TwigView::$twigDirectory = ROOT_PATH . 'vendor/Twig';
        $app = new Slim(array('view' => new TwigView(), 'templates.path' => '../templates', 'session.handler' => null));
    } else {
        // ..or with JSONView for API.
        require ROOT_PATH . 'lib/api/views/JSONView.php';
        $app = new Slim(array('view' => 'JSONView'));
    }
}
require ROOT_PATH . 'lib/visualization/DatawrapperVisualization.php';
require ROOT_PATH . 'lib/theme/DatawrapperTheme.php';
require ROOT_PATH . 'lib/plugin/DatawrapperPlugin.php';
require ROOT_PATH . 'lib/hooks/DatawrapperHooks.php';
require ROOT_PATH . 'lib/mail.php';
require ROOT_PATH . 'lib/utils/memcache.php';
require ROOT_PATH . 'lib/utils/vksprintf.php';
require ROOT_PATH . 'lib/utils/copy_recursively.php';
コード例 #4
0
define('USERNAME', 'admin');
define('PASSWORD', 'password');
require 'vendor/.composer/autoload.php';
// Slim
require 'vendor/codeguy/slim/Slim/Slim.php';
require 'vendor/codeguy/slim-extras/Views/TwigView.php';
// Paris and Idiorm
require 'vendor/j4mie/idiorm/idiorm.php';
require 'vendor/j4mie/paris/paris.php';
// Monolog
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// Models
require 'models/Article.php';
// Configuration
TwigView::$twigDirectory = __DIR__ . '/vendor/twig/twig/lib/Twig/';
ORM::configure('odbc:DRIVER={SQL Server};SERVER=sp7877nt106;DATABASE=7141_5;');
ORM::configure('username', 'user_7141');
ORM::configure('password', 'user_7141');
// Start Slim.
$app = new Slim(array('view' => new TwigView()));
// Auth Check.
$authCheck = function () use($app) {
    $authRequest = isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
    $authUser = $authRequest && $_SERVER['PHP_AUTH_USER'] === USERNAME;
    $authPass = $authRequest && $_SERVER['PHP_AUTH_PW'] === PASSWORD;
    if (!$authUser || !$authPass) {
        $app->response()->header('WWW-Authenticate: Basic realm="My Blog Administration"', '');
        $app->response()->header('HTTP/1.1 401 Unauthorized', '');
        $app->response()->body('<h1>Please enter valid administration credentials</h1>');
        $app->response()->send();
コード例 #5
0
ファイル: index.php プロジェクト: rasher/redditstream
<?php

define('__ROOT__', dirname(__FILE__));
require_once 'models/db.php';
require_once 'shared/Slim/Slim.php';
require_once 'shared/Slim/Views/TwigView.php';
TwigView::$twigDirectory = __DIR__ . '/shared/Slim/Views/Twig';
$app = new Slim(array('view' => new TwigView()));
$app->config(array('debug' => true, 'templates.path' => 'views'));
require_once 'controllers/home.php';
$app->run();
コード例 #6
0
ファイル: TwigView.php プロジェクト: nansenat16/4money
 public function __construct($twigDirectory, $cacheDir, $charset = 'utf-8')
 {
     self::$twigDirectory = $twigDirectory;
     self::$twigOptions = array('cache' => $cacheDir, 'charset' => $charset);
 }
コード例 #7
0
ファイル: index.php プロジェクト: prakashnsm/siteanalyzer
<?php

// (C) 2014 prakashsts <*****@*****.**>
set_include_path('../' . PATH_SEPARATOR . get_include_path());
require 'vendor/Slim/Slim.php';
require 'vendor/TwigView.php';
require 'lib/http.php';
require 'lib/site.php';
define('DATA_DIR', '../data/');
define('LOG_DIR', '../logs/');
define('CACHE_DIR', '../cache/');
define('DEBUG', getenv('APPLICATION_ENV'));
TwigView::$twigDirectory = 'vendor/Twig';
$twigview = new TwigView();
$app = new Slim(array('templates.path' => '../views', 'debug' => true, 'view' => $twigview));
// Add some functions that will be usable inside Twig
twig_add_function(array($twigview, 'is_float', 'var_dump'));
$app->get('/', function () use($app) {
    $data['url'] = 'http://' . get_random_url();
    $data['check_url'] = "http://{$_SERVER['SERVER_NAME']}/check?url=";
    $data['show_try'] = true;
    $app->render('index.twig', $data);
});
$app->get('/sms', function () use($app) {
    $data['url'] = 'http://' . get_random_url();
    $data['check_url'] = "http://{$_SERVER['SERVER_NAME']}/check?url=";
    $data['show_try'] = true;
    $app->render('sms.twig', $data);
});
$app->get('/check', function () use($app) {
    $url = trim($app->request()->params('url'));
コード例 #8
0
ファイル: index.php プロジェクト: Nerbeer/Slim_blog
<?php

// Slim PHP
require 'Slim/Slim.php';
require 'Views/TwigView.php';
// Paris and Idiorm
require 'Paris/idiorm.php';
require 'Paris/paris.php';
// Models
require 'models/Article.php';
require 'models/User.php';
// Configuration
TwigView::$twigDirectory = __DIR__ . '/Twig/lib/Twig/';
ORM::configure('mysql:host=localhost;dbname=blog');
ORM::configure('username', 'root');
ORM::configure('password', '');
// Start Slim.
$app = new Slim(array('view' => new TwigView()));
// Blog Homepage.
$app->get('/', function () use($app) {
    $articles = Model::factory('Article')->order_by_desc('timestamp')->find_many();
    $isLoginned = User::isLoginned();
    if ($isLoginned) {
        return $app->redirect('/newtest/user/' . $_COOKIE['login']);
    } else {
        return $app->redirect('/newtest/feed');
    }
});
// Blog Feed.
$app->get('/feed', function () use($app) {
    $articles = Model::factory('Article')->order_by_desc('timestamp')->find_many();
コード例 #9
0
ファイル: index.php プロジェクト: elvis2/simple-mvc
<?php

require_once realpath(__DIR__ . '/../vendor/autoload.php');
$app = new Application();
// By default but more clear
$app->setControllerPath(__DIR__ . '/../controllers');
$app->bootstrap("view", function () {
    $view = new TwigView();
    $view->addViewPath(realpath(__DIR__ . '/../layouts'));
    $view->addViewPath(realpath(__DIR__ . '/../views'));
    $view->setViewExt(".twig");
    $view->initTwig(__DIR__ . '/../views/cache');
    return $view;
});
$app->run();