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


PHP CreateServerFolder函数代码示例

本文整理汇总了PHP中CreateServerFolder函数的典型用法代码示例。如果您正苦于以下问题:PHP CreateServerFolder函数的具体用法?PHP CreateServerFolder怎么用?PHP CreateServerFolder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateServerFolder函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 '';
    }
}
开发者ID:LFSF,项目名称:oras,代码行数:28,代码来源:io.php

示例2: CreateFolder

function CreateFolder($resourceType, $currentFolder)
{
    $sErrorNumber = '0';
    $sErrorMsg = '';
    if (isset($_GET['NewFolderName'])) {
        $sNewFolderName = $_GET['NewFolderName'];
        // Map the virtual path to the local server path of the current folder.
        $sServerDir = ServerMapFolder($resourceType, $currentFolder);
        if (is_writable($sServerDir)) {
            $sServerDir .= $sNewFolderName;
            $sErrorMsg = CreateServerFolder($sServerDir);
            switch ($sErrorMsg) {
                case '':
                    $sErrorNumber = '0';
                    break;
                case 'Invalid argument':
                case 'No such file or directory':
                    $sErrorNumber = '102';
                    // Path too long.
                    break;
                default:
                    $sErrorNumber = '110';
                    break;
            }
        } else {
            $sErrorNumber = '103';
        }
    } else {
        $sErrorNumber = '102';
    }
    // Create the "Error" node.
    echo '<Error number="' . $sErrorNumber . '" originalDescription="' . ConvertToXmlAttribute($sErrorMsg) . '" />';
}
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:33,代码来源:commands.php

示例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 ( !file_exists( $sParent ) )
    if (!empty($sParent) && !file_exists($sParent)) {
        //prevents agains infinite loop when we can't create root folder
        if (!is_null($lastFolder) && $lastFolder === $sParent) {
            return "Не могу создать директорию " . $folderPath;
        }
        $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 '';
    }
}
开发者ID:smartcorestudio,项目名称:ckfsys,代码行数:47,代码来源:io.php

示例4: 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');
        $oldumask = umask(0);
        mkdir($folderPath);
        umask($oldumask);
        $sErrorMsg = $php_errormsg;
        // Restore the configurations.
        ini_restore('track_errors');
        ini_restore('error_reporting');
        return $sErrorMsg;
    } else {
        return '';
    }
}
开发者ID:bachnx92,项目名称:vemaybay,代码行数:37,代码来源:folder_helper.php

示例5: CreateFolder

function CreateFolder($resourceType, $currentFolder)
{
    if (!isset($_GET)) {
        global $_GET;
    }
    $sErrorNumber = '0';
    $sErrorMsg = '';
    if (isset($_GET['NewFolderName'])) {
        $sNewFolderName = $_GET['NewFolderName'];
        $sNewFolderName = SanitizeFolderName($sNewFolderName);
        if (strpos($sNewFolderName, '..') !== FALSE) {
            $sErrorNumber = '102';
        } else {
            // Map the virtual path to the local server path of the current folder.
            $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
            if (is_writable($sServerDir)) {
                $sServerDir .= $sNewFolderName;
                $sErrorMsg = CreateServerFolder($sServerDir);
                switch ($sErrorMsg) {
                    case '':
                        $sErrorNumber = '0';
                        break;
                    case 'Invalid argument':
                    case 'No such file or directory':
                        $sErrorNumber = '102';
                        // Path too long.
                        break;
                    default:
                        $sErrorNumber = '110';
                        break;
                }
            } else {
                $sErrorNumber = '103';
            }
        }
    } else {
        $sErrorNumber = '102';
    }
    // Create the "Error" node.
    echo '<Error number="' . $sErrorNumber . '" />';
}
开发者ID:thebrashgroup,项目名称:projects,代码行数:41,代码来源:commands.php

示例6: CreateFolder

