コード例 #1
0
 public function testCanReplaceStubsInConfigurationFile()
 {
     $this->bootstrapper->bindPaths();
     $path = $this->bootstrapper->exportConfiguration();
     $this->bootstrapper->updateConfiguration($path, array('basic_username' => 'foo'));
     $this->assertFileExists(__DIR__ . '/../.trucker');
     $this->assertContains('foo', file_get_contents(__DIR__ . '/../.trucker/auth.php'));
 }
コード例 #2
0
 public function parseWidgetHook($strBuffer, $objWidget)
 {
     if (TL_MODE == 'BE') {
         return $strBuffer;
     }
     return Bootstrapper::generateForm($objWidget, strlen($objWidget->label) == 0);
 }
コード例 #3
0
 * DBSR is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DBSR.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Bootstrapper for the DBSR CLI.
 *
 * @author Daniël van de Giessen
 * @package DBSR
 */
// Initialization
Bootstrapper::initialize();
// If it seems we're running from a webserver
if (PHP_SAPI != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) {
    // Build a argument array
    $_SERVER['argv'] = array(basename($_SERVER['SCRIPT_FILENAME']));
    if (isset($_GET['args']) && strlen(trim($_GET['args'])) > 0) {
        $_SERVER['argv'] = array_merge($_SERVER['argv'], explode(' ', trim($_GET['args'])));
    }
    // Don't output HTML in any of the internal functions
    @ini_set('html_errors', 0);
    /** Output buffer callback function with a simple CLI webinterface */
    function DBSR_CLI_output($output)
    {
        header('Content-Type: text/html; charset=UTF-8');
        return '<!DOCTYPE html>' . "\n" . '<html lang="en">' . "\n" . '<head>' . "\n" . "\t" . '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n" . "\t" . '<title>DBSR CLI</title>' . "\n" . '</head>' . "\n" . '<body>' . "\n" . "\t" . '<form action="' . @$_SERVER['argv'][0] . '" method="get">' . "\n" . "\t\t" . '<p>' . htmlspecialchars(@$_SERVER['argv'][0]) . ' <input type="text" name="args" value="' . htmlspecialchars(@$_GET['args']) . '" size="100" autofocus="autofocus"/></p>' . "\n" . "\t" . '</form>' . "\n" . "\t" . '<pre>' . htmlspecialchars($output) . '</pre>' . "\n" . '</body>' . "\n" . '</html>';
    }
コード例 #4
0
 * @author      Eric VILLARD <*****@*****.**>
 * @copyright	(c) 2013 Eric VILLARD <*****@*****.**>
 * @license     http://opensource.org/licenses/MIT MIT License
 */
namespace evidev\tests\boostrap;

final class Bootstrapper
{
    private $nspaths;
    private function __construct()
    {
    }
    public static function create()
    {
        return new static();
    }
    public function prepareNsPaths($nspaths = array())
    {
        $this->nspaths = $nspaths;
        return $this;
    }
    public function run()
    {
        $loader = (require __DIR__ . '/../vendor/autoload.php');
        foreach ($this->nspaths as $ns => $paths) {
            $loader->add($ns, $paths);
        }
    }
}
Bootstrapper::create()->prepareNsPaths(array('evidev' => array(__DIR__)))->run();
コード例 #5
0
{
    // Check if the current request is an AJAX-request
    if (isset($_GET['ajax'])) {
        // Send the error as JSON
        header('Content-Type: application/json');
        die(json_encode(array('error' => $e->getMessage(), 'errorCode' => $e->getCode(), 'errorFile' => $e->getFile(), 'errorLine' => $e->getLine(), 'errorTrace' => $e->getTrace())));
    } else {
        // Rethrow
        throw $e;
    }
}
set_exception_handler('DBSR_GUI_ExceptionHandler');
// Check if we're reloading the page?
if (!isset($_GET['ajax']) && !isset($_GET['resource'])) {
    Bootstrapper::sessionDestroy();
    Bootstrapper::sessionStart();
}
// Save a DBSR_GUI instance in the session
if (!isset($_SESSION['DBSR_GUI'])) {
    $_SESSION['DBSR_GUI'] = new DBSR_GUI();
}
$dbsr_gui = $_SESSION['DBSR_GUI'];
// Check if this is a AJAX-request
if (isset($_GET['ajax'])) {
    // Build a JSON-response
    header('Content-Type: application/json');
    // Check for JSON extension
    if (!extension_loaded('json')) {
        die('{"error":"The PHP JSON extension is not available!"}');
    }
    // Initialization
コード例 #6
0
 public static function initialize()
 {
     if (self::$is_initialized) {
         return;
     }
     set_error_handler(array(get_class(), 'exception_error_handler'));
     if (!defined('DEBUG')) {
         define('DEBUG', FALSE);
     }
     error_reporting(DEBUG ? E_ALL : 0);
     set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)));
     spl_autoload_register(array(get_class(), 'autoloader'));
     if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) {
         $_POST = self::stripslashes_recursive($_POST);
         $_GET = self::stripslashes_recursive($_GET);
         $_COOKIE = self::stripslashes_recursive($_COOKIE);
         $_REQUEST = self::stripslashes_recursive($_REQUEST);
         @ini_set('magic_quotes_gpc', FALSE);
     }
     if (function_exists('get_magic_quotes_gpc')) {
         @set_magic_quotes_runtime(FALSE);
     }
     @ini_set('memory_limit', '-1');
     @ini_set('pcre.recursion_limit', '100');
     if (extension_loaded('mbstring')) {
         mb_internal_encoding('UTF-8');
     }
     if (extension_loaded('iconv')) {
         iconv_set_encoding('internal_encoding', 'UTF-8');
     }
     date_default_timezone_set('UTC');
     self::$is_initialized = TRUE;
 }
