function _generate_filename($filename) { $filename = preg_replace('#(\\\\|/)+#', '', $filename); $filename = preg_replace('#^\\.+#', '', $filename); $ext = str_getext($filename); $new_filename = empty($ext) ? $filename : substr($filename, 0, -strlen($ext)); $new_filename = sprintf('%s_%s%s', $new_filename, random(), $ext); $new_filename = strtolower($new_filename); $filepath = pathjoin($this->get_home(), $new_filename); if (is_file($filepath)) { $new_filename = $this->_generate_filename($filename); } return $new_filename; }
while ($d = $read_dir->read()) { if ($d[0] != '.') { $ft->assign('CURRENT_TEMPLATE', $d); if (isset($_GET['tpl_dir'])) { $ft->assign('SELECTED', $d == $tpl_dir ? 'selected="selected"' : ''); } else { $ft->assign('SELECTED', $d == $template_dir ? 'selected="selected"' : ''); } $ft->parse('TEMPLATE_DIR', ".template_dir"); } } //lista szablonów $path = !isset($_GET['tpl_dir']) ? '../templates/' . $lang . '/' . $template_dir . '/tpl/' : '../templates/' . $lang . '/' . $tpl_dir . '/tpl/'; $dir = @dir($path); while ($file = $dir->read()) { $ext = str_getext($file, false); if (!in_array($ext, array('php', 'txt', 'html')) && is_file($path . $file)) { $file = explode('.', $file); $ft->assign(array('FILE' => $file[0] . "." . $file[1], 'FILE_PATH' => $file[0], 'TPL_DIR' => !isset($_GET['tpl_dir']) ? $template_dir : $tpl_dir)); //jesli plik nie jest zapisywalny, to tpl z gwiazdka if (is_writeable($path . $file)) { $ft->assign('STAR', ''); $ft->parse('TEMPLATE_ROW', ".template_row"); } else { $ft->assign('STAR', '*'); $ft->parse('TEMPLATE_ROW', ".template_row"); } } } $ft->parse('ROWS', "editlist_templates"); $dir->close();