/** * в автозапуск инициализацию вынести нельзя так как нет причин обращаться к Nostore а автозапуск * привязан к обращение к классу **/ public static function init() { $conf = Nostore::$conf; $action = Ans::GET('-nostore', 'string'); if ($action === 'true') { return Nostore::on(); } if ($conf['public']) { //Значения по умолчанию выставляются Nostore::pub(); //Администраторы вкурсе кэша } else { Nostore::off(); //Администраторы не знают как отключать кэш в браузере или для удобства } }
public static function init() { Once::exec(__FILE__ . 'init', function () { $action = Ans::GET('-update'); Config::init(); $path = Path::$conf; if ($action) { Access::test(true); if (!Update::$is) { Path::fullrmdir($path['cache']); Update::exec(); } } if ($path['fs'] && !Update::$is) { if (!is_dir($path['cache'])) { Access::$conf['test'] = true; Update::exec(); } if (Access::isTest()) { if (is_file($path['data'] . 'update')) { unlink($path['data'] . 'update'); Access::$conf['test'] = true; if (!Update::$is) { Path::fullrmdir($path['cache']); Update::exec(); } } } } if (Update::$is) { if (is_file($path['data'] . 'update')) { unlink($path['data'] . 'update'); } } }); }
23.04.2010 Скрипт получает src без расширения и без цифры сортировки.... а возвращает html 25.04.2010 Добавлено кэширование modified 09.05.2010 Добавлена поддерж php файлов и возможность передачи get параметров запрашиваемому файлу */ //..'xls'=>'?-pages/xls/xls.php?src=' namespace infrajs\doc; use infrajs\path\Path; use infrajs\ans\Ans; use infrajs\access\Access; use infrajs\load\Load; $isrc = Ans::GET('src'); //Path::toutf(urldecode($_SERVER['QUERY_STRING'])); Access::modified(); $fdata = Load::srcInfo($isrc); $src = Access::cache('files_get_php', function ($isrc) { $src = Path::theme($isrc); if ($src) { return $src; } $fdata = Load::srcInfo($isrc); $folder = Path::theme($fdata['folder']); if (!Path::theme($folder)) { return false; } array_map(function ($file) use(&$result, $fdata) { if ($file[0] == '.') {
<?php namespace infrajs\catalog; use infrajs\excel\Xlsx; use infrajs\path\Path; use infrajs\ans\Ans; use infrajs\load\Load; use infrajs\view\View; use infrajs\nostore\Nostore; use infrajs\config\Config; use infrajs\rubrics\Rubrics; $ans = array(); $md = Catalog::initMark($ans); $val = Ans::GET('val'); $val = Path::toutf(strip_tags($val)); if ($val) { $md['search'] = $val; } //Временное значение if (isset($_GET['seo'])) { $link = $_GET['seo']; if ($md['group']) { foreach ($md['group'] as $val => $one) { break; } $link = $link . '?m=:group.' . $val . '=1'; } else { if ($md['producer']) { foreach ($md['producer'] as $val => $one) { break;
<?php use infrajs\access\Access; use infrajs\ans\Ans; use infrajs\nostore\Nostore; $action = Ans::GET('-access'); if ($action == 'false') { if (Access::isTest()) { Access::$conf['test'] = true; } else { Access::$conf['test'] = false; } //Повышать права нельзя, если я не тестер, то нетестером и останусь!!! Access::$conf['debug'] = false; Access::$conf['admin'] = false; Nostore::on(); } else { if ($action == 'true') { Access::test(true); Access::adminSetTime(); Nostore::on(); //Страница с таким параметром не кэшируется в браузере и её можно всегда спокойно вызывать //Устанавливает будто админ только что заходил... это мягко обновит кэши шаблонов и проверит изменения файлов } }
$src = Imager::prepareSrc($isrc, $num); $or = Ans::GET('or'); //Путь на случай если src не найден if (!$src && $or) { $src = Imager::prepareSrc($or, $num); } //Путь не найден смотрим or Imager::modified($src); $mark = Ans::GET('mark', 'bool'); $w = Ans::GET('w', 'int'); $h = Ans::GET('h', 'int'); $top = Ans::GET('top', 'bool'); $crop = Ans::GET('crop', 'bool'); $ignoremark = Ans::GET('ignoremark', 'bool', null); //1 - Навсегда убирает водяной знак с картинки и больше водяной знак добавляться на неё не будет. 0 отменяет этот запрет. $getorig = Ans::GET('getorig', 'bool'); //Показывает оригинальную картинку без изменения размеров, как есть... без водяного знака $conf = Imager::$conf; $default = false; $orig = false; if (isset($_GET['info'])) { Access::admin(true); $info = imager_readInfo($src); if (!$info) { echo 'В файле нет сохранённых данных, файл оригинальный'; } echo '<pre>'; print_r($info); return; } if ($src && (preg_match("/\\/\\./", $src) || mb_substr($src, 0, 1) == '.' && mb_substr($src, 1, 1) != '/')) {
chdir('../../../'); require_once 'vendor/autoload.php'; Router::init(); } Config::init(); Access::test(true); header('Infrajs-Test: Start'); $type = Ans::GET('type'); /** type=auto - Запуск всех тестов. Выполняется из других скриптов Load::loadJSON('-tester/?type=auto'); * Если все result true выдать один положительный ответ result: true * Если найдена ошибка то добавляется переадресация на страницу с ошибками type=errors без exit * type=errors - показывает только ошибки и инструкцию для справления * Если ошибок нет переадресовывает на -tester/ **/ $ans = array(); $plugin = Ans::GET('plugin'); $conf = Config::get(); $list = array(); foreach ($conf as $name => $c) { if ($plugin && $plugin != $name) { continue; } if (empty($conf[$name]['tester'])) { continue; } $list[$name] = []; Each::exec($conf[$name]['tester'], function &($tsrc) use(&$list, $name, $c) { $r = null; $tsrc = Path::theme('-' . $name . '/' . $tsrc); if (!$tsrc) { echo '<pre>';
Router::init(); } $ans = array(); $osrc = Ans::GET('src'); if (!$osrc) { return Ans::err($ans, 'Для работы необходимо передать параметр ?src= до папки с иллюстрациями: ' . $osrc); } $src = Path::theme($osrc); if (!$src) { return Ans::err($ans, 'Неправильный путь до папки с иллюстрациями: ' . $osrc); } $list = Access::cache(__FILE__, function ($src) { $list = array(); array_map(function ($file) use(&$list, $src) { if ($file[0] == '.') { return; } $fdata = Load::nameInfo($file); if (!in_array($fdata['ext'], array('jpg', 'jpeg', 'png'))) { return; } $list[] = $src . Path::toutf($file); }, scandir($src)); return $list; }, array($src)); $conf = Config::get('teremok'); $count = $conf['count']; $count = Ans::GET('count', 'int', $count); $list = array_slice($list, 0, $count); $ans['list'] = $list; return Ans::ret($ans);
<?php use infrajs\access\Access; use infrajs\ans\Ans; use infrajs\config\Config; use infrajs\router\Router; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; Router::init(); } Access::debug(true); $plugin = Ans::GET('plugin', 'string', null); $conf = Config::get($plugin); echo '<h1>Конфиг ' . $plugin . '</h1><pre>'; print_r($conf);
<?php use infrajs\nostore\Nostore; use infrajs\ans\Ans; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; } Nostore::pubStat(); $ports = Nostore::$conf['port']; $port = Ans::GET('port'); if (!$port) { return Ans::html('Требутеся параметр ?port=... возможные значения регистриуются в конфиге. <pre>' . print_r($ports, true) . '</pre>'); } if (empty($ports[$port])) { return Ans::html('Указанный port=' . $port . ' не зарегистрирован в конфиге. <pre>' . print_r($ports, true) . '</pre>'); } $text = file_get_contents($ports[$port]); return Ans::js($text);
} $ans = array(); $lim = Ans::GET('lim', 'string', '0,100'); $p = explode(',', $lim); if (sizeof($p) != 2) { return Ans::err($ans, 'Некорректный параметр lim'); } list($start, $count) = $p; $dir = Ans::GET('src', 'string'); if (!$dir) { return Ans::err($ans, 'Укажите обязательный параметр src'); } if (!Path::isNest('~', $dir)) { return Ans::err($ans, 'Указан небезопасный путь src'); } $order = Ans::GET('order', ['descending', 'ascending']); $ans['order'] = $order; $list = Access::cache(__FILE__, function ($dir, $order) { $list = array(); array_map(function ($file) use(&$list, $dir) { if ($file[0] == '.') { return; } $file = Path::toutf($file); if (!Path::theme($dir . $file)) { return; } $fd = Load::nameInfo($file); if (!in_array($fd['ext'], array('jpg', 'png'))) { return; }
// Открываем искомый файл $f = fopen($filename, 'r'); while (!feof($f)) { // Читаем килобайтный блок, отдаем его в вывод и сбрасываем в буфер echo fread($f, 1024); flush(); } // Закрываем файл fclose($f); } else { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); header('Status: 404 Not Found'); } } } $file = Ans::GET('src'); //$file = urldecode($_SERVER['QUERY_STRING']); $set = 'fn'; $path = Path::theme($file, $set); if (!$path) { //Нет не скрытого файла $r = Access::admin(); if (!$r) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); header('Status: 404 Not Found'); exit; } else { $set = 'fns'; $path = Path::theme($file, $set); } }
<?php use infrajs\router\Router; use infrajs\ans\Ans; use infrajs\config\Config; use infrajs\access\Access; use infrajs\load\Load; use infrajs\nostore\Nostore; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; Router::init(); } $action = Ans::GET('-tester'); if ($action == 'true') { Nostore::on(); if (Access::test()) { $ans = Load::loadJSON('-tester/?type=auto'); if (!$ans || !$ans['result']) { error_log('TESTER: There are errors in the tests /-tester/?type=errors ' . $ans['msg']); //if (Access::debug()) die('TESTER: There are errors in the tests <a href="/-tester/?type=errors">errors</a> <b>'.$ans['msg'].'</b>'); } else { echo '<div class="well"><a href="/-tester/">Тестирование</a> выполнено, ошибок не обнаружено.</div>'; } } else { $ans = array(); die('<div class="alert alert-danger">Недостаточно прав для тестирования.</div>'); } }
use infrajs\ans\Ans; use infrajs\view\View; use infrajs\router\Router; use infrajs\rubrics\Rubrics; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; Router::init(); } $ans = array(); $src = Ans::GET('src'); if ($src) { if (!Path::isNest('~', $src)) { return Ans::err($ans, 'Передан некорректный или небезопасный путь'); } $id = Ans::GET('id'); $src = Rubrics::find($src, $id); $text = Rubrics::article($src); return Ans::html($text); } $conf = Config::get('rubrics'); $type = Path::toutf($_GET['type']); /* type два смысла.. type blog - имя рубрики и type list то как отображается всё */ if (empty($conf['list'][$type])) { return Ans::err($ans, 'Undefined type ' . $type); } $dir = '~' . $type . '/'; $ans['type'] = $conf['list'][$type]; if (in_array($conf['list'][$type]['type'], array('list', 'info'))) {
if (isset($_GET['js'])) { $isjs = 'js'; } else { if (isset($_GET['css'])) { $isjs = ''; } else { die('Необходимо добавить параметр css или js'); } } if (!Load::isphp()) { header('Infrajs-Cache: true'); } $re = isset($_GET['re']); //Modified re нужно обновлять с ctrl+F5 $debug = Access::debug(); $name = Ans::GET('name', 'string', ''); if ($debug || $re) { if (!Load::isphp()) { header('Infrajs-Cache: false'); } if ($isjs) { $code = Collect::js($name); } else { $code = Collect::css($name); } $key = 'Infrajs::Collect::' . $isjs . true; //Кэш с zip Mem::delete($key); $key = 'Infrajs::Collect::' . $isjs . false; //Кэш без zip Mem::delete($key);