Ejemplo n.º 1
0
function wp_tracy_init_action()
{
    if (defined("DOING_AJAX") && DOING_AJAX) {
        return;
        // for IE compatibility WordPress media upload
    }
    if (defined("WP_TRACY_CHECK_USER_LOGGED_IN") && WP_TRACY_CHECK_USER_LOGGED_IN && is_user_logged_in()) {
        return;
        // cancel for anonymous users
    }
    Tracy\Debugger::enable(defined("WP_TRACY_ENABLE_MODE") ? WP_TRACY_ENABLE_MODE : null);
    // hooray, enabling debugging using Tracy
    // panels in the correct order
    $defaultPanels = array("WpTracy\\WpPanel", "WpTracy\\WpUserPanel", "WpTracy\\WpPostPanel", "WpTracy\\WpQueryPanel", "WpTracy\\WpQueriedObjectPanel", "WpTracy\\WpDbPanel", "WpTracy\\WpRewritePanel");
    $panels = apply_filters("wp_tracy_panels_filter", $defaultPanels);
    // panels registration
    foreach ($panels as $className) {
        Tracy\Debugger::getBar()->addPanel(new $className());
    }
}
Ejemplo n.º 2
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Using Extension Methods | dibi</h1>

<?php 
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install dependencies using `composer install --dev`');
}
Tracy\Debugger::enable();
dibi::connect(array('driver' => 'sqlite3', 'database' => 'data/sample.s3db'));
// using the "prototype" to add custom method to class DibiResult
DibiResult::extensionMethod('fetchShuffle', function (DibiResult $obj) {
    $all = $obj->fetchAll();
    shuffle($all);
    return $all;
});
// fetch complete result set shuffled
$res = dibi::query('SELECT * FROM [customers]');
$all = $res->fetchShuffle();
Tracy\Dumper::dump($all);
Ejemplo n.º 3
0
<?php

