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


PHP make_dir函数代码示例

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


在下文中一共展示了make_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SaveHTTPFile

function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
    //记录程序开始的时间
    $BeginTime = getmicrotime();
    //取得文件名
    $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
    make_dir(dirname($fFileSaveName));
    //取得文件的内容
    ob_start();
    readfile($fFileHTTPPath);
    $img = ob_get_contents();
    ob_end_clean();
    //$size = strlen($img);
    //保存到本地
    $fp2 = @fopen($fFileSaveName, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    /*加水印代码*/
    require_once ROOT_PATH . 'includes/cls_image.php';
    $ext = get_extension($fFileSaveName);
    $fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
    if (CopyFiles($fFileSaveName)) {
        $image = new cls_image();
        $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
    }
    if ($ext == 'gif' || $ext == '.gif') {
        back_JPG_to_GIF($fFileSaveName);
    }
    /*加水印代码--end*/
    //记录程序运行结束的时间
    $EndTime = getmicrotime();
    //返回运行时间
    return $EndTime - $BeginTime;
}
开发者ID:norain2050,项目名称:benhu,代码行数:34,代码来源:ServerXMLHTTP.php

示例2: mb_template

 function mb_template($temp_file = null, $options = null, $caller = null)
 {
     if ($options !== null) {
         foreach ($options as $k => $v) {
             if ($v !== null) {
                 $this->{$k} = $v;
             }
         }
     }
     $this->caller = $caller ? $caller : $this;
     if ($temp_file != null) {
         $this->temp_file = $temp_file;
     }
     if (substr($this->temp_dir, -1, 1) != '/' && substr($this->temp_dir, -1, 1) != '\\') {
         $this->temp_dir .= '/';
     }
     if (substr($this->compile_dir, -1, 1) != '/' && substr($this->compile_dir, -1, 1) != '\\') {
         $this->compile_dir .= '/';
     }
     $pos = strrpos($temp_file, "/");
     if (false !== $pos) {
         $dir_part = substr($temp_file, 0, $pos + 1);
         $this->temp_dir .= $dir_part;
         $this->compile_dir .= $dir_part;
         $this->temp_file = substr($temp_file, $pos + 1, strlen($temp_file));
     }
     if (!file_exists($this->temp_dir . $this->temp_file)) {
         $this->_raise_error('Template File "' . $this->temp_dir . $this->temp_file . '" doesn\'t exists.');
     }
     if (!make_dir($this->compile_dir)) {
         $this->_raise_error('Cont\'t create template compile dir "' . $this->compile_dir . '".');
     }
 }
开发者ID:duanshuyong0,项目名称:Murloc,代码行数:33,代码来源:template.class.php

示例3: insert_page

function insert_page($cat_id, $title, $parent_cat_id)
{
    global $database;
    $title = trim($title);
    if (1 > $cat_id) {
        return;
    }
    $parent = (int) $database->get_one("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE cat_id = {$parent_cat_id} LIMIT 1");
    $parent_section = '';
    $parent_titles = array_reverse(get_parent_titles($parent));
    foreach ($parent_titles as $parent_title) {
        $parent_section .= page_filename($parent_title) . '/';
    }
    if ($parent_section == '/') {
        $parent_section = '';
    }
    $link = '/' . $parent_section . page_filename($title);
    $filename = WB_PATH . PAGES_DIRECTORY . $link . '.php';
    make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
    $get_same_page = $database->query("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE link = '{$link}' LIMIT 1");
    if ($get_same_page->numRows() > 0) {
        echo "Page {$link} exists.";
        return;
    }
    $q = "INSERT INTO " . TABLE_PREFIX . "pages (cat_id,  page_title, menu_title, parent, template, target, visibility, searching, menu, language, admin_groups, viewing_groups, modified_when, modified_by)\n        VALUES ({$cat_id},  '{$title}', '{$title}', {$parent}, '', '', 'public', '1', '3', 'CS', '1,2', '1', '" . time() . "', 1)";
    $pages = $database->query($q);
    if ($database->is_error()) {
        echo $database->get_error();
        return;
    }
    $page_id = $pages->handle->insert_id;
    return $page_id;
}
开发者ID:tomasjakl,项目名称:parse-pohoda-xml,代码行数:33,代码来源:parse-categories.php

