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


PHP mkdir_p函数代码示例

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


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

示例1: fetch

 protected function fetch($pTplName, &$pTplSource, &$pTplTime)
 {
     global $gBitLanguage, $gBitThemes, $gBitSmarty;
     $ret = '';
     // We're gonna run our own cache mechanism for user_modules
     // the cache is here to avoid calls to consumming queries,
     // each module is different for each language because of the strings
     $cacheDir = TEMP_PKG_PATH . 'modules/cache/';
     if (!is_dir($cacheDir)) {
         mkdir_p($cacheDir);
     }
     list($package, $template) = explode('/', $pTplName);
     $cacheFile = $cacheDir . '_custom.' . $gBitLanguage->mLanguage . '.' . $template . '.tpl.cache';
     if (!empty($r["cache_time"]) && file_exists($cacheFile) && !($gBitSystem->getUTCTime() - filemtime($cacheFile) > $r["cache_time"])) {
         $pTplSource = file_get_contents($cacheFile);
     } else {
         global $moduleParams;
         if ($moduleParams = $gBitThemes->getCustomModule($template)) {
             $gBitSmarty->assign_by_ref('moduleParams', $moduleParams);
             $pTplSource = $gBitSmarty->fetch('bitpackage:themes/custom_module.tpl');
             // write to chache file
             $fp = fopen($cacheFile, "w+");
             fwrite($fp, $data, strlen($data));
             fclose($fp);
         }
     }
     $pTplTime = filemtime($cacheFile);
 }
开发者ID:kailIII,项目名称:themes,代码行数:28,代码来源:resource._custom.php

