本文整理汇总了PHP中io_mkdir_p函数的典型用法代码示例。如果您正苦于以下问题:PHP io_mkdir_p函数的具体用法?PHP io_mkdir_p怎么用?PHP io_mkdir_p使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了io_mkdir_p函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initRepo
private function initRepo()
{
//get path to the repo root (by default DokuWiki's savedir)
if (defined('DOKU_FARM')) {
$repoPath = $this->getConf('repoPath');
} else {
$repoPath = DOKU_INC . $this->getConf('repoPath');
}
//set the path to the git binary
$gitPath = trim($this->getConf('gitPath'));
if ($gitPath !== '') {
Git::set_bin($gitPath);
}
//init the repo and create a new one if it is not present
io_mkdir_p($repoPath);
$repo = new GitRepo($repoPath, true, true);
//set git working directory (by default DokuWiki's savedir)
$repoWorkDir = DOKU_INC . $this->getConf('repoWorkDir');
Git::set_bin(Git::get_bin() . ' --work-tree ' . escapeshellarg($repoWorkDir));
$params = str_replace(array('%mail%', '%user%'), array($this->getAuthorMail(), $this->getAuthor()), $this->getConf('addParams'));
if ($params) {
Git::set_bin(Git::get_bin() . ' ' . $params);
}
return $repo;
}
示例2: ajax_prepare
/**
* Prepare the static dump
*/
function ajax_prepare()
{
global $conf;
$today = date('Y-m-d');
$staticDir = DOKU_INC . $conf['savedir'] . '/static/' . $today . "/";
// create output directory
io_mkdir_p($rootStaticPath);
// acquire a lock
$lock = $conf['lockdir'] . '/_dokukiwix.lock';
if (!file_exists($lock) || time() - @filemtime($lock) > 60 * 5) {
unlink($lock);
if ($fp = fopen($lock, 'w+')) {
fwrite($fp, $today);
fclose($fp);
}
} else {
print 'dokukiwix is locked.';
exit;
}
// create mandatory directories
io_mkdir_p($staticDir . '/images/');
io_mkdir_p($staticDir . '/images/extern/');
io_mkdir_p($staticDir . '/pages/');
io_mkdir_p($staticDir . '/css/');
print 'true';
}
示例3: __construct
function __construct($pagesize = 'A4', $orientation = 'portrait')
{
global $conf;
io_mkdir_p(_MPDF_TTFONTDATAPATH);
io_mkdir_p(_MPDF_TEMP_PATH);
$format = $pagesize;
if ($orientation == 'landscape') {
$format .= '-L';
}
switch ($conf['lang']) {
case 'zh':
case 'zh-tw':
case 'ja':
case 'ko':
$mode = '+aCJK';
break;
default:
$mode = 'UTF-8-s';
}
// we're always UTF-8
parent::__construct($mode, $format);
$this->autoScriptToLang = true;
$this->baseScript = 1;
$this->autoVietnamese = true;
$this->autoArabic = true;
$this->autoLangToFont = true;
$this->ignore_invalid_utf8 = true;
$this->tabSpaces = 4;
}
示例4: __construct
function __construct()
{
io_mkdir_p(_MPDF_TTFONTDATAPATH);
io_mkdir_p(_MPDF_TEMP_PATH);
// we're always UTF-8
parent::__construct('UTF-8-s');
$this->SetAutoFont(AUTOFONT_ALL);
$this->ignore_invalid_utf8 = true;
}
示例5: send_theme
/**
* Send a zipped theme
*
* @author Samuele Tognini <samuele@netsons.org>
*/
function send_theme($file)
{
require_once DOKU_PLUGIN . 'indexmenu/syntax/indexmenu.php';
$idxm = new syntax_plugin_indexmenu_indexmenu();
//clean the file name
$file = cleanID($file);
//check config
if (!$idxm->getConf('be_repo') || empty($file)) {
return false;
}
$repodir = INDEXMENU_IMG_ABSDIR . "/repository";
$zipfile = $repodir . "/{$file}.zip";
$localtheme = INDEXMENU_IMG_ABSDIR . "/{$file}/";
//theme does not exists
if (!file_exists($localtheme)) {
return false;
}
if (!io_mkdir_p($repodir)) {
return false;
}
$lm = @filemtime($zipfile);
//no cached zip or older than 1 day
if ($lm < time() - 60 * 60 * 24) {
//create the zip
require_once DOKU_PLUGIN . "indexmenu/inc/pclzip.lib.php";
@unlink($zipfile);
$zip = new PclZip($zipfile);
$status = $zip->add($localtheme, PCLZIP_OPT_REMOVE_ALL_PATH);
//error
if ($status == 0) {
return false;
}
}
$len = (int) filesize($zipfile);
//don't send large zips
if ($len > 2 * 1024 * 1024) {
return false;
}
//headers
header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="' . basename($zipfile) . '";');
header("Content-Transfer-Encoding: binary");
//send zip
$fp = @fopen($zipfile, 'rb');
if ($fp) {
$ct = @fread($fp, $len);
print $ct;
}
@fclose($fp);
return true;
}
示例6: initRepo
private function initRepo()
{
//get path to the repo root (by default DokuWiki's savedir)
$repoPath = DOKU_INC . $this->getConf('repoPath');
//init the repo and create a new one if it is not present
io_mkdir_p($repoPath);
$repo = new GitRepo($repoPath, true, true);
//set git working directory (by default DokuWiki's savedir)
$repoWorkDir = DOKU_INC . $this->getConf('repoWorkDir');
$repo->git_path .= ' --work-tree ' . escapeshellarg($repoWorkDir);
$params = str_replace(array('%mail%', '%user%'), array($this->getAuthorMail(), $this->getAuthor()), $this->getConf('addParams'));
if ($params) {
$repo->git_path .= ' ' . $params;
}
return $repo;
}
示例7: handle
/**
*
*
* @param Doku_Event $event Not used
* @param mixed $param Not used
* @return void
*/
public function handle(Doku_Event &$event, $param)
{
global $conf;
if ($event->data != 'feedaggregator') {
return;
}
$event->preventDefault();
// See if we need a token and whether it matches.
$requiredToken = $this->getConf('token');
$suppliedToken = isset($_GET['token']) ? $_GET['token'] : false;
if (!empty($requiredToken) && $suppliedToken !== $requiredToken) {
msg("Token doesn't match for feedaggregator");
return true;
}
// Get the feed list.
$feeds = file(fullpath($conf['tmpdir'] . '/feedaggregator.csv'));
// Set up SimplePie and merge all the feeds together.
$simplepie = new FeedParser();
$ua = 'Mozilla/4.0 (compatible; DokuWiki feedaggregator plugin ' . wl('', '', true) . ')';
$simplepie->set_useragent($ua);
$simplepie->force_feed($this->getConf('force_feed'));
$simplepie->force_fsockopen($this->getConf('force_fsockopen'));
$simplepie->set_feed_url($feeds);
// Set up caching.
$cacheDir = fullpath($conf['cachedir'] . '/feedaggregator');
io_mkdir_p($cacheDir);
$simplepie->enable_cache();
$simplepie->set_cache_location($cacheDir);
// Run the actual feed aggregation.
$simplepie->init();
// Check for errors.
if ($simplepie->error()) {
header("Content-type:text/plain");
echo join("\n", $simplepie->error());
}
// Create the output HTML and cache it for use by the syntax component.
$html = '';
foreach ($simplepie->get_items() as $item) {
$html .= "<div class='feedaggregator_item'>\n" . "<h2>" . $item->get_title() . "</h2>\n" . $item->get_content() . "\n" . "<p>" . " <a href='" . $item->get_permalink() . "'>Published " . $item->get_date('j M Y') . "</a> " . " in <a href='" . $item->get_feed()->get_permalink() . "'>" . $item->get_feed()->get_title() . "</a>" . "</p>\n" . "</div>\n\n";
}
io_saveFile($cacheDir . '/output.html', $html);
// Output nothing, as this should be run from cron and we don't want to
// flood the logs with success.
exit(0);
}
示例8: move_files
/**
* Internal function for moving and renaming meta/attic files between namespaces
*
* @param string $dir The root path of the files (e.g. $conf['metadir'] or $conf['olddir']
* @param array $opts Move options (used here: ns, newns, name, newname)
* @param string $extregex Regular expression for matching the extension of the file that shall be moved
* @return bool If the files were moved successfully
*/
private function move_files($dir, $opts, $extregex) {
$old_path = $dir;
if ($opts['ns'] != '') $old_path .= '/'.utf8_encodeFN(str_replace(':', '/', $opts['ns']));
$new_path = $dir;
if ($opts['newns'] != '') $new_path .= '/'.utf8_encodeFN(str_replace(':', '/', $opts['newns']));
$regex = '/^'.preg_quote(utf8_encodeFN($opts['name'])).'('.$extregex.')$/u';
if (!is_dir($old_path)) return true; // no media files found
$dh = @opendir($old_path);
if($dh) {
while(($file = readdir($dh)) !== false) {
if (substr($file, 0, 1) == '.') continue;
$match = array();
if (is_file($old_path.'/'.$file) && preg_match($regex, $file, $match)) {
if (!is_dir($new_path)) {
if (!io_mkdir_p($new_path)) {
msg('Creating directory '.hsc($new_path).' failed.', -1);
return false;
}
}
if (!io_rename($old_path.'/'.$file, $new_path.'/'.utf8_encodeFN($opts['newname'].$match[1]))) {
msg('Moving '.hsc($old_path.'/'.$file).' to '.hsc($new_path.'/'.utf8_encodeFN($opts['newname'].$match[1])).' failed.', -1);
return false;
}
}
}
closedir($dh);
} else {
msg('Directory '.hsc($old_path).' couldn\'t be opened.', -1);
return false;
}
return true;
}
示例9: handle_action_act_preprocess
public function handle_action_act_preprocess(Doku_Event &$event, $param)
{
global $ID;
global $TEXT;
global $ACT;
global $SUM;
global $RANGE;
global $REV;
$act = $event->data;
if ($act != 'dokutranslate_review') {
$act = act_clean($act);
$act = act_permcheck($act);
}
# Ignore drafts if the page is being translated
# FIXME: Find a way to save $_REQUEST['parid'] into the draft
if (@file_exists(metaFN($ID, '.translate')) && in_array($act, array('draft', 'recover'))) {
act_draftdel('draftdel');
$ACT = $act = 'edit';
}
if ($act == 'save') {
# Take over save action if translation is in progress
# or we're starting it
if (!@file_exists(metaFN($ID, '.translate')) && empty($_REQUEST['translate'])) {
return;
}
if (!checkSecurityToken()) {
return;
}
# We're starting a translation
if (!@file_exists(metaFN($ID, '.translate')) && !empty($_REQUEST['translate'])) {
# Check if the user has permission to start
# translation in this namespace
if (!isModerator($ID)) {
return;
}
# Take the event over
$event->stopPropagation();
$event->preventDefault();
# Save the data but exit if it fails
$ACT = act_save($act);
if ($ACT != 'show') {
return;
}
# Page was deleted, exit
if (!@file_exists(wikiFN($ID))) {
return;
}
# Prepare data path
$datapath = dataPath($ID);
io_mkdir_p($datapath, 0755, true);
# Backup the original page
io_rename(wikiFN($ID), $datapath . '/orig.txt');
# Backup old revisions
$revisions = allRevisions($ID);
foreach ($revisions as $rev) {
$tmp = wikiFN($ID, $rev);
io_rename($tmp, $datapath . '/' . basename($tmp));
}
# Backup meta files
$metas = metaFiles($ID);
foreach ($metas as $f) {
io_rename($f, $datapath . '/' . basename($f));
}
# Generate empty page to hold translated text
$data = getCleanInstructions($datapath . '/orig.txt');
saveWikiText($ID, genTranslateFile($data), $SUM, $_REQUEST['minor']);
$translateMeta = genMeta(count($data));
# create meta file for current translation state
io_saveFile(metaFN($ID, '.translate'), serialize($translateMeta));
# create separate meta file for translation history
io_saveFile(metaFN($ID, '.translateHistory'), serialize(array('current' => $translateMeta)));
} else {
# Translation in progress, take the event over
$event->preventDefault();
# Save the data but exit if it fails
$ACT = act_save($act);
# Save failed, exit
if ($ACT != 'show') {
return;
}
# Save successful, update translation metadata
$lastrev = getRevisions($ID, 0, 1, 1024);
updateMeta($ID, getParID(), $lastrev[0]);
}
} else {
if ($act == 'revert') {
# Take over save action if translation is in progress
if (!@file_exists(metaFN($ID, '.translate'))) {
return;
}
if (!checkSecurityToken()) {
return;
}
# Translation in progress, take the event over
$event->preventDefault();
# Save the data but exit if it fails
$revert = $REV;
$ACT = act_revert($act);
# Revert failed, exit
if ($ACT != 'show') {
//.........这里部分代码省略.........
示例10: test_full_hierarchy
function test_full_hierarchy()
{
// setup hierachy and test it exists
$dir = io_mktmpdir();
$top = dirname($dir);
$this->assertTrue($dir !== false);
$this->assertTrue(is_dir($dir));
$this->assertTrue(io_mkdir_p("{$dir}/foo/bar/baz"));
$this->assertTrue(is_dir("{$dir}/foo/bar/baz"));
$this->assertTrue(io_mkdir_p("{$dir}/foobar/bar/baz"));
$this->assertTrue(is_dir("{$dir}/foobar/bar/baz"));
// put files
$this->assertTrue(io_saveFile("{$dir}/testfile.txt", 'foobar'));
$this->assertFileExists("{$dir}/testfile.txt");
$this->assertTrue(io_saveFile("{$dir}/foo/testfile.txt", 'foobar'));
$this->assertFileExists("{$dir}/foo/testfile.txt");
$this->assertTrue(io_saveFile("{$dir}/foo/bar/baz/testfile.txt", 'foobar'));
$this->assertFileExists("{$dir}/foo/bar/baz/testfile.txt");
// delete unsuccessfully
$this->assertFalse(io_rmdir($dir, false));
// check result
clearstatcache();
$this->assertFileExists("{$dir}/testfile.txt");
$this->assertFileExists("{$dir}/foo/testfile.txt");
$this->assertFileExists("{$dir}/foo/bar/baz/testfile.txt");
$this->assertTrue(is_dir("{$dir}/foo/bar/baz"));
$this->assertTrue(is_dir("{$dir}/foobar/bar/baz"));
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
// delete successfully
$this->assertTrue(io_rmdir($dir, true));
// check result
clearstatcache();
$this->assertFileNotExists("{$dir}/testfile.txt");
$this->assertFileNotExists("{$dir}/foo/testfile.txt");
$this->assertFileNotExists("{$dir}/foo/bar/baz/testfile.txt");
$this->assertFalse(is_dir("{$dir}/foo/bar/baz"));
$this->assertFalse(is_dir("{$dir}/foobar/bar/baz"));
$this->assertFalse(is_dir($dir));
$this->assertTrue(is_dir($top));
}
示例11: _dircopy
function _dircopy($srcdir, $dstdir)
{
io_mkdir_p($dstdir);
$num = 0;
if ($curdir = opendir($srcdir)) {
while ($file = readdir($curdir)) {
if ($file != '.' && $file != '..') {
$srcfile = $srcdir . DIRECTORY_SEPARATOR . $file;
$dstfile = $dstdir . DIRECTORY_SEPARATOR . $file;
if (is_file($srcfile)) {
if (!$this->_copy($srcfile, $dstfile)) {
msg(sprintf($this->getLang('error_copying'), $srcfile), -1);
} else {
$num++;
}
} else {
if (is_dir($srcfile)) {
$num += $this->_dircopy($srcfile, $dstfile);
}
}
}
}
closedir($curdir);
}
return $num;
}
示例12: build
/**
* Build the document from the template.
* (code taken from old function 'document_end_scratch')
*
* @param string $doc
* @param string $autostyles
* @param array $commonstyles
* @param string $meta
* @param string $userfields
* @param ODTDefaultStyles $styleset
* @return mixed
*/
public function build($doc = null, $meta = null, $userfields = null, $pagestyles = null)
{
// for the temp dir
global $ID;
// Temp dir
if (is_dir($this->config->getParam('tmpdir'))) {
// version > 20070626
$temp_dir = $this->config->getParam('tmpdir');
} else {
// version <= 20070626
$temp_dir = $this->config->getParam('savedir') . '/cache/tmp';
}
$temp_dir = $temp_dir . "/odt/" . str_replace(':', '-', $ID);
if (is_dir($temp_dir)) {
io_rmdir($temp_dir, true);
}
io_mkdir_p($temp_dir);
// Extract template
$template_path = $this->config->getParam('mediadir') . '/' . $this->directory . "/" . $this->template;
$ok = $this->ZIP->Extract($template_path, $temp_dir);
if ($ok == -1) {
throw new Exception(' Error extracting the zip archive:' . $template_path . ' to ' . $temp_dir);
}
// Import styles from ODT template
//$this->styleset->importFromODTFile($temp_dir.'/content.xml', 'office:automatic-styles');
//$this->styleset->importFromODTFile($temp_dir.'/styles.xml', 'office:styles');
$autostyles = $this->styleset->export('office:automatic-styles');
$commonstyles = $this->styleset->export('office:styles');
// Prepare content
$missingfonts = $this->styleset->getMissingFonts($temp_dir . '/styles.xml');
// Insert content
$old_content = io_readFile($temp_dir . '/content.xml');
if (strpos($old_content, 'DOKUWIKI-ODT-INSERT') !== FALSE) {
// Replace the mark
$this->_odtReplaceInFile('/<text:p[^>]*>DOKUWIKI-ODT-INSERT<\\/text:p>/', $doc, $temp_dir . '/content.xml', true);
} else {
// Append to the template
$this->_odtReplaceInFile('</office:text>', $doc . '</office:text>', $temp_dir . '/content.xml');
}
// Cut off unwanted content
if (strpos($old_content, 'DOKUWIKI-ODT-CUT-START') !== FALSE && strpos($old_content, 'DOKUWIKI-ODT-CUT-STOP') !== FALSE) {
$this->_odtReplaceInFile('/DOKUWIKI-ODT-CUT-START.*DOKUWIKI-ODT-CUT-STOP/', '', $temp_dir . '/content.xml', true);
}
// Insert userfields
if (strpos($old_content, "text:user-field-decls") === FALSE) {
// no existing userfields
$this->_odtReplaceInFile('/<office:text([^>]*)>/U', '<office:text\\1>' . $userfields, $temp_dir . '/content.xml', TRUE);
} else {
$this->_odtReplaceInFile('</text:user-field-decls>', substr($userfields, 23), $temp_dir . '/content.xml');
}
// Insert styles & fonts
$value = io_readFile($temp_dir . '/content.xml');
$original = XMLUtil::getElement('office:automatic-styles', $value);
$this->_odtReplaceInFile($original, $autostyles, $temp_dir . '/content.xml');
$value = io_readFile($temp_dir . '/styles.xml');
$original = XMLUtil::getElement('office:automatic-styles', $value);
$this->_odtReplaceInFile($original, $autostyles, $temp_dir . '/styles.xml');
$value = io_readFile($temp_dir . '/styles.xml');
$original = XMLUtil::getElement('office:styles', $value);
$this->_odtReplaceInFile($original, $commonstyles, $temp_dir . '/styles.xml');
$this->_odtReplaceInFile('</office:font-face-decls>', $missingfonts . '</office:font-face-decls>', $temp_dir . '/styles.xml');
// Insert page styles
$page = '';
foreach ($pagestyles as $name => $layout_name) {
$page .= '<style:master-page style:name="' . $name . '" style:page-layout-name="' . $layout_name . '"/>';
}
if (!empty($page)) {
$this->_odtReplaceInFile('</office:master-styles>', $page . '</office:master-styles>', $temp_dir . '/styles.xml');
}
// Add manifest data
$this->_odtReplaceInFile('</manifest:manifest>', $this->manifest->getExtraContent() . '</manifest:manifest>', $temp_dir . '/META-INF/manifest.xml');
// Build the Zip
$this->ZIP->Compress(null, $temp_dir, null);
io_rmdir($temp_dir, true);
}
示例13: epub_setup_book_skel
function epub_setup_book_skel($user_title = false)
{
$dir = epub_get_metadirectory();
$meta = $dir . 'META-INF';
$oebps = epub_get_oebps();
$media_dir = epub_get_data_media() . 'epub';
io_mkdir_p($meta);
io_mkdir_p($oebps);
io_mkdir_p($oebps . 'Images/');
io_mkdir_p($oebps . 'Text/');
io_mkdir_p($media_dir);
io_mkdir_p($oebps . 'Styles/');
if (isset($_POST['client'])) {
$user = cleanID(rawurldecode($_POST['client'])) . '/';
io_mkdir_p($media_dir . '/' . $user);
}
$book_id = cleanID(rawurldecode($_POST['book_page']));
copy(EPUB_DIR . 'scripts/package/my-book.epub', $dir . 'my-book.epub');
copy(EPUB_DIR . 'scripts/package/container.xml', $dir . 'META-INF/container.xml');
if (!$user_title) {
copy(EPUB_DIR . 'scripts/package/title.html', $oebps . 'Text/title.html');
copy(EPUB_DIR . 'scripts/package/cover.png', $oebps . 'Images/cover.png');
}
$zip = epub_zip_handle($dir . 'my-book.epub');
if ($zip) {
$zip->addFile(EPUB_DIR . 'scripts/package/container.xml', 'META-INF/container.xml');
if (!$user_title) {
$zip->addFile(EPUB_DIR . 'scripts/package/title.html', 'OEBPS/Text/title.html');
$zip->addFile(EPUB_DIR . 'scripts/package/cover.png', 'OEBPS/Images/cover.png');
}
}
}
示例14: _traverse
/**
* Traverse over the given dir and compare it to the DokuWiki dir
*
* Checks what files need an update, tests for writability and copies
*
* @param string $dir
* @param bool $dryrun do not copy but only check permissions
* @return bool
*/
private function _traverse($dir, $dryrun)
{
$base = $this->tgzdir;
$ok = true;
$dh = @opendir($base . '/' . $dir);
if (!$dh) {
return false;
}
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$from = "{$base}/{$dir}/{$file}";
$to = DOKU_INC . "{$dir}/{$file}";
if (is_dir($from)) {
if ($dryrun) {
// just check for writability
if (!is_dir($to)) {
if (is_dir(dirname($to)) && !is_writable(dirname($to))) {
$this->_warn('<b>' . $this->getLang('tv_noperm') . '</b>', hsc("{$dir}/{$file}"));
$ok = false;
}
}
}
// recursion
if (!$this->_traverse("{$dir}/{$file}", $dryrun)) {
$ok = false;
}
} else {
$fmd5 = md5(@file_get_contents($from));
$tmd5 = md5(@file_get_contents($to));
if ($fmd5 != $tmd5 || !file_exists($to)) {
if ($dryrun) {
// just check for writability
if (file_exists($to) && !is_writable($to) || !file_exists($to) && is_dir(dirname($to)) && !is_writable(dirname($to))) {
$this->_warn('<b>' . $this->getLang('tv_noperm') . '</b>', hsc("{$dir}/{$file}"));
$ok = false;
} else {
$this->_say($this->getLang('tv_upd'), hsc("{$dir}/{$file}"));
}
} else {
// check dir
if (io_mkdir_p(dirname($to))) {
// copy
if (!copy($from, $to)) {
$this->_warn('<b>' . $this->getLang('tv_nocopy') . '</b>', hsc("{$dir}/{$file}"));
$ok = false;
} else {
$this->_say($this->getLang('tv_done'), hsc("{$dir}/{$file}"));
}
} else {
$this->_warn('<b>' . $this->getLang('tv_nodir') . '</b>', hsc("{$dir}"));
$ok = false;
}
}
}
}
}
closedir($dh);
return $ok;
}
示例15: _dirApp
function _dirApp($d)
{
// map to dokuwiki function (its more robust)
return io_mkdir_p($d);
}