Exemple #1
0
 public function getUnInstalled()
 {
     $installed = (array) $this->getInstalled();
     $folders = dir::folders(ZPATH_MODULES, '.', false);
     $folders = array_diff($folders, array_keys($installed));
     $modules = array();
     foreach ($folders as $folder) {
         $modulePath = ZPATH_MODULES . DS . $folder;
         $moduleUrl = url::modules() . '/' . $folder;
         $moduleFile = $modulePath . DS . 'module.php';
         if (file::exists($moduleFile)) {
             $m = (include $moduleFile);
             $m['path'] = '$modules/' . $folder;
             $m['url'] = '$modules/' . $folder;
             if (!isset($m['icon'])) {
                 if (!file::exists($modulePath . '/icon.png')) {
                     $m['icon'] = url::theme() . '/image/skin/none.png';
                 } else {
                     $m['icon'] = $moduleUrl . '/icon.png';
                 }
             }
             $modules[$m['id']] = $m;
         }
     }
     return $modules;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 /**
  * 删除文件
  * @param string $file
  * @return boolean
  */
 public static function delete($file)
 {
     if (file::exists($file)) {
         $file = path::clean($file);
         return @unlink($file);
     }
     return true;
 }
Exemple #4
0
 public function template($name = '')
 {
     if (file::exists($name)) {
         return $name;
     }
     $template = theme::template($name);
     if (file::exists($template)) {
         return $template;
     }
     $template = application::template($name);
     return $template;
 }
Exemple #5
0
 /**
  * Writes a line in the log file
  *
  * @param string $line
  */
 public function write($line)
 {
     file::append($this->filepath, date($this->date_format) . ' - ' . $line . "\n");
     // If the max size is exceeded
     if (file::getSize($this->filepath) >= $this->max_size) {
         file::delete($this->filepath . '.' . $this->nb_old_logs);
         for ($i = $this->nb_old_logs; $i >= 1; $i--) {
             if (file::exists($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)))) {
                 file::rename($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)), $this->filepath . '.' . $i);
             }
         }
     }
 }
Exemple #6
0
 public function licenseAction($id)
 {
     $module = zotop::model('zotop.module');
     $modules = $module->getUnInstalled();
     if (empty($id) || !isset($modules[$id])) {
         msg::error(zotop::t('ID为<b>{$id}</b>的模块不存在,请确认是否已经上传该模块?'));
     }
     $licenseFile = $modules[$id]['path'] . DS . 'license.txt';
     if (!file::exists($licenseFile)) {
         zotop::redirect('zotop/module/install', array('id' => $id));
         exit;
     }
     $license = file::read($licenseFile);
     $page = new dialog();
     $page->set('title', '许可协议');
     $page->set('license', html::decode($license));
     $page->set('next', zotop::url('zotop/module/install', array('id' => $id)));
     $page->display();
 }
Exemple #7
0
 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();
 }
Exemple #8
0
 public function notInstalled()
 {
     $datalist = (array) $this->datalist();
     $folders = dir::folders(ZOTOP_MODULES, '.', false);
     $folders = array_diff($folders, array_keys($datalist));
     $modules = array();
     foreach ($folders as $folder) {
         $modulePath = ZOTOP_MODULES . DS . $folder;
         $moduleUrl = url::modules() . '/' . $folder;
         $moduleFile = $modulePath . DS . 'module.php';
         if (file::exists($moduleFile)) {
             $m = (include $moduleFile);
             if (!isset($m['icon'])) {
                 $m['icon'] = $moduleUrl . '/icon.gif';
                 if (!file::exists($m['icon'])) {
                     $m['icon'] = url::theme() . '/image/icon/module.gif';
                 }
             }
             $modules[$m['id']] = $m;
         }
     }
     return $modules;
 }
 public function configurate()
 {
     //Create settings string
     $string = "";
     if (Input::get("debug") !== Config::get("app.debug")) {
         $string .= "debug: " . Input::get("debug") . "\r\n";
     }
     if (Input::get("registration") !== Config::get("paperwork.registration")) {
         $string .= "registration: " . Input::get("registration") . "\r\n";
     }
     if (Input::get("forgot_password") !== Config::get("paperwork.forgot_password")) {
         $string .= "forgot_password: "******"forgot_password") . "\r\n";
     }
     if (Input::get("showIssueReportingLink") !== Config::get("paperwork.showIssueReportingLink")) {
         $string .= "showIssueReportingLink: " . Input::get("showIssueReportingLink") . "\r\n";
     }
     File::put(storage_path() . "/paperwork_settings", $string);
     if (file::exists(storage_path() . "/paperwork_settings")) {
         $response = PaperworkHelpers::STATUS_SUCCESS;
     } else {
         $response = PaperworkHelpers::STATUS_NOTFOUND;
     }
     return PaperworkHelpers::apiResponse($response, array());
 }