コード例 #7
0
ファイル: CommandClient.php プロジェクト: amphp/aerys
 public static function socketPath(string $config)
 {
     // that base64_encode instead of the standard hex representation of sha1 is necessary to avoid overly long paths for unix domain sockets
     return sys_get_temp_dir() . "/aerys_" . strtr(base64_encode(sha1(Bootstrapper::selectConfigFile($config), true)), "+/", "-_") . ".tmp";
 }
コード例 #8
0
ファイル: Bootstrapper.php プロジェクト: dvdgiessen/dbsr
 /**
  * Initializes basic PHP stuff like error handling, include paths, magic quote reversal, internal character encoding, timezones.
  */
 public static function initialize()
 {
     // Check initialization status
     if (self::$is_initialized) {
         return;
     }
     // Set up error handling
     set_error_handler(array(get_class(), 'exception_error_handler'));
     // Define DEBUG constant
     if (!defined('DEBUG')) {
         define('DEBUG', FALSE);
     }
     // Set error reporting level
     error_reporting(DEBUG ? E_ALL : 0);
     // Set up include path
     set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)));
     // Set up autoloader
     spl_autoload_register(array(get_class(), 'autoloader'));
     // Get rid of magic quotes
     if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) {
         $_POST = self::stripslashes_recursive($_POST);
         $_GET = self::stripslashes_recursive($_GET);
         $_COOKIE = self::stripslashes_recursive($_COOKIE);
         $_REQUEST = self::stripslashes_recursive($_REQUEST);
         @ini_set('magic_quotes_gpc', FALSE);
     }
     if (function_exists('get_magic_quotes_gpc') && function_exists('set_magic_quotes_runtime')) {
         @set_magic_quotes_runtime(FALSE);
     }
     // Try to remove any memory limitations
     @ini_set('memory_limit', '-1');
     // Try to set the PCRE recursion limit to a sane value
     // See http://stackoverflow.com/a/7627962
     @ini_set('pcre.recursion_limit', '100');
     // Set internal character encoding
     @ini_set('default_charset', 'UTF-8');
     if (extension_loaded('mbstring')) {
         @mb_internal_encoding('UTF-8');
     }
     if (version_compare(PHP_VERSION, '5.6', '<') && extension_loaded('iconv')) {
         @iconv_set_encoding('internal_encoding', 'UTF-8');
     }
     // Set the timezone
     date_default_timezone_set('UTC');
     // Set initialization status
     self::$is_initialized = TRUE;
 }
コード例 #9
0
ファイル: CommandClient.php プロジェクト: beentrill/aerys
 public static function socketPath(string $config)
 {
     return sys_get_temp_dir() . "/aerys_" . str_replace(["/", ":"], "_", Bootstrapper::selectConfigFile($config)) . ".tmp";
 }
コード例 #10
0
ファイル: WatcherProcess.php プロジェクト: beentrill/aerys
 private function bindCommandServer(string $config)
 {
     $path = CommandClient::socketPath(Bootstrapper::selectConfigFile($config));
     if ((yield \Amp\file\exists($path))) {
         if (is_resource(@stream_socket_client((yield \Amp\file\get($path))))) {
             throw new \RuntimeException("Aerys is already running, can't start it again");
         }
     }
     if (!($commandServer = @stream_socket_server("tcp://127.0.0.1:*", $errno, $errstr))) {
         throw new \RuntimeException(sprintf("Failed binding socket server on tcp://127.0.0.1:*: [%d] %s", $errno, $errstr));
     }
     stream_set_blocking($commandServer, false);
     \Amp\onReadable($commandServer, function (...$args) {
         $this->acceptCommand(...$args);
     });
     register_shutdown_function(function () use($path) {
         @\unlink($path);
     });
     (yield \Amp\file\put($path, stream_socket_get_name($commandServer, $wantPeer = false)));
 }
