Exemple #1
0
function prephp_rt_prepareEval($code)
{
    $cachePath = PREPHP_DIR . Prephp_Core::cacheDir . DIRECTORY_SEPARATOR . md5($code) . '.php';
    if ((!is_file($cachePath) || false === ($compiledCode = file_get_contents($cachePath))) && false === file_put_contents($cachePath, $compiledCode = Prephp_Core::getInstance()->getPreprocessor()->process($code))) {
        throw new Prephp_FileException('Cannot write to ' . $cachePath);
    }
    return $compiledCode;
}
Exemple #2
0
 public static function getInstance()
 {
     if (!class_exists('Prephp_Core')) {
         throw new LogicException('You have to define a Prephp_Core class!');
     }
     if (!isset(Prephp_Core::$instance)) {
         Prephp_Core::$instance = new Prephp_Core();
     }
     return Prephp_Core::$instance;
 }
Exemple #3
0
<?php

// directory of this file for accessing prephp files while in another directory
define('PREPHP_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
// stop script execution if no path given or path doesn't exist
if (!isset($_GET['prephp_path']) || !file_exists($_GET['prephp_path'])) {
    die;
}
// load core
require_once PREPHP_DIR . 'classes/CoreAbstract.php';
// configure core
class Prephp_Core extends Prephp_CoreAbstract
{
}
// load runtime functions and classes
require_once PREPHP_DIR . 'runtime.php';
// register autoload simulator for namespaced code
if (version_compare(PHP_VERSION, '5.3', '<')) {
    spl_autoload_register(array('Prephp_RT_Autoload', 'call'));
}
// chdir to executing file (as php does)
chdir(dirname($_GET['prephp_path']));
// compile and run file
require Prephp_Core::getInstance()->process($_GET['prephp_path']);
Exemple #4
0
function prephp_DIR($token)
{
    return "'" . dirname(Prephp_Core::getInstance()->currentFile()) . "'";
}