Exemple #10
0
 public function actionInstall($id = '')
 {
     $id = empty($id) ? zotop::post('id') : $id;
     $module = zotop::model('system.module');
     $modules = $module->getUnInstalled();
     if (!isset($modules[$id])) {
         msg::error(array('title' => zotop::t('安装失败'), 'content' => zotop::t('未找到模块<b>{$id}</b>,请检查', array('id' => $id))));
     }
     if (form::isPostBack()) {
         $install = $module->install($modules[$id]['path']);
         if ($install) {
             $module->cache(true);
             msg::success(zotop::t('模块安装成功'), zotop::url('system/module'));
         }
     }
     $moduleFile = $modules[$id]['path'] . DS . 'module.php';
     if (!file::exists($moduleFile)) {
         msg::error(array('title' => zotop::t('安装失败'), 'content' => zotop::t('未找到模块标记文件<b>module.php</b>,请检查')));
     }
     $page = new dialog();
     $page->set('title', '安装模块');
     $page->set('module', $modules[$id]);
     $page->display();
 }
Exemple #11
0
 /**
  * Loads an image file
  *
  * @param string $filepath	Path of the image file
  */
 public static function load($filepath)
 {
     self::$loaded = false;
     if (file::exists($filepath)) {
         list(self::$width, self::$height, $type) = getimagesize($filepath);
         // unset(self::$img);
         self::$img = null;
         if ($type == IMAGETYPE_JPEG) {
             self::$img = @imagecreatefromjpeg($filepath);
         } else {
             if ($type == IMAGETYPE_GIF) {
                 self::$img = @imagecreatefromgif($filepath);
             } else {
                 if ($type == IMAGETYPE_PNG) {
                     self::$img = @imagecreatefrompng($filepath);
                 }
             }
         }
         if (!isset(self::$img)) {
             throw new \RuntimeException('Error opening image file "' . $filepath . '"');
         }
         if (!in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             throw new \RuntimeException('Unsupported image file type : "' . $filepath . '"');
         }
         self::$type = $type;
         // Preservation of the transparence / alpha for PNG and GIF
         if ($type == IMAGETYPE_GIF || $type == IMAGETYPE_PNG) {
             imagealphablending(self::$img, false);
             imagesavealpha(self::$img, true);
         }
         self::$loaded = true;
     } else {
         var_dump(4);
         throw new \RuntimeException('The image file "' . $filepath . '" doesn\'t exist');
     }
 }
Exemple #12
0
 /**
  * 文件重命名
  *
  * @param string $file  文件路径
  * @param string $newname 新文件名称,含文件扩展名
  *
  * @return bool
  * @since 0.1
  */
 public static function rename($file, $newname)
 {
     $file = path::decode($file);
     $path = dirname($file);
     $newfile = $path . DS . file::safename($newname);
     if ($file == $newfile) {
         zotop::error(zotop::t('目标文件名称和原文件名称相同'));
         return false;
     } elseif (file::exists($newfile)) {
         zotop::error(zotop::t('目标文件已经存在'));
         return false;
     } elseif (rename($file, $newfile)) {
         return true;
     }
     return false;
 }
Exemple #13
0
	/**
	 * Show a file to the client
	 *
	 * @param string $file File Path
	 */
	public function showFile($file) {
		if (file::exists($file)) {
			$type = file::getType($file);
			if (strpos($type, 'audio') === 0 || strpos($type, 'video') === 0) {
				$this->mediaDownload($file);
			} else {
				$this->cfg->compress = false;
				$this->neverExpire();
				$this->addHeader('Last-Modified', gmdate('D, j M Y H:i:s', filemtime($file)).' GMT', true);
				$this->addHeader('Content-Type', $type, true);
				$this->addHeader('Cache-Control', 'public', false);
				$this->addHeader('Pragma', null, false);
				$this->addHeader('Content-length', file::size($file), true);
				$this->sendText(file::read($file));
			}
		}
	}
