本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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();
}
示例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();
}
示例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;
}
示例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());
}
示例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();
}
示例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');
}
}
示例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;
}
示例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));
}
}
}
示例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;
}
示例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;
}
}