function CreateFolder($resourceType, $currentFolder)
{
    global $_FolderClass;
    global $Config;
    if (!isset($_GET)) {
        global $_GET;
    }
    $sErrorNumber = '0';
    $sErrorMsg = '';
    if (!has_permission($currentFolder, $resourceType) || $_FolderClass < 8) {
        if (!has_open_access()) {
            $sErrorNumber = 103;
            echo '<Error number="' . $sErrorNumber . '" />';
            return;
        }
    }
    if (isset($_GET['NewFolderName'])) {
        $sess_id = session_id();
        if (!isset($sess_id) || $sess_id != $_COOKIE['FCK_NmSp_acl']) {
            session_id($_COOKIE['FCK_NmSp_acl']);
            session_start();
        }
        global $Dwfck_conf_values;
        global $dwfck_conf;
        $dwfck_conf = $_SESSION['dwfck_conf'];
        if (empty($dwfck_conf)) {
            $dwfck_conf['deaccent'] = isset($Dwfck_conf_values['deaccent']) ? $Dwfck_conf_values['deaccent'] : 1;
            $dwfck_conf['useslash'] = isset($Dwfck_conf_values['useslash']) ? $Dwfck_conf_values['useslash'] : 0;
            $dwfck_conf['sepchar'] = isset($Dwfck_conf_values['sepchar']) ? $Dwfck_conf_values['sepchar'] : '_';
        }
        $sNewFolderName = $_GET['NewFolderName'];
        $sNewFolderName = str_replace(' ', $dwfck_conf['sepchar'], $sNewFolderName);
        $sNewFolderName = Dwfck_sanitize($sNewFolderName);
        if (strpos($sNewFolderName, '..') !== FALSE) {
            $sErrorNumber = '102';
        } else {
            // Map the virtual path to the local server path of the current folder.
            $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
            if ($Dwfck_conf_values['fnencode'] == 'url' || $Config['osWindows'] && !isset($Dwfck_conf_values['fnencode'])) {
                $sServerDir = encode_dir($sServerDir);
            }
            if ($Config['osWindows']) {
                $sServerDir = normalizeWIN($sServerDir);
            }
            if (is_writable($sServerDir)) {
                $sServerDir .= $sNewFolderName;
                $sErrorMsg = CreateServerFolder($sServerDir);
                switch ($sErrorMsg) {
                    case '':
                        $sErrorNumber = '0';
                        break;
                    case 'Invalid argument':
                    case 'No such file or directory':
                        $sErrorNumber = '102';
                        // Path too long.
                        break;
                    default:
                        $sErrorNumber = '110';
                        break;
                }
            } else {
                $sErrorNumber = '103';
            }
        }
    } else {
        $sErrorNumber = '102';
    }
    // Create the "Error" node.
    echo '<Error number="' . $sErrorNumber . '" />';
}
开发者ID:violetfish,项目名称:ckgedit,代码行数:70,代码来源:commands.php

示例7: 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 '';
    }
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:66,代码来源:io.php

示例8: define

 // Strip the temp .part suffix off
 @rename("{$filePath}.part", $filePath);
 // Time to move the temp file to the right folder
 $_FILES['NewFile']['name'] = $fileName;
 $_FILES['NewFile']['size'] = @filesize($filePath);
 $_FILES['NewFile']['tmp_name'] = $filePath;
 $_FILES['NewFile']['error'] = 0;
 // get our existing uploader into action
 define('K_GALLERY_UPLOAD', 1);
 require_once K_COUCH_DIR . 'includes/fileuploader/connector.php';
 $_GET['Type'] = 'Image';
 // create destination folder if required
 $fn = trim(implode('/', array_map(array($FUNCS, 'get_clean_url'), explode('/', $fn))), '/');
 $fpath = $Config['UserFilesAbsolutePath'] . 'image/';
 $fpath .= $fn ? $fn . '/' : '';
 $res = CreateServerFolder($fpath);
 if ($res) {
     die($res);
 }
 // move the file
 global $_K_IMAGE;
 // will contain either full url of the uploaded image or error
 $_GET['Command'] = 'FileUpload';
 $_GET['CurrentFolder'] = $fn;
 DoResponse();
 // success?
 if ($FUNCS->is_error($_K_IMAGE)) {
     die($_K_IMAGE->err_msg);
 }
 // Move on to create a cloned page using the uploaded image
 $path_parts = $FUNCS->pathinfo($fileName);