Exemple #14
0
	/**
	 * Fetch the template
	 *
	 * @param array $prm Array parameter for retrieve the tpl file (exemple: used to force the tpl extension via tplExt)
	 * return string The result fetched
	 * @see file::nyroExists
	 */
	public function fetch(array $prm=array()) {
		$content = null;
		$cachedContent = false;
		$cachedLayout = false;

		$oldProxy = response::getProxy();
		response::setProxy($this->responseProxy);

		$cacheResp = null;

		if ($this->cfg->cache['auto']) {
			$cache = cache::getInstance(array_merge(array('serialize'=>false), $this->cfg->cache));
			$cache->get($content, array(
				'id'=>$this->cfg->module.'-'.$this->cfg->action.'-'.str_replace(':', '..', $this->cfg->param)
			));
			$cacheResp = cache::getInstance($this->cfg->cache);
			$cacheResp->get($callResp, array(
				'id'=>$this->cfg->module.'-'.$this->cfg->action.'-'.str_replace(':', '..', $this->cfg->param).'-callResp'
			));
			if (!empty($content)) {
				$cachedContent = true;
				$cachedLayout = $this->cfg->cache['layout'];
				if (!empty($callResp)) {
					$this->responseProxy->doCalls($callResp);
					$this->responseProxy->initCall();
				}
			}
		}

		if (!$cachedContent) {
			// Nothing was cached
			$action = $this->cfg->action;
			if (array_key_exists('callback', $prm))
				$action = call_user_func($prm['callback'], $prm['callbackPrm']);
			$file = $this->findTpl($prm, array(
				'module_'.$this->cfg->module.'_view_'.$action,
				'module_'.$this->cfg->defaultModule.'_view_'.$this->cfg->default
			));

			if (file::exists($file))
				$content = $this->_fetch($file);
		}

		if ($this->cfg->layout && !$cachedLayout) {
			// Action layout
			$file = $this->findTpl($prm, array(
				'module_'.$this->cfg->module.'_view_'.$this->cfg->action.'Layout',
				'module_'.$this->cfg->module.'_view_layout'
			));
			if (file::exists($file)) {
				$this->content = $content;
				$content = $this->_fetch($file);
			}
			if ($this->cfg->cache['auto'] && $this->cfg->cache['layout'])
				$cache->save();
		}

		if ($cacheResp && $this->responseProxy->hasCall()) {
			$callResp = $this->responseProxy->getCall();
			$cacheResp->save();
		}

		response::setProxy($oldProxy);
		return $content;
	}
 public function password($id = '')
 {
     if (empty($id)) {
         $this->redirect('index');
     }
     $file = new file();
     $file->find($id);
     if ($file->exists()) {
         $this->view->setLayout("admin");
         $this->title_for_layout($this->l10n->__("Archivo protegido"));
         $this->view->name = $file->name;
         $this->view->file_id = $file->id_file;
         $this->render();
     } else {
         header('HTTP/1.0 404 Not Found', true);
         exit;
     }
 }
