Exemplo n.º 1
0
 public static function exec($conds, $name, $fn, $args = array(), $re = false)
 {
     $name = 'Cache::exec' . $name;
     return Once::exec($name, function ($args, $r, $hash) use($name, $fn, $conds, $re) {
         $data = Mem::get($name . $hash);
         if (!$data) {
             $data = array('time' => 0);
         }
         $execute = Access::adminIsTime($data['time'], function ($cache_time) use($conds) {
             if (!sizeof($conds)) {
                 return false;
                 //Если нет conds кэш навсегда и develop не поможет
             }
             $max_time = 1;
             for ($i = 0, $l = sizeof($conds); $i < $l; $i++) {
                 $mark = $conds[$i];
                 $mark = Path::theme($mark);
                 if (!$mark) {
                     continue;
                 }
                 $m = filemtime($mark);
                 if ($m > $max_time) {
                     $max_time = $m;
                 }
                 if (!is_dir($mark)) {
                     continue;
                 }
                 foreach (glob($mark . '*.*') as $filename) {
                     $m = filemtime($filename);
                     if ($m > $max_time) {
                         $max_time = $m;
                     }
                 }
             }
             return $max_time > $cache_time;
         }, $re);
         if ($execute) {
             $cache = Nostore::check(function () use(&$data, $fn, $args, $re) {
                 $data['result'] = call_user_func_array($fn, array_merge($args, array($re)));
             });
             if ($cache) {
                 $data['time'] = time();
                 Mem::set($name . $hash, $data);
             } else {
                 Mem::delete($name . $hash);
             }
         }
         return $data['result'];
     }, array($args), $re);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public static function runfolder($dir, $f = 1, $d = 0, $sub = false, $exts = false, &$filelist = array(), $pre = '')
 {
     $dir = Path::theme($dir);
     if ($dir && is_dir($dir) && ($dh = opendir($dir))) {
         while (($file = readdir($dh)) !== false) {
             if ($file[0] == '.') {
                 continue;
             }
             if ($file == 'vendor') {
                 continue;
             }
             if ($file[0] == '~') {
                 continue;
             }
             $path = $dir . $file;
             if (is_file($path) && $exts) {
                 preg_match('/\\.(\\w{0,4})$/', $file, $math);
                 //Расширение при поиске не учитываем
                 $ext = strtolower($math[1]);
                 if (!in_array($ext, $exts)) {
                     continue;
                 }
             }
             //$count++;
             //if($count<$lims)continue;
             //if($count>=($lims+$limc))break;
             if (!$f && is_file($path) && (!$d || !is_dir($path))) {
                 continue;
             }
             //Файлы не надо
             //if(!$f && is_file($path))continue;//Файлы не надо
             if (is_dir($path)) {
                 if ($sub) {
                     static::runfolder($path . '/', $f, $d, $sub, $exts, $filelist, $pre . $file . '/');
                 }
                 if (!$d) {
                     continue;
                 }
                 //Папки не надо
             }
             if ($d && preg_match("/\\.files\$/", $file)) {
                 continue;
             }
             array_push($filelist, $pre . $file);
         }
         closedir($dh);
     }
     return $filelist;
 }
Exemplo n.º 4
0
 /**
  * Кэширумеая функция, основной разбор.
  */
 public static function parse($src)
 {
     $args = array($src);
     $param = Cache::exec(array($src), 'docx_parse', function ($src, $re) {
         $conf = Docx::$conf;
         $imgmaxwidth = $conf['imgmaxwidth'];
         $previewlen = $conf['previewlen'];
         $cachename = Path::tofs(Path::encode($src));
         $cacheFolder = Path::mkdir(Docx::$conf['cache'] . $cachename . '/');
         //В винде ингда вылетает о шибка что нет прав удалить какой-то файл в папке и как следствие саму папку
         //Обновление страницы проходит уже нормально
         //Полагаю в линукс такой ошибки не будет хз почему возникает
         Cache::fullrmdir($cacheFolder);
         $path = Path::theme($src);
         if (!$path) {
             return array('html' => false);
         }
         $xmls = docx_getTextFromZippedXML($path, 'word/document.xml', $cacheFolder, $re);
         $rIds = array();
         $param = array('folder' => $cacheFolder, 'imgmaxwidth' => $imgmaxwidth, 'previewlen' => $previewlen, 'rIds' => $rIds);
         if ($xmls[0]) {
             $xmlar = docx_dom_to_array($xmls[0]);
             $xmlar2 = docx_dom_to_array($xmls[1]);
             foreach ($xmlar2['Relationships']['Relationship'] as $v) {
                 $rIds[$v['Id']] = $v['Target'];
             }
             $param['rIds'] = $rIds;
             $html = docx_each($xmlar, '\\infrajs\\doc\\docx_analyse', $param);
         } else {
             $param['rIds'] = array();
             $html = '';
         }
         $param['html'] = $html;
         return $param;
     }, $args, isset($_GET['re']));
     unset($param['rIds']);
     unset($param['type']);
     unset($param['imgmaxwidth']);
     unset($param['previewlen']);
     unset($param['isli']);
     unset($param['isul']);
     unset($param['imgnum']);
     unset($param['folder']);
     return $param;
 }
Exemplo n.º 5
0
function autoedit_theme($isrc)
{
    $src = Access::cache('autoedit_theme', 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] == '.') {
                return;
            }
            $file = Path::toutf($file);
            $fd = Load::nameInfo($file);
            if ($fdata['id'] && $fdata['id'] != $fd['id']) {
                return;
            }
            if ($fdata['name'] && $fdata['name'] != $fd['name']) {
                return;
            }
            if ($fdata['ext'] && $fdata['ext'] != $fd['ext']) {
                return;
            } elseif ($result) {
                //Расширение не указано и уже есть результат
                //Исключение.. расширение tpl самое авторитетное
                if ($fd['ext'] != 'tpl') {
                    return;
                }
            }
            $result = $file;
        }, scandir(Path::theme($folder)));
        if (!$result) {
            return false;
        }
        return Path::theme($folder . $result);
    }, array($isrc), isset($_GET['re']));
    return $src;
}
Exemplo n.º 6
0
Arquivo: Mem.php Projeto: infrajs/mem
 public static function flush()
 {
     $mem =& static::memcache();
     if ($mem) {
         $mem->flush();
     } else {
         $conf = static::$conf;
         if (!$conf['cache']) {
             throw new \Exception('Set up cache folder Mem::$conf[cache]');
         }
         $dir = Path::theme($conf['cache']);
         if ($dir) {
             if (!Path::$conf['fs']) {
                 throw new \Exception('Filesystem protected by Path::$conf[fs]=false set it on true');
             }
             foreach (glob($dir . '*.*') as $filename) {
                 @unlink($filename);
             }
         }
     }
 }
