本文整理汇总了PHP中mkpath函数的典型用法代码示例。如果您正苦于以下问题:PHP mkpath函数的具体用法?PHP mkpath怎么用?PHP mkpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mkpath
function mkpath($path)
{
if (@mkdir($path) or file_exists($path)) {
return true;
}
return mkpath(dirname($path)) and mkdir($path);
}
示例2: write_file
function write_file($path, $data = '')
{
$dir = dirname($path);
if (!is_dir($dir)) {
mkpath($dir);
}
return file_put_contents($path, $data);
}
示例3: mkpath
function mkpath($path)
{
# Via Zingus J. Rinkle
if (@mkdir($path) or file_exists($path)) {
return true;
}
return mkpath(dirname($path)) and mkdir($path);
}
示例4: create_course_dirs
/**
* @brief create course directories
* @global type $webDir
* @param type $code
* @return boolean
*/
function create_course_dirs($code)
{
global $webDir;
$base = $webDir . "/courses/{$code}";
umask(0);
if (!(mkpath("{$base}") and mkpath("{$base}/image") and mkpath("{$base}/document") and mkpath("{$base}/dropbox") and mkpath("{$base}/page") and mkpath("{$base}/work") and mkpath("{$base}/group") and mkpath("{$base}/temp") and mkpath("{$base}/scormPackages") and mkpath($webDir . "/video/{$code}"))) {
return false;
}
return true;
}
示例5: build
public function build()
{
if (!file_exists($this->mPath)) {
mkpath($this->mPath);
}
$filename = date("Ymdhis") . ".sql";
/*echo "mysqldump -h "._DB_HOST." -u "._DB_USER." -p"._DB_PASS." "._DB_NAME." > ".$this->mPath.$filename;
die();*/
system("mysqldump -h " . _DB_HOST . " -u " . _DB_USER . " -p" . _DB_PASS . " " . _DB_NAME . " --skip-lock-tables > " . $this->mPath . "/" . $filename);
$sql = "INSERT INTO " . get_table("backuplist") . " SET filename='{$filename}',path='" . $this->mPath . "'";
$this->mDb->execute($sql);
return $filename;
}
示例6: mkpath
function mkpath($dir, $basepath)
{
global $switches;
$output = '';
if ($dh = opendir($dir)) {
$dirlist = array();
$cdok = false;
while (($file = readdir($dh)) !== false) {
if ($file == '.svn') {
continue;
}
$type = filetype($dir . '/' . $file);
if ($type == 'dir') {
if ($file != '.' && $file != '..') {
$dirlist[] = $file;
}
} else {
if (!$cdok) {
$output .= "cd " . $basepath . "\n";
$cdok = true;
}
$output .= " " . $file . "\n";
}
}
closedir($dh);
if (!$cdok && count($dirlist) == 0 && isset($switches['-e'])) {
$output .= "cd " . $basepath . "\n";
}
foreach ($dirlist as $d) {
$output .= mkpath($dir . '/' . $d, $basepath . '/' . $d);
}
} else {
echo "error opening directory {$dir}\n";
exit(1);
}
return $output;
}
示例7: doArchive
/**
* Do the main task of archiving a course.
*
* @param int $course_id
* @param string $course_code
* @return boolean $success
*/
function doArchive($course_id, $course_code)
{
global $webDir, $urlServer, $urlAppend, $siteName;
if (extension_loaded('zlib')) {
include 'include/pclzip/pclzip.lib.php';
}
$basedir = "{$webDir}/courses/archive/{$course_code}";
mkpath($basedir);
// Remove previous back-ups older than 10 minutes
cleanup("{$webDir}/courses/archive", 600);
$backup_date = date('Ymd-His');
$backup_date_short = date('Ymd');
$archivedir = $basedir . '/' . $backup_date;
mkpath($archivedir);
$zipfile = $basedir . "/{$course_code}-{$backup_date_short}.zip";
// backup subsystems from main db
$sql_course = "course_id = {$course_id}";
$archive_conditions = array('course' => "id = {$course_id}", 'user' => "id IN (SELECT user_id FROM course_user\n WHERE course_id = {$course_id})", 'course_user' => "course_id = {$course_id}", 'course_settings' => "course_id = {$course_id}", 'course_department' => "course = {$course_id}", 'course_module' => $sql_course, 'hierarchy' => "id IN (SELECT department FROM course_department\n WHERE course = {$course_id})", 'announcement' => $sql_course, 'group_properties' => $sql_course, 'group' => $sql_course, 'group_members' => "group_id IN (SELECT id FROM `group`\n WHERE course_id = {$course_id})", 'document' => $sql_course, 'link_category' => $sql_course, 'link' => $sql_course, 'ebook' => $sql_course, 'ebook_section' => "ebook_id IN (SELECT id FROM ebook\n WHERE course_id = {$course_id})", 'ebook_subsection' => "section_id IN (SELECT ebook_section.id\n FROM ebook, ebook_section\n WHERE ebook.id = ebook_id AND\n course_id = {$course_id})", 'course_units' => $sql_course, 'unit_resources' => "unit_id IN (SELECT id FROM course_units\n WHERE course_id = {$course_id})", 'forum' => $sql_course, 'forum_category' => $sql_course, 'forum_topic' => "forum_id IN (SELECT id FROM forum\n WHERE course_id = {$course_id})", 'forum_post' => "topic_id IN (SELECT forum_topic.id\n FROM forum, forum_topic\n WHERE forum.id = forum_id AND\n course_id = {$course_id})", 'forum_notify' => $sql_course, 'forum_user_stats' => $sql_course, 'course_description' => $sql_course, 'glossary' => $sql_course, 'glossary_category' => $sql_course, 'video_category' => $sql_course, 'video' => $sql_course, 'videolink' => $sql_course, 'dropbox_msg' => $sql_course, 'dropbox_attachment' => "msg_id IN (SELECT id from dropbox_msg WHERE course_id = {$course_id})", 'dropbox_index' => "msg_id IN (SELECT id from dropbox_msg WHERE course_id = {$course_id})", 'lp_learnPath' => $sql_course, 'lp_module' => $sql_course, 'lp_asset' => "module_id IN (SELECT module_id FROM lp_module WHERE course_id = {$course_id})", 'lp_rel_learnPath_module' => "learnPath_id IN (SELECT learnPath_id FROM lp_learnPath WHERE course_id = {$course_id})", 'lp_user_module_progress' => "learnPath_id IN (SELECT learnPath_id FROM lp_learnPath WHERE course_id = {$course_id})", 'wiki_properties' => $sql_course, 'wiki_acls' => "wiki_id IN (SELECT id FROM wiki_properties WHERE course_id = {$course_id})", 'wiki_pages' => "wiki_id IN (SELECT id FROM wiki_properties WHERE course_id = {$course_id})", 'wiki_pages_content' => "pid IN (SELECT id FROM wiki_pages\n WHERE wiki_id IN (SELECT id FROM wiki_properties\n WHERE course_id = {$course_id}))", 'poll' => $sql_course, 'poll_question' => "pid IN (SELECT pid FROM poll WHERE course_id = {$course_id})", 'poll_answer_record' => "pid IN (SELECT pid FROM poll WHERE course_id = {$course_id})", 'poll_question_answer' => "pqid IN (SELECT pqid FROM poll_question\n WHERE pid IN (SELECT pid FROM poll\n WHERE course_id = {$course_id}))", 'assignment' => $sql_course, 'assignment_submit' => "assignment_id IN (SELECT id FROM assignment\n WHERE course_id = {$course_id})", 'gradebook' => $sql_course, 'gradebook_activities' => "gradebook_id IN (SELECT id FROM gradebook\n WHERE course_id = {$course_id})", 'gradebook_book' => "gradebook_activity_id IN (SELECT gradebook_activities.id FROM gradebook_activities, gradebook\n WHERE gradebook.course_id = {$course_id} AND gradebook_activities.gradebook_id = gradebook.id)", 'gradebook_users' => "gradebook_id IN (SELECT id FROM gradebook WHERE course_id = {$course_id})", 'attendance' => $sql_course, 'attendance_activities' => "attendance_id IN (SELECT id FROM attendance\n WHERE course_id = {$course_id})", 'attendance_book' => "attendance_activity_id IN (SELECT attendance_activities.id FROM attendance_activities, attendance\n WHERE attendance.course_id = {$course_id} AND attendance_activities.attendance_id = attendance.id)", 'attendance_users' => "attendance_id IN (SELECT id FROM attendance WHERE course_id = {$course_id})", 'agenda' => $sql_course, 'exercise' => $sql_course, 'exercise_question' => $sql_course, 'exercise_answer' => "question_id IN (SELECT id FROM exercise_question\n WHERE course_id = {$course_id})", 'exercise_user_record' => "eid IN (SELECT id FROM exercise WHERE course_id = {$course_id})", 'exercise_with_questions' => "question_id IN (SELECT id FROM exercise_question\n WHERE course_id = {$course_id}) OR\n exercise_id IN (SELECT id FROM exercise\n WHERE course_id = {$course_id})", 'bbb_session' => "course_id IN (SELECT id FROM bbb_session WHERE course_id = {$course_id})", 'blog_post' => "id IN (SELECT id FROM blog_post WHERE course_id = {$course_id})", 'comments' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'rating' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'rating_cache' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'note' => "(reference_obj_course IS NOT NULL AND reference_obj_course = {$course_id})");
foreach ($archive_conditions as $table => $condition) {
backup_table($archivedir, $table, $condition);
}
file_put_contents("{$archivedir}/config_vars", serialize(array('urlServer' => $urlServer, 'urlAppend' => $urlAppend, 'siteName' => $siteName, 'version' => get_config('version'))));
// $htmldir is not needed anywhere
//$htmldir = $archivedir . '/html';
// create zip file
$zipCourse = new PclZip($zipfile);
$result1 = $zipCourse->create($archivedir, PCLZIP_OPT_REMOVE_PATH, "{$webDir}/courses/archive");
$result2 = $zipCourse->add("{$webDir}/courses/{$course_code}", PCLZIP_OPT_REMOVE_PATH, "{$webDir}/courses/{$course_code}", PCLZIP_OPT_ADD_PATH, "{$course_code}/{$backup_date}/html");
$result3 = $zipCourse->add("{$webDir}/video/{$course_code}", PCLZIP_OPT_REMOVE_PATH, "{$webDir}/video/{$course_code}", PCLZIP_OPT_ADD_PATH, "{$course_code}/{$backup_date}/video_files");
$success = true;
if ($result1 === 0 || $result2 === 0 || $result3 === 0) {
$success = false;
}
removeDir($archivedir);
return $success;
}
示例8: mkpath
/**
* Crea un path.
*
* @param string $path ruta a crear
* @return boolean
*/
function mkpath($path)
{
$path = join_path(func_get_args());
if (@mkdir($path) or file_exists($path)) {
return true;
}
return mkpath(dirname($path)) and mkdir($path);
}
示例9: unserialize
<?php
/*ini_set('error_reporting', E_ALL); //打开所有的错误级别
ini_set('display_errors', 1); //显示错误*/
require_once "../../configs/initdb.php";
$root = "/data/wwwroot/vhost/";
//$db->debug=1;
$data = unserialize($_POST["data"]);
if ($data["domain"]) {
$path = $root . $data["domain"] . ".feidaoyu.com";
mkpath($path . "/htdocs");
$user = $data["domain"] . random(2);
$password = random(6);
$start = date("Y-m-d");
$end = date("Y-m-d", strtotime($data["year"] . "year"));
$vpsid = $data["vpsid"];
$sql = "INSERT INTO `ftpuser` VALUES (null, '{$user}','{$vpsid}', '{$password}', 5500, 5500, '{$path}', '/sbin/nologin', 10, '{$start} 00:00:00', '{$end} 00:00:00');";
$db->execute($sql);
$fp = fopen("{$path}/htdocs/index.html", "a+");
fwrite($fp, "Hello world! by feidaoyu.com");
fclose($fp);
system("chmod -R 777 {$path}");
$sql = "CREATE DATABASE `{$user}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
$db->execute($sql);
$sql = "GRANT ALL PRIVILEGES ON {$user}.* TO {$user}@localhost IDENTIFIED BY '{$password}';";
$db->execute($sql);
$rs["domain"] = $data["domain"] . ".feidaoyu.com";
$rs["user"] = $user;
$rs["password"] = $password;
$rs["dbhost"] = "localhost";
$rs["dbname"] = $user;
示例10: writeBigOrderSkuLog
function writeBigOrderSkuLog($file, $data)
{
$tmp_dir = dirname($file);
if (!is_dir($tmp_dir)) {
mkpath($tmp_dir);
}
if (!($handle = fopen($file, 'a'))) {
return false;
}
if (flock($handle, LOCK_EX)) {
if (fwrite($handle, $data) === FALSE) {
return false;
}
flock($handle, LOCK_UN);
}
fclose($handle);
return true;
}
示例11: download_images_for_page
function download_images_for_page($target)
{
echo "target = {$target}\n";
# Download the web page
$web_page = http_get($target, $referer = "");
# Update the target in case there was a redirection
$target = $web_page['STATUS']['url'];
# Strip file name off target for use as page base
$page_base = get_base_page_address($target);
# Identify the directory where iamges are to be saved
$save_image_directory = "saved_images_" . str_replace("http://", "", $page_base);
# Parse the image tags
$img_tag_array = parse_array($web_page['FILE'], "<img", ">");
if (count($img_tag_array) == 0) {
echo "No images found at {$target}\n";
exit;
}
# Echo the image source attribute from each image tag
for ($xx = 0; $xx < count($img_tag_array); $xx++) {
$image_path = get_attribute($img_tag_array[$xx], $attribute = "src");
echo " image: " . $image_path;
$image_url = resolve_address($image_path, $page_base);
if (get_base_domain_address($page_base) == get_base_domain_address($image_url)) {
# Make image storage directory for image, if one doesn't exist
$directory = substr($image_path, 0, strrpos($image_path, "/"));
$directory = str_replace(":", "-", $directory);
$image_path = str_replace(":", "-", $image_path);
clearstatcache();
// clear cache to get accurate directory status
if (!is_dir($save_image_directory . "/" . $directory)) {
mkpath($save_image_directory . "/" . $directory);
}
# Download the image, report image size
$this_image_file = download_binary_file($image_url, $ref = "");
echo " size: " . strlen($this_image_file);
# Save the image
if (stristr($image_url, ".jpg") || stristr($image_url, ".gif") || stristr($image_url, ".png")) {
$fp = fopen($save_image_directory . "/" . $image_path, "w");
fputs($fp, $this_image_file);
fclose($fp);
echo "\n";
}
} else {
echo "\nSkipping off-domain image.\n";
}
}
}
示例12: mkpath
/**
* 创建一条路径(递归地创建文件夹)
* @param string $path
* @param int $mode
* @return bool
*/
function mkpath($path, $mode = 0777)
{
if (is_dir($path)) {
return true;
}
if (@mkdir($path, $mode)) {
@touch($path . '/index.html');
return true;
}
/* 递归的创建父亲文件夹 */
if (!mkpath(dirname($path), $mode)) {
return false;
}
/* 创建自身 */
$result = @mkdir($path, $mode);
if ($result) {
@touch($path . '/index.html');
}
return $result;
}
示例13: jikes_compile
function jikes_compile($src_path, $target_path, $verbose, $extra_classpath = '')
{
// Initialize path to jikes. First assume jikes is in the same directory as this script
$jikes_pp = explode('/', __FILE__);
$jikes_pp[count($jikes_pp) - 1] = 'jikes';
$jikes_cmd = implode('/', $jikes_pp);
if (!file_exists($jikes_cmd)) {
$jikes_cmd = $jikes_cmd . '.exe';
if (!file_exists($jikes_cmd)) {
$jikes_cmd = 'jikes';
// Try path
}
}
$src_path = realpath($src_path);
mkpath($target_path, 0750);
$target_path = realpath($target_path);
$System = new JavaClass("java.lang.System");
$Properties = $System->getProperties();
$java_home = $Properties->get("java.home");
$classpath = $Properties->get("java.class.path");
if ($extra_classpath != '') {
$classpath .= ":{$extra_classpath}";
}
$bootclasspath = $Properties->get("sun.boot.class.path");
$target_version = $Properties->get("java.specification.version");
clearstatcache();
// Neccessary, otherwise file modification dates and calls to "file_exists" get cached.
$files = dir_pattern_scan($src_path, "\\.java\$", '/', 6);
$files = filter_unmodified($files, $src_path, $target_path);
if (count($files) == 0) {
return 0;
}
$filearg = implode(' ', $files);
$output = array();
if ($verbose) {
$command = "{$jikes_cmd} -Xstdout -verbose ";
} else {
$command = "{$jikes_cmd} -Xstdout ";
}
$command .= "-bootclasspath {$bootclasspath} -classpath {$classpath}:{$target_path} -target {$target_version} -source {$target_version} ";
$command .= "-sourcepath {$src_path} -d {$target_path} {$filearg}";
$retval = -99999;
exec($command, $output, $retval);
if ($retval == 126) {
throw new JavaCompilationException($command, "No execute permission for '{$jikes_cmd}'", $retval);
}
if ($retval == 127) {
throw new JavaCompilationException($command, "Jikes Executable '{$jikes_cmd}' not found", $retval);
}
if ($retval != 0) {
throw new JavaCompilationException($command, implode("\n", $output), $retval);
}
return count($files);
}
示例14: date
$newTag->execute();
}
$file->setType(issetOrBlank($_POST['file-type']));
$file->setUploadDate(date('Y-m-d H:i:s'));
$file->setActive(1);
$file->setAliasID(0);
//echo UPLOADS_DIR;
$DATEPATH = date('Y') . DIRECTORY_SEPARATOR . date('m') . DIRECTORY_SEPARATOR;
$uploadTo = $DATEPATH . $file->getCampus() . DIRECTORY_SEPARATOR . $file->getFaculty() . DIRECTORY_SEPARATOR . $file->getCategory() . DIRECTORY_SEPARATOR;
$uploadTo = issetOrBlank($uploadTo);
//$uploadTo = "";
//echo $uploadTo;
//Ensure that the directory path exists
//echo UPLOADS_DIR;
//exit;
mkpath(UPLOADS_DIR . $uploadTo);
//echo UPLOADS_DIR.$uploadTo;
$uploaded = 0;
if (!file_exists(UPLOADS_DIR . $uploadTo)) {
//could not create directory
echo '<h1 class="error">Could not create directory for upload</h1>';
} else {
if (isset($_FILES["file-file"])) {
//file uploaded
$targetFile = UPLOADS_DIR . $uploadTo . $_FILES["file-file"]['name'];
if (!file_exists($targetFile)) {
if (move_uploaded_file($_FILES["file-file"]["tmp_name"], issetOrBlank($targetFile))) {
$uploaded = 1;
}
} else {
echo '<h1 class="error">File already Exists!</h1>';
示例15: get_thumbnail
function get_thumbnail(&$dest, &$width, &$height, $id, $scale = 0, $format = '%f-thumb-%wx%h-%i%x', $dest_type = 'auto', $square = false)
{
if (empty($this->src_file)) {
return false;
}
if (!file_exists($this->src_file)) {
return false;
}
if (!$this->is_available()) {
global $mt;
$mt->warning_log($mt->translate('GD support has not been available. Please install GD support.'));
return false;
}
# Get source image information
list($this->src_w, $this->src_h, $this->src_type, $src_attr) = getimagesize($this->src_file);
# Load source image
$src_img;
switch ($this->src_type) {
case 1:
#GIF
$src_img = @imagecreatefromgif($this->src_file);
break;
case 2:
#JPEG
$src_img = @imagecreatefromjpeg($this->src_file);
break;
case 3:
#PNG
$src_img = @imagecreatefrompng($this->src_file);
break;
default:
#Unsupported format
return false;
}
if (empty($src_img)) {
return false;
}
# Calculate thumbnail size
list($thumb_w, $thumb_h, $thumb_w_name, $thumb_h_name) = $this->_calculate_size($width, $height, $scale, $square);
$width = $thumb_w;
$height = $thumb_h;
# Decide a destination file name
if (empty($dest)) {
$dest = $this->_make_dest_name($thumb_w_name, $thumb_h_name, $format, $dest_type, $id);
}
# Generate
if (!file_exists($dest)) {
$dir_name = dirname($dest);
if (!file_exists($dir_name)) {
mkpath($dir_name, 0777);
}
if (!is_writable($dir_name)) {
imagedestroy($src_img);
return false;
}
# if square modifier is enable, crop & resize
$src_x = 0;
$src_y = 0;
$target_w = $this->src_w;
$target_h = $this->src_h;
if ($square) {
if ($this->src_w > $this->src_h) {
$src_x = (int) ($this->src_w - $this->src_h) / 2;
$src_y = 0;
$target_w = $this->src_h;
} else {
$src_x = 0;
$src_y = (int) ($this->src_h - $this->src_w) / 2;
$target_h = $this->src_w;
}
}
# Create thumbnail
$dst_img = imagecreatetruecolor($thumb_w, $thumb_h);
$result = imagecopyresampled($dst_img, $src_img, 0, 0, $src_x, $src_y, $thumb_w, $thumb_h, $target_w, $target_h);
$output = $this->src_type;
if ($dest_type != 'auto') {
$output = strtolower($dest_type) == 'gif' ? 1 : strtolower($dest_type) == 'jpeg' ? 2 : strtolower($dest_type) == 'png' ? 3 : $src_type;
}
switch ($output) {
case 1:
#GIF
imagegif($dst_img, $dest);
break;
case 2:
#JPEG
imagejpeg($dst_img, $dest);
break;
case 3:
#PNG
imagepng($dst_img, $dest);
break;
}
imagedestroy($dst_img);
}
imagedestroy($src_img);
return true;
}