示例4: init_lang_tpl

 public static function init_lang_tpl()
 {
     $dir = PHPDISK_ROOT . 'system/global/';
     make_dir($dir);
     $file = $dir . 'lang_settings.inc.php';
     file_exists($file) ? require_once $file : lang_cache();
     $file = $dir . 'tpl_settings.inc.php';
     file_exists($file) ? require_once $file : tpl_cache();
     if (count($tpl_settings)) {
         foreach ($tpl_settings as $v) {
             if ($v[actived] && $v[tpl_type] == 'user') {
                 $user_tpl_dir = $v[tpl_name];
             }
             if ($v[actived] && $v[tpl_type] == 'admin') {
                 $admin_tpl_dir = $v[tpl_name];
             }
         }
     }
     if (count($lang_settings)) {
         foreach ($lang_settings as $v) {
             if ($v[actived]) {
                 $lang_name = $v[lang_name];
             }
         }
     }
     $user_tpl_dir = $user_tpl_dir ? "templates/{$user_tpl_dir}/" : 'templates/default/';
     $admin_tpl_dir = $admin_tpl_dir ? "templates/{$admin_tpl_dir}/" : 'templates/admin/';
     $lang_name = $lang_name ? $lang_name : 'zh_cn';
     return array('user_tpl_dir' => $user_tpl_dir, 'admin_tpl_dir' => $admin_tpl_dir, 'lang_name' => $lang_name);
 }
开发者ID:saintho,项目名称:phpdisk,代码行数:30,代码来源:core.class.php

示例5: create_csv_file

function create_csv_file($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'create_csv';
    # merge opts
    $opts = merge_opts($opts, $pipe, 'file');
    # get file opt
    $file = get_opt($prefix, $opts, 'file');
    if (!check_opt_set_type($cmd, $file, 'file', 'string')) {
        return false;
    }
    # get fields opt
    $fields = get_opt($prefix, $opts, 'fields');
    if (!check_opt_set_type($cmd, $fields, 'fields', 'array_of_strings')) {
        return false;
    }
    # get data opt
    $data = get_opt($prefix, $opts, 'data');
    if (!check_opt_set_type($cmd, $data, 'data', 'array')) {
        return false;
    }
    # make parent dir
    if (!make_dir($opts, dirname($file))) {
        return false;
    }
    # create temp file
    $file_handle = @fopen('php://temp/csv-out', 'w');
    if (!$file_handle) {
        return error($cmd, "cannot create temp CSV file");
    }
    # output the fields
    if (!fputcsv($file_handle, $fields)) {
        return error($cmd, "could not output the fields CSV file : {$file}");
    }
    # output the data
    foreach ($data as $line_no => $line) {
        if (!fputcsv($file_handle, $line)) {
            return error($cmd, "could not output line {$line_no} to CSV file : {$file}");
        }
    }
    # grab contents and close temp file
    rewind($file_handle);
    $text = stream_get_contents($file_handle);
    fclose($file_handle);
    # create file and
    if (!file_put_contents($file, $text)) {
        return error($cmd, "cannot store CSV data to file : {$file}");
    }
    # report
    $lines = count($data);
    debug_echo($cmd, "CSV file created ({$lines} lines) : {$file}");
    # return
    if ($pipe === false) {
        return $file;
    }
    return array('file' => $file);
}
开发者ID:simpl,项目名称:datapipe,代码行数:57,代码来源:csv.php

示例6: cover_image

function cover_image($description, $upload_dir)
{
    make_dir($upload_dir);
    if (preg_match('/<img.+src="(.+?)">/i', $description, $image)) {
        $file_name = random(rand(8, 12)) . '.jpg';
        if (file_put_contents($upload_dir . '/' . $file_name, file_get_contents($image[1]))) {
            return substr($upload_dir . '/' . $file_name, 3);
        }
    }
    return '';
}
开发者ID:reake,项目名称:share-travel,代码行数:11,代码来源:baidu.php

示例7: make_dir

 function make_dir($path, $write_file = 1)
 {
     if (!is_dir($path)) {
         $str = dirname($path);
         if ($str) {
             make_dir($str . '/');
             @mkdir($path, 0777);
             if ($write_file) {
                 file_put_contents($path . 'index.htm', 'PHPDisk');
             }
         }
     }
 }