if (!($loader = (include __DIR__ . '/../../vendor/autoload.php'))) {
    echo 'Install Nette Tester using `composer update --dev`';
    exit(1);
}
$loader->add('LibretteTests', __DIR__ . '/../');
Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, __DIR__ . '/../tmp/');
Tester\Environment::setup();
date_default_timezone_set('Europe/Prague');
define('TEMP_DIR', __DIR__ . '/../tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
Tester\Helpers::purge(TEMP_DIR);
$_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv')));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = array();
function run(Tester\TestCase $testCase)
{
    $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL);
}
Ejemplo n.º 4
0
} elseif (is_dir($view_folder)) {
    if (($_temp = realpath($view_folder)) !== FALSE) {
        $view_folder = $_temp;
    } else {
        $view_folder = strtr(rtrim($view_folder, '/\\'), '/\\', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
    }
} elseif (is_dir(APPPATH . $view_folder . DIRECTORY_SEPARATOR)) {
    $view_folder = APPPATH . strtr(trim($view_folder, '/\\'), '/\\', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
} else {
    header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
    echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: ' . SELF;
    exit(3);
    // EXIT_CONFIG
}
define('VIEWPATH', $view_folder . DIRECTORY_SEPARATOR);
/*
 * --------------------------------------------------------------------
 * LOAD THE VENDOR AUTOLOAD FILE
 * --------------------------------------------------------------------
 */
require_once FCPATH . 'vendor/autoload.php';
Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT);
Tracy\Debugger::$showBar = False;
/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 */
require_once BASEPATH . 'core/CodeIgniter.php';
Ejemplo n.º 5
0
<?php

header('Content-Type:text/html;charset=utf-8');
require_once __DIR__ . '/vendor/autoload.php';
Tracy\Debugger::enable(Tracy\Debugger::DETECT, __DIR__ . '/log');
function utf8Url($url)
{
    if (strpos($url, '%') !== FALSE) {
        return $url;
    }
    list($protocol, $rest) = explode('://', $url);
    $parts = explode('/', $rest);
    $parts = array_map('rawurlencode', $parts);
    return $protocol . '://' . implode('/', $parts);
}
function fromZomato($url, $force = FALSE)
{
    $url = utf8Url($url);
    $cachePath = __DIR__ . '/cache/temp-' . date('Y-m-d') . '-' . md5($url) . '.html';
    if (!$force && file_exists($cachePath)) {
        return file_get_contents($cachePath);
    }
    $document = new DOMDocument();
    @$document->loadHTMLFile($url);
    $xpath = new DOMXPath($document);
    $nodes = $xpath->query('//div[contains(concat(" ", normalize-space(@class), " "), " tmi-group ")]');
    $node = $nodes->item(0);
    $content = "";
    if ($nodes->length && $node->ownerDocument) {
        $content = $node->ownerDocument->saveHTML($node);
    }
Ejemplo n.º 6
0
<?php

require_once __DIR__ . '/../src/Router/AbstractRouter.php';
require_once __DIR__ . '/../src/Router/Router.php';
@(include __DIR__ . '/../../lib/vendor/autoload.php');
@(include __DIR__ . '/../../../autoload.php');
Tracy\Debugger::enable(FALSE);
$r = new Lemmon\Router\Router();
/*
$r->match(['GET', 'PUT'], '', function() {
    dump('== empty ==');
});
$r->match('{controller}(/(?<trail>{action:read|write|update}(/{id:num:1,3=1}))!)', ['controller' => '\w+'], function($r) {
    dump('controller/action/id');
}, 'Default');
$r->match(['POST'], function() {
    dump('== POST ==');
});
$r->match('*', function() {
    dump('== * ==');
});
$r->match(function() {
    dump('== default ==');
});
*/
#$r->match('{action:signin|signup}', 'Auth#');
#$r->match('logout', 'Auth#signout');
#$r->match('{controller:page}(/{page:num:1,5=1})', 'Posts#');
$r->match('({controller=index}(/{action=index}(/{id:num=1})))', 'crud');
$r->match('({link=index})', function () {
}, 'link');
Ejemplo n.º 7
0
<?php

// define constants
define('BASE_DIR', realpath(__DIR__ . '/..'));
define('WWW_DIR', __DIR__);
define('APP_DIR', BASE_DIR . '/app');
define('LIBS_DIR', BASE_DIR . '/vendor');
define('BIN_DIR', BASE_DIR . '/bin');
define('LOG_DIR', BASE_DIR . '/log');
define('TEMP_DIR', BASE_DIR . '/temp');
define('TESTS_DIR', BASE_DIR . '/tests');
define('MIGRATIONS_DIR', BASE_DIR . '/migrations');
define('CONFIG_DIR', BASE_DIR . '/config');
define('WP_DIR', WWW_DIR . '/wp-core');
// require Composer autoloader
if (file_exists(LIBS_DIR . '/autoload.php')) {
    require LIBS_DIR . '/autoload.php';
} else {
    header('Content-Type: text/plain;charset=utf-8');
    die("Please install Composer dependencies.\n\nhttp://getcomposer.org");
}
// start debugging
Tracy\Debugger::enable(Tracy\Debugger::DETECT, LOG_DIR);
Tracy\Debugger::$maxDepth = 6;
define('SCRIPT_DEBUG', TRUE);
$App = (require APP_DIR . '/bootstrap.php');
if (!$App) {
    header('Content-Type: text/plain;charset=utf-8');
    die("App was not created in bootstrap.");
}
Ejemplo n.º 8
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
// setup environment
$debug = TRUE;
$temp = __DIR__ . '/../temp';
$cache = $temp . '/cache';
Tracy\Debugger::enable(!$debug);
// register robotloader
$loader = (new \Nette\Loaders\RobotLoader())->setCacheStorage(new Nette\Caching\Storages\FileStorage($cache))->addDirectory(__DIR__);
$loader->autoRebuild = $debug;
$loader->register();
// compile container
$class = (new \Nette\DI\ContainerLoader($cache, $debug))->load('SystemContainer', function (\Nette\DI\Compiler $compiler) use($debug) {
    $compiler->getContainerBuilder()->parameters['debugMode'] = $debug;
    $compiler->getContainerBuilder()->addExcludedClasses(['stdClass']);
    $compiler->addExtension('extensions', new \Nette\DI\Extensions\ExtensionsExtension());
    $compiler->loadConfig(__DIR__ . '/config.neon');
});
// create container
$container = new $class();
$container->initialize();
return $container;