Beispiel #1
0
        return false;
    }
    return infra_theme($folder . $result);
}, array($fdata['path']), isset($_GET['re']));
$ans = array('src' => $isrc);
if (!$src) {
    if (!infra_isphp()) {
        header('HTTP/1.0 404 Not Found');
    }
    return;
}
$fdata = infra_srcinfo($src);
if (in_array($fdata['ext'], array('docx'))) {
    $txt = files\Docx::get($src);
    return Ans::txt($txt);
}
if (in_array($fdata['ext'], array('mht'))) {
    $txt = files\Mht::get($src);
    return Ans::txt($txt);
}
if (in_array($fdata['ext'], array('xls', 'xlsx'))) {
    $ans = files\Xlsx::get($src);
    return Ans::ans($ans);
}
if (in_array($fdata['ext'], array('tpl', 'html', 'htm', 'php'))) {
    $txt = infra_loadTEXT($src);
    return Ans::txt($txt);
}
if (!infra_isphp()) {
    header('HTTP/1.0 400 Bad Request');
}
Beispiel #2
0
                $ans['breadcrumbs'][] = array('href' => '', 'title' => $group['name'], 'add' => 'group::group.' . $p . ':1');
            }, $group['path']);
            if (sizeof($ans['breadcrumbs']) == 1) {
                array_unshift($ans['breadcrumbs'], array('main' => true, "title" => "Главная", "nomark" => true));
            }
            $ans['name'] = $group['name'];
            //имя группы длинное
            $ans['descr'] = @$group['descr']['Описание группы'];
            $ans['title'] = $group['title'];
        }
    }
    Catalog::sort($ans['list'], $md);
    //Numbers
    $pages = ceil(sizeof($ans['list']) / $md['count']);
    if ($pages < $page) {
        $page = $pages;
    }
    $ans['numbers'] = Catalog::numbers($page, $pages, 11);
    $ans['list'] = array_slice($ans['list'], ($page - 1) * $md['count'], $md['count']);
    //Text
    $ans['text'] = infra_loadTEXT('*files/get.php?' . $conf['catalog']['dir'] . 'articals/' . $ans['title']);
    //Изменение текста не отражается как изменение каталога, должно быть вне кэша
    foreach ($ans['list'] as $k => $pos) {
        $pos = Catalog::getPos($pos);
        unset($pos['texts']);
        unset($pos['files']);
        $ans['list'][$k] = $pos;
    }
    return $ans;
}, $args, $re);
return infra_ret($ans);
Beispiel #3
0
 public static function parse($src)
 {
     $src = infra_theme($src);
     if (!$src) {
         return;
     }
     $args = array($src);
     return infra_cache(array($src), 'mhtparse', function ($src) {
         $conf = infra_config();
         $imgmaxwidth = $conf['files']['imgmaxwidth'];
         $previewlen = $conf['files']['previewlen'];
         $filename = infra_theme($src);
         $fdata = infra_srcinfo($src);
         if ($fdata['ext'] == 'php') {
             $data = infra_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 = infra_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);
             $dirs = infra_dirs();
             $folder = $dirs['cache'] . 'mht/' . md5($src) . '/';
             @mkdir($folder);
             $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 = infra_toutf($html);
             //Виндовые файлы хранятся в cp1251
             $folder = infra_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/imager.php?w=$w&h=$h&src=".($path.$big)."' align='$align' class='$align' alt='$alt'>";
                     $i = "<IMG src='?*imager/imager.php?w={$w}&h={$h}&src=" . ($path . $big) . "' align='{$align}' class='{$align}'>";
                     //urlencode решает проблему с ie7 когда иллюстрации с адресом содержащим пробел не показываются
                     if ($isbig) {
                         $i = "<a target='about:blank' href='?*imager/imager.php?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;
         return $ans;
     }, $args);
 }
Beispiel #4
0
     } else {
         $da = false;
     }
 }
 if (!$submit) {
     //Распарсить json. Нет itemslist, Нет item не найден
     //item обязательно должен быть либо в дефолтных, либо в созданных, либо в itemslist
     if (isset($seo['tpl'])) {
         $tpl = infra_template_parse(array($seo['tpl']), $da);
         $ans['tpl'] = $tpl;
         if (isset($seo['json'])) {
             $json = infra_template_parse(array($seo['json']), $da);
             $d = infra_loadJSON($json);
             $ans['text'] = infra_template_parse($tpl, $d);
         } else {
             $ans['text'] = infra_loadTEXT($tpl);
         }
         $ans['text'] = strip_tags($ans['text'], '<p><a><ul><li><table><tr><td><b><strong><h1><h2><h3>');
     }
     $ans['result'] = 1;
     $ans['seo'] = array('name' => $seo['name'], 'item' => @$seo['item'], 'defitem' => @$seo['defitem']);
 } else {
     if (!$da) {
         $ans['msg'] = 'Для редактирвоания нужно создать страницу';
     } else {
         $item = $_REQUEST['seo'];
         $item['data'] = $da;
         $src = infrajs_seo_saveitem($name, $item);
         $ans['noclose'] = 1;
         $ans['msg'] = 'Сохранено ' . date('d.m.Y H:i', filemtime($src));
         $ans['result'] = 1;
Beispiel #5
0
            //приоритет
            $ext = 'tpl';
            $info = infra_loadTEXT($exts[$ext] . $isrc . '.' . $ext);
            if (!$info) {
                $ext = 'html';
                $info = infra_loadTEXT($exts[$ext] . $isrc . '.' . $ext);
                if (!$info) {
                    $ext = 'docx';
                    $info = infra_loadTEXT($exts[$ext] . $isrc . '.' . $ext);
                    if (!$info) {
                        $ext = 'mht';
                        $info = infra_loadTEXT($exts[$ext] . $isrc . '.' . $ext);
                    }
                }
            }
            if (!$info) {
                $p = infra_srcinfo($src);
                $ext = $p['ext'];
                if (isset($exts[$ext])) {
                    $info = infra_loadTEXT($exts[$ext] . $isrc, $set);
                }
            }
        } else {
            $info = '';
            //$info=infra_plugin($isrc);
        }
    }
    echo $info;
} else {
    //@header("HTTP/1.0 404 Not Found");
}
Beispiel #6
0
$ans['menu'] = infra_loadJSON('*catalog/menu.json');
$submit = !empty($_GET['submit']);
// сбор статистики
$conf = infra_config();
$ans['breadcrumbs'][] = array('href' => '', 'title' => $conf['catalog']['title'], 'add' => 'group');
$ans['breadcrumbs'][] = array('href' => 'stat', 'title' => 'Статистика поиска');
$dirs = infra_dirs();
$dir = $dirs['data'];
$data = infra_loadJSON($dir . 'catalog_stat.json');
if (!$data) {
    $data = array('users' => array(), 'cat_id' => 0, 'time' => time());
    //100 10 user list array('val'=>$val,'time'=>time())
}
if (!$submit) {
    $conf = infra_config();
    $ans['text'] = infra_loadTEXT('*files/get.php?' + $conf['catalog']['dir'] . '/articals/stat');
    $ans['stat'] = $data;
    return infra_ret($ans);
}
$val = strip_tags(@$_GET['val']);
if (!$val) {
    return infra_err($ans, 'Incorrect parameters');
}
infra_cache_no();
$val = infra_forFS($val);
$val = infra_toutf($val);
$id = infra_view_getCookie('cat_id');
$time = infra_view_getCookie('cat_time');
if (!$time || !$id || $time != $data['time']) {
    $id = ++$data['cat_id'];
    infra_view_setCookie('cat_id', $id);
Beispiel #7
0
     }
     $links[] = array('title' => $title, 'href' => $match[1][$k]);
 }
 do {
     preg_match('/(<a.*)title=.##(.*)##.(.*>)/U', $html, $match);
     if (sizeof($match) > 1) {
         $param = $match[2];
         $param = strip_tags($param);
         $param = html_entity_decode($param, ENT_QUOTES, 'utf-8');
         $param = preg_split('/#/', $param);
         for ($i = 0, $l = sizeof($param); $i < $l; ++$i) {
             $param[$i] = trim($param[$i]);
         }
         $name = $param[0];
         $qp = http_build_query($param, 'p', '&');
         $inset = infra_loadTEXT('*pages/insets/' . $name . '.php?type=title&' . $qp);
         if ($inset) {
             $html = preg_replace('/<a.*title=.##.*##.*>/U', $match[1] . $inset . $match[3], $html, 1);
         } else {
             $html = preg_replace('/##.*##/U', '', $html, 1);
         }
     } else {
         break;
     }
 } while (sizeof($match) > 1);
 //$html=preg_replace("/\s+/",' ',$html); С этим появляется какой-то левый символ и всё падает... глюкс был
 $preview = preg_replace("/\\s+/", ' ', $preview);
 $preview = trim($preview);
 $img = trim($img);
 $title = trim($title);
 $html = trim($html);
Beispiel #8
0
 public static function getPos(&$pos)
 {
     $args = array($pos['producer'], $pos['article']);
     return Catalog::cache('getPos', function () use($pos) {
         Xlsx::addFiles($pos);
         $files = explode(',', @$pos['Файлы']);
         foreach ($files as $f) {
             if (!$f) {
                 continue;
             }
             $f = trim($f);
             $conf = infra_config();
             Xlsx::addFiles($pos, $conf['catalog']['dir'] . $f);
         }
         $files = array();
         foreach ($pos['files'] as $f) {
             if (is_string($f)) {
                 $f = infra_theme($f);
                 //убрали звездочку
                 $d = infra_srcinfo(infra_toutf($f));
             } else {
                 $d = $f;
                 $f = $d['src'];
             }
             $d['size'] = round(filesize(infra_tofs($f)) / 1000000, 2);
             if (!$d['size']) {
                 $d['size'] = '0.01';
             }
             $files[] = $d;
         }
         $pos['files'] = $files;
         if ($pos['texts']) {
             foreach ($pos['texts'] as $k => $t) {
                 $pos['texts'][$k] = infra_loadTEXT('*files/get.php?' . $t);
             }
         }
         return $pos;
     }, $args);
 }