Exemplo n.º 7
0
 public static function getReal($src)
 {
     //php
     $conf = static::$conf;
     $p = explode('?', $src, 2);
     $path = $p[0];
     $query = $p[1];
     if (!$query) {
         return Path::theme($src);
     }
     if (!$path) {
         return static::getReal($query);
     } elseif (preg_match("/imager\\/p\$/", $path)) {
         $p = explode('&', $query);
         $obj = array();
         for ($i = 0, $l = sizeof($p); $i < $l; ++$i) {
             $b = explode('=', $p[$i], 2);
             $obj[$b[0]] = $b[1];
         }
         $src = $obj['src'];
         $ext = Path::getExt($src);
         if ($ext == 'php') {
             return static::getReal($obj['src']);
         } else {
             return Path::theme($src);
         }
     }
 }
Exemplo n.º 8
0
 **/
$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>';
            print_r($c);
            throw new \Exception('Tester. Некорректно указан путь до теста.');
        }
        if (Path::isDir($tsrc)) {
            $files = scandir($tsrc);
            foreach ($files as $file) {
                if ($file[0] == '.') {
                    continue;
                }
                if (!is_file($tsrc . $file)) {
                    continue;
                }
                $list[$name][] = Path::pretty($tsrc . $file);
Exemplo n.º 9
0
if (!is_null($ignoremark)) {
    Access::admin(true);
}
if ($getorig) {
    Access::admin(true);
}
$gray = isset($_GET['gray']);
$args = array($src, $ignoremark, $mark, $default, $getorig, $w, $h, $crop, $top, $gray);
$execute = false;
$cachesrc = Imager::$conf['cache'] . 'resize/' . Hash::make($args);
if (is_file($cachesrc)) {
    $cachetime = filemtime($cachesrc);
} else {
    $cachetime = 0;
}
$time = filemtime(Path::theme($isrc));
if ($re || $time > $cachetime) {
    $execute = true;
}
if (!$execute) {
    $ans = Load::loadJSON($cachesrc);
    $ans['data'] = Load::loadTEXT($cachesrc . '.data');
    if (!$ans['data']) {
        $execute = true;
    }
}
if ($execute) {
    //$data = Cache::exec(array($isrc), __FILE__, function ($src, $ignoremark, $mark, $default, $getorig, $w, $h, $crop, $top, $gray, $re) use ($isrc) {
    $ext = Path::getExt($src);
    if (in_array($ext, array('docx', 'mht'))) {
        die("docx, mht TODO");
Exemplo n.º 10
0
$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;
        }
        $slide = $fd;
        $slide['title'] = $fd['name'];
        $src = Rubrics::find($dir, $fd['name'], 'articles');
        if ($src) {
            $slide['title'] = Rubrics::article($src);
        }
        $list[] = $slide;
    }, scandir(Path::theme($dir)));
    Load::sort($list, $order);
    //$list = array_reverse($list);
    return $list;
}, array($dir, $order));
$list = array_slice($list, $start, $count);
$ans['dir'] = $dir;
$ans['list'] = $list;
return Ans::ret($ans);
Exemplo n.º 11
0
    }
}
$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);
    }
}
if (!$path) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
    header('Status: 404 Not Found');
    exit;
} else {
    $ext = false;
    $dyn = preg_match('/\\?/', $path);
    if (!$dyn) {
        preg_match('/.*\\.(.*)$/', '.' . $path, $match);
        $ext = mb_strtolower($match[1]);
        $file_types_user = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'rtf' => 'text/rtf', 'png' => 'image/png', 'mht' => 'application/msword', 'doc' => 'application/msword', 'docx' => 'application/msword', 'avi' => 'video/x-msvideo', 'xls' => 'application/msexcel', 'tpl' => 'text/html', 'html' => 'text/html', 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'doc' => 'application/msword', 'docx' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet');
        $file_types_admin = array('php' => 'text/html');
    }
Exemplo n.º 12
0
 private static function load($path)
 {
     $args = array($path);
     $res = Once::exec('Load::load', function ($path) {
         //php файлы эмитация веб запроса
         //всё остальное file_get_content
         $_r_e_s_ = array();
         $_r_e_s_['cache'] = !Nostore::check(function () use($path, &$_r_e_s_) {
             if (Path::isDir($path)) {
                 $p = explode('?', $path, 2);
                 $p[0] .= 'index.php';
                 $path = implode('?', $p);
             }
             $load_path = Path::theme($path);
             $fdata = Load::srcinfo($load_path);
             if ($load_path && $fdata['file']) {
                 $plug = Path::theme($fdata['path']);
                 if ($fdata['ext'] == 'php') {
                     $getstr = Path::toutf($fdata['query']);
                     //get параметры в utf8, с вопросом
                     $getstr = preg_replace("/^\\?/", '', $getstr);
                     parse_str($getstr, $get);
                     if (!$get) {
                         $get = array();
                     }
                     $GET = $_GET;
                     $_GET = $get;
                     $REQUEST = $_REQUEST;
                     $_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
                     $SERVER_QUERY_STRING = $_SERVER['QUERY_STRING'];
                     $_SERVER['QUERY_STRING'] = $getstr;
                     $from_php_old = Load::isphp();
                     Load::isphp(true);
                     ob_start();
                     //headers надо ловить
                     $ans = array();
                     $rrr = (include $plug);
                     $result = ob_get_contents();
                     $resecho = $result;
                     ob_end_clean();
                     Load::isphp($from_php_old);
                     if ($rrr !== 1 && !is_null($rrr)) {
                         //Есть возвращённый результат
                         $result = $rrr;
                         if ($resecho) {
                             //Сообщение об ошибке... далее всё ломаем
                             $result = $resecho . Load::json_encode($result);
                             //Есть вывод в браузер и return
                         }
                     }
                     $_SERVER['QUERY_STRING'] = $SERVER_QUERY_STRING;
                     $_REQUEST =& $REQUEST;
                     $_GET =& $GET;
                     $data = $result;
                     //$data='php file';
                 } else {
                     $data = file_get_contents($plug);
                 }
                 $_r_e_s_ = array();
                 //Если в include это имя использовалось. Главное чтобы оно небыло ссылкой &
                 $_r_e_s_['status'] = 200;
                 $_r_e_s_['value'] = $data;
             } else {
                 $_r_e_s_['status'] = 404;
                 $_r_e_s_['value'] = '';
             }
         });
         return $_r_e_s_;
     }, $args);
     if (!$res['cache']) {
         Nostore::on();
     }
     return $res['value'];
 }
Exemplo n.º 13
0
<?php

namespace infrajs\yml;

use infrajs\path\Path;
use infrajs\ans\Ans;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../../');
    require_once 'vendor/autoload.php';
}
$ans = [];
if (!is_dir('data/')) {
    return Ans::err($ans, 'Папки data нет');
}
if (!is_file('data/yml.xlsx')) {
    return Ans::err($ans, 'Файла excel нет');
}
$src = '~yml.xlsx';
if (!Path::theme($src)) {
    return Ans::err($ans, 'Файл не найден.' . $src);
}
return Ans::ret($ans);
Exemplo n.º 14
0
                }
                if (!is_file($dir . $file)) {
                    return;
                }
                $ext = Path::getExt($file);
                if ($ext != 'md') {
                    return;
                }
                $res = array('src' => $dir . $file, 'vendor' => $vendor, 'name' => $name, 'file' => $file);
                $map['vendors'][$vendor][$name]['list'][] = $res;
                $map['names'][$dir] =& $map['vendors'][$vendor][$name];
            }, scandir($dir));
        }, scandir($dir));
    }, scandir($dir));
    return $map;
});
$fd = Load::srcInfo($src);
if (isset($map['names'][$fd['folder']])) {
    $namedata = $map['names'][$fd['folder']];
} else {
    $namedata = array();
}
$text = file_get_contents(Path::theme($src));
$body = Markdown::defaultTransform($text);
//$data['files']=$files;
$data['map'] = $map;
$data['src'] = $src;
$data['namedata'] = $namedata;
$data['body'] = $body;
$html = Template::parse(Path::theme('-mdreader/index.tpl'), $data);
echo $html;
Exemplo n.º 15
0
 private function makeMark($data)
 {
     if (!$data) {
         return '';
     }
     self::rksort($data);
     $key = md5(serialize($data));
     $that = $this;
     $mark = Once::exec($this->prefix . $key, function () use($data, $that, $key) {
         $isoutdate = true;
         $raise = $this->raise;
         //На сколько символов разрешено увеличивать хэш
         $note = $this->note;
         //При увеличении на сколько записывается сообщение в лог
         $len = $this->len - 1;
         while ($isoutdate && $len < $this->len + $raise) {
             $len++;
             $mark = substr($key, 0, $len);
             $src = Path::theme('~.marks/' . $that->prefix . $mark . '.json');
             if ($src) {
                 $otherdata = file_get_contents($src);
                 $otherdata = Load::json_decode($otherdata, true);
             } else {
                 $otherdata = false;
             }
             //$otherdata=infra_mem_get($that->prefix.$mark);
             if ($otherdata && is_array($otherdata['data']) && $otherdata['time']) {
                 if ($otherdata['data'] == $data) {
                     $isoutdate = false;
                     //Такая метка уже есть и она правильная
                 } else {
                     //Решается судьба старой метки
                     $isoutdate = time() > $data['time'] + $this->warrantytime;
                 }
             } else {
                 $isoutdate = false;
             }
         }
         if ($len >= $this->len + $note) {
             $that->notice = 'Mark adding to hash ' . ($len - $this->len) . ' symbol(s) for save time warranty ' . print_r($data, true);
             error_log($that->notice);
         }
         if ($isoutdate) {
             //Все метки актуальны... перезаписываем первую
             $that->error = 'Mark rewrite actual hashmark';
             error_log($that->error);
             $mark = substr($key, 0, $this->len);
         }
         $src = Path::theme('~.marks/');
         if (!$src) {
             die('Fatal error no marks dir');
         }
         $src = $src . $this->prefix . $mark . '.json';
         $data = Load::json_encode(array('time' => time(), 'data' => $data));
         $data = file_put_contents($src, $data);
         //infra_mem_set($that->prefix.$mark, array(
         //	'time'=>time(),
         //	'data'=>$data
         //));
         return $mark;
     });
     return $mark;
 }