Exemple #16
0
    $column['manage edit'] = '权限';
    $column['manage lock'] = '禁用';
    $column['manage delete'] = '卸载';
    table::header('list', $column);
    foreach ($modules as $module) {
        $module['root'] = ZPATH_MODULES . DS . $module['id'];
        $module['status-icon'] = $module['status'] == -1 ? html::image(url::theme() . '/image/icon/lock.gif') : html::image(url::theme() . '/image/icon/ok.gif');
        $column = array();
        $column['status w30 center'] = $module['status-icon'];
        //$column['name w60'] = $module['id'];
        $column['name'] = '<a class="dialog" href="' . zotop::url('zotop/module/about', array('id' => $module['id'])) . '"><b>' . $module['name'] . ' ( ' . $module['id'] . ' )</b></a><h5>' . $module['description'] . '</h5>';
        //$column['loginnum w60'] = $module['path'];
        $column['loginip w60 center'] = $module['version'];
        $column['logintime w130'] = time::format($module['updatetime']);
        $column['manage setting'] = file::exists($module['root'] . DS . 'admin' . DS . 'settings.php') ? '<a href="' . zotop::url('zotop/module/setting', array('id' => $module['id'])) . '">设置</a>' : '<span class="disabled">设置</span>';
        $column['manage priv'] = file::exists($module['root'] . DS . 'admin' . DS . 'priv.php') ? '<a href="' . zotop::url('zotop/module/priv', array('id' => $module['id'])) . '">权限</a>' : '<span class="disabled">权限</span>';
        if ($module['type'] == 'core') {
            $column['manage lock'] = '<span class="disabled">禁用</span>';
        } else {
            if ($module['status'] == -1) {
                $column['manage lock'] = '<a class="confirm" href="' . zotop::url('zotop/module/lock', array('id' => $module['id'], 'status' => 0)) . '">启用</a>';
            } else {
                $column['manage lock'] = '<a class="confirm" href="' . zotop::url('zotop/module/lock', array('id' => $module['id'])) . '">禁用</a>';
            }
        }
        $column['manage delete'] = $module['type'] == 'system' ? '<span class="disabled">卸载</span>' : '<a class="confirm" href="' . zotop::url('zotop/module/uninstall', array('id' => $module['id'])) . '">卸载</a>';
        table::row($column);
    }
    table::footer();
}
block::footer();
Exemple #17
0
 /**
  * Attach a file
  *
  * @param string|array $prm File path if string or array with key:
  *  - string file (required) File path name
  *  - string name File name
  *  - string type File Mime type
  * @return bool True if added (file exists)
  */
 public function attach($prm)
 {
     if (!is_array($prm)) {
         $prm = array('file' => $prm);
     }
     if (!array_key_exists('file', $prm)) {
         return false;
     }
     $ret = false;
     if (file::exists($prm['file'])) {
         if (!array_key_exists('name', $prm)) {
             $prm['name'] = file::name($prm['file']);
         }
         if (!array_key_exists('type', $prm)) {
             $prm['type'] = file::getType($prm['file']);
         }
         $this->attachment[] = $prm;
         $ret = true;
     }
     return $ret;
 }
Exemple #18
0
	protected function execIndex(array $prm = array()) {
		$this->prepare();
		
		$pattern = FILESROOT.$this->dir.DS.'*';
		$search = http_vars::getInstance()->get('search');
		if ($search) {
			$pattern.= strtolower($search).'*';
			$this->uri.= 'search='.$search.'&';
		}
		
		$delete = http_vars::getInstance()->get('delete');
		if ($delete) {
			$file = FILESROOT.urldecode($delete);
			if (file::exists($file)) {
				file::delete($file);
				file::multipleDelete(substr($file, 0, -strlen(file::getExt($file))-1).'_*');
				response::getInstance()->redirect($this->uri);
			}
		}
		
		$form = $this->getForm();
		
		if (request::isPost()) {
			$form->refill();
			if ($form->isValid())
				response::getInstance()->sendText('ok');
		}
		
		$files = array();
		foreach(file::search($pattern) as $f) {
			if (strpos($f, 'nyroBrowserThumb') === false) {
				$name = basename($f);
				if ($this->type == 'image' && strlen($name) > 15)
					$name = substr($name, 0, 15).'...'.file::getExt($f);
				$files[] = array(
					$f,
					request::uploadedUri(str_replace(FILESROOT, '', $f), $this->myCfg['uploadedUri']),
					$name,
					file::humanSize($f),
					utils::formatDate(filemtime($f)),
					$this->uri.'delete='.urlencode(str_replace(FILESROOT, '', $f)).'&'
				);
			}
		}
		
		$this->setViewVars(array(
			'uri'=>$this->uri,
			'form'=>$form,
			'config'=>$this->config,
			'type'=>$this->type,
			'files'=>$files,
			'searchButton'=>$this->myCfg['search'],
			'search'=>$search,
			'imgHelper'=>$this->myCfg['imgHelper'],
			'filesTitle'=>$this->myCfg['filesTitle'],
			'noFiles'=>$this->myCfg['noFiles'],
			'name'=>$this->myCfg['name'],
			'size'=>$this->myCfg['size'],
			'date'=>$this->myCfg['date'],
			'delete'=>$this->myCfg['delete'],
		));
	}
