public static function preview($src) { $param = self::parse($src); $data = infra_srcinfo($src); $data = infra_nameinfo($data['file']); $temphtml = strip_tags($param['html'], '<p><b><strong><i>'); $temphtml = preg_replace('/\\n/', ' ', $temphtml); preg_match('/(<p.*>.{1}.*<\\/p>)/U', $temphtml, $match); if (sizeof($match) > 1) { $preview = $match[1]; } else { $preview = $param['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); $filetime = filemtime(infra_theme($src)); $data['modified'] = $filetime; if (!empty($param['links'])) { $data['links'] = $param['links']; } if (!empty($param['heading'])) { $data['heading'] = $param['heading']; } //title - depricated if (!empty($data['name'])) { $data['title'] = $data['name']; } if (!empty($param['images'])) { $data['images'] = $param['images']; } $data['preview'] = $preview; return $data; }
$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; } }
function imager_prepareSrc($src) { if (preg_match("/^https{0,1}:\\/\\//", $src)) { //$src=infra_theme('*imager/noimage.png'); $src = imager_remote($src, $hour); } else { if (preg_match("/\\.php/", $src)) { //Такое может быть если путь до картинки передан тоже с imager то есть двойной вызов $src = imager_getReal($src); } else { $src = infra_theme($src); } } if ($src && is_dir($src)) { //папка смотрим в ней для src $list = array(); array_map(function ($file) use(&$list) { if ($file[0] == '.') { return; } $fd = infra_nameinfo($file); $ext = infra_strtolower($fd['ext']); if (in_array($ext, array('jpg', 'gif', 'png'))) { $list[] = $file; } }, scandir($src)); if (empty($list[0])) { $src = false; } else { $src = $src . $list[0]; } } return $src; }
$filelist = array_reverse($filelist); } //$filelist=array_slice($filelist,$lims,$limc); //$reali - реальный номер позиции после фильтра $reali = 0; for ($i = 0, $l = sizeof($filelist); $i < $l; ++$i) { $real_file = $filelist[$i]; $path = $dir . infra_tofs($real_file); $prefile = dirname($real_file); if ($prefile != '.') { $prefile .= '/'; } else { $prefile = ''; } $fileXXX = preg_replace('/^.+[\\\\\\/]/', '', $real_file); $p = infra_nameinfo($fileXXX); $p['f'] = is_file($path); $p['dir'] = $prefile; $ar = explode('.', $fileXXX); if (sizeof($ar) == 2 && !$ar[0] && $ar[1]) { $filename = implode('.', $ar); } elseif (sizeof($ar) > 1) { //Это может быть папка или файл без расширения, тогда считаем что имя файла есть а расширения нет $ext = array_pop($ar); $filename = implode('.', $ar); } else { $filename = array_pop($ar); $ext = ''; } if ($e && is_file($path)) { if (!in_array(strtolower($p['ext']), $e)) {
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']); }
$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); if ($what) { $filetime = filemtime($filename); $s = infra_toutf($fnameext); $data = infra_nameinfo($s); $data['modified'] = $filetime; if ($heading) { $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;
public static function preview($src) { $param = self::parse($src); $data = infra_srcinfo($src); $data = infra_nameinfo($data['file']); $patern = '/###cut###/U'; $d = preg_split($patern, $param['html']); if (sizeof($d) > 1) { $param['html'] = preg_replace($patern, '', $param['html']); $preview = $d[0]; } else { $temphtml = strip_tags($param['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 = $param['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', $param['html'], $match); if ($match && $match[1]) { $img = $match[1]; } else { $img = false; }*/ $filetime = filemtime(infra_theme($src)); $data['modified'] = $filetime; if (!empty($param['links'])) { $data['links'] = $param['links']; } if (!empty($param['heading'])) { $data['heading'] = $param['heading']; } //title - depricated if (!empty($data['name'])) { $data['title'] = $data['name']; } /*if ($img) { $data['img'] = $img; }*/ if (!empty($param['images'])) { $data['images'] = $param['images']; } $data['preview'] = $preview; return $data; }
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; }