Exemplo n.º 16
0
use infrajs\path\Path;
use infrajs\router\Router;
use infrajs\load\Load;
use infrajs\config\Config;
use infrajs\access\Access;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
    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));
Exemplo n.º 17
0
 public static function info($src)
 {
     if (!Path::theme($src)) {
         return array();
     }
     $rr = Load::srcInfo($src);
     $ext = $rr['ext'];
     $size = filesize(Path::theme($src));
     if (in_array($ext, array('mht', 'tpl', 'html', 'txt', 'php'))) {
         $rr = Mht::preview($src);
     } elseif (in_array($ext, array('docx'))) {
         $rr = Docx::preview($src);
     }
     $rr['size'] = round($size / 1000000, 2);
     //Mb
     if (!empty($rr['links'])) {
         $links = $rr['links'];
         unset($rr['links']);
         foreach ($links as $v) {
             $r = preg_match('/http.*youtube\\.com.*watch.*=([\\w\\-]+).*/', $v['href'], $match);
             $r2 = preg_match('/http.{0,1}:\\/\\/youtu\\.be\\/([\\w\\-]+)/', $v['href'], $match);
             if ($r) {
                 if (empty($rr['video'])) {
                     $rr['video'] = array();
                 }
                 $v['id'] = $match[1];
                 $rr['video'][] = $v;
             } elseif ($r2) {
                 if (empty($rr['video'])) {
                     $rr['video'] = array();
                 }
                 $v['id'] = $match[1];
                 $rr['video'][] = $v;
             } else {
                 if (empty($rr['links'])) {
                     $rr['links'] = array();
                 }
                 $rr['links'][] = $v;
             }
         }
     }
     if (!empty($rr['name'])) {
         $dir = Path::theme($rr['folder'] . $rr['name'] . '/');
         if ($dir) {
             $list = array();
             array_map(function ($file) use(&$list, $src) {
                 if ($file[0] == '.') {
                     return;
                 }
                 //if (!is_file($dir.$file)) return;
                 $fd = Load::nameinfo($file);
                 if (!in_array($fd['ext'], ['jpeg', 'jpg', 'png'])) {
                     return;
                 }
                 $list[] = Path::toutf($fd);
             }, scandir($dir));
             Load::sort($list, 'ascending');
             foreach ($list as $k => $fd) {
                 $list[$k] = Path::toutf($fd['file']);
             }
             $rr['gallerydir'] = $rr['folder'] . $rr['name'] . '/';
             $rr['gallery'] = $list;
         }
     }
     return $rr;
 }