Exemple #19
0
$column['updatetime'] = '更新时间';
$column['manage rename'] = '设置';
$column['manage edit'] = '权限';
$column['manage lock'] = '禁用';
$column['manage delete'] = '卸载';
table::header('list', $column);
foreach ($modules as $module) {
    $column = array();
    $column['status w30 center'] = $module['status'] == -1 ? '<span class="zotop-icon zotop-icon-lock"></span>' : '<span class="zotop-icon zotop-icon-ok"></span>';
    $column['logo center'] = empty($module['icon']) ? '<div class="zotop-icon zotop-icon-module"></div>' : html::image($module['icon'], array('width' => '32px'));
    $column['name'] = '<a class="dialog" href="' . zotop::url('system/module/about/' . $module['id']) . '"><b>' . $module['name'] . ' ( ' . $module['id'] . ' )</b></a><h5>' . $module['description'] . '</h5>';
    //$column['loginnum w60'] = $module['path'];
    $column['loginip w60 center'] = $module['version'];
    $column['logintime w130'] = time::format($module['updatetime']);
    $column['manage setting'] = file::exists($module['path'] . DS . 'admin' . DS . 'setting.php') ? '<a href="' . zotop::url($module['id'] . '/setting') . '">设置</a>' : '<span class="disabled">设置</span>';
    $column['manage priv'] = file::exists($module['path'] . DS . 'admin' . DS . 'priv.php') ? '<a href="' . zotop::url($module['id'] . '/priv') . '">权限</a>' : '<span class="disabled">权限</span>';
    if ($module['type'] == 'core') {
        $column['manage lock'] = '<span class="disabled">禁用</span>';
    } else {
        if ($module['status'] == -1) {
            $column['manage lock'] = '<a class="confirm" href="' . zotop::url('system/module/status/' . $module['id'] . '/0') . '">启用</a>';
        } else {
            $column['manage lock'] = '<a class="confirm" href="' . zotop::url('system/module/status/' . $module['id'] . '/-1') . '">禁用</a>';
        }
    }
    $column['manage delete'] = $module['type'] == 'core' ? '<span class="disabled">卸载</span>' : '<a class="confirm" href="' . zotop::url('system/module/uninstall/' . $module['id']) . '">卸载</a>';
    table::row($column);
}
table::footer();
box::footer();
?>
Exemple #20
0
  * URL path to tcpdf installation folder (http://localhost/tcpdf/).
  * By default it is automatically calculated but you can also set it as a fixed string to improve performances.
  */
 define('K_PATH_URL', $k_path_url);
 /**
  * path for PDF fonts
  * use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
  */
 define('K_PATH_FONTS', K_PATH_MAIN . 'fonts/');
 /**
  * cache directory for temporary files (full path)
  */
 //define ('K_PATH_CACHE', K_PATH_MAIN.'cache/');
 // Update for nyroFwk
 define('K_PATH_CACHE', TMPROOT . 'tcpdf/');
 if (!file::exists(K_PATH_CACHE)) {
     file::createDir(K_PATH_CACHE);
 }
 /**
  * cache directory for temporary files (url path)
  */
 define('K_PATH_URL_CACHE', K_PATH_URL . 'cache/');
 /**
  *images directory
  */
 define('K_PATH_IMAGES', K_PATH_MAIN . 'images/');
 /**
  * blank image
  */
 define('K_BLANK_IMAGE', K_PATH_IMAGES . '_blank.png');
 /**
Exemple #21
0
 /**
  * Create an image ressource and get the dimension of the
  *
  * @param string $file The image path
  * @return false|array False if not a valid image or an array with Image ressource, width and height
  */
 protected function createImage($file)
 {
     if (!file::exists($file) || !is_file($file)) {
         return false;
     }
     $this->info = getimagesize($file);
     $img = null;
     switch ($this->info[2]) {
         case IMAGETYPE_JPEG:
             $img = imagecreatefromjpeg($file);
             break;
         case IMAGETYPE_GIF:
             $img = imagecreatefromgif($file);
             imagealphablending($img, false);
             imagesavealpha($img, true);
             break;
         case IMAGETYPE_PNG:
             $img = imagecreatefrompng($file);
             imagealphablending($img, false);
             imagesavealpha($img, true);
             break;
         default:
             return false;
     }
     return array(&$img, $this->info[0], $this->info[1]);
 }
Exemple #22
0
 private static function go($module, $controller, $action)
 {
     $cdir = APPLICATION_PATH . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module) . DS . 'controllers';
     if (!is_dir($cdir)) {
         static::is404();
     } else {
         $dirApps = realpath(APPLICATION_PATH);
         $tplDir = realpath($dirApps . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module) . DS . 'views');
         $controllerDir = realpath($dirApps . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module) . DS . 'controllers');
         $tpl = $tplDir . DS . Inflector::lower($controller) . DS . Inflector::lower($action) . '.phtml';
         $controllerFile = $controllerDir . DS . Inflector::lower($controller) . 'Controller.php';
         if (!file::exists($controllerFile)) {
             return static::is404();
         } else {
             if (File::exists($tpl)) {
                 $view = new View($tpl);
             }
             require_once $controllerFile;
             $controllerClass = 'Thin\\' . Inflector::lower($controller) . 'Controller';
             $instance = new $controllerClass();
             if (File::exists($tpl)) {
                 $instance->view = $view;
             }
             if (strstr($action, '-')) {
                 $words = explode('-', $action);
                 $newAction = '';
                 for ($i = 0; $i < count($words); $i++) {
                     $word = trim($words[$i]);
                     if ($i > 0) {
                         $word = ucfirst($word);
                     }
                     $newAction .= $word;
                 }
                 $action = $newAction;
             }
             $actionName = $action . 'Action';
             $actions = get_class_methods($controllerClass);
             if (!Arrays::in($actionName, $actions)) {
                 $continue = false;
                 foreach ($actions as $act) {
                     if (Inflector::lower($act) == Inflector::lower($actionName)) {
                         $actionName = $act;
                         $continue = true;
                         break;
                     }
                 }
                 if (false === $continue) {
                     return static::is404();
                 }
             }
             if (Arrays::in('init', $actions)) {
                 $instance->init();
             }
             if (Arrays::in('preDispatch', $actions)) {
                 $instance->preDispatch();
             }
             $instance->{$actionName}();
             if (File::exists($tpl)) {
                 $instance->view->render();
             }
             /* stats */
             if (File::exists($tpl) && null === container()->getNoShowStats()) {
                 echo View::showStats();
             }
             if (Arrays::in('postDispatch', $actions)) {
                 $instance->postDispatch();
             }
             if (Arrays::in('exit', $actions)) {
                 $instance->exit();
             }
         }
     }
     exit;
 }
 /**
  * Create a filename to not erease existing files
  *
  * @param string $name Filename
  * @return string Filename useable
  */
 protected function safeFileName($name)
 {
     $name = strtolower(utils::urlify($name, '.'));
     $ext = file::getExt($name);
     if ($ext) {
         $ext = '.' . $ext;
     }
     $initName = substr($name, 0, -strlen($ext));
     $i = 2;
     while (file::exists($this->dir . DS . $name)) {
         $name = $initName . '-' . $i . $ext;
         $i++;
     }
     return $name;
 }
