public static function decode($path) { $p = array('$modules' => ZPATH_MODULES); $path = strtr($path, $p); $path = path::clean($path); return $path; }
/** * * Renders a token into text matching the requested format. * * @access public * * @param array $options The "options" portion of the token (second * element). * * @return string The text rendered from the token options. * */ function token($options) { $text = $options['text']; $attr = $options['attr']; $type = strtolower($attr['type']); $css = $this->formatConf(' class="%s"', 'css'); $css_code = $this->formatConf(' class="%s"', 'css_code'); $css_php = $this->formatConf(' class="%s"', 'css_php'); $css_html = $this->formatConf(' class="%s"', 'css_html'); $geshi_class = path::file("plugins") . "geshi/geshi.php"; if ($type != "" && file_exists(path::file("plugins") . "geshi/geshi.php") && is_readable(path::file("plugins") . "geshi/geshi.php")) { require_once path::file("plugins") . "geshi/geshi.php"; $geshi = new GeSHi(trim($text), $type, path::file("plugins") . "geshi/geshi/"); $geshi->set_encoding("utf-8"); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS, 1); $geshi->set_header_type(GESHI_HEADER_DIV); $geshi->enable_classes(); $geshi->set_overall_class('geshi_code'); $text = $geshi->parse_code(); $style = $geshi->get_stylesheet(); global $page_handler; $style = "<style type='text/css'>\n{$style}\n</style>"; $page_handler->add_header_data($style); } else { //generic code example: //convert tabs to four spaces, //convert entities. $text = trim(htmlentities($text)); $text = str_replace("\t", " ", $text); $text = str_replace(" ", " ", $text); $text = "<code{$css_code}>{$text}</code>"; } return "\n{$text}\n\n"; }
public function actionSelect($field = '', $dir = '') { $dir = empty($dir) ? zotop::get('dir') : $dir; $dir = trim(url::decode($dir), '/'); $path = site::template(); $path = $path . DS . str_replace('/', DS, $dir); $path = path::clean($path); $folders = folder::folders($path); $files = folder::files($path); $position = '<a href="' . zotop::url('system/template/select') . '">' . zotop::t('根目录') . '</a><em> : //</em> '; if (!empty($dir)) { $dirs = arr::dirpath($dir, '/'); foreach ($dirs as $d) { $position .= '<a href="' . zotop::url('system/template/select', array('dir' => rawurlencode($d[1]))) . '">' . $d[0] . '</a> <em>/</em>'; } } $page = new dialog(); $page->title = zotop::t('模板管理'); $page->set('field', $field); $page->set('dir', $dir); $page->set('position', $position); $page->set('folders', $folders); $page->set('files', $files); $page->display(); }
/** Inits dcBlog object @param core <b>dcCore</b> Dotclear core reference @param id <b>string</b> Blog ID */ public function __construct(&$core, $id) { $this->con =& $core->con; $this->prefix = $core->prefix; $this->core =& $core; if (($b = $this->core->getBlog($id)) !== false) { $this->id = $id; $this->uid = $b->blog_uid; $this->name = $b->blog_name; $this->desc = $b->blog_desc; $this->url = $b->blog_url; $this->host = preg_replace('|^([a-z]{3,}://)(.*?)/.*$|', '$1$2', $this->url); $this->creadt = strtotime($b->blog_creadt); $this->upddt = strtotime($b->blog_upddt); $this->status = $b->blog_status; $this->settings = new dcSettings($this->core, $this->id); $this->themes_path = path::fullFromRoot($this->settings->themes_path, DC_ROOT); $this->public_path = path::fullFromRoot($this->settings->public_path, DC_ROOT); $this->post_status['-2'] = __('pending'); $this->post_status['-1'] = __('scheduled'); $this->post_status['0'] = __('unpublished'); $this->post_status['1'] = __('published'); $this->comment_status['-2'] = __('junk'); $this->comment_status['-1'] = __('pending'); $this->comment_status['0'] = __('unpublished'); $this->comment_status['1'] = __('published'); # --BEHAVIOR-- coreBlogConstruct $this->core->callBehavior('coreBlogConstruct', $this); } }
static function join_with($Separator, $Paths) { if (!$Paths) { return ''; } return path::normal(implode($Separator, array_filter($Paths, __NAMESPACE__ . '\\type::str')), $Separator); }
public function install($path = '') { $path = empty($path) ? $this->path : $path; $module = @(include path::decode($path . DS . 'module.php')); if (is_array($module)) { $module['path'] = $path; $module['url'] = $path; if (!isset($module['icon'])) { if (file::exists($path . '/icon.png')) { $module['icon'] = $module['url'] . '/icon.png'; } } $module['type'] = empty($module['type']) ? 'plugin' : $module['type']; $module['status'] = 0; $module['order'] = $this->max('order') + 1; $module['installtime'] = TIME; $module['updatetime'] = TIME; $insert = $this->insert($module); } if ($insert) { $driver = $this->db()->config('driver'); $sqls = file::read($path . DS . 'install' . DS . $driver . '.sql'); if ($sqls) { $this->db()->run($sqls); } } return true; }
public static function decode($path) { $p = array('$system' => ZOTOP_PATH_SYSTEM, '$modules' => ZOTOP_PATH_MODULES); $path = strtr($path, $p); $path = path::clean($path); return $path; }
/** Inits dcBlog object @param core <b>dcCore</b> Dotclear core reference @param id <b>string</b> Blog ID */ public function __construct($core, $id) { $this->con =& $core->con; $this->prefix = $core->prefix; $this->core =& $core; if (($b = $this->core->getBlog($id)) !== false) { $this->id = $id; $this->uid = $b->blog_uid; $this->name = $b->blog_name; $this->desc = $b->blog_desc; $this->url = $b->blog_url; $this->host = http::getHostFromURL($this->url); $this->creadt = strtotime($b->blog_creadt); $this->upddt = strtotime($b->blog_upddt); $this->status = $b->blog_status; $this->settings = new dcSettings($this->core, $this->id); $this->themes_path = path::fullFromRoot($this->settings->system->themes_path, DC_ROOT); $this->public_path = path::fullFromRoot($this->settings->system->public_path, DC_ROOT); $this->post_status['-2'] = __('Pending'); $this->post_status['-1'] = __('Scheduled'); $this->post_status['0'] = __('Unpublished'); $this->post_status['1'] = __('Published'); $this->comment_status['-2'] = __('Junk'); $this->comment_status['-1'] = __('Pending'); $this->comment_status['0'] = __('Unpublished'); $this->comment_status['1'] = __('Published'); # --BEHAVIOR-- coreBlogConstruct $this->core->callBehavior('coreBlogConstruct', $this); } }
/** * 删除文件 * @param string $file * @return boolean */ public static function delete($file) { if (file::exists($file)) { $file = path::clean($file); return @unlink($file); } return true; }
function store_revision_history($tag, $history) { if (!is_array($history)) { return false; } $data = var_export($history, true); return file_put_contents(path::file("data") . "wiki_history/{$tag}.hist", $data); }
/** * 打包全部的hook文件 * */ public static function hooks() { $modules = zotop::data('module'); foreach ((array) $modules as $module) { if ((int) $module['status'] >= 0 && folder::exists($module['path'])) { //加载hook文件 runtime::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APPLICATION_GROUP . '.php'; //加载库文件 zotop::register(@(include path::decode($module['path']) . DS . 'classes.php')); } } }
public static function hook() { //打包全部hook $hooks = array(); $modules = zotop::data('module'); foreach ($modules as $module) { $path = $module['path'] . DS . 'hook'; $path = path::decode($path); $hook = (array) dir::files($path, '', true, true); $hooks = array_merge($hooks, $hook); } $content = runtime::compile($hooks); if (!empty($content)) { file::write(ZPATH_RUNTIME . DS . 'hook.php', $content, true); } }
/** Checks if the given directory is really writable. The standard PHP * function is_writable() does not work properly on Windows servers * @param string $dir * @return bool */ public static function isWritable($dir) { $dir = path::normalize($dir); if (!is_dir($dir)) { return false; } $i = 0; do { $file = "{$dir}/is_writable_" . md5($i++); } while (file_exists($file)); if (!@touch($file)) { return false; } unlink($file); return true; }
function output_page($page_title = "") { global $smarty, $settings, $time_start; $smarty->assign("page_content", $this->get_page()); $smarty->assign("page_title", "{$settings['site']['long_name']} - {$page_title}"); $smarty->assign("header_data", $this->get_header_data()); $smarty->assign("page_footer", implode("\n", $this->footer_objects) . "\n#RENDERTIME#"); $smarty->load_filter('output', 'rewrite_urls'); if ($type == true && file_exists(path::file("templates") . "{$settings['theme']}/main_{$type}.html")) { $output = trim($smarty->fetch("{$settings['theme']}/main_{$type}.html")); } else { $output = trim($smarty->fetch("{$settings['theme']}/main.html")); } $time_end = microtime_float(); $time = round($time_end - $time_start, 4); echo str_replace("#RENDERTIME#", "[Render Time: {$time}s]", $output); }
public function __get($name) { switch ($name) { case 'name': return $this->name; case 'version': if (is_null($this->version)) { $versionFile = path::glue($this->basePath(), 'VERSION'); if (file_exists($versionFile)) { $this->version = trim(file_get_contents($versionFile)); } if (!$this->version) { throw new \RuntimeException('missing extension version'); } } return $this->version; } }
function dc_admin_icon_url($img) { global $core; $core->auth->user_prefs->addWorkspace('interface'); $user_ui_iconset = @$core->auth->user_prefs->interface->iconset; if ($user_ui_iconset && $img) { $icon = false; if (preg_match('/^images\\/menu\\/(.+)$/', $img, $m) || preg_match('/^index\\.php\\?pf=(.+)$/', $img, $m)) { if ($m[1]) { $icon = path::real(dirname(__FILE__) . '/../../admin/images/iconset/' . $user_ui_iconset . '/' . $m[1], false); if ($icon !== false) { $allow_types = array('png', 'jpg', 'jpeg', 'gif'); if (is_file($icon) && is_readable($icon) && in_array(files::getExtension($icon), $allow_types)) { return DC_ADMIN_URL . 'images/iconset/' . $user_ui_iconset . '/' . $m[1]; } } } } } return $img; }
public function install($id, $path = '') { $path = empty($path) ? $id : $path; $modulePath = ZOTOP_MODULES . DS . $id; $modulePath = path::clean($modulePath); $moduleFile = $modulePath . DS . 'module.php'; $module = @(include $moduleFile); $module['path'] = $path; $module['type'] = '1'; $module['url'] = $path; $module['status'] = 1; $module['order'] = $this->max() + 1; $module['installtime'] = time::now(); $module['updatetime'] = time::now(); if (is_array($module)) { $insert = $this->insert($module); if ($insert) { return $this->reload(); } } return false; }
public function actionInstall($path) { $module = zotop::model('zotop.module'); if (form::isPostBack()) { $install = $module->install($path); if ($install) { $module->cache(true); msg::success(zotop::t('模块安装成功'), zotop::url('zotop/module')); } } $moduleFile = $path . DS . 'module.php'; if (!file::exists($moduleFile)) { msg::error(array('content' => zotop::t('未找到模块标记文件<b>module.php</b>,请检查?'))); } $m = @(include path::decode($moduleFile)); $id = $m['id']; $modules = $module->getUnInstalled(); $page = new dialog(); $page->set('title', '安装模块'); $page->set('module', $modules[$id]); $page->display(); }
public static function loadStyle($load_style_widget = false) { global $core; $current_theme = tplMenu::getTheme(); $config = path::fullFromRoot($core->blog->settings->system->themes_path . '/' . $current_theme, DC_ROOT) . '/menu.' . $current_theme . '.php'; if (!file_exists($config)) { $config = dirname(__FILE__) . '/themes-config/menu.' . $current_theme . '.php'; } if (file_exists($config)) { require $config; if ($load_style_widget == false && isset($template_theme_style)) { foreach ($template_theme_style as $k => $v) { define($k, $v); } } elseif (isset($widget_theme_style)) { foreach ($widget_theme_style as $k => $v) { define($k, $v); } } } return; }
function create_thumb($filename, $max_width, $max_height) { $size = GetImageSize(path::file("images") . $filename); // Read the size $width = $size[0]; $height = $size[1]; // Proportionally resize the image to the // max sizes specified above $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if ($width <= $max_width && $height <= $max_height) { $tn_width = $width; $tn_height = $height; } elseif ($x_ratio * $height < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } return "<img src='" . path::http("images") . "{$filename}' style='height: {$tn_height}px; width: {$tn_width}px;' />"; }
public function actionIndex($dir = '') { $dir = url::clean($dir); $path = ZOTOP_PATH_ROOT . DS . trim($dir, DS); $path = path::clean($path); //获取当前目录的子目录及子文件 $folders = (array) dir::folders($path); $files = (array) dir::files($path); $position = '<a href="' . zotop::url('webftp/index/index') . '">wwwroot</a>'; $dirs = arr::dirpath($dir, '/'); foreach ($dirs as $d) { $position .= ' / <a href="' . zotop::url('webftp/index/index', array('dir' => rawurlencode($d[1]))) . '">' . $d[0] . '</a>'; } $page = new page(); $page->title = '文件管理器'; $page->set('position', $position); $page->set('navbar', $this->navbar($dir)); $page->set('folders', $folders); $page->set('files', $files); $page->set('path', $path); $page->set('dir', $dir); $page->display(); }
public static function file($file, $value = '', $expire = 0) { static $files = array(); $file = path::clean($file); //echo $file.'<br>'; if ('' !== $value) { if (is_null($value)) { $result = unlink($file); if ($result) { unset($files[$file]); } return $result; } else { $content = "<?php\nif (!defined('ZOTOP')) exit();\n//" . sprintf('%012d', $expire) . "\nreturn " . var_export($value, true) . ";\n?>"; $result = file_put_contents($file, $content); $files[$file] = $value; } return true; } if (isset($files[$file])) { return $files[$file]; } if (file_exists($file) && false !== ($content = file_get_contents($file))) { //注意:Dreamweaver会在文件最前面插入两个未知字符,39 $expire = (int) substr($content, strpos($content, '//') + 2, 12); if ($expire != 0 && time() > filemtime($file) + $expire) { //过期删除 unlink($file); return false; } $value = eval(substr($content, strpos($content, '//') + 14, -2)); $files[$file] = $value; } else { $value = false; } return $value; }
public function execute() { // Get theme path $path = $this->core->blog->themes_path; $theme = $this->core->blog->settings->system->theme; $dir = path::real($path . '/' . $theme); if (empty($path) || empty($theme) || !is_dir($dir)) { return false; } // Create zip @set_time_limit(300); $fp = fopen('php://output', 'wb'); $zip = new fileZip($fp); $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); $zip->addDirectory($dir . '/', '', true); // Log task execution here as we sent file and stop script $this->log(); // Send zip header('Content-Disposition: attachment;filename=theme-' . $theme . '.zip'); header('Content-Type: application/x-zip'); $zip->write(); unset($zip); exit(1); }
protected function act_downloadClipboard() { if (!isset($this->post['files']) || !is_array($this->post['files']) || $this->config['denyZipDownload']) { $this->errorMsg("Unknown error."); } $zipFiles = array(); foreach ($this->post['files'] as $file) { $file = path::normalize($file); if (substr($file, 0, 1) == ".") { continue; } $type = explode("/", $file); $type = $type[0]; if ($type != $this->type) { continue; } $file = $this->config['uploadDir'] . "/{$file}"; if (!is_file($file) || !is_readable($file)) { continue; } $zipFiles[] = $file; } do { $file = md5(time() . session_id()); $file = "{$this->config['uploadDir']}/{$file}.zip"; } while (file_exists($file)); $zip = new ZipArchive(); $res = $zip->open($file, ZipArchive::CREATE); if ($res === TRUE) { foreach ($zipFiles as $cfile) { $zip->addFile($cfile, basename($cfile)); } $zip->close(); } header("Content-Type: application/x-zip"); header('Content-Disposition: attachment; filename="clipboard_' . basename($file) . '"'); header("Content-Length: " . filesize($file)); readfile($file); unlink($file); die; }
/** * 返回目录下的全部文件夹的数组 * @param string $path 路径 * @param array $filter * @param bool|int $recurse 子目录,或者子目录级数 * @param bool $fullpath 全路径或者仅仅获取文件名称 * @param array $ignore 忽略的文件夹名称 * @return array */ public static function folders($path, $filter = '.', $recurse = false, $fullpath = false, $ignore = array('.svn', 'CVS', '.DS_Store', '__MACOSX')) { $folders = array(); $path = path::clean($path); if (!is_dir($path)) { return false; } $handle = opendir($path); while (($file = readdir($handle)) !== false) { $f = $path . DS . $file; if ($file != '.' && $file != '..' && !in_array($file, $ignore) && is_dir($f)) { if (preg_match("/{$filter}/", $file)) { if ($fullpath) { $folders[] = $f; } else { $folders[] = $file; } } if ($recurse) { if (is_integer($recurse)) { $recurse--; } $subfolders = dir::folders($f, $filter, $recurse, $fullpath, $ignore); $folders = array_merge($folders, $subfolders); } } } closedir($handle); return $folders; }
public function homepage_from_structure($all_languages = false) { $homepage_relative_url = $this->homepage; if (is_numeric($homepage_relative_url)) { $homepage_relative_url = path::loadElementPaths('structure', $homepage_relative_url); if (!$all_languages) { $homepage_relative_url = array_shift($homepage_relative_url); } } return $homepage_relative_url; }
$form_page = true; if (!empty($_GET['router'])) { $router = $_GET['router']; $router_file = __DIR__ . "/includes/router/$router.php"; if (file_exists($router_file)) { include_once __DIR__ . "/includes/router/$router.php"; }else{ die('No router found!. Error @ form.php @@ line 10'); } } else if (!empty($_GET['class_name'])) { $class_names = $_GET['class_name']; } else if (!empty($_GET['module_code'])) { $class_names = 'ino_generic'; $type = !empty($_GET['type']) ? $_GET['type'] : null; include_once('includes/basics/basics.inc'); $path = new path(); if (!empty($_GET['path_id'])) { $ino_generic_html = $path->findBy_moduleCode($_GET['module_code'], $type, array($_GET['path_id'])); } else { $ino_generic_html = $path->findBy_moduleCode($_GET['module_code'], $type, null); } include_once('includes/functions/loader.inc'); if (!empty($_GET['window_type']) && $_GET['window_type'] == 'popup') { include_once(THEME_DIR . '/popup_main_template.inc'); } else { include_once(THEME_DIR . '/main_template.inc'); } return; } else { die('No class found!. Error @ form.php @@ line 15'); }
/** Get inexistant filename based on the given filename. If you skip $dir * parameter the directory will be fetched from $filename and returned * value will be full filename path. The third parameter is optional and * defines the template, the filename will be renamed to. Default template * is {name}({sufix}){ext}. Examples: * * file::getInexistantFilename("/my/directory/myfile.txt"); * If myfile.txt does not exist - returns the same path to the file * otherwise returns "/my/directory/myfile(1).txt" * * file::getInexistantFilename("myfile.txt", "/my/directory"); * returns "myfile.txt" or "myfile(1).txt" or "myfile(2).txt" etc... * * file::getInexistantFilename("myfile.txt", "/dir", "{name}[{sufix}]{ext}"); * returns "myfile.txt" or "myfile[1].txt" or "myfile[2].txt" etc... * * @param string $filename * @param string $dir * @param string $tpl * @return string */ static function getInexistantFilename($filename, $dir = null, $tpl = null) { if ($tpl === null) { $tpl = "{name}({sufix}){ext}"; } $fullPath = $dir === null; if ($fullPath) { $dir = path::normalize(dirname($filename)); } else { $fdir = dirname($filename); $dir = strlen($fdir) ? path::normalize("{$dir}/{$fdir}") : path::normalize($dir); } $filename = basename($filename); $ext = self::getExtension($filename, false); $name = strlen($ext) ? substr($filename, 0, -strlen($ext) - 1) : $filename; $tpl = str_replace('{name}', $name, $tpl); $tpl = str_replace('{ext}', strlen($ext) ? ".{$ext}" : "", $tpl); $i = 1; $file = "{$dir}/{$filename}"; while (file_exists($file)) { $file = "{$dir}/" . str_replace('{sufix}', $i++, $tpl); } return $fullPath ? $file : (strlen($fdir) ? "{$fdir}/" . basename($file) : basename($file)); }
protected function makeThumb($file, $overwrite = true) { $img = image::factory($this->imageDriver, $file); // Drop files which are not images if ($img->initError) { return true; } $fimg = new fastImage($file); $type = $fimg->getType(); $fimg->close(); if ($type === false) { return true; } $thumb = substr($file, strlen($this->config['uploadDir'])); $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb; $thumb = path::normalize($thumb); $thumbDir = dirname($thumb); if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) { return false; } if (!$overwrite && is_file($thumb)) { return true; } // Images with smaller resolutions than thumbnails if ($img->width <= $this->config['thumbWidth'] && $img->height <= $this->config['thumbHeight']) { // Drop only browsable types if (in_array($type, array("gif", "jpeg", "png"))) { return true; } // Resize image } elseif (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) { return false; } // Save thumbnail $options = array('file' => $thumb); if ($type == "gif") { $type = "jpeg"; } if ($type == "jpeg") { $options['quality'] = $this->config['jpegQuality']; } return $img->output($type, $options); }
<?php $hideContextMenu = true; global $s; if (!empty($_GET['class_name']) && !empty($_GET['report_name'])) { $class_names = $_GET['class_name']; $report_name = $_GET['report_name']; // $label = $_GET['label']; $_GET['mode'] = 2; } else { $class_names[] = 'path'; include_once "includes/functions/loader.inc"; $path = new path(); $all_search_paths = $path->findAll_searchPaths(); $search_result_statement = ""; $search_result_statement .= "<table class=\"first_table normal\"><thead><tr>"; $search_result_statement .= '<th> Module </th>'; $search_result_statement .= '<th> Search Details </th>'; $search_result_statement .= '</tr></thead>'; if (!empty($all_search_paths)) { $search_result_statement .= '<tbody>'; foreach ($all_search_paths as $key => $module_group) { $search_result_statement .= ' <tr class="major_row"><td>' . $key . '</td><td><table class="second">'; foreach ($module_group as $paths) { $search_result_statement .= '<tr class="minor_row">'; $search_result_statement .= '<td>' . $paths->name . '</td>'; $search_result_statement .= '<td>' . $paths->description . '</td>'; $search_result_statement .= '<td><a href="' . HOME_URL . $paths->path_link . '">' . HOME_URL . $paths->path_link . '</a></td>'; $search_result_statement .= '</tr>'; } $search_result_statement .= '</table></td></tr>';