示例2: __get_local_file

 function __get_local_file($local_id, $test_dir = false)
 {
     $path = HOME_DIR . '/upload/' . $local_id;
     if (!is_dir($dir = dirname($path))) {
         mkdir_p($dir, 0777);
     }
     return $path;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:8,代码来源:mdl.gimage.php

示例3: Nexus

 /**
  * Initialisation of this class
  */
 function Nexus($pMenuId = NULL)
 {
     parent::__construct();
     $this->mMenuId = $pMenuId;
     // if the cache folder doesn't exist yet, create it
     if (!is_dir(TEMP_PKG_PATH . NEXUS_PKG_NAME . '/modules')) {
         mkdir_p(TEMP_PKG_PATH . NEXUS_PKG_NAME . '/modules');
     }
 }
开发者ID:bitweaver,项目名称:nexus,代码行数:12,代码来源:Nexus.php

示例4: _path

 function _path($key, $mkdir = false)
 {
     $dir = HOME_DIR . '/cache/' . $key[0] . $key[1];
     if ($mkdir) {
         if (!mkdir_p($dir)) {
             return false;
         }
     }
     return $dir . '/' . substr($key, 2);
 }
开发者ID:noikiy,项目名称:MyShop,代码行数:10,代码来源:cachedir.php

示例5: upgrade_gimages

 function upgrade_gimages()
 {
     $this->title = '商品图片';
     $aGoods = $this->db->select('SELECT goods_id,type_id, image_default, image_file FROM sdb_goods ORDER BY goods_id ASC LIMIT ' . ($this->step - 1) * 100 . ', 100');
     if (empty($aGoods)) {
         $this->updateMsg = update_message('商品图片升级成功');
         return 'finish';
     }
     foreach ($aGoods as $gv) {
         $hasG = $this->db->selectrow('SELECT COUNT(gimage_id) AS c FROM sdb_gimages WHERE goods_id = ' . $gv['goods_id']);
         if ($hasG['c']) {
             continue;
         }
         foreach (explode(',', $gv['image_file']) as $iv) {
             $iv = trim($iv);
             $gimagesData['is_remote'] = 'false';
             //                $gimagesData['source'] = $iv;
             $gimagesData['goods_id'] = $gv['goods_id'];
             $defPicSrc = '';
             if (substr($iv, 0, 4) == 'http') {
                 $gimagesData['is_remote'] = 'true';
                 $defPicSrc = 'N';
                 foreach (array('small', 'big', 'thumbnail') as $iType) {
                     $gimagesData[$iType] = $iv;
                 }
             } else {
                 $oldImgSrc = explode('|', $iv);
                 $defPicSrc = $oldImgSrc[0];
                 $extName = strrchr($defPicSrc, '.');
                 mkdir_p(dirname(HOME_DIR . '/upload/' . $defPicSrc));
                 copy(BASE_DIR . $defPicSrc, HOME_DIR . '/upload/' . $defPicSrc);
                 unlink(BASE_DIR . $defPicSrc);
                 chmod(HOME_DIR . '/upload/' . $defPicSrc, 0777);
                 foreach (array('small', 'big', 'thumbnail') as $iType) {
                     $gimagesData[$iType] = str_replace($extName, '_' . $iType . $extName, $iv);
                 }
             }
             $this->db->exec('INSERT INTO sdb_gimages ( 
                 goods_id , is_remote , source , src_size_width , src_size_height , small , big , thumbnail , up_time 
             ) VALUES (
                 ' . $gv['goods_id'] . ' , "' . $gimagesData['is_remote'] . '" , "' . $defPicSrc . '" , 100 , 100 , "' . $gimagesData['small'] . '" , "' . $gimagesData['big'] . '" , "' . $gimagesData['thumbnail'] . '" , ' . time() . '
             )');
             $lastId = $this->db->lastInsertId();
             if ($iv == trim($gv['image_default'])) {
                 if (!$this->db->exec('UPDATE sdb_goods SET image_default = "' . $lastId . '" , small_pic = "' . $gimagesData['small'] . '", big_pic = "' . $gimagesData['big'] . '" WHERE goods_id = ' . $gv['goods_id'])) {
                     $this->updateMsg = update_message('商品图片升级失败', E_WARNING);
                     return 'error';
                 }
             }
         }
     }
     return 'continue';
 }
开发者ID:noikiy,项目名称:MyShop,代码行数:53,代码来源:21246.php

示例6: dazuiLog

 function dazuiLog()
 {
     $system =& $GLOBALS['system'];
     $map = array('date' => date('Y-m-d'), 'worker' => 'shop', 'controller' => isset($system->request['action']['controller']) ? $system->request['action']['controller'] : '-', 'method' => isset($system->request['action']['method']) ? $system->request['action']['method'] : '-', 'query' => isset($system->request['query']) ? $system->request['query'] : '-', 'ip' => remote_addr());
     foreach ($map as $k => $v) {
         $find[] = '/\\{' . $k . '\\}/i';
     }
     $this->file = preg_replace($find, $map, LOG_FILE);
     if (!is_dir($dir = dirname($this->file))) {
         mkdir_p($dir);
     }
     $this->logStr = create_function('$e', 'return "' . preg_replace(array_merge($find, array('/\\{time\\}/i', '/\\{gmt\\}/i', '/\\{code\\}/i', '/\\{msg\\}/i')), array_merge($map, array('".mydate(\'h:i:s\')."', '[".mydate(\'r\')."]', '".str_pad($e[\'code\'],4,0, STR_PAD_LEFT)."', '".str_replace("\\n",\'\\n\',$e[\'msg\'])."')), str_replace('"', '\\"', LOG_FORMAT)) . '";');
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:13,代码来源:dazuiLog.php

示例7: data_graphviz

function data_graphviz($data, $params)
{
    $data = trim($data);
    $data = html_entity_decode($data);
    $storageurl = STORAGE_PKG_URL . 'GraphViz/';
    $storagepath = STORAGE_PKG_PATH . 'GraphViz/';
    $temppath = TEMP_PKG_PATH . 'GraphViz/';
    if (!is_dir($temppath)) {
        mkdir_p($temppath);
    }
    if (!is_dir($storagepath)) {
        mkdir_p($storagepath);
    }
    $file = md5($data);
    $dotFile = $temppath . $file . '.dot';
    $pngFile = $storagepath . $file . '.png';
    $pngURL = $storageurl . $file . '.png';
    if (!file_exists($pngFile)) {
        if (@(include_once 'PEAR.php')) {
            if (@(include_once 'Image/GraphViz.php')) {
                $graph = new Image_GraphViz();
                $error = '<div class=error>' . tra("Unable to write temporary file. Please check your server configuration.") . '</div>';
                if (!($fp = fopen($dotFile, 'w'))) {
                    return $error;
                }
                if (fwrite($fp, $data) === false) {
                    return $error;
                }
                fclose($fp);
                $graph->renderDotFile($dotFile, $pngFile, 'png');
                // No need to keep this lying around
                unlink($dotFile);
                // If it still isn't there....
                if (!file_exists($pngFile)) {
                    return '<div class=error>' . tra("Unable to generate graphviz image file. Please check your data.") . '</div>';
                }
            } else {
                return "<div class=error>" . tra("The Image_Graphviz pear plugin is not installed. Install with `pear install Image_Graphviz`.") . "</div>";
            }
        } else {
            return "<div class=error>" . tra("PEAR and the Image_Graphviz pear plugin are not installed.") . "</div>";
        }
    }
    return "<img src=\"{$pngURL}\"/> ";
}
开发者ID:kailIII,项目名称:liberty,代码行数:45,代码来源:data.graphviz.php

示例8: _get_ident

 function _get_ident($file, $type, $addons, &$url, &$path)
 {
     $addons = implode('-', $addons);
     $dir = '/' . $type . '/' . date('Ymd') . '/';
     $uri = $dir . substr(md5(($addons ? $addons : $file) . microtime()), 0, 16) . ext_name(basename($addons ? $addons : $file));
     $path = MEDIA_DIR . $uri;
     $url = 'images' . $uri;
     if (file_exists($path) && !unlink($path)) {
         return false;
     }
     $dir = dirname($path);
     if (!is_dir($dir)) {
         if (!mkdir_p($dir)) {
             return false;
         }
     }
     return $uri;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:18,代码来源:fs_storage.php

示例9: mkdir_p

function mkdir_p($target)
{
    // from php.net/mkdir user contributed notes
    if (file_exists($target)) {
        if (!is_dir($target)) {
            return false;
        } else {
            return true;
        }
    }
    // Attempting to create the directory may clutter up our display.
    if (@mkdir($target)) {
        return true;
    }
    // If the above failed, attempt to create the parent node, then try again.
    if (mkdir_p(dirname($target))) {
        return mkdir_p($target);
    }
    return false;
}
开发者ID:robertlange81,项目名称:Website,代码行数:20,代码来源:xmlrpc.php

示例10: copy_manifest

 protected function copy_manifest()
 {
     foreach ($this->manifest() as $target => $source) {
         if ($source === true) {
             if ($target[strlen($target) - 1] == '/') {
                 mkdir_p($target);
             } else {
                 mkdir_p(dirname($target));
                 touch($target);
             }
         } else {
             $target = ZING_ROOT . '/' . ltrim($target, '/');
             mkdir_p(dirname($target));
             if ($this->is_file_templated($source, $target)) {
                 file_put_contents($target, $this->render_template($source));
             } else {
                 file_put_contents($target, file_get_contents($source));
             }
         }
     }
 }
开发者ID:jaz303,项目名称:zing,代码行数:21,代码来源:generator.php

示例11: mkdir_p

function mkdir_p($target)
{
    //creates a new directory
    //Returns 1 for success
    //        2 for "directory/file by that name exists
    //        0 for other errors
    if (file_exists($target) || is_dir($target)) {
        return 2;
    }
    if (mkdir($target, 0777)) {
        return 1;
    }
    if (mkdir_p(substr($target, 0, strrpos($target, '/'))) == 1) {
        if (mkdir_p($target) == 1) {
            return 1;
        } else {
            return 0;
        }
    } else {
        return 0;
    }
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:22,代码来源:template_helper.php

示例12: mkdir_p

function mkdir_p($target)
{
    // from php.net/mkdir user contributed notes
    $target = str_replace('//', '/', $target);
    if (file_exists($target)) {
        return @is_dir($target);
    }
    // Attempting to create the directory may clutter up our display.
    if (@mkdir($target)) {
        $stat = @stat(dirname($target));
        $dir_perms = 0777;
        // Get the permission bits.
        @chmod($target, $dir_perms);
        return true;
    } elseif (is_dir(dirname($target))) {
        return false;
    }
    // If the above failed, attempt to create the parent node, then try again.
    if ($target != '/' && mkdir_p(dirname($target))) {
        return mkdir_p($target);
    }
    return false;
}
开发者ID:chaobj001,项目名称:tt,代码行数:23,代码来源:func_main.php

示例13: smarty_function_moduleinc

/**
 * moduleinc 
 * 
 * Usage: add to the body of any .tpl file
 * Example: {inlinemodule file="_custom:custom/my_custom_module" cache_time=600}
 *
 * Note: currently only supports custom modules generated in themes package, 
 * could support any module with more work
 *
 * @param array $pParams 
 * @param string $pParams['module_rsrc'] the full name of the template, example: _custom:custom/my_custom_module 
 * @param integer $pParams['cache_time'] seconds the template will be cached
 */
function smarty_function_moduleinc($pParams, &$gBitSmarty)
{
    global $gBitSystem, $gBitThemes;
    // go through some hassle here in consideration of a future day when this handles any module
    list($package, $template) = split('/', $pParams['module_rsrc']);
    if ($package == '_custom:custom') {
        global $gBitLanguage;
        // We're gonna run our own cache mechanism for user_modules
        // the cache is here to avoid calls to consumming queries,
        // each module is different for each language because of the strings
        $cacheDir = TEMP_PKG_PATH . 'modules/cache/';
        if (!is_dir($cacheDir)) {
            mkdir_p($cacheDir);
        }
        $cachefile = $cacheDir . '_custom.' . $gBitLanguage->mLanguage . '.' . $template . '.tpl.cache';
        if (!empty($pParams["cache_time"]) && file_exists($cachefile) && !($gBitSystem->getUTCTime() - filemtime($cachefile) > $pParams["cache_time"])) {
            $fp = fopen($cachefile, "r");
            $data = fread($fp, filesize($cachefile));
            fclose($fp);
            print $data;
        } else {
            if ($moduleParams = $gBitThemes->getCustomModule($template)) {
                $moduleParams = array_merge($pParams, $moduleParams);
                $gBitSmarty->assign_by_ref('moduleParams', $moduleParams);
                $data = $gBitSmarty->fetch('bitpackage:themes/custom_module.tpl');
                if (!empty($pParams["cache_time"])) {
                    // write to chache file
                    $fp = fopen($cachefile, "w+");
                    fwrite($fp, $data, strlen($data));
                    fclose($fp);
                }
                print $data;
            }
        }
        unset($data);
    }
}
开发者ID:kailIII,项目名称:themes,代码行数:50,代码来源:function.moduleinc.php

示例14: compile

 public static function compile($__source__, $__target__)
 {
     $R = new self();
     require $__source__;
     $compilation = $R->perform_compile();
     $fp = fopen(__FILE__, 'r');
     fseek($fp, __COMPILER_HALT_OFFSET__);
     $compiled_source = '';
     $in = false;
     while (!feof($fp)) {
         $line = fgets($fp, 8192);
         if (preg_match('|// START-ROUTES|', $line)) {
             $compiled_source .= $compilation->export();
             $in = true;
         } elseif (preg_match('|// END-ROUTES|', $line)) {
             $in = false;
         } elseif (!$in) {
             $compiled_source .= $line;
         }
     }
     fclose($fp);
     mkdir_p(dirname($__target__));
     file_put_contents($__target__, ltrim($compiled_source));
 }
开发者ID:jaz303,项目名称:zing,代码行数:24,代码来源:routing.php

示例15: _run

 function _run($file_id)
 {
     $this->system->__session_close(false);
     $this->cur_file_id = $file_id;
     $result = explode("|", $this->taskinfo['download_list'][$file_id]);
     $file_url = $result[0];
     if ($this->taskinfo['key_as_name']) {
         $file = $this->workdir . '/' . $file_id;
     } else {
         $file = $this->workdir . '/' . basename($file_url);
     }
     if (!is_dir($dir = dirname($file))) {
         mkdir_p($dir);
     }
     touch($file);
     $this->file_rs = fopen($file, 'rb+') or exit(__('Error: 无法创建文件:') . $file);
     fseek($this->file_rs, 0, SEEK_END);
     $cur_size = ftell($this->file_rs);
     $header = $cur_size ? array('Range' => 'bytes=' . $cur_size . '-') : null;
     set_time_limit($this->max_runtime + 3);
     $this->starttime = time();
     register_shutdown_function(array(&$this, '_next_request'));
     ob_start();
     $this->_next_request();
     $netcore =& $this->system->loadModel('utility/http_client');
     $netcore->get($file_url, $header, array(&$this, '_runner_handle'));
     ob_end_clean();
     while (key($this->taskinfo['download_list']) != $file_id) {
         next($this->taskinfo['download_list']);
     }
     if (next($this->taskinfo['download_list'])) {
         $this->cur_file_id = key($this->taskinfo['download_list']);
     } else {
         $this->cur_file_id = -1;
     }
 }
开发者ID:noikiy,项目名称:MyShop,代码行数:36,代码来源:ctl.download.php


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