Exemple #1
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'];
 }
Exemple #2
0
 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);
         }
     } else {
         $list[$name][] = Path::pretty($tsrc);
     }
     return $r;
 });