Exemplo n.º 18
0
 public static function addFiles($root, &$pos, $dir = false)
 {
     $props = array('producer', 'article');
     if (!isset($pos['images'])) {
         $pos['images'] = array();
     }
     if (!isset($pos['texts'])) {
         $pos['texts'] = array();
     }
     if (!isset($pos['files'])) {
         $pos['files'] = array();
     }
     if (!$dir) {
         $dir = array();
         $pth = Path::resolve($root);
         if (Each::forr($props, function &($name) use(&$dir, &$pos) {
             $rname = Sequence::right($name);
             $val = Sequence::get($pos, $rname);
             if (!$val) {
                 return true;
             }
             $dir[] = $val;
             $r = null;
             return $r;
         })) {
             return;
         }
         if ($dir) {
             $dir = implode('/', $dir) . '/';
             $dir = $pth . $dir;
         } else {
             $dir = $pth;
         }
     } else {
         $dir = $root . $dir;
     }
     $dir = Path::theme($dir);
     if (!$dir) {
         return false;
     }
     if (is_dir($dir)) {
         $paths = glob($dir . '*');
     } elseif (is_file($dir)) {
         $paths = array($dir);
         $p = Load::srcInfo($dir);
         $dir = $p['folder'];
     }
     Each::forr($paths, function &($p) use(&$pos, $dir) {
         $d = explode('/', $p);
         $name = array_pop($d);
         $n = mb_strtolower($name);
         $fd = Load::nameInfo($n);
         $ext = $fd['ext'];
         //if(!$ext)return;
         if (!is_file($dir . $name)) {
             return;
         }
         //$name=preg_replace('/\.\w{0,4}$/','',$name);
         /*$p=pathinfo($p);
         		$name=$p['basename'];
         		$ext=strtolower($p['extension']);*/
         if ($name[0] == '.') {
             return;
         }
         $dir = Path::pretty($dir);
         $name = Path::toutf($dir . $name);
         $im = array('png', 'gif', 'jpg');
         $te = array('html', 'tpl', 'mht', 'docx');
         if (in_array($ext, $im)) {
             $pos['images'][] = $name;
         } else {
             if (in_array($ext, $te)) {
                 $pos['texts'][] = $name;
             } else {
                 if ($ext != 'db') {
                     $pos['files'][] = $name;
                 }
             }
         }
         $r = null;
         return $r;
     });
     $pos['images'] = array_unique($pos['images']);
     $pos['texts'] = array_unique($pos['texts']);
     $pos['files'] = array_unique($pos['files']);
 }