开发者ID:saintho,项目名称:phpdisk,代码行数:13,代码来源:core.post.php

示例8: upload_image

 /**
  * 图片上传的处理函数
  *
  * @access      public
  * @param       array       upload       包含上传的图片文件信息的数组
  * @param       array       dir          文件要上传在$this->data_dir下的目录名。如果为空图片放在则在$this->images_dir下以当月命名的目录下
  * @param       array       img_name     上传图片名称,为空则随机生成
  * @return      mix         如果成功则返回文件名,否则返回false
  */
 function upload_image($upload, $dir = '', $img_name = '')
 {
     /* 没有指定目录默认为根目录images */
     if (empty($dir)) {
         /* 创建当月目录 */
         $dir = date('Ym');
         $dir = ROOT_PATH . $this->images_dir . '/' . $dir . '/';
     } else {
         /* 创建目录 */
         $dir = ROOT_PATH . $this->data_dir . '/' . $dir . '/';
         if ($img_name) {
             $img_name = $dir . $img_name;
             // 将图片定位到正确地址
         }
     }
     /* 如果目标目录不存在,则创建它 */
     if (!file_exists($dir)) {
         if (!make_dir($dir)) {
             /* 创建目录失败 */
             $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
             $this->error_no = ERR_DIRECTORY_READONLY;
             return false;
         }
     }
     if (empty($img_name)) {
         $img_name = $this->unique_name($dir);
         $img_name = $dir . $img_name . $this->get_filetype($upload['name']);
     }
     if (!$this->check_img_type($upload['type'])) {
         $this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
         $this->error_no = ERR_INVALID_IMAGE_TYPE;
         return false;
     }
     /* 允许上传的文件类型 */
     $allow_file_types = '|GIF|JPG|JEPG|PNG|BMP|SWF|';
     if (!check_file_type($upload['tmp_name'], $img_name, $allow_file_types)) {
         $this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
         $this->error_no = ERR_INVALID_IMAGE_TYPE;
         return false;
     }
     if ($this->move_file($upload, $img_name)) {
         return str_replace(ROOT_PATH, '', $img_name);
     } else {
         $this->error_msg = sprintf($GLOBALS['_LANG']['upload_failure'], $upload['name']);
         $this->error_no = ERR_UPLOAD_FAILURE;
         return false;
     }
 }
开发者ID:diandengs,项目名称:RechoPHP,代码行数:57,代码来源:class.Image.php

示例9: make_dir

function make_dir($node, $path = null, $root = null)
{
    if (is_null($root)) {
        $root = ".." . DIRECTORY_SEPARATOR;
    }
    $root = trim($root, "/") . DIRECTORY_SEPARATOR;
    $keep = false;
    $ignore = false;
    if ($node == "#keep#") {
        $keep = true;
        $node = null;
    } else {
        if ($node == "#ignore#") {
            $ignore = true;
            $node = null;
        }
    }
    if (!is_null($node) && !is_array($node)) {
        $path = $node;
    }
    if (!is_null($path)) {
        $root = $root . $path . DIRECTORY_SEPARATOR;
        if (!file_exists($root)) {
            echo "> dir " . $root . "\n";
            mkdir($root);
        }
    }
    if ($keep) {
        $keep = $root . ".gitkeep";
        if (!file_exists($keep)) {
            echo "> file " . $keep . "\n";
            file_put_contents($keep, "");
        }
    } else {
        if ($ignore) {
            $ignore = $root . ".gitignore";
            if (!file_exists($ignore)) {
                echo "> file " . $ignore . "\n";
                file_put_contents($ignore, "*");
            }
        }
    }
    if (is_array($node)) {
        foreach ($node as $k => $v) {
            make_dir($v, $k, $root);
        }
    }
}
开发者ID:jura-php,项目名称:jura,代码行数:48,代码来源:install.php

示例10: __construct

 function __construct($opts)
 {
     $this->build_config($opts['config'], $opts['template']);
     // fix paths
     foreach (array('db', 'img') as $path) {
         $this->cfg->rrd->paths->{$path} = absolute_path((string) $this->cfg->rrd->paths->{$path}, $opts['paths'][$path]);
         if (!is_dir((string) $this->cfg->rrd->paths->{$path})) {
             // create a path if not exsits
             echo 'creating ' . $this->cfg->rrd->paths->{$path} . PHP_EOL;
             make_dir((string) $this->cfg->rrd->paths->{$path});
         }
     }
     $this->rrdtool = new rrdtool($this->cfg->rrd);
     //			echo $this->cfg->asXML() . PHP_EOL;
     //			print_r($this->cfg);
     //			exit;
 }
