Esempio n. 1
0
 public static function clearBranch($modules)
 {
     global $_PATH;
     if (is_array($modules)) {
         foreach ($modules as $dir) {
             XFILES::unlink_recursive(xConfig::get('PATH', 'CACHE') . $dir, 0);
         }
     }
 }
Esempio n. 2
0
 /**
  * Индексация шаблонов у которых прозошли изменения
  * 
  * @param mixed $startdir
  */
 function indexChangedMainTpls($startdir)
 {
     if ($allTemplates = XFILES::files_list($startdir, 'all', array('.html'), true)) {
         foreach ($allTemplates as $file) {
             if (strstr($file, '.html')) {
                 $fmtime = filemtime($file);
                 $template = str_replace($startdir . '/', '', $file);
                 $tplData = $this->getTplData($template);
                 $tParts = explode('/', $template);
                 preg_match("/(.+)@(.+)\\.html/", $tParts[1], $tplExp);
                 if (strstr($tParts[1], '_index')) {
                     $isMain = true;
                 } else {
                     $isMain = false;
                 }
                 if ($tParts[0] == '_index.html') {
                     $this->mainTemlateChanged = true;
                 }
                 if ($fmtime > $tplData['lastModified'] or !$tplData) {
                     $changedMainTpls[$tParts[0]][] = array('tpl' => $tParts[1], 'main' => $isMain, 'lang' => $tplExp[2]);
                 } else {
                     $this->nonChangedTpls[$tParts[0]][] = array('tpl' => $tParts[1], 'main' => $isMain, 'lang' => $tplExp[2]);
                 }
             }
         }
         if ($changedMainTpls) {
             foreach ($changedMainTpls as $domain => $tpls) {
                 foreach ($tpls as $tpl) {
                     if ($tpl['main']) {
                         if ($this->nonChangedTpls[$domain]) {
                             foreach ($this->nonChangedTpls[$domain] as $itpl) {
                                 if (!$itpl['main'] && $itpl['lang'] == $tpl['lang']) {
                                     $changedMainTpls[$domain][] = $itpl;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         unset($changedMainTpls['_index.html']);
         return $changedMainTpls;
     }
 }
Esempio n. 3
0
 function handlePageData(&$page_data)
 {
     global $TDB;
     if (strpos($page_data['url'], 'sec_pic.php') || strpos($page_data['url'], 'image.php')) {
         return false;
     }
     if ($page_data['insite_status']) {
         $page_data['http_status_code'] = $page_data['insite_status'];
     }
     preg_match('/<title>(.*?)<\\/title>/', $page_data['source'], $result);
     $title = $result[1] && $page_data['http_status_code'] == 200 ? $result[1] : '';
     $pattern = '/<\\!--<index>-->(.+)<\\!--<\\/index>-->/is';
     if ($page_data['http_status_code'] == 200 && preg_match_all($pattern, $page_data['source'], $matches)) {
         list(, $body) = each($matches[1]);
         $body = iconv('UTF-8', 'windows-1251', $body);
         $body = mysql_escape_string(strip_tags(preg_replace(array('/\\s+/', '#<script[^>]*>.*?</script>#is'), array(' ', ''), $body)));
         $index = XTRcrawler::Words2BaseForm(preg_replace('/\\s+/', ' ', $body));
     }
     $TDB->insertIN('search_pages_index', array('id' => 'null', 'url' => $page_data['url'], 'title' => $title, 'body' => iconv('windows-1251', 'UTF-8', $body), 'index' => iconv('windows-1251', 'UTF-8', $index), 'status' => $page_data['http_status_code']));
     $this->pages[] = array('url' => $page_data['url'], 'bytes_recieved' => XFILES::format_size($page_data['bytes_received']), 'body' => $title, 'status' => $page_data['http_status_code']);
 }
Esempio n. 4
0
 /**
 * обход директории
 */
 function _fs_walk($path)
 {
     $xml =& $this->xml;
     $zp = ',';
     if ($files = XFILES::files_list($path, $this->fs_walk_params['capture_type'], $this->fs_walk_params['allow_files_types'], 0, 0, true)) {
         $cc = count($files);
         foreach ($files as $file) {
             if (is_dir($ndir = $path . '/' . $file)) {
                 $ot = $this->fs_walk_params['dir_ot'];
                 $p = ",child:'1'";
                 $file = $ndir;
             } else {
                 $ot = $this->fs_walk_params['files_ot'];
                 $p = '';
             }
             if ($this->fs_walk_params['exclude_path_prefix']) {
                 $filename = str_replace($this->fs_walk_params['exclude_path_prefix'], '', $file);
             } else {
                 $filename = $file;
             }
             if ($cc == $i) {
                 $zp = '';
             }
             $this->xml .= "{id:'{$filename}', text:'" . basename($file) . "'" . $p . " ,obj_type:'" . $ot . "'}" . $zp;
         }
         return $xml;
     }
 }
Esempio n. 5
0
File: core.php Progetto: umaxfun/x4m
 public static function pluginsList()
 {
     if (self::$plugins) {
         return self::$plugins;
     }
     if ($plugs = XFILES::directory_list(xConfig::get('PATH', 'PLUGINS'))) {
         foreach ($plugs as $plug) {
             $plugParts = explode('.', $plug);
             self::$plugins[$plugParts[0]][$plugParts[1]] = $plug;
         }
         return self::$plugins;
     }
 }
Esempio n. 6
0
 function refresh_album($params)
 {
     function microtime_float()
     {
         list($usec, $sec) = explode(" ", microtime());
         return (double) $usec + (double) $sec;
     }
     session_start();
     unset($_SESSION['files'], $_SESSION['dfiles']);
     $cat = $this->_tree->GetNodeInfo($params['id']);
     $files = XFILES::files_list('./media/gallery/' . $cat['params']['folders'], 'files', array('.gif', '.jpeg', '.jpg', '.JPEG', '.JPG'), 0, true);
     $path = $_SERVER['DOCUMENT_ROOT'] . '/media/gallery/' . $cat['params']['folders'] . '/';
     $ch = $this->_tree->GetChilds($params['id']);
     if (sizeof($ch) != 0) {
         foreach ($ch as $c) {
             $qqq = $this->_tree->GetNodeInfo($c['id']);
             $_SESSION['dfiles'][] = $qqq['params']['image'];
         }
     } else {
         $_SESSION['dfiles'] = null;
     }
     foreach ($files as $file) {
         if (!preg_match('/[а-яА-Я ]/', $file, $arr)) {
             if (!in_array($path . $file, $_SESSION['dfiles'])) {
                 $_SESSION['files'][] = $file;
             }
         }
     }
     if (sizeof($_SESSION['files']) != 0) {
         $start_time = microtime_float();
         foreach ($_SESSION['files'] as $file) {
             $cur_time = microtime_float();
             if (($delta = $cur_time - $start_time) < 20) {
                 $data['LastModified'] = time();
                 $f = explode('.', $file);
                 array_pop($f);
                 $f = implode('', $f);
                 $data['Name'] = $f;
                 $data['image'] = '/media/gallery/' . $cat['params']['folders'] . '/' . $file;
                 $data['category'] = $params['id'];
                 $data['info'] = '';
                 $data['changed'] = filemtime($_SERVER['DOCUMENT_ROOT'] . '/media/gallery/' . $cat['params']['folders'] . '/' . $file);
                 if ($id = $this->_tree->InitTreeOBJ($cat['id'], $data['Name'], '_PHOTO', $data, true)) {
                     $data['id'] = $cat['id'];
                 }
                 $_SESSION['id'][] = $id;
             }
             $this->result['progress'] = ceil(sizeof($_SESSION['id']) * 100 / sizeof($_SESSION['files']));
             if ($this->result['progress'] >= 100) {
                 unset($_SESSION['id']);
             }
         }
     } else {
         $this->result['progress'] = 100;
         $this->result['completed'] = true;
     }
 }
Esempio n. 7
0
 public static function getModuleTemplateList($module, $extensions = array('.html'), $langversion = '')
 {
     if (is_array($files = XFILES::files_list(xConfig::get('PATH', 'MODULES_TEMPLATES') . $module, 'files', $extensions, 0, true))) {
         return $files;
     }
 }
Esempio n. 8
0
 function get_pictures_from_folder($params)
 {
     $types = array('.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF');
     if ($params[0]) {
         if (!$params[0]['folder']) {
             return;
         }
         if ($params[0]['types']) {
             $types = $params[0]['types'];
         }
         if ($files = XFILES::files_list(PATH_ . $params[0]['folder'], 'files', $types, 0, true)) {
             if ($params[0]['sort']) {
                 switch ($params[0]['sort']) {
                     case 'natsort':
                         natsort($files);
                         break;
                     case 'rsort':
                         rsort($files);
                         break;
                 }
             }
             foreach ($files as $file) {
                 $ext[] = array('image' => $params[0]['folder'] . $file);
             }
             return $ext;
         }
     }
 }
Esempio n. 9
0
 function load_paysystems($parameters)
 {
     global $_PATH, $TMS, $Adm;
     if ($files = XFILES::files_list($_PATH['PATH_MOD'] . 'ishop/tpl/', 'files', array('.paysystem.html'), 0, true)) {
         foreach ($files as $file) {
             $TMS->AddFileSection($Adm->load_module_tpls($this->_module_name, array(array('tpl_name' => str_replace('.html', '', $file))), true), true);
             $file = strtok($file, '.');
             $this->result['data_set']['rows'][$file] = array('data' => array(0 => $file, 1 => $TMS->parseSection('name')));
             $TMS->delSection('name');
         }
     }
 }
Esempio n. 10
0
 function download($params)
 {
     global $TMS, $TPA, $REQUEST_ASSOC, $HTTP_SERVER_VARS;
     $link = isset($REQUEST_ASSOC['link']) ? $REQUEST_ASSOC['link'] : 0;
     switch ($params["Action"]) {
         case 'show_folder':
             $filesnames = XFILES::files_list(substr($params["Folder"], 1), 'files', $extensions, 0, true);
             $pos = -1;
             for ($i = 0; $i < count($filesnames); $i++) {
                 if ($link == md5(strrev($params["Folder"] . $filesnames[$i]))) {
                     $pos = $i;
                     break;
                 }
             }
             if ($pos != -1) {
                 $file = substr($params["Folder"], 1) . $filesnames[$pos];
                 if (!$this->send_file($file)) {
                     $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
                     return $TMS->parseSection('_file_not_found');
                 }
             }
             break;
         default:
             $found = $this->hashfile_search($params['category'], $link);
             if ($found === false) {
                 //$found = $this->hashfile_recursive_search($params['category'], $link);
                 /* медленный вариант поиска, если hash не был вычислен при добавлении (для совместимости со старыми версиями модуля), перебирает всех элементы и проверяет по имени файла */
                 //if ($found === false)
                 $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
                 return $TMS->parseSection('_file_not_found');
             }
             if (!$this->send_file($found)) {
                 $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
                 return $TMS->parseSection('_file_not_found');
             }
             break;
     }
 }
Esempio n. 11
0
 function catalogExport($params)
 {
     global $TMS, $_PATH;
     $this->_tree->recursiveChildCollect($params['id'], '%', array('obj_type' => array('_CATGROUP', '_CATOBJ')), $order = 'ASC', array('_CATGROUP', '_CATOBJ'));
     $p = array();
     $idc = array($params['id'] => $this->_tree->getNodeInfo($params['id']));
     if ($params['Property_sets']) {
         $p += array('Property_set' => $params['Property_sets']);
     }
     $this->exportSettings = $p;
     if (is_array($this->_tree->EXPcache)) {
         $TMS->AddFileSection(Common::get_site_tpl($this->_module_name, $params['Template']));
         $this->recursiveExport($params['id'], 1);
         if ($params['encoding'] != 'utf8') {
             $s = XCODE::utf2win($TMS->parseSection('export_head'), $params['encoding']);
         } else {
             $s = $TMS->parseSection('export_head');
         }
         if (XFILES::filewrite($_PATH['PATH_EXPORT'] . $params['filename'], $s)) {
             $this->result['uploadfile'] = $_PATH['WEB_PATH_EXPORT'] . $params['filename'];
         } else {
             $this->result['ERROR'] = 2;
         }
         //cant_write_file
     } else {
         $this->result['ERROR'] = 1;
     }
     //objects not found
 }