當前位置: 首頁>>代碼示例>>PHP>>正文


PHP file::exists方法代碼示例

本文整理匯總了PHP中file::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP file::exists方法的具體用法?PHP file::exists怎麽用?PHP file::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在file的用法示例。


在下文中一共展示了file::exists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getUnInstalled

 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;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:26,代碼來源:module.php

示例2: install

 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;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:28,代碼來源:module.php

示例3: delete

 /**
  * 刪除文件
  * @param string $file
  * @return boolean
  */
 public static function delete($file)
 {
     if (file::exists($file)) {
         $file = path::clean($file);
         return @unlink($file);
     }
     return true;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:13,代碼來源:file.php

示例4: template

 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;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:12,代碼來源:page.php

示例5: write

 /**
  * 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);
             }
         }
     }
 }
開發者ID:Ermile,項目名稱:Saloos,代碼行數:18,代碼來源:log.php

示例6: licenseAction

 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();
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:19,代碼來源:module.php

示例7: actionInstall

 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();
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:22,代碼來源:module.php

示例8: notInstalled

 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;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:23,代碼來源:module.php

示例9: configurate

 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: " . Input::get("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());
 }
開發者ID:folkevil,項目名稱:paperwork,代碼行數:24,代碼來源:SetupController.php

示例10: actionInstall

 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();
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:24,代碼來源:module.php

示例11: load

 /**
  * 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');
     }
 }
開發者ID:Ermile,項目名稱:Saloos,代碼行數:41,代碼來源:image.php

示例12: rename

 /**
  * 文件重命名
  *
  * @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;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:25,代碼來源:file.php

示例13: showFile

	/**
	 * 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));
			}
		}
	}
開發者ID:nyroDev,項目名稱:nyroFwk,代碼行數:22,代碼來源:http.class.php

示例14: fetch

	/**
	 * 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;
	}
開發者ID:nyroDev,項目名稱:nyroFwk,代碼行數:72,代碼來源:tpl.class.php

示例15: password

 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;
     }
 }
開發者ID:ravenlp,項目名稱:CodiceCMS,代碼行數:18,代碼來源:files_controller.php


注:本文中的file::exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。