コード例 #11
0
ファイル: CommandClient.php プロジェクト: staabm/aerys
 public static function socketPath(string $config)
 {
     return sys_get_temp_dir() . "/aerys_" . sha1(Bootstrapper::selectConfigFile($config)) . ".tmp";
 }
コード例 #12
0
    private function __construct()
    {
    }
    public static function create()
    {
        return new static();
    }
    public function prepareNsPaths($nspaths = array())
    {
        $this->nspaths = $nspaths;
        return $this;
    }
    public function loadFiles($files = array())
    {
        foreach ($files as $file) {
            if (file_exists($file)) {
                require_once $file;
            }
        }
        return $this;
    }
    public function run()
    {
        $loader = (require __DIR__ . '/../vendor/autoload.php');
        foreach ($this->nspaths as $ns => $paths) {
            $loader->add($ns, $paths);
        }
    }
}
Bootstrapper::create()->prepareNsPaths(array('evidev' => array(__DIR__)))->loadFiles(array(__DIR__ . '/../vendor/antecedent/patchwork/Patchwork.php'))->run();
コード例 #13
0
<?php

require '../vendor/autoload.php';
require '../bootstrapper.php';
Bootstrapper::run();
$app = new \Slim\Slim(array('cookies.encrypt' => true, 'cookies.lifetime' => '20 minutes', 'cookies.path' => '/', 'cookies.domain' => 'flysmuthe.com', 'cookies.secure' => true, 'cookies.httponly' => true, 'cookies.secret_key' => \config\SecureConfig::$cookieEncryptionKey, 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, 'http.version' => '1.1', 'mode' => 'development'));
class DatabaseConnector extends \Slim\Middleware
{
    public function call()
    {
        $container = new Illuminate\Container\Container();
        $connFactory = new \Illuminate\Database\Connectors\ConnectionFactory($container);
        $conn = $connFactory->make(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'flysmuthe', 'username' => \config\SecureConfig::$dbUsername, 'password' => \config\SecureConfig::$dbPassword, 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''));
        $resolver = new \Illuminate\Database\ConnectionResolver();
        $resolver->addConnection('default', $conn);
        $resolver->setDefaultConnection('default');
        \Illuminate\Database\Eloquent\Model::setConnectionResolver($resolver);
        //Call next middleware
        $this->next->call();
    }
}
use Slim\Middleware\HttpBasicAuthentication\AuthenticatorInterface;
$app->add(new \Slim\Middleware\HttpBasicAuthentication(["path" => "/api", "realm" => "Protected", "authenticator" => function ($arguments) use($app) {
    $results = \app\models\UserAuthorization::apiId($arguments['user'])->get();
    if ($results == null || count($results) == 0) {
        return false;
    }
    $userAuthorization = $results[0];
    if (!password_verify($arguments['password'], $userAuthorization->api_key)) {
        return false;
    }
コード例 #14
0
<?php

/**
 * Plugin Name: WPMVC
 * Plugin URI: http://anthonyontheweb.com
 * Description: A MVC framework for rapid development of wordpress plugins.
 * Version: 1.0.0
 * Author: Anthony Massie
 * Author URI: http://anthonyontheweb.com
 * License: GPL2
 */
/*****************************
	DO NOT EDIT BELOW HERE
*****************************/
namespace Phi\MVCWP;

defined('ABSPATH') or die("Nein.");
define('MVCWP_LIBRARY', realpath(__DIR__ . '/../MVCWP-Lib/'));
require realpath(MVCWP_LIBRARY . '/vendor/Phi/MVCWP/Autoloader/BaseAutoloader.php');
require realpath(MVCWP_LIBRARY . '/vendor/Phi/MVCWP/Autoloader/StandardAutoloader.php');
$autoloader = new Autoloader\StandardAutoloader();
$autoloader->addLibraryPath(MVCWP_LIBRARY);
$autoloader->register();
$BS = new Bootstrapper();
$BS->init(__DIR__);
コード例 #15
0
ファイル: Plugin.php プロジェクト: nk2580/wordsmith
 public static function init($dir)
 {
     Bootstrapper::init($dir);
     return Bootstrapper::boot();
 }