Exemple #24
0
 /**
  * Indicate if a cache exists
  *
  * @param array $prm Parameter for the cached variable:
  *  - string type: Cache type, must be 'get' or 'start' (required)
  *  - string id: Cache id (required)
  *  - array tags: Optionnal tags for the id
  *  - array request: Array for build the request ID (@see cache::idRequest)
  *  - bool serialize: True if need to serialize the content (default: true)
  * @return bool True if it exists
  * @see get, start
  */
 public function exists(array $prm)
 {
     return file::exists($this->file($prm));
 }
Exemple #25
0
 public function actionNewfile($dir = '')
 {
     $dir = empty($dir) ? zotop::get('dir') : $dir;
     $dir = trim(url::decode($dir), '/');
     $file = 'newfile.php';
     if (form::isPostBack()) {
         $file = zotop::post('name');
         $title = zotop::post('title');
         $description = zotop::post('description');
         $filepath = site::template($dir . DS . $file);
         $filecontent = "<?php\r\n/**\r\n * title:{$title}\r\n * description:{$description}\r\n*/\r\n?>";
         if (file::exists($filepath)) {
             msg::error(zotop::t('新建失败,当前目录已经存在文件:{$file}', array('file' => $file)));
         }
         if (file::write($filepath, $filecontent)) {
             msg::success('新建文件成功');
         }
         msg::error('新建文件失败');
     }
     $page = new dialog();
     $page->title = zotop::t('模板编辑器');
     $page->set('dir', $dir);
     $page->set('file', $file);
     $page->display();
 }
Exemple #26
0
 public function isDuplicated($name = null)
 {
     $f = new file();
     $f->findBy('name', $name);
     return $f->exists();
 }
Exemple #27
0
 /**
  * 写入文件
  *
  * @param string $file
  * @param string $content
  * @param boolean $overwrite
  * @return boolean
  */
 public static function write($file, $content = '', $overwrite = TRUE)
 {
     $file = path::decode($file);
     //当目录不存在的情况下先创建目录
     if (!dir::exists(dirname($file))) {
         dir::create(dirname($file));
     }
     if (!file::exists($file) || $overwrite) {
         return @file_put_contents($file, $content);
     }
     return false;
 }