开发者ID:ngorchilov,项目名称:lgr,代码行数:17,代码来源:rrd.main.class.php

示例11: createNewsAccessFile

/**
 *
 * @category        modules
 * @package         news
 * @author          WebsiteBaker Project
 * @copyright       WebsiteBaker Org. e.V.
 * @link            http://websitebaker.org/
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.3
 * @requirements    PHP 5.3.6 and higher
 * @version         $Id: save_post.php 1538 2011-12-10 15:06:15Z Luisehahne $
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb_svn/wb280/tags/2.8.3/wb/modules/news/save_post.php $
 * @lastmodified    $Date: 2011-12-10 16:06:15 +0100 (Sa, 10. Dez 2011) $
 *
 */
function createNewsAccessFile($newLink, $oldLink, $page_id, $section_id, $post_id)
{
    global $admin, $MESSAGE;
    $sPagesPath = WB_PATH . PAGES_DIRECTORY;
    $sPostsPath = $sPagesPath . '/posts';
    // create /posts/ - directory if not exists
    if (!file_exists($sPostsPath)) {
        if (is_writable($sPagesPath)) {
            make_dir(WB_PATH . PAGES_DIRECTORY . '/posts/');
        } else {
            $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
        }
    }
    // check if /posts/ - dir is writable
    if (!is_writable($sPostsPath . '/')) {
        $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
    }
    /*
       // delete old accessfile if link has changed
        if (($newLink != $oldLink) && (is_writable($sPostsPath.$oldLink.PAGE_EXTENSION))) {
           if (!unlink($sPostsPath.$oldLink.PAGE_EXTENSION)) {
              $admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'].' - '.$oldLink);
           }
        }
    */
    // delete old accessfile if link has changed
    if ($newLink != $oldLink && is_writable($sPagesPath . $oldLink . PAGE_EXTENSION)) {
        if (!unlink($sPagesPath . $oldLink . PAGE_EXTENSION)) {
            $admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'] . ' - ' . $oldLink);
        }
    }
    // all ok, now create new accessfile
    $newFile = $sPagesPath . $newLink . PAGE_EXTENSION;
    // $backSteps = preg_replace('/^'.preg_quote(WB_PATH).'/', '', $sPostsPath);
    $backSteps = preg_replace('@^' . preg_quote(WB_PATH) . '@', '', $sPostsPath);
    $backSteps = str_repeat('../', substr_count($backSteps, '/'));
    $content = '<?php' . "\n" . '// *** This file is generated by WebsiteBaker Ver.' . WB_VERSION . "\n" . '// *** Creation date: ' . date('c') . "\n" . '// *** Do not modify this file manually' . "\n" . '// *** WB will rebuild this file from time to time!!' . "\n" . '// *************************************************' . "\n" . "\t" . '$page_id      = ' . $page_id . ';' . "\n" . "\t" . '$section_id   = ' . $section_id . ';' . "\n" . "\t" . '$post_id      = ' . $post_id . ';' . "\n" . "\t" . '$post_section = ' . $section_id . ';' . "\n" . "\t" . 'require(\'' . $backSteps . 'index.php\');' . "\n" . '// *************************************************' . "\n";
    if (file_put_contents($newFile, $content) !== false) {
        // Chmod the file
        change_mode($newFile);
    } else {
        $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'], ADMIN_URL . '/pages/modify.php?page_id=' . $page_id);
        // $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'].': '.$newFile);
    }
}
开发者ID:WebsiteBaker-modules,项目名称:News,代码行数:60,代码来源:save_post.php

示例12: wxch_file

