当前位置: 首页>>代码示例>>PHP>>正文


PHP common::DirName方法代码示例

本文整理汇总了PHP中common::DirName方法的典型用法代码示例。如果您正苦于以下问题:PHP common::DirName方法的具体用法?PHP common::DirName怎么用?PHP common::DirName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common的用法示例。


在下文中一共展示了common::DirName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_filesystem_method

 /**
  * Determine which class is needed to write to $context
  *
  * @param string $context
  */
 public static function get_filesystem_method($context)
 {
     while (!file_exists($context)) {
         $context = \common::DirName($context);
     }
     if (gp_is_writable($context)) {
         return 'gp_filesystem_direct';
     }
     if (function_exists('ftp_connect')) {
         return 'gp_filesystem_ftp';
     }
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:17,代码来源:FileSystem.php

示例2: get_filesystem_method

 static function get_filesystem_method($context = false)
 {
     global $dataDir;
     if ($context === false) {
         $context = $dataDir . '/include';
     }
     while (!file_exists($context)) {
         $context = common::DirName($context);
     }
     //direct
     if (gp_is_writable($context)) {
         if (!is_dir($context)) {
             return 'gp_filesystem_direct';
         }
         if (function_exists('posix_getuid') && function_exists('fileowner')) {
             $direct = false;
             //check more for directories
             $temp_file_name = $context . '/temp-write-test-' . time();
             $temp_handle = @fopen($temp_file_name, 'w');
             if ($temp_handle) {
                 if (posix_getuid() == @fileowner($temp_file_name)) {
                     $direct = true;
                 }
                 @fclose($temp_handle);
                 @unlink($temp_file_name);
             }
             if ($direct) {
                 return 'gp_filesystem_direct';
             }
         }
     }
     //ftp
     if (function_exists('ftp_connect')) {
         return 'gp_filesystem_ftp';
     }
     return false;
 }
开发者ID:GedionChang,项目名称:gpEasy-CMS,代码行数:37,代码来源:FileSystem.php

示例3: CheckDir

 /**
  * Check recursively to see if a directory exists, if it doesn't attempt to create it
  *
  * @param string $dir The directory path
  * @param bool $index Whether or not to add an index.hmtl file in the directory
  * @return bool True on success
  */
 public static function CheckDir($dir, $index = true)
 {
     global $config;
     if (!file_exists($dir)) {
         $parent = common::DirName($dir);
         gpFiles::CheckDir($parent, $index);
         //ftp mkdir
         if (isset($config['useftp'])) {
             if (!gpFiles::FTP_CheckDir($dir)) {
                 return false;
             }
         } else {
             if (!@mkdir($dir, gp_chmod_dir)) {
                 return false;
             }
             @chmod($dir, gp_chmod_dir);
             //some systems need more than just the 0755 in the mkdir() function
         }
         // make sure there's an index.html file
         // only check if we just created the directory, we don't want to keep creating an index.html file if a user deletes it
         if ($index && gp_dir_index) {
             $indexFile = $dir . '/index.html';
             if (!file_exists($indexFile)) {
                 //not using gpFiles::Save() so we can avoid infinite looping (it's safe since we already know the directory exists and we're not concerned about the content)
                 file_put_contents($indexFile, '<html></html>');
                 @chmod($indexFile, gp_chmod_file);
             }
         }
     }
     return true;
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:38,代码来源:Files.php

示例4: ArchiveRoot

 /**
  * Find $archive_root by finding Addon.ini
  *
  */
 public function ArchiveRoot($archive)
 {
     $archive_files = $archive->ListFiles();
     $archive_root = null;
     foreach ($archive_files as $file) {
         if (strpos($file['name'], '/Addon.ini') === false) {
             continue;
         }
         $root = common::DirName($file['name']);
         if (is_null($archive_root) || strlen($root) < strlen($archive_root)) {
             $archive_root = $root;
         }
     }
     return $archive_root;
 }
开发者ID:jozefkrz,项目名称:gpEasy-CMS,代码行数:19,代码来源:Archive.php

示例5: Folder

 /**
  * Return the folder path used for resized images of $img
  *
  */
 static function Folder($img)
 {
     global $dataDir;
     $name = basename($img);
     return $dataDir . '/data/_resized' . common::DirName($img) . '/' . gp_resized::EncodePath($name);
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:10,代码来源:image.php

示例6: ArchiveRoot

 /**
  * Find $archive_root by finding Addon.ini
  *
  */
 function ArchiveRoot($archive)
 {
     $archive_files = $archive->listContent();
     $archive_root = false;
     //find $archive_root by finding Addon.ini
     foreach ($archive_files as $file) {
         $filename =& $file['filename'];
         if (strpos($filename, '/Addon.ini') === false) {
             continue;
         }
         $root = common::DirName($filename);
         if (!$archive_root || strlen($root) < strlen($archive_root)) {
             $archive_root = $root;
         }
     }
     return $archive_root;
 }
开发者ID:barbrick,项目名称:gpEasy-CMS,代码行数:21,代码来源:update.php

示例7: CreateImage

 /**
  * Create a resized image of the file at $src_relative
  *
  */
 static function CreateImage($src_relative, $width, $height)
 {
     global $dataDir;
     $src_path = $dataDir . '/data/_uploaded' . $src_relative;
     if (!file_exists($src_path)) {
         return false;
     }
     //compare to actual size
     includeFile('tool/Images.php');
     $src_img = thumbnail::getSrcImg($src_path);
     if (!$src_img) {
         return false;
     }
     //Original Size
     $actual_w = imagesx($src_img);
     $actual_h = imagesy($src_img);
     if ($actual_w <= $width && $actual_h <= $height) {
         return false;
     }
     $info = gp_resized::ImageInfo($src_relative, $width, $height);
     if (!$info) {
         return false;
     }
     $dest_index = $info['index'];
     if (!$dest_index) {
         $dest_index = gp_resized::NewIndex();
     }
     $dest_path = $dataDir . '/data/_resized/' . $dest_index . '/' . $info['name'];
     $exists_before = file_exists($dest_path);
     //make sure the folder exists
     if (!gpFiles::CheckDir(common::DirName($dest_path))) {
         return false;
     }
     //create new resized image
     if (!thumbnail::createImg($src_img, $dest_path, 0, 0, 0, 0, $width, $height, $actual_w, $actual_h)) {
         return false;
     }
     //not needed if the resized image is larger than the original
     if (filesize($dest_path) > filesize($src_path)) {
         if (!$exists_before) {
             unlink($dest_path);
         }
         return false;
     }
     $data['index'] = $dest_index;
     $data['w'] = $width;
     $data['h'] = $height;
     $data['img'] = $src_relative;
     return $data;
 }
开发者ID:GedionChang,项目名称:gpEasy-CMS,代码行数:54,代码来源:editing.php

示例8: ViewRevision

 /**
  * Display the contents of a past revision
  *
  */
 function ViewRevision()
 {
     global $langmessage;
     $time = $_REQUEST['time'];
     $full_path = $this->BackupFile($time);
     if (!$full_path) {
         return false;
     }
     $file_sections = $file_stats = array();
     //if it's a compressed file, we need an uncompressed version
     if (strpos($full_path, '.gze') !== false) {
         ob_start();
         readgzfile($full_path);
         $contents = ob_get_clean();
         $dir = common::DirName($full_path);
         $full_path = tempnam($dir, 'backup');
         gpFiles::Save($full_path, $contents);
         $file_sections = gpFiles::Get($full_path, 'file_sections');
         unlink($full_path);
     } else {
         $file_sections = gpFiles::Get($full_path, 'file_sections');
     }
     $this->contentBuffer = section_content::Render($file_sections, $this->title, gpFiles::$last_stats);
     $date = common::date($langmessage['strftime_datetime'], $time);
     $message = sprintf($langmessage['viewing_revision'], $date);
     $message .= ' <br/> ' . common::Link($this->title, $langmessage['Restore this revision'], 'cmd=use_revision&time=' . $time, array('data-cmd' => 'cnreq'));
     $message .= ' &nbsp; ' . common::Link($this->title, $langmessage['Revision History'], 'cmd=view_history', array('title' => $langmessage['Revision History'], 'data-cmd' => 'gpabox'));
     message($message);
 }
开发者ID:Bomberus,项目名称:gpEasy-CMS,代码行数:33,代码来源:editing_page.php

示例9: GetUrl

 static function GetUrl($href = '', $query = '', $ampersands = true, $nonce_action = false)
 {
     global $linkPrefix, $config;
     $filtered = gpPlugin::Filter('GetUrl', array(array($href, $query)));
     if (is_array($filtered)) {
         list($href, $query) = $filtered;
     }
     $href = common::SpecialHref($href);
     //home page link
     if (isset($config['homepath']) && $href == $config['homepath']) {
         $href = $linkPrefix;
         if (!$_SERVER['gp_rewrite']) {
             $href = common::DirName($href);
         }
         $href = rtrim($href, '/') . '/';
     } else {
         $href = $linkPrefix . '/' . ltrim($href, '/');
     }
     $query = common::QueryEncode($query, $ampersands);
     if ($nonce_action) {
         $nonce = common::new_nonce($nonce_action);
         if (!empty($query)) {
             $query .= '&amp;';
             //in the cases where $ampersands is false, nonces are not used
         }
         $query .= '_gpnonce=' . $nonce;
     }
     if (!empty($query)) {
         $query = '?' . ltrim($query, '?');
     }
     return common::HrefEncode($href, $ampersands) . $query;
 }
开发者ID:barbrick,项目名称:gpEasy-CMS,代码行数:32,代码来源:common.php

示例10: CreateThumbnail

 /**
  * Create a thumbnail for the image at the path given by $original
  *
  */
 static function CreateThumbnail($original)
 {
     global $config, $dataDir;
     $prefix = $dataDir . '/data/_uploaded';
     $thumb_prefix = $dataDir . '/data/_uploaded/image/thumbnails';
     if (strpos($original, $thumb_prefix) !== false) {
         return;
     }
     if (strpos($original, $prefix) !== 0) {
         return;
     }
     $len = strlen($prefix);
     $thumb_path = substr($original, $len);
     $thumb_path = $thumb_prefix . $thumb_path;
     $thumb_dir = common::DirName($thumb_path);
     $thumb_path = $thumb_dir . '/' . basename($thumb_path) . '.jpg';
     gpFiles::CheckDir($thumb_dir);
     thumbnail::createSquare($original, $thumb_path, $config['maxthumbsize']);
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:23,代码来源:admin_uploaded.php

示例11: CheckDir

 /**
  * Make sure the directory exists for a file
  *
  */
 public function CheckDir($file)
 {
     $dir = \common::DirName($file);
     if ($this->file_exists($dir)) {
         return true;
     }
     if (!$this->CheckDir($dir)) {
         return false;
     }
     return $this->mkdir($dir);
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:15,代码来源:FileSystemFtp.php

示例12: ViewRevision

 /**
  * Display the contents of a past revision
  *
  */
 public function ViewRevision()
 {
     global $langmessage;
     $time = $_REQUEST['time'];
     $full_path = $this->BackupFile($time);
     if (is_null($full_path)) {
         return false;
     }
     //if it's a compressed file, we need an uncompressed version
     if (strpos($full_path, '.gze') !== false) {
         ob_start();
         readgzfile($full_path);
         $contents = ob_get_clean();
         $dir = common::DirName($full_path);
         $full_path = tempnam($dir, 'backup') . '.php';
         gpFiles::Save($full_path, $contents);
         $file_sections = gpFiles::Get($full_path, 'file_sections');
         unlink($full_path);
     } else {
         $file_sections = gpFiles::Get($full_path, 'file_sections');
     }
     $this->contentBuffer = section_content::Render($file_sections, $this->title, gpFiles::$last_stats);
     $date = common::date($langmessage['strftime_datetime'], $time);
     $message = sprintf($langmessage['viewing_revision'], $date);
     $message .= ' <span class="msg_buttons">';
     $message .= common::Link($this->title, $langmessage['Restore this revision'], 'cmd=UseRevision&time=' . $time, array('data-cmd' => 'cnreq'));
     $message .= common::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('data-cmd' => 'gpabox', 'class' => 'msg_view_history'));
     $message .= '</span>';
     msg($message);
 }
开发者ID:AndFer22,项目名称:Typesetter,代码行数:34,代码来源:editing_page.php


注:本文中的common::DirName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。