本文整理汇总了PHP中make_upload_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP make_upload_directory函数的具体用法?PHP make_upload_directory怎么用?PHP make_upload_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_upload_directory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: latex
/**
* Constructor - create temporary directories and build paths to
* external 'helper' binaries.
* Other platforms could/should be added
*/
function latex()
{
global $CFG;
// construct directory structure
$this->temp_dir = $CFG->dataroot . "/temp/latex";
make_upload_directory('temp/latex');
}
示例2: webquest_upgrade
function webquest_upgrade($oldversion)
{
/// This function does anything necessary to upgrade
/// older versions to match current functionality
$status = true;
global $CFG;
if ($oldversion < 2007081222) {
require_once $CFG->dirroot . '/backup/lib.php';
//make the change into each course
$courses = get_records("course");
foreach ($courses as $course) {
$newdir = "{$course->id}/{$CFG->moddata}/webquest";
if (make_upload_directory($newdir)) {
$olddir = "{$CFG->dataroot}/{$course->id}/{$CFG->moddata}/webquest/submissions";
//chec k if the old directory exists
if (is_dir($olddir)) {
$status = backup_copy_file($olddir, $CFG->dataroot . "/" . $newdir);
}
if ($status) {
fulldelete($olddir);
}
}
}
}
return $status;
}
示例3: close
function close()
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
$dir = 'temp/ods/' . time();
make_upload_directory($dir);
make_upload_directory($dir . '/META-INF');
$dir = "{$CFG->dataroot}/{$dir}";
$files = array();
$handle = fopen("{$dir}/mimetype", 'w');
fwrite($handle, get_ods_mimetype());
$files[] = "{$dir}/mimetype";
$handle = fopen("{$dir}/content.xml", 'w');
fwrite($handle, get_ods_content($this->worksheets));
$files[] = "{$dir}/content.xml";
$handle = fopen("{$dir}/meta.xml", 'w');
fwrite($handle, get_ods_meta());
$files[] = "{$dir}/meta.xml";
$handle = fopen("{$dir}/styles.xml", 'w');
fwrite($handle, get_ods_styles());
$files[] = "{$dir}/styles.xml";
$handle = fopen("{$dir}/META-INF/manifest.xml", 'w');
fwrite($handle, get_ods_manifest());
$files[] = "{$dir}/META-INF";
$filename = "{$dir}/result.ods";
zip_files($files, $filename);
$handle = fopen($filename, 'rb');
$contents = fread($handle, filesize($filename));
fclose($handle);
remove_dir($dir);
// cleanup the temp directory
send_file($contents, $this->filename, 0, 0, true, true, 'application/vnd.oasis.opendocument.spreadsheet');
}
示例4: __construct
public function __construct()
{
global $CFG;
make_upload_directory('upgradelogs');
$date = date('Ymd-His');
$this->handle = fopen($CFG->dataroot . '/upgradelogs/qe_' . $date . '.html', 'a');
fwrite($this->handle, '<html><head><title>Question engine upgrade assumptions ' . $date . '</title></head><body><h2>Question engine upgrade assumptions ' . $date . "</h2>\n\n");
}
示例5: __construct
/**
* Constructor.
*/
public function __construct()
{
make_temp_directory('');
make_upload_directory('lang');
$this->info = array();
$this->errors = array();
$this->installer = new \lang_installer();
$this->availablelangs = $this->installer->get_remote_list_of_languages();
}
示例6: textlib_get_instance
/**
* As we implement the singleton pattern to use this class (only one instance
* is shared globally), we need this helper function
*
* IMPORTANT Note: Typo3 libraries always expect lowercase charsets to use 100%
* its capabilities so, don't forget to make the conversion
* from every wrapper function!
*
* @return textlib singleton instance of textlib
*/
function textlib_get_instance()
{
global $CFG;
static $instance = null;
if (!$instance) {
/// initialisation is delayed because we do not want this on each page ;-)
/// Required files
require_once $CFG->libdir . '/typo3/class.t3lib_cs.php';
require_once $CFG->libdir . '/typo3/class.t3lib_div.php';
/// If ICONV is available, lets Typo3 library use it for convert
if (extension_loaded('iconv')) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'iconv';
/// Else if mbstring is available, lets Typo3 library use it
} else {
if (extension_loaded('mbstring')) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'mbstring';
/// Else if recode is available, lets Typo3 library use it
} else {
if (extension_loaded('recode')) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'recode';
} else {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = '';
}
}
}
/// If mbstring is available, lets Typo3 library use it for functions
if (extension_loaded('mbstring')) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
} else {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = '';
}
/// Tell Typo3 we are curl enabled always (mandatory since 2.0)
$GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] = '1';
/// And this directory must exist to allow Typo to cache conversion
/// tables when using internal functions
make_upload_directory('temp/typo3temp/cs');
/// Make sure typo is using our dir permissions
$GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = decoct($CFG->directorypermissions);
/// Default mask for Typo
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = $CFG->directorypermissions;
/// This full path constants must be defined too, transforming backslashes
/// to forward slashed beacuse Typo3 requires it.
define('PATH_t3lib', str_replace('\\', '/', $CFG->libdir . '/typo3/'));
define('PATH_typo3', str_replace('\\', '/', $CFG->libdir . '/typo3/'));
define('PATH_site', str_replace('\\', '/', $CFG->dataroot . '/temp/'));
define('TYPO3_OS', stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin') ? 'WIN' : '');
$instance = new textlib();
}
return $instance;
}
示例7: MoodleExcelWorkbook
/**
* Constructs one Moodle Workbook.
*
* @global object
* @param string $filename The name of the file
*/
function MoodleExcelWorkbook($filename) {
global $CFG;
/// Internally, create one PEAR Spreadsheet_Excel_Writer_Workbook class
$this->pear_excel_workbook = new Spreadsheet_Excel_Writer($filename);
/// Prepare it to accept UTF-16LE data and to encode it properly
if (empty($CFG->latinexcelexport)) { /// Only if don't want to use latin (win1252) stronger output
$this->pear_excel_workbook->setVersion(8);
$this->latin_output = false;
} else { /// We want latin (win1252) output
$this->latin_output = true;
}
/// Choose our temporary directory - see MDL-7176, found by paulo.matos
make_upload_directory('temp/excel');
$this->pear_excel_workbook->setTempDir($CFG->dataroot.'/temp/excel');
}
示例8: get_course_media_files
/**
* gets a list of all the media files for the given course
*
* @param int courseid
* @return array containing filenames
* @calledfrom type/<typename>/editquestion.php
* @package questionbank
* @subpackage importexport
*/
function get_course_media_files($courseid)
{
// this code lifted from mod/quiz/question.php and modified
global $CFG;
$images = null;
make_upload_directory("{$course->id}");
// Just in case
$coursefiles = get_directory_list("{$CFG->dataroot}/{$courseid}", $CFG->moddata);
foreach ($coursefiles as $filename) {
if (is_media_by_extension($filename)) {
$images["{$filename}"] = $filename;
}
}
return $images;
}
示例9: moodle_binary_get_path
function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid)
{
global $CFG;
$entry = wiki_get_entry($wiki, $course, $userid, $groupid);
if (!$entry) {
print_error('cannotgetentry', 'wiki');
}
$dir = make_upload_directory("{$course->id}/{$CFG->moddata}/wiki/{$wiki->id}/{$entry->id}/" . $meta["section"]);
if (substr($id, 0, strlen(EWIKI_IDF_INTERNAL)) != EWIKI_IDF_INTERNAL) {
print_error('cannotstartwith', 'wiki', '', EWIKI_IDF_INTERNAL . substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
}
$id = substr($id, strlen(EWIKI_IDF_INTERNAL));
$id = clean_filename($id);
return "{$dir}/{$id}";
}
示例10: imagegallery_process_zip_file
function imagegallery_process_zip_file($file)
{
global $CFG, $USER, $gallery;
$tmpdir = random_string(6);
$fullpath = make_upload_directory($tmpdir);
$origpath = dirname($file->path);
if (!unzip_file($file->path, $fullpath)) {
error(get_string("unzipfileserror", "error"));
}
$images = imagegallery_search_images($fullpath);
if (!empty($images)) {
foreach ($images as $image) {
$newpath = $origpath . '/' . basename($image);
// If file already exists, just skip it.
if (@file_exists($newpath)) {
continue;
}
$fileinfo = getimagesize($image);
if (!rename($image, $newpath)) {
error("Could not move file to new location!");
}
$newfile = new stdClass();
$newfile->galleryid = $file->galleryid;
$newfile->categoryid = $file->categoryid;
$newfile->userid = $USER->id;
$newfile->name = basename($image);
$newfile->path = $newpath;
$newfile->size = filesize($newpath);
$newfile->mime = mimeinfo('type', basename($image));
$newfile->width = $fileinfo[0];
$newfile->height = $fileinfo[1];
$newfile->timecreated = time();
$newfile->timemodified = time();
// Check dimensions.
$gallery->check_dimensions($newfile);
$newfile->path = $gallery->get_file_path($newpath);
if (!insert_record("imagegallery_images", $newfile)) {
@unlink($newpath);
error("Could not add new file {$file->name} to database!", "{$CFG->wwwroot}/mod/imagegallery/view.php?id={$gallery->cm->id}");
}
// Make thumbnail.
$thumb = $origpath . '/thumb_' . $newfile->name;
$gallery->make_thumbnail($newpath, $thumb);
}
}
fulldelete($fullpath);
@unlink($file->path);
}
示例11: setup_test_maxima_connection
/**
* Helper that sets up the maxima configuration. This allows maxima to be used
* from test classes that cannot subclass this one, for whatever reason.
*/
public static function setup_test_maxima_connection()
{
global $CFG;
if (!self::is_test_config_available()) {
throw new coding_exception('The calling code should call setup_test_maxima_connection ' . 'and skip the test in an appropriate way if it returns false.');
}
if (!defined('QTYPE_STACK_EXPECTED_VERSION')) {
if (!preg_match('~\\[ STACK-Maxima started, library version (\\d{10}) \\]~', file_get_contents($CFG->dirroot . '/question/type/stack/stack/maxima/stackmaxima.mac'), $matches)) {
throw new coding_exception('Maxima libraries version number not found in stackmaxima.mac.');
}
define('QTYPE_STACK_EXPECTED_VERSION', $matches[1]);
}
set_config('platform', QTYPE_STACK_TEST_CONFIG_PLATFORM, 'qtype_stack');
set_config('maximaversion', QTYPE_STACK_TEST_CONFIG_MAXIMAVERSION, 'qtype_stack');
set_config('castimeout', QTYPE_STACK_TEST_CONFIG_CASTIMEOUT, 'qtype_stack');
set_config('casresultscache', QTYPE_STACK_TEST_CONFIG_CASRESULTSCACHE, 'qtype_stack');
set_config('maximacommand', QTYPE_STACK_TEST_CONFIG_MAXIMACOMMAND, 'qtype_stack');
set_config('plotcommand', QTYPE_STACK_TEST_CONFIG_PLOTCOMMAND, 'qtype_stack');
set_config('casdebugging', QTYPE_STACK_TEST_CONFIG_CASDEBUGGING, 'qtype_stack');
set_config('mathsdisplay', 'mathjax', 'qtype_stack');
set_config('replacedollars', 0, 'qtype_stack');
set_config('stackmaximaversion', QTYPE_STACK_EXPECTED_VERSION, 'qtype_stack');
if (QTYPE_STACK_TEST_CONFIG_CASRESULTSCACHE == 'otherdb') {
set_config('cascachedbtype', QTYPE_STACK_TEST_CONFIG_CASCACHEDBTYPE, 'qtype_stack');
set_config('cascachedblibrary', QTYPE_STACK_TEST_CONFIG_CASCACHEDBLIBRARY, 'qtype_stack');
set_config('cascachedbhost', QTYPE_STACK_TEST_CONFIG_CASCACHEDBHOST, 'qtype_stack');
set_config('cascachedbname', QTYPE_STACK_TEST_CONFIG_CASCACHEDBNAME, 'qtype_stack');
set_config('cascachedbuser', QTYPE_STACK_TEST_CONFIG_CASCACHEDBUSER, 'qtype_stack');
set_config('cascachedbpass', QTYPE_STACK_TEST_CONFIG_CASCACHEDBPASS, 'qtype_stack');
set_config('cascachedbprefix', QTYPE_STACK_TEST_CONFIG_CASCACHEDBPREFIX, 'qtype_stack');
if (defined('QTYPE_STACK_TEST_CONFIG_CASCACHEDBSOCKET')) {
set_config('cascachedbsocket', QTYPE_STACK_TEST_CONFIG_CASCACHEDBSOCKET, 'qtype_stack');
}
}
if (defined('QTYPE_STACK_TEST_CONFIG_SERVERUSERPASS')) {
set_config('serveruserpass', QTYPE_STACK_TEST_CONFIG_SERVERUSERPASS, 'qtype_stack');
}
if (stack_cas_configuration::maxima_bat_is_missing()) {
stack_cas_configuration::create_maximalocal();
}
// Create the required directories inside moodledata.
make_upload_directory('stack');
make_upload_directory('stack/logs');
make_upload_directory('stack/plots');
make_upload_directory('stack/tmp');
}
示例12: outdated_langpack_is_installed
/**
* Downloads a langpack and fakes it being outdated
*
* @param string $langcode The language code (e.g. en)
* @Given /^outdated langpack \'([^\']*)\' is installed$/
*/
public function outdated_langpack_is_installed($langcode)
{
global $CFG;
require_once $CFG->libdir . '/componentlib.class.php';
// Download the langpack.
$dir = make_upload_directory('lang');
$installer = new lang_installer($langcode);
$result = $installer->run();
if ($result[$langcode] !== lang_installer::RESULT_INSTALLED) {
throw new coding_exception("Failed to install langpack '{$langcode}'");
}
$path = "{$dir}/{$langcode}/{$langcode}.md5";
if (!file_exists($path)) {
throw new coding_exception("Failed to find '{$langcode}' checksum");
}
file_put_contents($path, '000000');
}
示例13: block_community_download_course_backup
/**
* Download the community course backup and save it in file API
* @param integer $courseid
* @param string $huburl
* @return array 'privatefile' the file name saved in private area
* 'tmpfile' the file name saved in the moodledata temp dir (for restore)
*/
public function block_community_download_course_backup($course)
{
global $CFG, $USER;
require_once $CFG->libdir . "/filelib.php";
require_once $CFG->dirroot . "/course/publish/lib.php";
$params['courseid'] = $course->id;
$params['filetype'] = HUB_BACKUP_FILE_TYPE;
make_upload_directory('temp/backup');
$filename = md5(time() . '-' . $course->id . '-' . $USER->id . '-' . random_string(20));
$url = new moodle_url($course->huburl . '/local/hub/webservice/download.php', $params);
$path = $CFG->dataroot . '/temp/backup/' . $filename . ".mbz";
$fp = fopen($path, 'w');
$curlurl = $course->huburl . '/local/hub/webservice/download.php?filetype=' . HUB_BACKUP_FILE_TYPE . '&courseid=' . $course->id;
//send an identification token if the site is registered on the hub
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php';
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_registeredhub($course->huburl);
if (!empty($registeredhub)) {
$token = $registeredhub->token;
$curlurl .= '&token=' . $token;
}
$ch = curl_init($curlurl);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
$fs = get_file_storage();
$record = new stdClass();
$record->contextid = get_context_instance(CONTEXT_USER, $USER->id)->id;
$record->component = 'user';
$record->filearea = 'private';
$record->itemid = 0;
$record->filename = urlencode($course->fullname) . "_" . time() . ".mbz";
$record->filepath = '/downloaded_backup/';
if (!$fs->file_exists($record->contextid, $record->component, $record->filearea, 0, $record->filepath, $record->filename)) {
$fs->create_file_from_pathname($record, $CFG->dataroot . '/temp/backup/' . $filename . ".mbz");
}
$filenames = array();
$filenames['privatefile'] = $record->filename;
$filenames['tmpfile'] = $filename;
return $filenames;
}
示例14: definition
function definition()
{
global $CFG;
global $COURSE;
$mform =& $this->_form;
//-- General --------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
/// name
$mform->addElement('text', 'name', get_string('name'), array('size' => '60'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
/// text (description)
$mform->addElement('htmleditor', 'text', get_string('description'));
$mform->setType('text', PARAM_RAW);
//$mform->addRule('text', get_string('required'), 'required', null, 'client');
$mform->setHelpButton('text', array('writing', 'richtext'), false, 'editorhelpbutton');
/// introformat
$mform->addElement('format', 'introformat', get_string('format'));
//-- Stamp Collection------------------------------------------------------------
$mform->addElement('header', 'stampcollection', get_string('modulename', 'stampcoll'));
/// stampimage
make_upload_directory("{$COURSE->id}");
// Just in case
$images = array();
$coursefiles = get_directory_list("{$CFG->dataroot}/{$COURSE->id}", $CFG->moddata);
foreach ($coursefiles as $filename) {
if (mimeinfo("icon", $filename) == "image.gif") {
$images["{$filename}"] = $filename;
}
}
$mform->addElement('select', 'image', get_string('stampimage', 'stampcoll'), array_merge(array('' => get_string('default')), $images), 'a', 'b', 'c', 'd');
$mform->addElement('static', 'stampimageinfo', '', get_string('stampimageinfo', 'stampcoll'));
/// displayzero
$mform->addElement('selectyesno', 'displayzero', get_string('displayzero', 'stampcoll'));
$mform->setDefault('displayzero', 0);
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// add standard buttons, common to all modules
$this->add_action_buttons();
}
示例15: prepare_authorization
/**
* Generates a random token and stores it in a file in moodledata directory.
*
* @return array of the (string)filename and (string)password in this order
*/
public function prepare_authorization()
{
global $CFG;
make_upload_directory('mdeploy/auth/');
$attempts = 0;
$success = false;
while (!$success and $attempts < 5) {
$attempts++;
$passfile = $this->generate_passfile();
$password = $this->generate_password();
$now = time();
$filepath = $CFG->dataroot . '/mdeploy/auth/' . $passfile;
if (!file_exists($filepath)) {
$success = file_put_contents($filepath, $password . PHP_EOL . $now . PHP_EOL, LOCK_EX);
}
}
if ($success) {
return array($passfile, $password);
} else {
throw new moodle_exception('unable_prepare_authorization', 'core_plugin');
}
}