function wxch_file($upload)
{
    $dir = date('Ymdh');
    $img_path = 'images' . '/' . $dir . '/';
    $dir = ROOT_PATH . 'images' . '/' . $dir . '/';
    if (!file_exists($dir)) {
        if (!make_dir($dir)) {
            $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
            $this->error_no = ERR_DIRECTORY_READONLY;
            return false;
        }
    }
    $file_name = random_filename();
    $path_name = $dir . $file_name;
    file_put_contents($path_name, $upload);
    $img_name = $img_path . $file_name;
    return $img_name;
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:18,代码来源:userinfo.php

示例13: rename_recursive_dirs

function rename_recursive_dirs($dirsource, $dirdest, $deep = 0)
{
    if (true === is_dir($dirsource)) {
        $dir = dir($dirsource);
        while ($file = $dir->read()) {
            if ($file[0] != ".") {
                if (!is_dir($dirsource . "/" . $file)) {
                    copy($dirsource . "/" . $file, $dirdest . "/" . $file);
                    change_mode($dirdest . "/" . $file);
                } else {
                    make_dir($dirdest . "/" . $file);
                    rename_recursive_dirs($dirsource . "/" . $file, $dirdest . '/' . $file, $deep + 1);
                }
            }
        }
        $dir->close();
    }
    if ($deep == 0) {
        rm_full_dir($dirsource);
    }
    return true;
}
开发者ID:pixelhulk,项目名称:LEPTON,代码行数:22,代码来源:function.rename_recursive_dirs.php

示例14: init_lang_tpl

 public static function init_lang_tpl()
 {
     global $C, $settings, $auth;
     $dir = PHPDISK_ROOT . 'system/global/';
     make_dir($dir);
     $file = $dir . 'lang_settings.inc.php';
     file_exists($file) ? require_once $file : lang_cache();
     $file = $dir . 'tpl_settings.inc.php';
     file_exists($file) ? require_once $file : tpl_cache();
     if (count($tpl_settings)) {
         foreach ($tpl_settings as $v) {
             if ($v[actived] && $v[tpl_type] == 'user') {
                 $user_tpl_dir = $v[tpl_name];
             }
             if ($v[actived] && $v[tpl_type] == 'admin') {
                 $admin_tpl_dir = $v[tpl_name];
             }
         }
     }
     if (count($lang_settings)) {
         foreach ($lang_settings as $v) {
             if ($v[actived]) {
                 $lang_name = $v[lang_name];
             }
         }
     }
     if ($settings[open_switch_tpls]) {
         $ptpl = gpc('ptpl', 'C', '');
         $user_tpl_dir = $C[tpl_name] = $ptpl ? check_template($ptpl) ? $ptpl : $user_tpl_dir : $user_tpl_dir;
         //$C[tpl_name] = $user_tpl_dir;
     }
     $arr = get_template_info($user_tpl_dir);
     $is_fms = $arr['template_core'] == 'fms' && $auth[open_fms] ? 1 : 0;
     $user_tpl_dir = $user_tpl_dir ? "templates/{$user_tpl_dir}/" : 'templates/default/';
     $admin_tpl_dir = $admin_tpl_dir ? "templates/{$admin_tpl_dir}/" : 'templates/admin/';
     $lang_name = $lang_name ? $lang_name : 'zh_cn';
     return array('user_tpl_dir' => $user_tpl_dir, 'admin_tpl_dir' => $admin_tpl_dir, 'lang_name' => $lang_name, 'fms' => $is_fms);
 }
开发者ID:saintho,项目名称:phpdisk,代码行数:38,代码来源:core.class.php

示例15: write

 function write($log_type, $str)
 {
     $log_arr = array('cache_log', 'db_log');
     if (in_array($log_type, $log_arr)) {
         $log_dir = PHPDISK_ROOT . "system/{$log_type}/";
         $log_file = $log_dir . date('Ymd') . '.php';
         make_dir($log_dir);
         $str = '<?php exit; ?>' . $str . LF;
         $fp = fopen($log_file, 'ab');
         if (!$fp) {
             die("Logger: Can not open file <b>{$log_type}</b> .code:1");
         }
         if (is_writable($log_file)) {
             if (!fwrite($fp, $str)) {
                 die("Logger: Can not write file <b>{$log_type}</b> .code:2");
             }
         } else {
             die("Logger: Can not write file <b>{$log_type}</b> .code:3");
         }
         fclose($fp);
     } else {
         die("Logger: Logger write error!");
     }
 }
开发者ID:saintho,项目名称:phpdisk,代码行数:24,代码来源:logger.class.php


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