function displayCodeLines() { $back = ''; // $traces = Thin\Input::globals('dbg_stack', []); $traces = debug_backtrace(); array_pop($traces); if (!empty($traces)) { foreach ($traces as $trace) { $file = isAke($trace, 'file', false); $line = isAke($trace, 'line', false); if (false !== $file && false !== $line && $file != __FILE__) { $start = $line > 5 ? $line - 5 : $line; $code = Thin\File::readLines($file, $start, $line + 5); $lines = explode("\n", $code); $codeLines = []; $i = $start; foreach ($lines as $codeLine) { if ($i == $line) { array_push($codeLines, $i . '. <span style="background-color: gold; color: black;">' . $codeLine . '</span>'); } else { array_push($codeLines, $i . '. ' . $codeLine); } $i++; } if (strlen($back)) { $back .= "\n"; } $back .= "File: {$file} [<em>line: <u>{$line}</u></em>]\n\nCode\n*******************************\n<div style=\"font-weight: normal; font-family: Consolas;\">" . implode("\n", $codeLines) . "</div>\n*******************************\n"; } } } return $back; }
defined('CONFIG_PATH') || define('CONFIG_PATH', realpath(dirname(__FILE__) . '/../app/config')); defined('CACHE_PATH') || define('CACHE_PATH', realpath(dirname(__FILE__) . '/../app/storage/cache')); defined('LOGS_PATH') || define('LOGS_PATH', realpath(dirname(__FILE__) . '/../app/storage/logs')); defined('TMP_PATH') || define('TMP_PATH', realpath(dirname(__FILE__) . '/../app/storage/tmp')); defined('STORAGE_DIR') || define('STORAGE_DIR', realpath(dirname(__FILE__) . '/../app/storage')); defined('TMP_PUBLIC_PATH') || define('TMP_PUBLIC_PATH', realpath(dirname(__FILE__) . '/tmp')); // Define path to libs directory defined('LIBRARIES_PATH') || define('LIBRARIES_PATH', realpath(dirname(__FILE__) . '/../inc')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'); define('DS', DIRECTORY_SEPARATOR); define('PS', PATH_SEPARATOR); define('DEFAULT_LANGUAGE', 'fr'); define('STORAGE_PATH', STORAGE_DIR . DS . SITE_NAME); // Ensure library/ is on include_path set_include_path(implode(PS, array(LIBRARIES_PATH, get_include_path()))); $debug = 'production' != APPLICATION_ENV; require_once 'Thin/Loader.php'; if (!is_dir(STORAGE_PATH)) { $createDir = Thin\File::mkdir(STORAGE_PATH, 0777); if (!$createDir) { throw new Thin\Exception("You must give 777 rights to " . STORAGE_PATH); } $file = STORAGE_PATH . DS . time(); $createFile = Thin\File::create($file); if (!$createFile) { throw new Thin\Exception("You must give 777 rights to " . STORAGE_PATH); } else { Thin\File::delete($file); } }