本文整理汇总了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';
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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 .= ' ' . common::Link($this->title, $langmessage['Revision History'], 'cmd=view_history', array('title' => $langmessage['Revision History'], 'data-cmd' => 'gpabox'));
message($message);
}
示例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 .= '&';
//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;
}
示例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']);
}
示例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);
}
示例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);
}