Exemplo n.º 19
0
 /**
  * Рекурсивный скан папки
  * Функция $fn($src, $level) может возвращать управляющие данные
  * null - идём дальше и вглубь и в ширь
  * true - вглубь не идём, в ширь идём - переход к соседней папке
  * false - вглубь не идём, в ширь не идём - выход на уровень выше
  **/
 public static function scan($dir, $fn, $level = 0)
 {
     if ($dir === '') {
         $d = opendir('./');
     } else {
         $dir = Path::theme($dir);
         $d = opendir($dir);
     }
     if ($level) {
         //Для 0 левел не запускаем $fn
         $r = $fn($dir, $level);
         if ($r === true) {
             return;
         }
         if (!is_null($r)) {
             return $r;
         }
     }
     while ($file = readdir($d)) {
         if ($file[0] == '.') {
             continue;
         }
         $src = $dir . $file;
         if (is_file($src)) {
             continue;
         }
         $src .= '/';
         $r = static::scan($src, $fn, $level + 1);
         if ($r === false) {
             $r = null;
             break;
         }
         if (!is_null($r)) {
             break;
         }
     }
     closedir($d);
     return $r;
 }
Exemplo n.º 20
0
     $src = $dir . $file;
     $info = imager_readInfo($src);
     //Долгая операция
     $orig = $info['orig'];
     if ($orig) {
         if (!isset($_SESSION['imager']['origs'][$orig])) {
             $_SESSION['imager']['origs'][$orig] = array();
         }
         $_SESSION['imager']['origs'][$orig][] = $dir . $file;
     }
     unset($_SESSION['imager']['files'][$k]);
     //Чтобы при обнолении страницы, не бегать снова
 }
 //Теперь у нас есть только массив origs
 foreach ($_SESSION['imager']['origs'] as $orig => $srcs) {
     $origf = Path::theme($orig);
     if (!$origf) {
         //if(preg_match("/^core\/data\//",$orig))continue;//старая версия сайта ничего с этим не поделать
         //die('Не найден оригинал '.Path::toutf($orig)." для картинки ".Path::toutf(print_r($srcs,true)).'<br>\n');
         echo 'Не найден оригинал ' . Path::toutf($orig) . ' для картинки ' . Path::toutf(print_r($srcs, true)) . '<br>\\n';
         continue;
     }
     foreach ($srcs as $src) {
         $r = copy($origf, $src);
         if (!$r) {
             die('Не удалось скопировать на место оригинал ' . Path::toutf($src));
         }
     }
     $r = unlink($origf);
     if (!$r) {
         die('Не удалось удалить востановленный оригинал');
Exemplo n.º 21
0
    }
} 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) {
            $ans['noaction'] = true;
            //Собственно всё осталось как было
Exemplo n.º 22
0
 public static function getPos(&$pos)
 {
     $args = array($pos['producer'], $pos['article']);
     return Access::cache('Catalog::getPos', function () use($pos) {
         Xlsx::addFiles(Catalog::$conf['dir'], $pos);
         $files = explode(',', @$pos['Файлы']);
         foreach ($files as $f) {
             if (!$f) {
                 continue;
             }
             $f = trim($f);
             Xlsx::addFiles(Catalog::$conf['dir'], $pos, $f);
         }
         $files = array();
         foreach ($pos['files'] as $f) {
             if (is_string($f)) {
                 $f = Path::theme($f);
                 //убрали звездочку
                 $d = Load::srcInfo(Path::toutf($f));
             } else {
                 $d = $f;
                 $f = $d['src'];
             }
             $d['size'] = round(filesize(Path::tofs($f)) / 1000000, 2);
             if (!$d['size']) {
                 $d['size'] = '0.01';
             }
             $d['src'] = Path::pretty($d['src']);
             $files[] = $d;
         }
         $pos['files'] = $files;
         if ($pos['texts']) {
             foreach ($pos['texts'] as $k => $t) {
                 $pos['texts'][$k] = Load::loadTEXT('-doc/get.php?src=' . $t);
             }
         }
         return $pos;
     }, $args);
 }
Exemplo n.º 23
0
    $mdata['subject'] = 'ПРОВЕРОЧНОЕ ' . $mdata['subject'];
    $mdata['testmail'] = true;
} else {
    $mdata['testmail'] = false;
    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();
}
$ans['testmail'] = $mdata['testmail'];
if ($maildir) {
    $folder = Path::theme($maildir);
    $name = Path::tofs(Path::encode($data['name']));
    $fname = date('Y F j H-i') . ' ' . $name . ' ' . time();
    if ($conf['file'] && $file) {
        $src = $folder . $fname . '.' . Path::tofs($file['name']);
        $r = move_uploaded_file($file['tmp_name'], $src);
        if (!$r) {
            return Ans::err($ans, 'Неудалось загрузить файл');
        }
        $data['file'] = Path::toutf(Path::pretty($src));
    }
}
$body = Template::parse('-contacts/mail.tpl', $data);
if (!$body) {
    $body = 'Ошибка. Не найден шаблон письма!';
}
Exemplo n.º 24
0
 /**
  *  true если путь $dir существует и вложен в $root
  **/
 public static function isNest($root, $dir)
 {
     $src = Path::theme($dir);
     if (!$src) {
         return false;
     }
     $src = realpath($src);
     if (!$src) {
         return false;
     }
     $home = Path::theme($root);
     if (!$home) {
         return false;
     }
     $home = realpath($home);
     if (!$home) {
         return false;
     }
     if (preg_match('/\\' . DIRECTORY_SEPARATOR . '\\./', $home)) {
         return false;
     }
     if (preg_match('/\\' . DIRECTORY_SEPARATOR . '\\./', $src)) {
         return false;
     }
     $p = explode($home, $src, 2);
     if (sizeof($p) != 2 || $p[0] || !$p[1]) {
         return false;
     }
     return true;
 }
