public static function init()
 {
     $app = new \Slim\Slim();
     $app->setName(Application::InstanceName());
     if (strpos($app->request()->getPath(), Application::BasePath()) === 0) {
         Doc::createInstance($app);
         Posts::createInstance($app);
         $app->run();
         exit;
     }
 }
 function init()
 {
     if (strstr($_SERVER['REQUEST_URI'], 'api/')) {
         define('SHORTINIT', true);
         $app = new \Slim\Slim();
         $app->setName('wp-elastic-api');
         new DocRoutes($app);
         new v1\Routes($app);
         $app->run();
         exit;
     }
 }
Example #3
0
 public function getSlimInstance()
 {
     $capsule = new Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
     $capsule->setEventDispatcher(new Illuminate\Events\Dispatcher());
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
     require __DIR__ . '/../app/schema.php';
     $app = new \Slim\Slim(['debug' => false, 'mode' => 'testing', 'templates.path' => __DIR__ . '/../views']);
     $app->setName('default');
     require __DIR__ . '/../app/app.php';
     return $app;
 }
Example #4
0
/**
 * create slim app
 */
function create_app($name)
{
    $app = new \Slim\Slim(array('templates.path' => ROOT . 'templates/', 'cookies.lifetime' => '2 days', 'cookies.secret_key' => 'livehubsecretkey'));
    $app->configureMode('development', function () use($app) {
        $app->config(array('debug' => true, 'log.enable' => true, 'log.level' => \Slim\Log::DEBUG, 'cookies.lifetime' => '2 days', 'cookies.secret_key' => 'livehubsecretkey'));
    });
    $app->configureMode('production', function () use($app) {
        $app - config(array('log.level' => \Slim\Log::ERROR, 'cookies.lifetime' => '2 days', 'cookies.encrypt' => true, 'cookies.secret_key' => 'livehubsecretkey'));
    });
    $app->container->singleton('log', function () use($name) {
        $log = new \Monolog\Logger($name);
        $log->pushHandler(new \Monolog\Handler\StreamHandler(ROOT . "logs/{$name}.log", \Monolog\Logger::DEBUG));
        return $log;
    });
    $app->view(new \Slim\Views\Twig());
    $app->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath('templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
    $app->view->parserExtensions = array(new \Slim\Views\TwigExtension());
    $app->setName($name);
    return $app;
}
Example #5
0
<?php

require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'database.php';
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'models.php';
use Illuminate\Database\Query\Expression as raw;
$app = new \Slim\Slim(array('debug' => true, 'templates.path' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates', 'view' => new \Slim\Views\Twig()));
$app->setName('Talententest Admin');
// Include Wordpress header for authentication
if ($app->request->getResourceUri() == '/login') {
    define('WP_USE_THEMES', false);
    // Do not show themes
    require $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'wp-blog-header.php';
}
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => dirname(__FILE__) . '/cache');
$view->parserExtensions = array(new \Slim\Views\TwigExtension(), new Twig_Extension_Debug());
$data = array();
$data['base_url'] = '/admin/';
$data['current_url'] = rtrim($data['base_url'], '/') . $app->request->getResourceUri();
$data['mainmenu'] = array(array('title' => 'Dashboard', 'url' => 'dashboard', 'icon' => 'fa-dashboard'), array('title' => 'Gebruikers', 'url' => 'users_overview', 'icon' => 'fa-users'), array('title' => 'Scholen', 'url' => 'schools_overview', 'icon' => 'fa-university'), array('title' => 'Talenten', 'url' => 'talents_overview', 'icon' => 'fa-tasks'), array('title' => 'Vaardigheden', 'url' => 'skills_overview', 'icon' => 'fa-sliders'), array('title' => 'Beroepen', 'url' => 'occupations_overview', 'icon' => 'fa-briefcase'), array('title' => 'Uitloggen', 'url' => 'logout', 'icon' => 'fa-lock'));
$app->notFound(function () use($app, $data) {
    $app->render('404.html', $data);
});
$app->get('/dashboard(/:school_id)', function ($school_id = null) use($app, $data) {
    $data['active_school_id'] = $school_id;
    if ($school_id == null) {
        $users = User::with('talents', 'skills', 'educationLevel')->get();
    } else {
        $users = User::with('talents', 'skills', 'educationLevel')->where('school_id', '=', (int) $school_id)->get();
    }
Example #6
0
    $result_18->free();
    if ($result_65->fetch_assoc()['@error_65']) {
        $response_body_array['errors'][] = 65;
    }
    $result_65->free();
    if ($result_75->fetch_assoc()['@error_75']) {
        $response_body_array['errors'][] = 75;
    }
    $result_75->free();
    // return response
    echo prepare_response_body($response_body_array);
    return;
}
// create API
$app = new \Slim\Slim(array('mode' => 'development'));
$app->setName('See Time API');
$app->configureMode('development', function () use($app) {
    $app->config(array('debug' => true, 'log.enable' => true, 'log.level' => \Slim\Log::DEBUG));
});
$app->configureMode('production', function () use($app) {
    $app->config(array('debug' => false, 'log.enable' => true, 'log.level' => \Slim\Log::DEBUG));
});
$app->group('/users', function () use($app) {
    global $decode_body;
    $app->post('', $decode_body, function () {
        create_user();
    });
    $app->group('/:username', function () use($app) {
        global $check_token_exists;
        global $decode_body;
        $app->put('', $check_token_exists, $decode_body, function ($username) {
Example #7
0
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
require_once '../includes/defaults.inc.php';
require_once '../config.php';
require_once '../includes/definitions.inc.php';
require_once '../includes/common.php';
require_once '../includes/dbFacile.php';
require_once '../includes/rewrites.php';
require_once 'includes/functions.inc.php';
require_once '../includes/rrdtool.inc.php';
require 'lib/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
require_once 'includes/api_functions.inc.php';
$app->setName('api');
$app->group('/api', function () use($app) {
    $app->group('/v0', function () use($app) {
        $app->get('/bgp', 'authToken', 'list_bgp')->name('list_bgp');
        // api/v0/bgp
        $app->get('/oxidized', 'authToken', 'list_oxidized')->name('list_oxidized');
        $app->group('/devices', function () use($app) {
            $app->delete('/:hostname', 'authToken', 'del_device')->name('del_device');
            // api/v0/devices/$hostname
            $app->get('/:hostname', 'authToken', 'get_device')->name('get_device');
            // api/v0/devices/$hostname
            $app->patch('/:hostname', 'authToken', 'update_device')->name('update_device_field');
            $app->get('/:hostname/vlans', 'authToken', 'get_vlans')->name('get_vlans');
            // api/v0/devices/$hostname/vlans
            $app->get('/:hostname/graphs', 'authToken', 'get_graphs')->name('get_graphs');
            // api/v0/devices/$hostname/graphs
    \Slim\Extras\Views\Twig::$twigOptions['cache'] = ROOT_PATH . 'cache';
}
// Twig i18n config
\Slim\Extras\Views\Twig::$twigExtensions = array('Twig_Extensions_Extension_I18n');
$locality = $site_cfg['website']['i18n'];
// locality should be determined here
require_once APP_PATH . 'config/locales.php';
// Setup $app
$app = new \Slim\Slim(array('templates.path' => APP_PATH . 'views/' . $site_cfg['website']['theme'] . '/', 'locales.path' => APP_PATH . 'i18n/', 'debug' => true, 'view' => new \Slim\Extras\Views\Twig(), 'log.enabled' => false, 'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter(array('path' => ROOT_PATH . 'logs', 'name_format' => 'Y-m-d', 'message_format' => '%label% - %date% - %message%'))));
// Cookie
$app->add(new \Slim\Middleware\SessionCookie(array('expires' => '40 minutes', 'path' => '/', 'domain' => 'slim', 'secure' => false, 'httponly' => false, 'encrypt' => false, 'name' => 'slimblog', 'secret' => md5($site_cfg['website']['secret']))));
// Authenticate
$app->add(new \SlimBasicAuth('', 'admin'));
$app->add(new \CsrfGuard());
// Set our app name
$app->setName($site_cfg['website']['name']);
// Template Globals
$twig = $app->view()->getEnvironment();
$twig->addGlobal('SITE_NAME', $site_cfg['website']['name']);
$twig->addGlobal('SITE_VER', $site_cfg['website']['version']);
$twig->addGlobal('SITE_AUTHOR', $site_cfg['website']['author']);
$twig->addGlobal('LICENCE', $site_cfg['website']['licence']);
$twig->addGlobal('LICENCE_URL', $site_cfg['website']['licence_url']);
if (isset($site_cfg['website']['ua_id']) && !empty($site_cfg['website']['ua_id'])) {
    $twig->addGlobal('GOOGLE_UA_ID', $site_cfg['website']['ua_id']);
}
// Load Controllers
if (!is_dir(APP_PATH . 'controllers/')) {
    throw new Exception('Invalid controller path: ' . APP_PATH . 'controllers/');
}
if ($cdh = opendir(APP_PATH . 'controllers')) {
Example #9
0
<?php

// Smarty
define('THEME_NAME', 'two');
// Verzeichnisname der verwendeten Theme
global $smarty;
$smarty = new Smarty();
$smarty->setTemplateDir(__PATH__ . '/themes/' . THEME_NAME . '/');
$smarty->setCompileDir(__PATH__ . '/cache/smarty-compiled/');
$smarty->setConfigDir(__PATH__ . '/cache/smarty-config/');
$smarty->setCacheDir(__PATH__ . '/cache/smary-cache/');
$smarty->assign('theme_dir', __URL__ . '/themes/' . THEME_NAME);
$smarty->assign('url', __URL__);
// Bei Fehlern die untere Zeile aktivieren um die Debug-Konsole zu starten
// $smarty->debugging = true;
// SLIM REST Framework
\Slim\Slim::registerAutoloader();
// Interne API
$api = new \Slim\Slim();
$api->config(array('debug' => true, 'log.level' => \Slim\Log::DEBUG, 'cookies.lifetime' => '60 minutes'));
$api->setName('vfn-nrw:pr-generator:api');
// Diverses
define('OPTION_LOGFILE', true);
Example #10
0
<?php

require 'vendor/autoload.php';
// http://docs.slimframework.com
$app = new \Slim\Slim(array('debug' => true, 'log.level' => \Slim\Log::DEBUG, 'log.level' => \Slim\Log::DEBUG, 'mode' => 'development', 'cookies.encrypt' => true));
$app->setName('BabyREST');
// $app->response->headers->set('Content-Type', 'application/json');
$app->get('/hello/:name', function ($name) {
    echo "Hello, {$name}";
});
$app->get('/sounds', function () {
    $playlistFile = 'playlist.json';
    $cacheLife = '120';
    // cache life, in seconds
    $sounds = array();
    if (!file_exists($playlistFile) or time() - filemtime($playlistFile) >= $cacheLife) {
        $getID3 = new getID3();
        foreach (glob('sounds/*.mp3') as $filename) {
            $title = $filename;
            $playtime = 'Unknown';
            try {
                $id3 = $getID3->analyze($filename);
                getid3_lib::CopyTagsToComments($id3);
                $title = $id3['comments_html']['artist'][0] . ' - ' . $id3['comments_html']['title'][0];
                $playtime = $id3['playtime_string'];
            } catch (Exception $e) {
            }
            array_push($sounds, array('id' => md5($filename), 'file' => $filename, 'title' => $title, 'playtime' => $playtime));
        }
        file_put_contents($playlistFile, json_encode($sounds), LOCK_EX);
    } else {
Example #11
0
        $_SESSION['CREATED'] = time();
    }
}
if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > 1800) {
    // last request was more than 30 minutes ago
    session_unset();
    // unset $_SESSION variable for the run-time
    session_destroy();
    // destroy session data in storage
}
if (isset($_SESSION['isAuthed']) && $_SESSION['isAuthed']) {
    $User->isAuthed = true;
    $_SESSION['LAST_ACTIVITY'] = time();
    // update last activity time stamp
}
$app->setName('reach.k3wl.net');
$app->get('/', function () use($app, $User, $Helper) {
    $app->render('home.php', array('app' => $app, 'User' => $User, 'Helper' => $Helper));
})->name('home');
$app->get('/p/:username', function ($username) use($app, $User) {
    $UserToView = new User();
    if ($UserToView->setName($username) && $UserToView->UserPublic) {
        $app->render('user.php', array('app' => $app, 'User' => $UserToView));
    } else {
        $app->render('userNotFound.php', array('app' => $app, 'User' => $User));
    }
})->name('user');
$app->get('/u/:type', function ($type) use($app, $User, $type, $Helper) {
    if (isset($_SESSION['isAuthed']) && $_SESSION['isAuthed']) {
        $users = $app->render('users.php', array('app' => $app, 'User' => $User, 'Users' => $Helper->listUsers()));
    } else {
Example #12
0
<?php

require ROOT . '/app/dbloader.php';
/*
|--------------------------------------------------------------------------
| Create Slim Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Slim application instance
| which serves as the "glue" for all the components of RedSlim.
|
*/
// Instantiate application
$app = new \Slim\Slim(require_once ROOT . '/app/config/app.php');
$app->setName('RedSlim');
// For native PHP session
session_cache_limiter(false);
session_start();
// For encrypted cookie session
/*
$app->add(new \Slim\Middleware\SessionCookie(array(
            'expires' => '20 minutes',
            'path' => '/',
            'domain' => null,
            'secure' => false,
            'httponly' => false,
            'name' => 'app_session_name',
            'secret' => md5('appsecretkey'),
            'cipher' => MCRYPT_RIJNDAEL_256,
            'cipher_mode' => MCRYPT_MODE_CBC
        )));
Example #13
0
<?php

require 'vendor/autoload.php';
$app = new \Slim\Slim(array('slim' => array('templates.path' => __DIR__ . '/templates', 'log.enabled' => false), 'view' => new \Slim\Views\Twig(), 'some.api.key' => 'hjhk'));
//$view = $app->view();
$app->setName('MyRouterApp');
$app->get('/', function () use($app) {
    $app->render('index/index.html');
});
$app->get('/login', function () use($app) {
    $app->render('login/login.php');
});
$app->get('/institution', function () use($app) {
    $app->render('institution/institution.php');
});
$app->get('/profile/:aadhaarId', function ($aadhaarId) use($app) {
    //Fetch the userdetails from Parse APIs
    $url = 'https://api.parse.com/1/users';
    $appId = '6dlJGFlCY3dDn3cNU9d1HPKrvWzA6GhitE7FEYdt';
    $restKey = 'zJVeYPOAPBq4pDJOeYM7eFbefLeDgs6KU2cJ3zGi';
    $headers = array("Content-Type: application/json", "X-Parse-Application-Id: " . $appId, "X-Parse-REST-API-Key: " . $restKey);
    $data = 'where={"username":"******"}';
    //echo $data;
    $rest = curl_init();
    curl_setopt($rest, CURLOPT_URL, $url . '?' . $data);
    curl_setopt($rest, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($rest, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($rest);
    $jsonResponse = json_decode($response, true);
    //print_r($jsonResponse);
Example #14
0
 *         title="STUN TURN REST API",
 *         description="NIIF Intitute STUN TURN REST API pilot",
 *         @SWG\Contact(name="Mihály MÉSZÁROS", url="https://brain.lab.vvc.niif.hu"),
 *     ),
 *     @SWG\Tag(
 *       name="rest api",
 *       description="STUN/TURN time limited long term credential mechanism"
 *     )
 * )
 */
require_once "../vendor/autoload.php";
require_once "../../Db.php";
require_once "lib/Coturn.php";
require_once "lib/ApiResponse.php";
$app = new \Slim\Slim();
$app->setName('TURN REST API');
$app->container->singleton('token', function () {
    return "xyz";
    /// token
});
$app->get('/', function () use($app) {
    $app->redirect('doc/index.html');
});
$app->get('/swagger.json', function () {
    $swagger = \Swagger\scan('.');
    header('Content-Type: application/json');
    echo $swagger;
});
$app->get('/stun', '\\Coturn:Get');
$app->get('/turn', '\\Coturn:Get');
$app->run();
Example #15
0
<?php

/*
|--------------------------------------------------------------------------
| Crear instancia del SLIM
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Slim application instance
| which serves as the "glue" for all the components of RedSlim.
|
*/
\Slim\Slim::registerAutoloader();
// Instantiate application
$app = new \Slim\Slim(require_once ROOT . 'app/config/app.php');
//Nombre del sitio:
$app->setName('Eventos');
// For native PHP session
session_cache_limiter(false);
session_start();
// For encrypted cookie session
//*/
$app->add(new \Slim\Middleware\SessionCookie(array('expires' => '20 minutes', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'app_session_name', 'secret' => md5('site-template'), 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC)));
//*/
/*
|--------------------------------------------------------------------------
| Autenticacion de usuarios
|--------------------------------------------------------------------------
|
| Funcion $authentitace
| Recibe:  $app, $role
|   $app:  SLIM $app
Example #16
0
<?php

require '../vendor/autoload.php';
include '../config.php';
include '../db.php';
define('APP_PATH', realpath(dirname(__DIR__)));
define('SITE_ROOT', $site_root);
checkAndInitDatabase(APP_PATH . "/database.sqlite");
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig()));
$app->config('debug', true);
$app->config('templates.path', '../templates');
$app->setName('SiteMigrator');
$app->container->singleton('db', function () {
    return new PDO("sqlite:" . APP_PATH . "/database.sqlite");
});
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => false);
$view->parserExtensions = array(new \Slim\Views\TwigExtension());
$app->get('/', function () use($app) {
    $app->render('index.html', array('title' => 'Home', 'site_root' => SITE_ROOT));
});
$app->get('/dns', function () use($app) {
    $sql = $app->db;
    $app->render('dns.html', array('title' => 'DNS', 'site_root' => SITE_ROOT));
});
$app->get('/emails', function () use($app) {
    $app->render('emails.html', array('title' => 'Emails', 'site_root' => SITE_ROOT));
});
$app->get('/databases', function () use($app) {
    $app->render('databases.html', array('title' => 'Databases', 'site_root' => SITE_ROOT));
});
Example #17
0
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
require 'lib/Slim/Slim.php';
require 'lib/Unirest.php';
require 'steamwebapi_config.php';
const STEAM_WEB_API_BASE_URL = 'http://api.steampowered.com';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->setName('Steam Web API');
// Do nothing when we index the Steam Web PHP API
$app->get('/', function () use($app) {
    $app->halt(403);
});
// Do nothing when we don't find an API endpoint
$app->notFound(function () {
});
function get($app, $endpoint)
{
    $parameters = ['key' => STEAM_WEB_API_KEY];
    foreach ($app->request->get() as $key => $value) {
        $parameters[$key] = $value;
    }
    $response = Unirest::get(STEAM_WEB_API_BASE_URL . $endpoint, NULL, $parameters);
    $app->response->setStatus($response->code);
Example #18
0
<?php

/*
|--------------------------------------------------------------------------
| Create Slim Application
|--------------------------------------------------------------------------
*/
// Instantiate application
$app = new \Slim\Slim(require_once ROOT . '/app/config/app.php');
$app->setName('Active Slim API');
\BurningDiode\Slim\Config\Yaml::_()->addParameters(array('app.mode' => SLIM_MODE, 'app.root' => ROOT, 'app.storage' => ROOT . DIRECTORY_SEPARATOR . 'storage'))->addDirectory(ROOT . '/app/config');
// For native PHP session
session_cache_limiter(false);
session_start();
// For encrypted cookie session
/*
$app->add(new \Slim\Middleware\SessionCookie(array(
            'expires' => '20 minutes',
            'path' => '/',
            'domain' => null,
            'secure' => false,
            'httponly' => false,
            'name' => 'app_session_name',
            'secret' => md5('appsecretkey'),
            'cipher' => MCRYPT_RIJNDAEL_256,
            'cipher_mode' => MCRYPT_MODE_CBC
        )));
*/
/*
|--------------------------------------------------------------------------
| Initialize the database
Example #19
0
<?php

require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'database.php';
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'models.php';
use Illuminate\Database\Eloquent\ModelNotFoundException;
$app = new \Slim\Slim(array('debug' => true));
$app->setName('Talententest API');
// modifies header to only a token
class AuthTokenMiddleware extends \Slim\Middleware
{
    public function call()
    {
        // Get reference to application
        $app = $this->app;
        // Strip 'Authorization: Token {{key}}' from header
        $auth_token = $app->request->headers->get('Authorization');
        if ($auth_token) {
            $key = ltrim($auth_token, 'Token ');
            $app->request->headers->set('Authorization', $key);
        }
        // Run inner middleware and application
        $this->next->call();
    }
}
$app->add(new \AuthTokenMiddleware());
$app->get('/test', function () use($app) {
    $app->response()->header('Content-Type', 'application/json');
    $user = User::with('talents', 'educationLevel')->where('nickname', '=', 'test')->first();
    echo $user;
});
Example #20
0
<?php

define("__APP__", __DIR__ . '/../app');
define("__CONFIG__", __DIR__ . '/../config');
require __APP__ . '/bootstrap/autoload.php';
if (!is_file(__CONFIG__ . '/env.php')) {
    echo "Please set the config/env.php file. You can use the config/env.default as a example.";
    die;
}
$env = (require_once __CONFIG__ . '/env.php');
$app = new \Slim\Slim(getConfigApp($env));
$app->setName(getAppEnv('app_name', 'app', $env));
$app->env = $env;
AppSession::setAppSession($app);
require __APP__ . '/bootstrap/singleton.php';
$app->view->parserOptions = ['charset' => 'utf-8', 'cache' => realpath(__APP__ . '/templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true];
$app->view->parserExtensions = [new \Slim\Views\TwigExtension()];
$app->em = (require __CONFIG__ . '/../config/doctrine.php');
require_once __APP__ . "/routes.php";
$app->run();
Example #21
0
include_once 'config_api.php';
global $security_areas, $security_groups, $security_headings, $path_to_root, $db, $db_connections;
$page_security = 'SA_API';
include_once API_ROOT . "/session-custom.inc";
include_once API_ROOT . "/vendor/autoload.php";
\Slim\Slim::registerAutoloader();
include_once API_ROOT . "/util.php";
include_once FA_ROOT . "/includes/date_functions.inc";
include_once FA_ROOT . "/includes/data_checks.inc";
// echo "sales quote => ".ST_SALESQUOTE;
// echo "sales order => ".ST_SALESORDER;
// echo "sales invoice => ".ST_SALESINVOICE;
// echo "cust delivery => ".ST_CUSTDELIVERY;
// echo "cust credit => ".ST_CUSTCREDIT;
$rest = new \Slim\Slim(array('log.enabled' => true, 'mode' => 'debug', 'debug' => true));
$rest->setName('SASYS');
// API Login Hook
api_login();
$req = $rest->request();
define("RESULTS_PER_PAGE", 2);
// API Routes
// ------------------------------- Items -------------------------------
// Get Items
$rest->get('/inventory/', function () use($rest) {
    global $req;
    include_once API_ROOT . "/inventory.inc";
    $page = $req->get("page");
    if ($page == null) {
        inventory_all();
    } else {
        // If page = 1 the value will be 0, if page = 2 the value will be 1, ...
Example #22
0
**/
/**
 * Step 1: Require the Slim Framework
 *
 * If you are not using Composer, you need to require the
 * Slim Framework and register its PSR-0 autoloader.
 *
 * If you are using Composer, you can skip this step.
 */
//auto-load
\Slim\Slim::registerAutoloader();
//instance
$app = new \Slim\Slim(array());
//more settings
const MY_APP_NAME = 'LDAPApi';
$app->setName(MY_APP_NAME);
//cfg here
$app->config('debug', false);
//just in-case
if (0) {
    $app->config('cookies.lifetime', '720 minutes');
    $app->config('cookies.path', '/');
    $app->config('cookies.encrypt', true);
    $app->config('cookies.secret_key', md5(sprintf("%s-%s", MY_APP_NAME, @date('Ymd'))));
    $app->config('http.version', '1.1');
}
//instantiate it here
debug("api(): Start!");
/**--------------------------------------------------------------------------
|
|	@run LDAP_Api
Example #23
0
<?php

/*
|--------------------------------------------------------------------------
| Crear instancia del SLIM
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Slim application instance
| which serves as the "glue" for all the components of RedSlim.
|
*/
\Slim\Slim::registerAutoloader();
// Instantiate application
$app = new \Slim\Slim(require_once ROOT . 'app/config/app.php');
//Nombre del sitio:
$app->setName('Site-Template');
// For native PHP session
session_cache_limiter(false);
session_start();
// For encrypted cookie session
//*/
$app->add(new \Slim\Middleware\SessionCookie(array('expires' => '20 minutes', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'app_session_name', 'secret' => md5('site-template'), 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC)));
//*/
/*
|--------------------------------------------------------------------------
| Autenticacion de usuarios
|--------------------------------------------------------------------------
|
| Funcion $authentitace
| Recibe:  $app, $role
|   $app:  SLIM $app
Example #24
0
<?php

//-- load the env file data
Dotenv::load(__DIR__ . '/../');
//-- Initiate the slim frame work
$app = new \Slim\Slim();
//-- Set up app name
$app->setName('SlimVanilla');
//-- load in the main app configurations
require_once 'config.php';
//-- load in the app rout file(s)
require_once 'routes.php';
return $app;
Example #25
0
<?php

date_default_timezone_set('Asia/Kolkata');
require '../vendor/autoload.php';
require 'controllers.php';
//ForLogging - AccessLogs
$log = new \Slim\LogWriter(fopen('../logs/access.log', 'a'));
$app = new \Slim\Slim(array('mode' => 'development', 'log.writer' => $log, 'log.level' => \Slim\Log::DEBUG, 'log.enabled' => true, 'http.version' => '1.1', 'contentType' => 'application/json'));
$app->setName('HIND');
// TEST GET route
$app->get('/hello', function () use($app) {
    $request = $app->request;
    $response = $app->response;
    $response->write(json_encode("API Application is Up and Running :) by " . $app->getName()));
    $app->log->info('RequestIP: ' . $request->getIp() . ',TimeStamp: ' . date('Y-m-d h:i:s') . ',RequestPath: /api/v1' . $request->getPathInfo() . ',ResponseCode: ' . $response->getStatus() . ',Response: ' . $response->getBody());
    $app->log->info('-----------------------------------------------------------------------------------------------------------------------');
});
//GET ROUTES
$app->get('/categories', 'getCategories');
$app->get('/users/count', 'getUsersCount');
$app->get('/threads/count', 'getThreadsCount');
$app->get('/view/profile/:username', function ($username) {
    getProfile($username);
});
$app->get('/view/:deal_category/:thread_type/:thread_state', function ($deal_category, $thread_type, $thread_state) {
    getThread($deal_category, $thread_type, $thread_state);
});
//POST ROUTES
$app->post('/submit/misc', 'postMiscellaneous');
$app->post('/submit/deal', 'postDeal');
$app->run();
Example #26
0
 private function runAppPreFlight($action, $actionName, $mwOptions = NULL, $headers = array())
 {
     \Slim\Environment::mock(array('REQUEST_METHOD' => 'OPTIONS', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => 80, 'ACCEPT' => 'application/json', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/' . $actionName));
     $app = new \Slim\Slim();
     $app->setName($actionName);
     $mw = function () {
         // Do nothing
     };
     if (isset($mwOptions)) {
         if (is_callable($mwOptions)) {
             $mw = $mwOptions;
         } else {
             $mwOptions['appName'] = $actionName;
             $mw = \CorsSlim\CorsSlim::routeMiddleware($mwOptions);
         }
     }
     $app->options('/:name', $mw, function ($name) use($app, $action) {
     });
     $app->delete('/:name', $mw, function ($name) use($app, $action) {
         if ($app->request->isHead()) {
             $app->status(204);
             return;
         }
         $app->contentType('application/json');
         $app->response->write(json_encode(array("action" => $action, "method" => "DELETE", "name" => $name)));
     });
     foreach ($headers as $key => $value) {
         $app->request->headers()->set($key, $value);
     }
     $app->run();
     return $app;
 }
Example #27
0
<?php

ini_set('display_errors', 1);
define('BASE_DIR', __DIR__ . "/..");
require BASE_DIR . '/vendor/autoload.php';
// Slim application instance
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig(), 'templates.path' => BASE_DIR . '/app/views/'));
$app->setName('gumaz/slim-base-mvc-json');
// Handling 404 error
$app->notFound(function () use($app) {
    $message = ['message' => 'My custom error message!'];
    $app->render('not-found.html', $message);
});
// Automatically load router files
$routers = glob(BASE_DIR . '/routers/*.router.php');
foreach ($routers as $router) {
    require $router;
}
$app->run();
Example #28
0
require_once __DIR__ . '/vendor/autoload.php';
// website configuration file
require_once 'config.php';
// set default timezone
date_default_timezone_set('Asia/Karachi');
// set error reporting
if ($config['mode'] === 'development') {
    ini_set('display_errors', true);
    error_reporting(1);
}
// path to save logs to
$logWriter = new \Slim\LogWriter(fopen($config['log_path'] . 'applog.log', 'a+'));
// instantiate slim framework
$options = array('debug' => $config['debug'], 'templates.path' => 'views/', 'mode' => $config['mode'], 'log.writer' => $logWriter, 'cookies.encrypt' => true, 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.secret_key' => md5('@!secret!@'), 'cookies.lifetime' => '20 minutes');
$app = new \Slim\Slim($options);
$app->setName($config['appname']);
// later in view for example: $app->getName()
$app->hook('slim.before.router', function () use($app, $config) {
    $setting = new \BloggerCMS\Setting();
    $app->view()->setData('app', $app);
    // we can now use $app in views
    $app->view()->setData('root', ltrim(dirname($_SERVER['SCRIPT_NAME']), '\\'));
    $app->view()->setData('layoutsDir', dirname(__FILE__) . '/layouts/');
    $app->view()->setData('dateFormat', $config['dateFormat']);
    $app->view()->setData('blogURL', $setting->getBlogURL());
});
// slim environment
$environment = \Slim\Environment::getInstance();
// logging
$log = $app->getLog();
$log->setEnabled(false);
Example #29
0
 /**
  * Test get named instance
  */
 public function testGetNamedInstance()
 {
     $s = new \Slim\Slim();
     $s->setName('foo');
     $this->assertSame($s, \Slim\Slim::getInstance('foo'));
 }
 */
/**
 * Pedal-to-Play WebAPI main file containing routes declarations
 *
 * @author Kael
 */
define('_BASE_PATH_', '/edu/ifrs/canoas/pedal2play/');
require_once __DIR__ . _BASE_PATH_ . 'resources/Slim/Slim/Slim.php';
require_once __DIR__ . _BASE_PATH_ . 'services/AuthenticationService.php';
require_once __DIR__ . _BASE_PATH_ . 'services/TokenMiddleware.php';
require_once __DIR__ . _BASE_PATH_ . 'services/AvatarService.php';
require_once __DIR__ . _BASE_PATH_ . 'services/ProfileService.php';
require_once __DIR__ . _BASE_PATH_ . 'services/ActivityLogService.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->setName("Pedal-to-Play");
$app->add(new \TokenMiddleware());
$app->response()->header('Content-Type', 'application/json;charset=utf-8');
$app->log->setEnabled(true);
$app->log->setLevel(\Slim\Log::DEBUG);
$app->environment['slim.errors'] = fopen(__DIR__ . '/log.txt', 'w');
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Configurations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400');
    //<! Cache for 1 day
}
/* Access-Control headers are received during OPTIONS requests */
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    // return only the headers and not the content