Exemple #1
0
        }
        $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);
    return Ans::txt($txt);
}
if (in_array($fdata['ext'], array('tpl', 'html', 'htm', 'php'))) {
    $txt = Load::loadTEXT($src);
    return Ans::txt($txt);
}
if (!Load::isphp()) {
    header('HTTP/1.0 400 Bad Request');
}
Exemple #2
0
<?php

namespace infrajs\load;

use infrajs\ans\Ans;
Ans::$conf['isReturn'] = function () {
    return Load::isphp();
};
Exemple #3
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 #4
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";
    }
}