Exemplo n.º 25
0
        }
        if ($fdata['ext'] && $fdata['ext'] != $fd['ext']) {
            return;
        } elseif ($result) {
            //Расширение не указано и уже есть результат
            //Исключение.. расширение tpl самое авторитетное
            if ($fd['ext'] != 'tpl') {
                return;
            }
        }
        $result = $file;
    }, scandir(Path::theme($folder)));
    if (!$result) {
        return false;
    }
    return Path::theme($folder . $result);
}, array($fdata['path']), isset($_GET['re']));
$ans = array('src' => $isrc);
if (!$src) {
    if (!Load::isphp()) {
        header('HTTP/1.0 404 Not Found');
    }
    return;
}
$fdata = Load::srcInfo($src);
if (in_array($fdata['ext'], array('docx'))) {
    $txt = Docx::get($src);
    return Ans::txt($txt);
}
if (in_array($fdata['ext'], array('mht'))) {
    $txt = Mht::get($src);
Exemplo n.º 26
0
    chdir('../../../');
    //Согласно фактическому расположению файла
    require_once 'vendor/autoload.php';
}
ini_set("display_errors", 1);
$from = 'noreplay@' . $_SERVER['HTTP_HOST'];
$headers = 'From: ' . $from . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
$headers .= 'Reply-To: aky@list.ru' . "\r\n";
//echo 'Нативная проверка<br>';
//$r=mail('*****@*****.**','Проверка с сервера '.$_SERVER['HTTP_HOST'],'Текст проверочного сообщения',$headers);
//var_dump($r);
//return;//нельзя зачастую лимит стоит сколько писем за раз можно отправлять
//echo '<br>Сложная проверка<br>';
$conf = Access::$conf['admin'];
$ans = array();
if (!$conf['support']) {
    return Ans::err($ans, 'У администратора не указан email support');
}
$body = Path::theme('-mail/update.tpl');
$body = file_get_contents($body);
$body = str_replace(array("{host}", "{date}"), array($_SERVER['HTTP_HOST'], date('j.m.Y')), $body);
$subject = 'Выполнено обновление ' . $_SERVER['HTTP_HOST'];
$email_from = 'noreplay@' . $_SERVER['HTTP_HOST'];
$r = Mail::toSupport($subject, $email_from, $body);
if (!$r) {
    error_log('Не удалось отправить тестовое письмо.');
    if (Access::debug() && !Load::isphp()) {
        echo '<pre>Не удалось отправить <a href="/-mail/update.php">тестовое письмо</a>.</pre>' . "\n";
    }
}
Exemplo n.º 27
0
 public static function load($src, $name = null)
 {
     $src = Path::theme($src);
     if (!$src) {
         return;
     }
     Once::exec('Config::load::' . $src, function () use($src, $name) {
         $d = file_get_contents($src);
         try {
             $d = Load::json_decode($d);
         } catch (\Exception $e) {
         }
         if (!is_array($d)) {
             echo '<pre>';
             throw new \Exception('Wrong config ' . $src);
         }
         if ($name) {
             Config::accept($name, $d);
         } else {
             foreach ($d as $k => &$v) {
                 Config::accept($k, $v);
             }
         }
     });
 }
Exemplo n.º 28
0
 public static function loadCSS(&$js, $name)
 {
     $c = Config::get($name);
     if (empty($c['css'])) {
         return;
     }
     if (!empty($c['off'])) {
         return;
     }
     if (!empty($c['dependencies'])) {
         Each::exec($c['dependencies'], function &($name) use(&$js) {
             Collect::loadCSS($js, $name);
             $r = null;
             return $r;
         });
     }
     if (!empty(Collect::$cssed[$name])) {
         return;
     }
     Collect::$cssed[$name] = true;
     $root = !empty($c['-collect']) && $c['-collect'] == 'root';
     Each::exec($c['css'], function &($path) use($name, &$js, $root) {
         $r = null;
         if ($root) {
             $src = $path;
         } else {
             $src = '-' . $name . '/' . $path;
         }
         $js .= "\n\n" . '/*load css ' . $src . "*/\r\n";
         if (!Path::theme($src)) {
             echo '<pre>';
             throw new \Exception('Не найден файл ' . $src);
         }
         $js .= Load::loadTEXT('-csspath/?src=' . $src);
         return $r;
     });
 }
