本文整理汇总了PHP中GetParentFolder函数的典型用法代码示例。如果您正苦于以下问题:PHP GetParentFolder函数的具体用法?PHP GetParentFolder怎么用?PHP GetParentFolder使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetParentFolder函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateServerFolder
function CreateServerFolder($folderPath)
{
$sParent = GetParentFolder($folderPath);
// Check if the parent exists, or create it.
if (!file_exists($sParent)) {
$sErrorMsg = CreateServerFolder($sParent);
if ($sErrorMsg != '') {
return $sErrorMsg;
}
}
if (!file_exists($folderPath)) {
// Turn off all error reporting.
error_reporting(0);
// Enable error tracking to catch the error.
ini_set('track_errors', '1');
// To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0);
mkdir($folderPath, 0777);
umask($oldumask);
$sErrorMsg = $php_errormsg;
// Restore the configurations.
ini_restore('track_errors');
ini_restore('error_reporting');
return $sErrorMsg;
} else {
return '';
}
}
示例2: CreateServerFolder
function CreateServerFolder($folderPath, $lastFolder = null)
{
global $Config;
$sParent = GetParentFolder($folderPath);
// Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
while (strpos($folderPath, '//') !== false) {
$folderPath = str_replace('//', '/', $folderPath);
$sParent = str_replace('//', '/', $sParent);
}
// Check if the parent exists, or create it.
if (!file_exists($sParent)) {
//prevents agains infinite loop when we can't create root folder
if (!is_null($lastFolder) && $lastFolder === $sParent) {
return "Can't create {$folderPath} directory";
}
$sErrorMsg = CreateServerFolder($sParent, $folderPath);
if ($sErrorMsg != '') {
return $sErrorMsg;
}
}
if (!file_exists($folderPath)) {
// Turn off all error reporting.
error_reporting(0);
$php_errormsg = '';
// Enable error tracking to catch the error.
ini_set('track_errors', '1');
if (isset($Config['ChmodOnFolderCreate']) && !$Config['ChmodOnFolderCreate']) {
mkdir($folderPath);
} else {
$permissions = 0777;
if (isset($Config['ChmodOnFolderCreate'])) {
$permissions = $Config['ChmodOnFolderCreate'];
}
// To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0);
mkdir($folderPath, $permissions);
umask($oldumask);
}
$sErrorMsg = $php_errormsg;
// Restore the configurations.
ini_restore('track_errors');
ini_restore('error_reporting');
return $sErrorMsg;
} else {
return '';
}
}
示例3: CreateServerFolder
function CreateServerFolder($folderPath, $lastFolder = null)
{
global $Config;
$sParent = GetParentFolder($folderPath);
// Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
while (strpos($folderPath, '//') !== false) {
$folderPath = str_replace('//', '/', $folderPath);
}
// Check if the parent exists, or create it.
if (!empty($sParent) && !file_exists($sParent)) {
//prevents agains infinite loop when we can't create root folder
if (!is_null($lastFolder) && $lastFolder === $sParent) {
return "Can't create {$folderPath} directory";
}
$sErrorMsg = CreateServerFolder($sParent, $folderPath);
if ($sErrorMsg != '') {
return $sErrorMsg;
}
}
if (!file_exists($folderPath)) {
// Turn off all error reporting.
error_reporting(0);
$php_errormsg = '';
// Enable error tracking to catch the error.
ini_set('track_errors', '1');
if (isset($Config['ChmodOnFolderCreate']) && !$Config['ChmodOnFolderCreate']) {
mkdir($folderPath);
} else {
$permissions = 0777;
// $permissions = 0770 ;
if (isset($Config['ChmodOnFolderCreate'])) {
$permissions = $Config['ChmodOnFolderCreate'];
}
// To create the folder with 0777 permissions, we need to set umask to zero.
//$oldumask = umask(0) ;
mkdir($folderPath, $permissions);
//umask( $oldumask ) ;
}
// While we are in a course: Registering the newly created folder in the course's database.
if (api_is_in_course()) {
global $_course, $_user;
$repository_path = api_get_path(REL_COURSE_PATH) . api_get_course_path() . '/document/';
$to_group_id = 0;
if (api_is_in_group()) {
global $group_properties;
$to_group_id = $group_properties['id'];
}
$folder_path = preg_replace("/^.*" . TOOL_DOCUMENT . "/", "", $folderPath);
//
$folder_path = preg_replace("/\\/\$/", "", $folder_path);
// should be done in 1 regexp I guess ...
// $folder_path = substr($folderPath, strpos($folderPath, $repository_path) + strlen($repository_path) - 1);
$folder_name = explode('/', $folder_path);
$folder_name = $folder_name[count($folder_name) - 1];
$doc_id = add_document($_course, $folder_path, 'folder', 0, $folder_name);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id);
}
$sErrorMsg = $php_errormsg;
// Restore the configurations.
ini_restore('track_errors');
ini_restore('error_reporting');
return $sErrorMsg;
} else {
return '';
}
}