public static function recivenews($list = array()) { global $infra_session_time; if (!$infra_session_time) { $infra_session_time = 1; } $data = array('time' => $infra_session_time, 'list' => Load::json_encode($list)); global $infra_session_lasttime; $infra_session_lasttime = true; //Метка что вызов из php $oldPOST = $_POST; $oldREQ = $_REQUEST; $_POST = $data; $_REQUEST = $data; $src = '-session/sync.php'; Load::unload($src); $ans = Load::loadJSON($src); if (isset($ans['time'])) { $infra_session_time = $ans['time']; } else { $infra_session_time = null; } $_POST = $oldPOST; $_REQUEST = $oldREQ; return $ans; }
public function load($src) { $item = Load::loadJSON($src); if (!$item) { $item = array(); } if (!empty($item['external'])) { if (!is_array($item['external'])) { $item['external'] = explode(', ', $item['external']); } foreach ($item['external'] as $esrc) { if (!Path::theme($esrc)) { echo '<pre>'; throw new \Exception('Not found seojson external ' . $esrc); } $ext = self::load($esrc); foreach ($ext as $k => $v) { if (!isset($item[$k])) { $item[$k] = $v; continue; } } if (!empty($ext['properties'])) { foreach ($ext['properties'] as $k => $v) { if (isset($item['properties'][$k])) { continue; } $item['properties'][$k] = $v; } } if (!empty($ext['names'])) { foreach ($ext['names'] as $k => $v) { if (isset($item['names'][$k])) { continue; } $item['names'][$k] = $v; } } if (!empty($ext['itemprops'])) { foreach ($ext['itemprops'] as $k => $v) { if (isset($item['itemprops'][$k])) { continue; } $item['itemprops'][$k] = $v; } } } } return $item; }
public static function &getData(&$layer) { //Используется в propcheck.js if (!isset($layer['json'])) { return $layer['data']; } $data = @$layer['json']; if (Each::isAssoc($data) === false) { //Если массив то это просто строка в виде данных $data = Load::loadTEXT($data[0]); } elseif (is_string($data)) { $data =& Load::loadJSON($data); //Забираем для текущего клиента что-то.. } return $data; }
public static function checkExt(&$layer, &$external) { if (!$external) { return; } unset($layer['external']); Each::fora($external, function &(&$exter) use(&$layer) { if (is_string($exter)) { $external =& Load::loadJSON($exter); } else { $external = $exter; } if ($external) { foreach ($external as $i => &$v) { external::merge($layer, $external, $i); } } $r = null; return $r; }); }
<?php namespace infrajs\controller; use infrajs\ans\Ans; use infrajs\path\Path; use infrajs\view\View; use infrajs\load\Load; use infrajs\router\Router; if (!is_file('vendor/autoload.php')) { chdir('../../../../'); require_once 'vendor/autoload.php'; Router::init(); } $query = Crumb::$href; $ans = array('title' => 'Проверки контроллера'); $composer = Load::loadJSON('-infrajs/composer.json'); $require = $composer['require']; foreach ($require as $path => $ver) { $p = explode('/', $path); $r = Path::reqif('-' . $p[1] . '/infra.php'); } $layer = array('data' => 1, 'tpl' => array('qewr{data}')); Crumb::change(''); $html = Controller::check($layer); if ($html != 'qewr1') { return Ans::err($ans, 'Результат неожиданный ' . $html); } Crumb::change($query); View::html('', true); return Ans::ret($ans);
$ans['msg'] .= 'Cохранено'; return Ans::ret($ans); } } elseif ($type == 'takeshow') { $takepath = autoedit_takepath(); $list = array(); array_map(function ($file) use(&$list, $takepath) { if ($file == '.' || $file == '..') { return; } $list[] = Path::toutf($file); }, scandir($takepath)); $files = array(); if ($list) { foreach ($list as $file) { $d = Load::loadJSON($takepath . $file); $d['path'] = Path::resolve($d['path']); $d['modified'] = filemtime(Path::theme($d['path'])); preg_match("/\\.([a-zA-Z]+)\$/", $d['path'], $match); $d['ext'] = strtolower($match[1]); $files[] = $d; } } $ans['files'] = $files; } elseif ($type == 'takefile') { if ($submit) { $take = (bool) $_GET['take']; $ans['take'] = $take; $file = autoedit_theme($id); $file = Path::toutf($file); if (!$file) {
} } $br = infra_imager_browser(); $name = preg_replace("/(.*\\/)*/", '', $isrc); if (!$name) { $name = Path::encode($isrc); } $name = Imager::toutf($name); if (!preg_match('/ff/', $br)) { $name = rawurlencode($name); } if (preg_match('/ie6/', $br)) { $name = preg_replace("/\\s/", '%20', $name); } if (!$type) { $type = 'image/jpeg'; } $ans = array('name' => $name, 'type' => $type); //return $data; //}, $args, isset($_GET['re'])); //) file_put_contents($cachesrc . '.data', $data); file_put_contents($cachesrc, Load::json_encode($ans)); $ans['data'] = $data; } else { $ans = Load::loadJSON($cachesrc); $ans['data'] = Load::loadTEXT($cachesrc . '.data'); } header('Content-Disposition: filename="' . $ans['name'] . '";'); header('content-type: image/' . $ans['type']); echo $ans['data'];
namespace infrajs\controller; use infrajs\config\Config; use infrajs\path\Path; use infrajs\view\View; use infrajs\load\Load; use infrajs\ans\Ans; if (!is_file('vendor/autoload.php')) { chdir('../../../../'); require_once 'vendor/autoload.php'; } $ans = array(); $ans['title'] = 'check4'; $query = Crumb::$query; Config::get('controller'); View::html('<div id="main1"></div><div id="main2"></div>', true); $layers = Load::loadJSON('-test-akiyatkin/resources/check4.json'); Crumb::change('test'); Controller::check($layers); $html = View::html(); preg_match_all('/x/', $html, $matches); $count = sizeof($matches[0]); $countneed = 2; Crumb::change($query); Layer::$start_id = 1; Layer::$ids = array(); View::html('', true); if ($count != $countneed) { return Ans::err($ans); } return Ans::ret($ans);
function autoedit_ismytake($file) { $takepath = autoedit_takepath($file); $take = Load::loadJSON($takepath); if (!$take) { return true; } if ($take['ip'] != $_SERVER['REMOTE_ADDR'] || $take['browser'] != $_SERVER['HTTP_USER_AGENT']) { return false; } return true; }
use infrajs\load\Load; use infrajs\access\Access; use infrajs\ans\Ans; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; } $ans = array(); $ans['title'] = 'Общая проверка'; Access::test(true); $res = Load::loadJSON('-autoedit/autoedit.php?type=editfile&id=~.infra.json'); if (Access::admin()) { if (!$res['result'] || !$res['isfile']) { return Ans::err($ans, 'Неудалось получить информацию о файле .infra.json'); } } else { if (!$res || $res['result']) { return Ans::err($ans, 'Неудалось обратиться за файлом .infra.json'); } } $res = Load::loadJSON('-autoedit/autoedit.php?type=editfolder&id=~'); if (Access::admin()) { if (!$res['result'] || !sizeof($res['list'])) { return Ans::err($ans, 'Неудалось прочитать папку'); } } else { if (!$res || $res['result']) { return Ans::err($ans, 'Неудалось обратиться к папке'); } } return Ans::ret($ans, 'Вроде ок, прочитали папку, посмотрели файл');
} $p = explode(',', $lim); if (sizeof($p) != 2) { return Ans::err($ans, 'Is wrong paramter lim'); } $start = (int) $p[0]; $count = (int) $p[1]; $args = array($start, $count); $list = Catalog::cache('producers.php', function ($start, $count) { $ans = array(); $data = Catalog::init(); $prods = array(); Xlsx::runPoss($data, function &(&$pos) use(&$prods) { if (empty($prods[$pos['producer']])) { $prods[$pos['producer']] = 0; } $prods[$pos['producer']]++; $r = null; return $r; }); arsort($prods, SORT_NUMERIC); $prods = array_slice($prods, $start, $count); return $prods; }, $args, isset($_GET['re'])); $ans['menu'] = Load::loadJSON('-catalog/menu.json'); $ans['list'] = $list; $conf = Catalog::$conf; $ans['breadcrumbs'][] = array('main' => true, 'href' => '', 'title' => 'Главная', 'add' => 'group'); $ans['breadcrumbs'][] = array('href' => '', 'title' => $conf['title'], 'add' => 'group'); $ans['breadcrumbs'][] = array('active' => true, 'href' => 'producers', 'title' => 'Производители'); return Ans::ret($ans);
<?php use infrajs\load\Load; use infrajs\access\Access; use infrajs\event\Event; use infrajs\config\Config; use infrajs\update\Update; $conf = Config::get('tester'); if ($conf['updatetest']) { Update::exec(); //Это отодвинет update testerа в конец очереди $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>'; } }
$name = Catalog::getProducer($producer); $ans['name'] = $name; $ans['title'] = $name; $conf = Config::get('catalog'); $ans['breadcrumbs'][] = array('title' => $conf['title'], 'add' => 'producer:'); $menu = Load::loadJSON('-catalog/menu.json'); $ans['breadcrumbs'][] = array('href' => 'producers', 'title' => $menu['producers']['title']); $ans['breadcrumbs'][] = array('add' => 'producer::producer.' . $name . '=1', 'title' => $name); $ans['breadcrumbs'][sizeof($ans['breadcrumbs']) - 1]['active'] = true; } else { if (!$md['group'] && $md['search']) { $ans['is'] = 'search'; $ans['name'] = $md['search']; $ans['title'] = Path::encode($md['search']); $ans['breadcrumbs'][] = array('title' => $conf['title'], 'add' => 'search:'); $menu = Load::loadJSON('-catalog/menu.json'); $ans['breadcrumbs'][] = array('href' => 'find', 'title' => $menu['find']['title']); $ans['breadcrumbs'][] = array('title' => $ans['name']); $ans['breadcrumbs'][sizeof($ans['breadcrumbs']) - 1]['active'] = true; } else { //is!, descr!, text!, name!, breadcrumbs!, title if ($md['group']) { foreach ($md['group'] as $group => $v) { break; } } else { $group = false; } $group = Catalog::getGroup($group); $ans['is'] = 'group'; $ans['breadcrumbs'][] = array('href' => '', 'title' => $conf['title'], 'add' => 'group:');
<?php namespace infrajs\autoedit; use infrajs\load\Load; use infrajs\access\Access; use infrajs\ans\Ans; if (!is_file('vendor/autoload.php')) { chdir('../../../../'); require_once 'vendor/autoload.php'; } $ans = array('title' => 'Проверка обработчиков каталога - позиция, группа, производители, рубрики и тп.'); $data = Load::loadJSON('-catalog/rubrics.php'); if (!$data) { return Ans::err($ans, 'Ошибка rubrics.php'); } $data = Load::loadJSON('-catalog/producers.php'); if (!$data) { return Ans::err($ans, 'Ошибка producers.php'); } $data = Load::loadJSON('-catalog/stat.php'); if (!$data) { return Ans::err($ans, 'Ошибка stat.php'); } return Ans::ret($ans);
use infrajs\ans\Ans; use infrajs\load\Load; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; Config::init(); } $ans = array('title' => 'Запуск шаблонизатора'); $tpl = '{infra.config(name).main}'; $data = array('name' => 'rubrics'); $html = Template::parse(array($tpl), $data); if (!$html) { return Ans::err($ans, $tpl . ' возрващает пустую строку ' . $html); } $tpl = '{infra.config(:rubrics).main}'; $data = true; $html = Template::parse(array($tpl), $data); if (!$html) { return Ans::err($ans, $tpl . ' возрващает пустую строку ' . $html); } $conf = Config::get('rubrics'); $tpl = '{list::test}{test:}1{:date}{date:}{~date(:F,~true)}'; $data = Load::loadJSON('-rubrics/?type=' . $conf['main'] . '&list'); if (sizeof($data['list'])) { //Это если есть данные иначе тест этот не проводим $html = Template::parse(array($tpl), $data); if (!$html) { return Ans::err($ans, ' возрващает пустую строку ' . $html); } } return Ans::ret($ans);
<?php namespace infrajs\controller; use infrajs\config\Config; use infrajs\view\View; use infrajs\load\Load; use infrajs\ans\Ans; if (!is_file('vendor/autoload.php')) { chdir('../../../../'); require_once 'vendor/autoload.php'; } $query = Crumb::$query; $ans = array(); $ans['title'] = 'check_ext_childs'; Config::get('controller'); View::html('<div id="main1"></div><div id="main2"></div>', true); $layers = Load::loadJSON('-test-akiyatkin/resources/check_ext_childs.json'); Crumb::change('test'); $html = Controller::check($layers); preg_match_all('/x/', $html, $matches); $count = sizeof($matches[0]); $countneed = 2; if ($count != $countneed) { return Ans::err($ans, 'line:' . __LINE__ . ' ' . $count); } Crumb::change($query); Layer::$start_id = 1; Layer::$ids = array(); View::html('', true); return Ans::ret($ans);
<?php namespace infrajs\catalog; use infrajs\excel\Xlsx; use infrajs\load\Load; use infrajs\ans\Ans; use infrajs\router\Router; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; Router::init(); } $ans = array(); $fd = Catalog::initMark($ans); //На главной странице каталога показываются $data = Load::loadJSON('-catalog/search.php?m=' . $ans['m']); $ans['childs'] = $data['childs']; return Ans::ret($ans);
$conf = Config::get('subscribe'); if (empty($_REQUEST['email'])) { return Ans::err($ans, $conf['msg']); } if (strlen($_REQUEST['email']) > 1000) { return Ans::err($ans, 'Слишком много данных. ' . $conf['msg']); } $email = strip_tags($_REQUEST['email']); $email = trim($email); $email = Path::encode($email); $agent = $_SERVER['HTTP_USER_AGENT']; $ip = $_SERVER['REMOTE_ADDR']; session_start(); if (empty($_SESSION['submit_time'])) { $_SESSION['submit_time'] = 0; } if (time() - $_SESSION['submit_time'] < 60) { return Ans::err($ans, 'Письмо уже отправлено! Новое сообщение можно будет отправить через 1 минуту!'); } $_SESSION['submit_time'] = time(); $data = array('email' => $email, 'agent' => $agent, 'ip' => $ip, 'host' => $_SERVER['HTTP_HOST']); $body = Template::parse('-subscribe/subscribe.mail.tpl', $data); Mail::toAdmin('Запрос ' . $data['host'] . ' ' . $email, 'noreplay@' . $data['host'], $body); $src = Path::resolve('~.subscribe.json'); $subs = Load::loadJSON($src); if (!$subs) { $subs = array(); } $subs[$email] = date('d.m.Y'); file_put_contents($src, Load::json_encode($subs)); return Ans::ret($ans, 'Ваша заявка принята');
<?php use infrajs\load\Load; use infrajs\router\Router; use infrajs\ans\Ans; if (!is_file('vendor/autoload.php')) { chdir('../../../'); require_once 'vendor/autoload.php'; Router::init(); } $ans = array(); $data = Load::loadJSON('-teremok/teremok.php?src=-teremok/images/'); if (!$data || !$data['result']) { return Ans::err($ans, 'Ошибка нет данных'); } return Ans::ret($ans, 'Данные есть, теремок должен работать');
<?php use infrajs\path\Path; use infrajs\load\Load; use infrajs\ans\Ans; use infrajs\config\Config; use infrajs\nostore\Nostore; /** * Формирует созданные в конфиге план рубрик, в виде слоёв * Кэшируется как статика **/ Nostore::pubStat(); $conf = Config::get('rubrics'); $layer = Load::loadJSON('-rubrics/layer.json'); $types = $layer['childs']; $layer['childs'] = array(); $list = $conf['list']; foreach ($list as $rub => $param) { if (!$param) { continue; } if (!$types[$param['type']]) { continue; } $layer['childs'][$rub] = $types[$param['type']]; if ($conf['main'] == $rub) { $layer['childs'][$rub]['config']['main'] = true; } } return Ans::ans($layer);