Exemplo n.º 29
0
 public static function parse($src)
 {
     $src = Path::theme($src);
     if (!$src) {
         return;
     }
     $args = array($src);
     return Cache::exec(array($src), 'mhtparse', function ($src) {
         $conf = Docx::$conf;
         $imgmaxwidth = $conf['imgmaxwidth'];
         $previewlen = $conf['previewlen'];
         $filename = Path::theme($src);
         $fdata = Load::srcInfo($src);
         if ($fdata['ext'] == 'php') {
             $data = Load::loadTEXT($filename);
         } else {
             $data = file_get_contents($filename);
         }
         $ans = array();
         if ($fdata['ext'] == 'mht') {
             $p = explode('/', $filename);
             $fname = array_pop($p);
             $fnameext = $fname;
             //$fname=basename($filename);
             preg_match("/^(\\d*)/", $fname, $match);
             $date = $match[0];
             $fname = Path::toutf(preg_replace('/^\\d*\\s+/', '', $fname));
             $fname = preg_replace('/\\.\\w{0,4}$/', '', $fname);
             $ar = preg_split('/------=_NextPart_.*/', $data);
             if (sizeof($ar) > 1) {
                 //На первом месте идёт информация о ворде...
                 unset($ar[0]);
                 unset($ar[sizeof($ar) - 1]);
             }
             $ar = array_values($ar);
             $folder = Path::mkdir(Docx::$conf['cache'] . md5($src) . '/');
             $html = '';
             for ($i = 0, $l = sizeof($ar); $i < $l; ++$i) {
                 if (!$ar[$i]) {
                     continue;
                 }
                 $d = preg_split("/\n/", $ar[$i], 6);
                 $j = -1;
                 do {
                     ++$j;
                 } while (@$d[$j][0] !== 'C' && $j <= 5);
                 if ($j >= 5) {
                     /*
                     	не нашли
                     	Content-Location: file:///C:/0FCF1655/file9909.files/header.htm
                     	Content-Transfer-Encoding: quoted-printable
                     	Content-Type: text/html; charset="us-ascii"
                     */
                     continue;
                 }
                 $location = preg_replace('/Content-Location: /', '', $d[$j]);
                 $location = trim($location);
                 $encoding = preg_replace('/Content-Transfer-Encoding: /', '', $d[$j + 1]);
                 $type = preg_replace('/Content-Type: /', '', $d[$j + 2]);
                 $content = $d[5];
                 $name = basename($location);
                 if (preg_match("/text\\/html/", $type) || preg_match('/Subject:/', $type)) {
                     $html .= $content;
                 } else {
                     @file_put_contents($folder . $name, base64_decode($content));
                     //Сохраняем картинку или тп...
                 }
             }
             if (!$html) {
                 $html = '';
             }
             $html = preg_replace("/=\r\n/", '', $html);
             $html = preg_replace("/\\s+/", ' ', $html);
             $html = preg_replace("/^.*<body .*>\\s*/U", '', $html, 1);
             $html = preg_replace("/\\s*<\\/body>.*/", '', $html, 1);
             $images = array();
             preg_match_all('/src=3D".*\\.files\\/(image.+)"/U', $html, $match, PREG_PATTERN_ORDER);
             for ($i = 0, $l = sizeof($match[1]); $i < $l; $i = $i + 2) {
                 $min = $match[1][$i + 1];
                 if (!$min) {
                     $min = $match[1][$i];
                 }
                 $images[$min] = $match[1][$i];
                 //Каждая следующая картинка есть уменьшенная копия предыдущей оригинального размера
             }
             $html = preg_replace("/<\\!--.*-->/U", '', $html);
             $html = preg_replace("/<!\\[if !vml\\]>/", '', $html);
             $html = preg_replace("/<!\\[endif\\]>/", '', $html);
             $html = preg_replace('/=3D/', '=', $html);
             $html = preg_replace('/align="right"/', 'align="right" class="right"', $html);
             $html = preg_replace('/align="left"/', 'align="left" class="left"', $html);
             $html = preg_replace('/align=right/', 'align="right" class="right"', $html);
             $html = preg_replace('/align=left/', 'align="left" class="left"', $html);
             $html = Path::toutf($html);
             //Виндовые файлы хранятся в cp1251
             $folder = Path::toutf($folder);
             $html = preg_replace('/ src=".*\\/(.*)"/U', ' src="' . $folder . '${1}"', $html);
             $html = preg_replace('/<span class=SpellE>(.*)<\\/span>/U', '${1}', $html);
             $html = preg_replace('/<span lang=.*>(.*)<\\/span>/U', '${1}', $html);
             $html = preg_replace('/<span class=GramE>(.*)<\\/span>/U', '${1}', $html);
             $html = preg_replace("/<span style='mso.*>(.*)<\\/span>/U", '${1}', $html);
             $html = preg_replace("/<span style='mso.*>(.*)<\\/span>/U", '${1}', $html);
             $html = preg_replace("/<span style='mso.*>(.*)<\\/span>/U", '${1}', $html);
             $html = preg_replace("/<span style='mso.*>(.*)<\\/span>/U", '${1}', $html);
             $html = preg_replace('/ class=MsoNormal/U', '', $html);
             $html = preg_replace('/<a name="_.*>(.*)<\\/a>/U', '${1}', $html);
             //Приводим к единому виду маркерные списки
             $patern = '/<p class=MsoListParagraphCxSp(\\w+) .*>(.*)<\\/p>/U';
             $count = 3;
             do {
                 preg_match($patern, $html, $match);
                 if (sizeof($match) == $count) {
                     $pos = strtolower($match[1]);
                     $text = $match[2];
                     $text = preg_replace('/^.*(<\\/span>)+/U', '', $text, 1);
                     $text = '<li>' . $text . '</li>';
                     if ($pos == 'first') {
                         $text = '<ul>' . $text;
                     }
                     if ($pos == 'last') {
                         $text = $text . '</ul>';
                     }
                     $html = preg_replace($patern, $text, $html, 1);
                 } else {
                     break;
                 }
             } while (sizeof($match) == $count);
             $title = $fname;
             $patern = '/<img(.*)>/U';
             $count = 2;
             do {
                 preg_match($patern, $html, $match);
                 if (sizeof($match) == $count) {
                     $sfind = $match[1];
                     //$sfind='<img src="/image.asdf">';
                     preg_match("/width=(\\d*)/", $sfind, $match2);
                     $w = trim($match2[1]);
                     preg_match("/height=(\\d*)/", $sfind, $match2);
                     $h = trim($match2[1]);
                     if (!$w || $w > $imgmaxwidth) {
                         $w = $imgmaxwidth;
                     }
                     preg_match('/src="(.*\\/)(image.*)"/U', $sfind, $match2);
                     $path = trim($match2[1]);
                     $small = $match2[2];
                     preg_match('/alt="(.*)".*/U', $sfind, $match2);
                     $alt = trim(@$match2[1]);
                     $alt = html_entity_decode($alt, ENT_QUOTES, 'utf-8');
                     preg_match('/align="(.*)".*/U', $sfind, $match2);
                     $align = trim($match2[1]);
                     $align = html_entity_decode($align, ENT_QUOTES, 'utf-8');
                     $big = $images[$small];
                     if (!$big) {
                         $big = $small;
                     }
                     $isbig = preg_match('/#/', $alt);
                     if ($isbig) {
                         $alt = preg_replace('/#/', '', $alt);
                     }
                     //$i="<IMG title='$alt' src='/-imager/?w=$w&h=$h&src=".($path.$big)."' align='$align' class='$align' alt='$alt'>";
                     $i = "<IMG src='/-imager/?w={$w}&h={$h}&src=" . ($path . $big) . "' align='{$align}' class='{$align}'>";
                     //urlencode решает проблему с ie7 когда иллюстрации с адресом содержащим пробел не показываются
                     if ($isbig) {
                         $i = "<a target='about:blank' href='/-imager/?src=" . urlencode($path . $big) . "'>{$i}</a>";
                     }
                     //$i.='<textarea style="width:500px; height:300px">'.$i.'</textarea>';
                     $html = preg_replace($patern, $i, $html, 1);
                 } else {
                     break;
                 }
             } while (sizeof($match) == $count);
             $patern = "/###\\{(.*)\\}###/U";
             //js код
             do {
                 preg_match($patern, $html, $match);
                 if (sizeof($match) > 0) {
                     $param = $match[1];
                     $param = strip_tags($param);
                     $param = html_entity_decode($param, ENT_QUOTES, 'utf-8');
                     $param = preg_replace('/(‘|’)/', "'", $param);
                     $param = preg_replace('/(“|«|»|”)/', '"', $param);
                     $html = preg_replace($patern, $param, $html, 1);
                 } else {
                     break;
                 }
             } while (sizeof($match) > 1);
             $patern = "/####.*<table.*>(.*)<\\/table>.*####/U";
             do {
                 preg_match($patern, $html, $match);
                 if (sizeof($match) > 0) {
                     $param = $match[1];
                     $param = preg_replace('/style=".*"/U', '', $param);
                     $param = preg_replace("/style='.*'/U", '', $param);
                     $html = preg_replace($patern, '<table class="table table-striped">' . $param . '</table>', $html, 1);
                 } else {
                     break;
                 }
             } while (sizeof($match) > 1);
             $ans['images'] = array();
             foreach ($images as $img) {
                 $ans['images'][] = array('src' => $folder . $img);
             }
         } else {
             $html = $data;
             $images = array();
             preg_match_all('/<img.*src="(.*)".*>/U', $html, $match, PREG_PATTERN_ORDER);
             for ($i = 0, $l = sizeof($match[1]); $i < $l; $i++) {
                 $images[] = array('src' => $match[1][$i]);
                 //Каждая следующая картинка есть уменьшенная копия предыдущей оригинального размера
             }
             $ans['images'] = $images;
         }
         $r = preg_match('/<h.*>(.*)<\\/h.>/U', $html, $match);
         if ($r) {
             $heading = strip_tags($match[1]);
         } else {
             $heading = false;
         }
         $ans['heading'] = $heading;
         preg_match_all('/<a.*href="(.*)".*>(.*)<\\/a>/U', $html, $match);
         $links = array();
         foreach ($match[1] as $k => $v) {
             $title = strip_tags($match[2][$k]);
             if (!$title) {
                 continue;
             }
             $links[] = array('title' => $title, 'href' => $match[1][$k]);
         }
         $ans['links'] = $links;
         $html = trim($html);
         $html = html_entity_decode($html, ENT_COMPAT, 'UTF-8');
         $html = preg_replace('/
/U', '', $html);
         //bugfix списки в mht порождаются адский символ. в eval-е скрипта недопустим.
         $ans['html'] = $html;
         foreach ($ans['images'] as &$item) {
             $item['src'] = preg_replace('/^\\//', '', $item['src']);
         }
         return $ans;
     }, $args);
 }
Exemplo n.º 30
0
<?php

use infrajs\access\Access;
use infrajs\event\Event;
use infrajs\ans\Ans;
use infrajs\path\Path;
use infrajs\each\Each;
use infrajs\config\Config;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../../');
    require_once 'vendor/autoload.php';
}
$ans = array();
$ans['title'] = 'Проверка наличия папок';
$conf = Config::get();
if ($conf['mem']['type'] == 'fs') {
    $dirs = Config::get('path');
    if (!Path::theme($dirs['cache'])) {
        return Ans::err($ans, 'Нет папки ' . $dirs['cache']);
    }
    if (!Path::theme($dirs['data'])) {
        return Ans::err($ans, 'Нет папки ' . $dirs['data']);
    }
    return Ans::ret($ans, 'Обязательные папки есть');
} else {
    return Ans::ret($ans, 'Используется memcache. Папки не создаются.');
}