function runfolder($dir, $hidden, $sub, $f, $d, &$filelist = array(), $pre = '') { if (is_dir($dir) && ($dh = opendir($dir))) { while (($file = readdir($dh)) !== false) { if (!$hidden && $file[0] == '.') { continue; } if ($file[0] == '~') { continue; } if ($file == 'Thumbs.db') { continue; } //$count++; //if($count<$lims)continue; //if($count>=($lims+$limc))break; $path = $dir . $file; if (!$f && is_file($path) && (!$d || !is_dir($path))) { continue; } //Файлы не надо if (is_dir($path)) { if ($sub) { runfolder($path . '/', $hidden, $sub, $f, $d, $filelist, $pre . infra_toutf($file) . '/'); } if (!$d) { continue; } //Папки не надо } if ($d && preg_match("/\\.files\$/", $file)) { continue; } //$weblife->modified(false,$path); $file = infra_toutf($file); array_push($filelist, $pre . $file); } closedir($dh); } return $filelist; }
$fdata = infra_srcinfo($isrc); $src = infra_admin_cache('files_get_php', function ($isrc) { $src = infra_theme($isrc); if ($src) { return $src; } $fdata = infra_srcinfo($isrc); $folder = infra_theme($fdata['folder']); if (!infra_theme($folder)) { return false; } array_map(function ($file) use(&$result, $fdata) { if ($file[0] == '.') { return; } $file = infra_toutf($file); $fd = infra_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; }
//die('Не найден оригинал'); } } } //$src с водяной меткой если нужно if ($gray) { $src = imager_makeGray($src, $temp); //новый src уже на серую картинку } $data = imager_scale($src, $w, $h, $crop, $top); if (!$data) { die('Resize Error'); } $br = infra_imager_browser(); $name = preg_replace("/(.*\\/)*/", '', $isrc); $name = infra_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'; } $data = array('data' => $data, 'name' => $name, 'type' => $type); return $data; }, $args, isset($_GET['re'])); header('Content-Disposition: filename="' . $data['name'] . '";'); header('content-type: image/' . $data['type']); echo $data['data'];
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); }
<?php /** * Страница "search" */ namespace itlife\catalog; use itlife\files\Xlsx; $ans = array(); $md = Catalog::initMark($ans); $val = infra_forFS(infra_toutf(strip_tags($_GET['val']))); if ($val) { $md['search'] = $val; } //Временное значение if (isset($_GET['seo'])) { $link = $_GET['seo']; if ($md['group']) { foreach ($md['group'] as $val => $one) { break; } $link = $link . '&m=:group.' . $val . ':1'; } else { if ($md['producer']) { foreach ($md['producer'] as $val => $one) { break; } $link = $link . '&m=:producer.' . $val . ':1'; } else { if ($md['search']) { $val = $md['search'];
function readxls($ifile, $name = 0, $onelist = false, $onlynew = false, $showlists = false, $list = false, $descr = false, $id = false, $nokey = false, $param = false, $obj = 0, $reverse = 0, $isname = 0) { $file = infra_theme($ifile, 'f'); if (!$file) { return array(); } $list = infra_toutf($list); $id = infra_toutf($id); $name = $name; $obj = (int) $obj; $data = pages_cache(array($file), 'readxlsmain', array($file)); /*foreach($data['boundsheets'] as &$sheet){ $sheet['name']=trim($sheet['name']); } foreach($data['sheets'] as &$sheet){ $sheet['name']=trim($sheet['name']); foreach($sheet['cells'] as &$row){ foreach($row as $k=>$cell){ $row[$k]=trim($cell); } } }*/ if ($showlists) { $r = array(); for ($i = 0, $l = sizeof($data['boundsheets']); $i < $l; ++$i) { if ($data['boundsheets'][$i]['name'][0] == '.') { continue; } if (!$name) { array_push($r, $data['boundsheets'][$i]['name']); } else { $r[$data['boundsheets'][$i]['name']] = 1; } } $result = $r; } else { $r = array(); for ($i = 0, $l = sizeof($data['boundsheets']); $i < $l; ++$i) { if (!$data['sheets'][$i]['cells']) { continue; } $listname = trim($data['boundsheets'][$i]['name']); if (!$param && $name) { if ($name == 'auto') { $test = $data['sheets'][$i]['cells']; $temp = 0; $find = false; foreach ($test as $v) { ++$temp; if (sizeof($v) > 2) { $find = true; break; } } if (!$find) { if ($isname) { $find = true; ++$temp; } else { $temp = 1; } } } else { $temp = $name; } $descrdata = array(); while ($temp > 1) { $descrd = array_shift($data['sheets'][$i]['cells']); $descrdata[] = $descrd; --$temp; } $names = array_shift($data['sheets'][$i]['cells']); //$data['sheets'][$i]['cells']=array_values($data['sheets'][$i]['cells']); if ($descr) { if ($descr == 1) { $descrd = array(); foreach ($descrdata as $v) { $ii = 0; foreach ($v as $jj) { if (!$ii) { $ii = $jj; } else { $descrd[$ii] = $jj; break; } } } } else { $descrd = $descrdata; } } else { $result = $r; } $r[$listname] = array(); for ($j = 0, $k = sizeof($data['sheets'][$i]['cells']); $j < $k; ++$j) { $r[$listname][$j] = array(); foreach ($names as $num => $value) { @($r[$listname][$j][$value] = $data['sheets'][$i]['cells'][$j][$num]); } } if ($descr) { $d = $r[$listname]; unset($r[$listname]); $r[$listname]['data'] = $d; $r[$listname]['descr'] = $descrd; } } else { $r[$data['boundsheets'][$i]['name']] = array_values($data['sheets'][$i]['cells']); foreach ($r[$data['boundsheets'][$i]['name']] as $k => $v) { $r[$data['boundsheets'][$i]['name']][$k] = array_values($r[$data['boundsheets'][$i]['name']][$k]); } //$r[$data['boundsheets'][$i]['name']] } } if ($reverse) { foreach ($r as $l => $d) { if ($descr) { $r[$l]['data'] = array_reverse($r[$l]['data'], true); } else { $r[$l] = array_reverse($r[$l], true); } } } if ($onelist || $list) { if ($list) { $r = $r[$list]; } else { foreach ($r as $l) { $r = $l; break; } } } $result = $r; if ($param) { if ($onelist) { $newres = array(); for ($i = (int) $name, $l = sizeof($result); $i < $l; ++$i) { $newres[$result[$i][0]] = $result[$i][1]; } $result = $newres; } else { foreach ($result as $k => $list) { $newres = array(); for ($i = (int) $name, $l = sizeof($list); $i < $l; ++$i) { $newres[$list[$i][0]] = $list[$i][1]; } $result[$k] = $newres; } } } else { if ($id && $name) { if ($descr) { $res = $result['data']; } else { $res = $result; } $newres = array(); for ($i = 0, $l = sizeof($res); $i < $l; ++$i) { $newres[$res[$i][$id]] = $res[$i]; //unset($newres[$res[$i][$id]][$id]); } if ($descr) { $result['data'] = $newres; } else { $result = $newres; } } if ($nokey) { foreach ($result as $k => &$v) { $result[$k] = array_values($result[$k]); } } } } return $result; }
function &imager_makeInfo($src) { $info = imager_readInfo($src); if ($info) { return $info; } $dirs = infra_dirs(); $dir = $dirs['data'] . 'imager/'; @mkdir($dir); $dir .= '.notwater/'; @mkdir($dir); $i = ''; $orig = $dir . infra_forFS($src); while (is_file($orig)) { $orig = $orig . $i; $i .= 'i'; } $r = copy($src, $orig); //по адресу orig не существует файла было проверено if (!$r) { die('Не удалось сохранить оригинал'); } $info = array(); $info['host'] = $_SERVER['HTTP_HOST']; $info['size'] = filesize(infra_tofs($orig)); $info['date'] = date('j.m.Y'); $info['orig'] = infra_toutf($orig); return $info; }
<?php namespace itlife\catalog; use itlife\files\Xlsx; infra_cache_no(); $orig_val = infra_toutf(strip_tags($_GET['val'])); $orig_art = infra_toutf(strip_tags($_GET['art'])); $val = infra_strtolower($orig_val); $art = infra_strtolower($orig_art); $args = array($val, $art); $ans = array(); $pos = Catalog::cache('position', function ($val, $art) { $data = Catalog::init(); // список всей продукции return Xlsx::runPoss($data, function (&$pos, $i, &$group) use(&$val, &$art) { if (mb_strtolower($pos['producer']) !== $val) { return; } if (mb_strtolower($pos['article']) !== $art) { return; } return $pos; }); }, $args, isset($_GET['re'])); if (isset($_GET['seo'])) { if (!$pos) { return infra_err($ans, 'Position not found'); } $link = $_GET['seo']; $link = $link . '/' . $pos['producer'] . '/' . $pos['article'];
<?php infra_require('*seo/seo.inc.php'); $type = infra_toutf(@$_REQUEST['type']); $id = infra_toutf(@$_REQUEST['id']); $submit = (bool) @$_REQUEST['submit']; $layers = infra_toutf(urldecode(@$_REQUEST['layers'])); @set_time_limit(300); //может быть отключена на хостинге $ans = array('result' => 0, 'id' => $id, 'type' => $type); if ($type == 'item') { $ans = infra_admin_cache('seoitemopt', function ($id) { $ans['result'] = 1; $p = explode('|', $id); $name = array_shift($p); $link = implode('|', $p); $seo = infrajs_seo_getSeo($name); if (isset($seo['all'][$link])) { $item = $seo['all'][$link]; } else { $item = array(); } $ans['item'] = $item; return $ans; }, array($id)); return infra_echo($ans); } else { if ($type == 'sitemap') { $html = infra_admin_cache('sitemap', function () { $data = array(); $all = array();
$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); infra_view_setCookie('cat_time', $data['time']); } $ans['cat_id'] = $id; $ans['cat_time'] = $time; $user = array('cat_id' => $id, 'list' => array(), 'time' => time()); foreach ($data['users'] as $k => $v) { if ($v['cat_id'] == $id) { $user = $v; unset($data['users'][$k]); break;
Добавлено кэширование modified 09.05.2010 Добавлена поддерж php файлов и возможность передачи get параметров запрашиваемому файлу */ require_once __DIR__ . '/../infra/infra.php'; $exts = array('tpl' => '', 'html' => '', 'docx' => '*pages/docx.php?src=', 'mht' => '*pages/mht/mht.php?src=', 'php' => ''); //..'xls'=>'?*pages/xls/xls.php?src=' $isrc = infra_toutf(urldecode($_SERVER['QUERY_STRING'])); $ext = preg_match('/\\.(\\w{0,4})$/', $isrc, $match); //Расширение при поиске не учитываем if ($ext) { $ext = $match[1]; } $src = infra_theme($isrc); $src = infra_toutf($src); $fdata = infra_srcinfo($isrc); $name = preg_replace('/\\.\\w{0,4}$/', '', $fdata['file']); $isrc = $fdata['folder'] . $name; if ($src) { @header('Content-Type: text/html; charset=utf-8'); if (isset($exts[$ext])) { //Расширение уже было $info = infra_loadTEXT($exts[$ext] . $src); } else { //Расширения небыло берём по приоритету if (!$ext) { //приоритет $ext = 'tpl'; $info = infra_loadTEXT($exts[$ext] . $isrc . '.' . $ext); if (!$info) {
public static function addFiles(&$pos, $dir = false) { $conf = infra_config(); $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 = $conf['catalog']['dir']; if (infra_forr($props, function &($name) use(&$dir, &$pos) { $rname = infra_seq_right($name); $val = infra_seq_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; } } $dir = infra_theme($dir); if (!$dir) { return false; } if (is_dir($dir)) { $paths = glob($dir . '*'); } elseif (is_file($dir)) { $paths = array($dir); $p = infra_srcinfo($dir); $dir = $p['folder']; } infra_forr($paths, function &($p) use(&$pos, $dir) { $d = explode('/', $p); $name = array_pop($d); $n = infra_strtolower($name); $fd = infra_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']);*/ $dirs = infra_dirs(); $dir = preg_replace('/^' . str_replace('/', '\\/', $dirs['data']) . '/', '*', $dir); $name = infra_toutf($dir . $name); if ($name[0] == '.') { return; } $im = array('png', 'gif', 'jpg'); $te = array('html', 'tpl', 'mht', 'docx'); if (infra_forr($im, function ($e) use($ext) { if ($ext == $e) { return true; } })) { $pos['images'][] = $name; } elseif (infra_forr($te, function ($e) use($ext) { if ($ext == $e) { return true; } })) { $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']); }
unset($_SESSION['imager']['files'][$k]); //Чтобы при обнолении страницы, не бегать снова } //Теперь у нас есть только массив origs foreach ($_SESSION['imager']['origs'] as $orig => $srcs) { $origf = infra_theme($orig); if (!$origf) { //if(preg_match("/^core\/data\//",$orig))continue;//старая версия сайта ничего с этим не поделать //die('Не найден оригинал '.infra_toutf($orig)." для картинки ".infra_toutf(print_r($srcs,true)).'<br>\n'); echo 'Не найден оригинал ' . infra_toutf($orig) . ' для картинки ' . infra_toutf(print_r($srcs, true)) . '<br>\\n'; continue; } foreach ($srcs as $src) { $r = copy($origf, $src); if (!$r) { die('Не удалось скопировать на место оригинал ' . infra_toutf($src)); } } $r = unlink($origf); if (!$r) { die('Не удалось удалить востановленный оригинал'); } unset($_SESSION['imager']['origs'][$orig]); //Пометили что этот оригинал уже востановили } $files = runfolder($dirorig, 1, 0); if (sizeof($files) > 0) { //Если остались не востановленные оригиналы.. делаем их backup $dirs = infra_dirs(); if (!is_dir($dirs['data'])) { mkdir($dirs['data']);
$data['heading'] = $heading; } //if($param['images'])$data['images']=$param['images']; if ($links) { $data['links'] = $links; } if ($data['name']) { $data['title'] = $data['name']; } $data['img'] = ''; if ($ftype == 'mht') { if ($img) { $data['img'] = $img; $data['images'] = array(); foreach ($images as $v) { $data['images'][] = array('src' => infra_toutf($folder) . $v); } } } else { if ($images) { $data['images'] = array(); foreach ($images as $v) { $data['images'][] = array('src' => $v); } } } if ($preview) { $data['preview'] = html_entity_decode($preview, ENT_COMPAT, 'UTF-8'); } if ($ftype != 'mht' && $data['img']) { $data['img'] = preg_replace('/^.*theme\\.php\\?/', '', $data['img']);
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); }
function docx_get($src, $type = 'norm', $re = false) { $debug = $re; $conf = infra_config(); if (@$conf['files'] && @$conf['files']['imgmaxwidth']) { $imgmaxwidth = $conf['files']['imgmaxwidth']; } if (!$imgmaxwidth) { $imgmaxwidth = 1000; } $imgmaxwidth = (int) $imgmaxwidth; $previewlen = 150; $args = array($src, $type, $imgmaxwidth, $previewlen); $dhtml = infra_cache(array($src), 'docx_parse', function ($src, $type, $imgmaxwidth, $previewlen, $debug) { $cachename = md5($src); $dirs = infra_dirs(); $cachefolder = $dirs['cache'] . 'docx/' . $cachename . '/'; //В винде ингда вылетает о шибка что нет прав удалить какой-то файл в папке и как следствие саму папку //Обновление страницы проходит уже нормально //Полагаю в линукс такой ошибки не будет хз почему возникает @docx_full_del_dir($cachefolder); $xmls = docx_getTextFromZippedXML($src, 'word/document.xml', $cachefolder, $debug); $rIds = array(); $param = array('com' => array(), 'folder' => $cachefolder, 'imgmaxwidth' => $imgmaxwidth, 'previewlen' => $previewlen, 'type' => $type, '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, 'docx_analyse', $param); } else { $param['rIds'] = array(); $html = ''; } /*if($debug){ echo $html; echo '<textarea style="width:600px; height:400px">'; echo $html; echo '</textarea>'; echo '<pre>'; print_r($xmlar); }*/ if ($type == 'preview' || $type == 'news') { $p = explode('/', $src); $fname = array_pop($p); $s = infra_toutf($fname); $data = infra_nameinfo($s); //$p=explode("/",$src); //$fname=array_pop($p); //preg_match("/^(\d*)/",$fname,$match); //$fname=infra_toutf(preg_replace('/^\d*/','',$fname)); //$fname=preg_replace('/\.\w{0,4}$/','',$fname); //$fname=trim($fname); //$date=$match[0]; $patern = '/###cut###/U'; $d = preg_split($patern, $html); if (sizeof($d) > 1) { $html = preg_replace($patern, '', $html); $preview = $d[0]; } else { $temphtml = strip_tags($html, '<p>'); //preg_match('/^(<p.*>.{'.$previewlen.'}.*<\/p>)/U',$temphtml,$match); preg_match('/(<p.*>.{1}.*<\\/p>)/U', $temphtml, $match); if (sizeof($match) > 1) { $preview = $match[1]; } else { $preview = $html; } } $preview = preg_replace('/<h1.*<\\/h1>/U', '', $preview); $preview = preg_replace('/<img.*>/U', '', $preview); $preview = preg_replace('/<p.*>\\s*<\\/p>/iU', '', $preview); $preview = preg_replace("/\\s+/", ' ', $preview); $preview = trim($preview); preg_match('/<img.*src=["\'](.*)["\'].*>/U', $html, $match); if ($match && $match[1]) { $img = $match[1]; } else { $img = false; } $filetime = filemtime($src); $data['modified'] = $filetime; if (@$param['links']) { $data['links'] = $param['links']; } if (@$param['heading']) { $data['heading'] = $param['heading']; } //title - depricated if (@$data['name']) { $data['title'] = $data['name']; } if ($img) { $data['img'] = $img; } if (@$param['images']) { $data['images'] = $param['images']; } if ($preview) { $data['preview'] = $preview; } return array($data, $param['com']); } else { return array($html, $param['com']); } }, $args, $re); //$html=$dhtml[0]; //кэш этого место в infrajs в getHTML return $dhtml; }