Beispiel #1
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;
     }
 }
Beispiel #2
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;
     }
 }
Beispiel #3
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;
     }
 }
Beispiel #4
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;
     }
 }
Beispiel #5
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;
         }
     }
 }
Beispiel #6
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');
         }
     }
 }
Beispiel #7
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;
     }
 }