开发者ID:bayurianoputra,项目名称:forum-ff,代码行数:31,代码来源:uploader.php

示例9: FileUpload

function FileUpload($resourceType, $currentFolder, $sCommand)
{
    if (!isset($_FILES)) {
        global $_FILES;
    }
    $sErrorNumber = '0';
    $sFileName = '';
    if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name'])) {
        global $Config;
        $oFile = $_FILES['NewFile'];
        // Map the virtual path to the local server path.
        $sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand);
        // Get the uploaded file name.
        $sFileName = $oFile['name'];
        $sFileName = SanitizeFileName($sFileName);
        $sOriginalFileName = $sFileName;
        // Get the extension.
        $sExtension = substr($sFileName, strrpos($sFileName, '.') + 1);
        $sExtension = strtolower($sExtension);
        if (isset($Config['SecureImageUploads'])) {
            if (($isImageValid = IsImageValid($oFile['tmp_name'], $sExtension)) === false) {
                $sErrorNumber = '202';
            }
        }
        if (isset($Config['HtmlExtensions'])) {
            if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && ($detectHtml = DetectHtml($oFile['tmp_name'])) === true) {
                $sErrorNumber = '202';
            }
        }
        // hack for XOOPS CHINA by ezsky < ezskyyoung@gmail.com >
        $name_pattern = "";
        if (!empty($Config['UserFilesNamePattern'])) {
            $patterns = explode("|", $Config['UserFilesNamePattern']);
            $delimiter = "";
            foreach ($patterns as $pattern) {
                switch ($pattern) {
                    case "date":
                        $name_pattern .= $delimiter . date("YmdHis");
                        break;
                    case "time":
                        $name_pattern .= $delimiter . strval(time());
                        break;
                    case "uid":
                        $name_pattern .= $delimiter . (is_object($GLOBALS["xoopsUser"]) ? str_pad($GLOBALS["xoopsUser"]->getVar("uid"), 10, "0", STR_PAD_LEFT) : "0");
                        break;
                }
                $delimiter = "-";
            }
        }
        if (!empty($name_pattern)) {
            $sFileName = $name_pattern . "." . $sExtension;
        }
        if (!empty($Config['UserFilesPathPattern'])) {
            $sServerDir .= date($Config['UserFilesPathPattern']) . '/';
            CreateServerFolder($sServerDir);
            if (is_dir($sServerDir)) {
                $currentFolder .= date($Config['UserFilesPathPattern']) . '/';
            }
        }
        // end hack
        // Check if it is an allowed extension.
        if (!$sErrorNumber && IsAllowedExt($sExtension, $resourceType)) {
            $iCounter = 0;
            while (true) {
                $sFilePath = $sServerDir . $sFileName;
                if (is_file($sFilePath)) {
                    $iCounter++;
                    $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension;
                    $sErrorNumber = '201';
                } else {
                    move_uploaded_file($oFile['tmp_name'], $sFilePath);
                    if (is_file($sFilePath)) {
                        if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload']) {
                            break;
                        }
                        $permissions = 0777;
                        if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload']) {
                            $permissions = $Config['ChmodOnUpload'];
                        }
                        $oldumask = umask(0);
                        chmod($sFilePath, $permissions);
                        umask($oldumask);
                    }
                    break;
                }
            }
            if (file_exists($sFilePath)) {
                //previous checks failed, try once again
                if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) {
                    @unlink($sFilePath);
                    $sErrorNumber = '202';
                } else {
                    if (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) {
                        @unlink($sFilePath);
                        $sErrorNumber = '202';
                    }
                }
            }
        } else {
            $sErrorNumber = '202';
//.........这里部分代码省略.........
开发者ID:yunsite,项目名称:xoopsdc,代码行数:101,代码来源:commands.php


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