Пример #1
0
// Paris and Idiorm
require 'api/Paris/idiorm.php';
require 'api/Paris/paris.php';
require 'api/models/User.php';
require 'api/config.php';
/* Congigurations are set fot ORM 
configuration are get from the @Config class.
*/
$con = new Config();
$config = $con->getConfig();
ORM::configure('mysql:host=' . $config["host"] . ';dbname=' . $config["db"]);
ORM::configure('username', $config['username']);
ORM::configure('password', $config['pass']);
/*New App object is created and configure its templates*/
$app = new Slim();
$app->config(array('templates.path' => '.'));
/*App post and get methods.
In get method inde.html is render.
In post method data is saved to database and response is preapred. 
*/
$app->post('/addresult', 'addResult');
$app->get('/', function () use($app) {
    $app->render('index.html');
});
$app->run();
/*This method is called when client post the data to server
Then request object is got and json body is parsed.
*/
function addResult()
{
    $request = Slim::getInstance()->request();
Пример #2
0
/* == *
 *
 * SLIM INIT
 *
 * ==============================================*/
$app = new Slim(array('mode' => 'dev', 'templates.path' => 'templates', 'view' => $index_view, 'cookies.secret_key' => 'r+hhiXlmC4NvsQpq/jaZPK6h+sornz0LC3cbdJNj', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, 'cookies.secure' => false));
// set name
//$app->setName('reviewApp');
// End SLIM INIT
/* == *
 *
 * CONFIGS
 *
 * ==============================================*/
$app->configureMode('prod', function () use($app) {
    $app->config(array('log.enable' => true, 'log.path' => '../logs', 'debug' => false));
});
$app->configureMode('dev', function () use($app) {
    $app->config(array('log.enable' => false, 'debug' => true));
});
// End CONFIGS
/* == *
 *
 * UTILS
 *
 * ==============================================*/
// recall template
function recall_template()
{
    $template_path = $app->config('templates.path');
    //returns "../templates"
Пример #3
0
 /**
  * Test batch set settings
  */
 public function testBatchSetSettings()
 {
     $s = new Slim();
     $this->assertEquals('./templates', $s->config('templates.path'));
     $this->assertTrue($s->config('debug'));
     $s->config(array('templates.path' => './tmpl', 'debug' => false));
     $this->assertEquals('./tmpl', $s->config('templates.path'));
     $this->assertFalse($s->config('debug'));
 }
Пример #4
0
<?php

/**
* Required necessary files
*/
ini_set('display_errors', true);
error_reporting(E_ALL);
require 'Slim/Slim.php';
require 'lib/Textpress.php';
require 'lib/View.php';
/**
* Require config file
* @return Array config values
*/
$config = (require 'config/config.php');
/**
* Create an instance of Slim with custom view
* and set the configurations from config file
*/
$app = new Slim(array('view' => 'View', 'mode' => 'development'));
$app->config($config);
/**
* Create an object of Textpress and pass the object of Slim to it.
*/
$textpress = new Textpress($app);
/**
* Finally run Textpress
*/
$textpress->run();
Пример #5
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->config("mode", "production");
$app->get('/say/hello/:name', function ($name) {
    echo "Hello, {$name}!";
});
$app->run();
Пример #6
0
<?php

require_once dirname(__DIR__) . '/bootstrap.php';
require_once PATH_VENDOR_ROOT . '/Slim/Slim.php';
$app = new Slim();
$app->config('templates.path', dirname(__DIR__) . '/templates');
$app->get('/', function () use($app) {
    $app->render('index.html', array());
});
$app->get('/mecab', function () use($app) {
    $sentence = $app->request()->get('s');
    $cl = new ClassLoader();
    $ret = $cl->load('Mecab');
    $mecab = new Mecab();
    /*
    $mecab_options = array(
        '-u' => PATH_RESOURCE_ROOT . '/word.dic',
    );
    */
    $ret = $mecab->parseToNode($sentence, $mecab_options);
    $app->response()->header('Content-Type', 'application/json; charset=utf-8');
    $app->response()->body(json_encode($ret));
});
$app->run();
Пример #7
0
if (empty($selectedLanguage) || !in_array($selectedLanguage, $allowedLanguages)) {
    $selectedLanguage = "en";
}
if (isset($_POST["language"]) && in_array($_POST["language"], $allowedLanguages)) {
    $selectedLanguage = $_POST["language"];
    $_SESSION["language"] = $selectedLanguage;
} elseif (isset($_SESSION["language"]) && in_array($_SESSION["language"], $allowedLanguages)) {
    $selectedLanguage = $_SESSION["language"];
} else {
    $_SESSION["language"] = $selectedLanguage;
}
$language = (require dirname(__FILE__) . "/assets/lang/{$selectedLanguage}.php");
// Initiate slim
$app = new Slim();
// Assign components
$app->config('install.requirements', new Shopware_Install_Requirements());
$app->config('install.requirementsPath', new Shopware_Install_Requirements_Path());
$app->config('install.language', $selectedLanguage);
// Save post - parameters
$params = $app->request()->params();
foreach ($params as $key => $value) {
    if (strpos($key, "c_") !== false) {
        $_SESSION["parameters"][$key] = $value;
    }
}
// Initiate database object
$databaseParameters = array("user" => isset($_SESSION["parameters"]["c_database_user"]) ? $_SESSION["parameters"]["c_database_user"] : "", "password" => isset($_SESSION["parameters"]["c_database_user"]) ? $_SESSION["parameters"]["c_database_password"] : "", "host" => isset($_SESSION["parameters"]["c_database_user"]) ? $_SESSION["parameters"]["c_database_host"] : "", "port" => isset($_SESSION["parameters"]["c_database_user"]) ? $_SESSION["parameters"]["c_database_port"] : "", "database" => isset($_SESSION["parameters"]["c_database_user"]) ? $_SESSION["parameters"]["c_database_schema"] : "");
$app->config("install.database.parameters", $databaseParameters);
$app->config('install.database', new Shopware_Install_Database($databaseParameters));
function getShopDomain()
{
Пример #8
0
 /**
  * Test Slim defines multiple settings with array
  *
  * Pre-conditions:
  * You have intiailized a Slim application, and you
  * pass an associative array into Slim::config
  *
  * Post-conditions:
  * Multiple settings are set correctly.
  */
 public function testSlimCongfigurationWithArray(){
     Slim::init();
     Slim::config(array(
         'one' => 'A',
         'two' => 'B',
         'three' => 'C'
     ));
     $this->assertEquals(Slim::config('one'), 'A');
     $this->assertEquals(Slim::config('two'), 'B');
     $this->assertEquals(Slim::config('three'), 'C');
 }
Пример #9
0
 /**
  * Test Slim defines multiple settings with array
  *
  * Pre-conditions:
  * Slim app instantiated;
  * Batch-define multiple configuration settings with associative array;
  *
  * Post-conditions:
  * Multiple settings are set correctly;
  */
 public function testSlimCongfigurationWithArray()
 {
     $app = new Slim();
     $app->config(array('one' => 'A', 'two' => 'B', 'three' => 'C'));
     $this->assertEquals('A', $app->config('one'));
     $this->assertEquals('B', $app->config('two'));
     $this->assertEquals('C', $app->config('three'));
 }
Пример #10
0
 /**
  * Render a template
  *
  * Call this method within a GET, POST, PUT, DELETE, NOT FOUND, or ERROR
  * callable to render a template whose output is appended to the
  * current HTTP response body. How the template is rendered is
  * delegated to the current View.
  *
  * @param   string  $template   The name of the template passed into the View::render method
  * @param   array   $data       Associative array of data made available to the View
  * @param   int     $status     The HTTP response status code to use (Optional)
  * @return  void
  */
 public static function render($template, $data = array(), $status = null)
 {
     $templatesPath = Slim::config('templates.path');
     //Legacy support
     if (is_null($templatesPath)) {
         $templatesPath = Slim::config('templates_dir');
     }
     self::view()->setTemplatesDirectory($templatesPath);
     if (!is_null($status)) {
         self::response()->status($status);
     }
     self::view()->appendData($data);
     self::view()->display($template);
 }
Пример #11
0
 /**
  * Set layout file
  */
 public function setLayout($layout)
 {
     $layoutFile = is_bool($layout) ? $this->slim->config('layout.file') . '.php' : $layout . ".php";
     $this->slim->view()->setLayout($layoutFile);
 }
Пример #12
0
<?php

require_once 'slim/Slim.php';
require_once 'slim/SmartyView.php';
require_once 'classes/app.php';
$app = new Slim(array('templates.path' => 'templates', 'view' => 'SmartyView', 'log.path' => 'slim/Logs', 'log.level' => 4, 'cookies.secret_key' => "[SALT]", 'mode' => 'development'));
$app->configureMode('production', function () use($app) {
    $app->config(array('log.enable' => true, 'debug' => false));
});
$app->configureMode('development', function () use($app) {
    $app->config(array('log.enable' => true, 'debug' => true));
});
//# Set your API_Key and Client secret                #//
//#   Available here: https://eventbrite.com/api/key  #//
$app->config('api_key', 'YOUR_API_KEY_HERE');
$app->config('client_secret', 'YOUR_CLIENT_SECRET_HERE');
function authenticate()
{
    $app = Slim::getInstance();
    if (!App::user()) {
        $app->redirect("/connect/");
    }
}
//## ROUTES ##//
$app->get('/', function () use($app) {
    $params = App::start();
    $params['title'] = "Home";
    $params['page'] = "home";
    if (!App::user()) {
        $params['button'] = "Connect";
    } else {
Пример #13
0
<?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();
Пример #14
0
<?php

// Initialize flags, config, models, cache, etc.
require_once 'init.php';
require_once BASE_DIR . '/vendor/Slim/Slim/Slim.php';
require_once BASE_DIR . '/vendor/Slim-Extras/Log Writers/TimestampLogFileWriter.php';
$app = new Slim(array('mode' => defined('PRODUCTION') ? 'production' : 'development', 'debug' => false, 'log.enabled' => true, 'log.writer' => new TimestampLogFileWriter(array('path' => BASE_DIR, 'name_format' => '\\s\\l\\i\\m\\_\\l\\o\\g'))));
$app->configureMode('development', function () use($app) {
    $app->config(array('debug' => true));
});
$app->configureMode('production', function () use($app) {
    error_reporting(0);
    $app->notFound(function () use($app) {
        $page = new ErrorController(404);
        $page->render();
    });
    $app->error(function (Exception $e) use($app) {
        $app->response()->status(500);
        if (!$app->request()->isAjax()) {
            $page = new ErrorController(500);
            $page->render();
        }
        $app->stop();
        if (file_exists(BASE_DIR . '/.gbemail')) {
            foreach (explode('\\n', file_get_contents(BASE_DIR . '/.gbemail')) as $email) {
                mail(trim($email), "GetchaBooks Error", get_error_message($e));
            }
        }
    });
});
$app->hook('slim.before', function () use($app) {
Пример #15
0
 /**
  * Initialize Slim
  *
  * This instantiates the Slim application using the provided
  * application settings if available.
  *
  * Legacy Support:
  *
  * To support applications built with an older version of Slim,
  * this method's argument may also be a string (the name of a View class)
  * or an instance of a View class or subclass.
  *
  * @param   array|string|Slim_View  $viewClass   An array of settings;
  *                                               The name of a View class;
  *                                               A View class or subclass instance;
  * @return  void
  */
 public static function init($userSettings = array())
 {
     //Legacy support
     if (is_string($userSettings) || $userSettings instanceof Slim_View) {
         $settings = array('view' => $userSettings);
     } else {
         $settings = (array) $userSettings;
     }
     //Init app
     self::$app = new Slim($settings);
     //Init Not Found and Error handlers
     self::notFound(array('Slim', 'defaultNotFound'));
     self::error(array('Slim', 'defaultError'));
     //Init view
     self::view(Slim::config('view'));
     //Init logging
     if (Slim::config('log.enable') === true) {
         $logger = Slim::config('log.logger');
         if (empty($logger)) {
             Slim_Log::setLogger(new Slim_Logger(Slim::config('log.path'), Slim::config('log.level')));
         } else {
             Slim_Log::setLogger($logger);
         }
     }
     //Start session if not already started
     if (session_id() === '') {
         $sessionHandler = Slim::config('session.handler');
         if ($sessionHandler instanceof Slim_Session_Handler) {
             $sessionHandler->register();
         }
         session_start();
         if (isset($_COOKIE[session_id()])) {
             Slim::deleteCookie(session_id());
         }
         session_regenerate_id(true);
     }
     //Init flash messaging
     self::$app->flash = new Slim_Session_Flash(self::config('session.flash_key'));
     self::view()->setData('flash', self::$app->flash);
     //Determine mode
     if (isset($_ENV['SLIM_MODE'])) {
         self::$app->mode = (string) $_ENV['SLIM_MODE'];
     } else {
         $configMode = Slim::config('mode');
         self::$app->mode = $configMode ? (string) $configMode : 'development';
     }
 }
Пример #16
0
 /**
  * Set layout file
  */
 function setLayout()
 {
     $this->slim->view()->setLayout($this->slim->config('layout.file') . '.php');
 }
Пример #17
0
$admin_logged_in = function ($app) {
    return function () use($app) {
        if (!User::is_logged_in()) {
            $app->redirect('/');
        }
    };
};
/**
 * Step 2: Instantiate the Slim application
 *
 * Here we instantiate the Slim application with its default settings.
 * However, we could also pass a key-value array of settings.
 * Refer to the online documentation for available settings.
 */
$app = new Slim(array('view' => new TwigView()));
$app->config($blog_options);
// Authenticate Function
/**
 * Step 3: Define the Slim application routes
 *
 * Here we define several Slim application routes that respond
 * to appropriate HTTP request methods. In this example, the second
 * argument for `Slim::get`, `Slim::post`, `Slim::put`, and `Slim::delete`
 * is an anonymous function. If you are using PHP < 5.3, the
 * second argument should be any variable that returns `true` for
 * `is_callable()`. An example GET route for PHP < 5.3 is:
 *
 * $app = new Slim();
 * $app->get('/hello/:name', 'myFunction');
 * function myFunction($name) { echo "Hello, $name"; }
 *
Пример #18
0
            // save each post to our array, and store
            // the post details as a new hash
            $posts[strtotime($post_meta['date'])] = array('title' => $post_meta['title'], 'desc' => $post_meta['desc'], 'date' => $post_meta['date'], 'tags' => $post_meta['tags'], 'link' => $post->getBasename('.md'), 'html' => $post_html);
        }
    }
    // sort our posts (inversely) by created date (the key value)
    krsort($posts);
    // return our posts
    return $posts;
};
// ----------------------------------------------------------
// ------------------------ ROUTES --------------------------
// home page
$blog->get('/', function () use($blog, $getMarkdownPosts) {
    // get our posts
    $posts = $getMarkdownPosts($blog->config('posts.path'));
    // limit our posts to pagination
    $posts_limit = array_slice($posts, 0, $blog->config('pagination'));
    // get the total number of posts
    $posts_count = count($posts);
    // calculate the number of page
    $pages_number = ceil($posts_count / $blog->config('pagination'));
    // render the main page
    $blog->render('index.html', array('posts' => $posts_limit, 'page_current' => 1, 'page_count' => $pages_number));
});
// about page
$blog->get('/about', function () use($blog) {
    // render the about page
    $blog->render('about.html');
});
// projects page
Пример #19
0
require 'service/bank_details.php';
require 'service/banner.php';
require 'service/advertisement.php';
require 'service/point_master.php';
require 'service/blogs.php';
require 'service/cart.php';
require 'service/qrcode.php';
require 'service/icon.php';
require 'service/dashboard.php';
require 'service/cart_cron.php';
require_once 'service/voucher_pdf.php';
require_once 'service/merchantrestaurants.php';
require_once 'service/merchantoutlet.php';
require_once 'service/merchantmenucategory.php';
$app = new Slim();
$app->config('debug', true);
$app->get('/wines', 'getWines');
$app->get('/wines/:id', 'getWine');
$app->get('/wines/search/:query', 'findByName');
$app->post('/wines', 'addWine');
$app->put('/wines/:id', 'updateWine');
$app->delete('/wines/:id', 'deleteWine');
/***************** Users ************/
$app->post('/users', 'addUser');
$app->post('/users/login', 'getlogin');
$app->post('/users/forgotPass', 'getforgetPass');
$app->post('/users/changePassword', 'changePassword');
$app->put('/users/:id', 'updateUser');
$app->put('/users/activeProfile/:id', 'activeProfile');
$app->get('/users', 'getAllUsers');
$app->get('/user/:id', 'getUser');
Пример #20
0
Файл: Slim.php Проект: ntdt/Slim
 /**
  * Initialize Slim
  *
  * This instantiates the Slim application using the provided
  * application settings if available. This also:
  *
  * - Sets a default Not Found handler
  * - Sets a default Error handler
  * - Sets the view class
  *
  * Legacy Support:
  *
  * To support applications built with an older version of Slim,
  * this method's argument may also be a string (the name of a View class)
  * or an instance of a View class or subclass.
  *
  * @param   array|string|Slim_View  $viewClass   An array of settings;
  *                                               The name of a View class;
  *                                               A View class or subclass instance;
  * @return  void
  */
 public static function init( $userSettings = array() ) {
     //Legacy support
     if ( is_string($userSettings) || $userSettings instanceof Slim_View ) {
         $settings = array('view' => $userSettings);
     } else {
         $settings = (array)$userSettings;
     }
     self::$app = new Slim($settings);
     self::notFound(array('Slim', 'defaultNotFound'));
     self::error(array('Slim', 'defaultError'));
     self::view(Slim::config('view'));
     if ( Slim::config('log.enable') === true ) {
         $logger = Slim::config('log.logger');
         if ( empty($logger) ) {
             Slim_Log::setLogger(new Slim_Logger(Slim::config('log.path'), Slim::config('log.level')));
         } else {
             Slim_Log::setLogger($logger);
         }
     }
 }
Пример #21
0
 * Refer to the online documentation for available settings.
 *
$app = new Slim();
*/
/**
 * Step 3: Define the Slim application routes
 *
 * Here we define several Slim application routes that respond
 * to appropriate HTTP request methods. In this example, the second
 * argument for `Slim::get`, `Slim::post`, `Slim::put`, and `Slim::delete`
 * is an anonymous function. If you are using PHP < 5.3, the
 * second argument should be any variable that returns `true` for
 * `is_callable()`. An example GET route for PHP < 5.3 is:
 */
$app = new Slim();
$app->config("debug", true);
$app->get("/", "raiz");
function raiz()
{
    echo "FUNCIONANDO WEB SERVICE!";
}
require "services/handles/handle_bd_connection.php";
require "services/handles/handle_msg_body.php";
require "services/handles/handle_image.php";
require "services/obj/obj_livro.php";
require "services/obj/obj_filme.php";
require "services/obj/obj_jogo.php";
require "services/user/friendship.php";
require "services/user/user.php";
require "services/user/patrimonio.php";
require "services/user/emprestimo.php";