本文整理汇总了PHP中wfMkdirParents函数的典型用法代码示例。如果您正苦于以下问题:PHP wfMkdirParents函数的具体用法?PHP wfMkdirParents怎么用?PHP wfMkdirParents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfMkdirParents函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: doSingleLock
/**
* Lock a single resource key
*
* @param $path string
* @param $type integer
* @return Status
*/
protected function doSingleLock($path, $type)
{
$status = Status::newGood();
if (isset($this->locksHeld[$path][$type])) {
++$this->locksHeld[$path][$type];
} elseif (isset($this->locksHeld[$path][self::LOCK_EX])) {
$this->locksHeld[$path][$type] = 1;
} else {
wfSuppressWarnings();
$handle = fopen($this->getLockPath($path), 'a+');
wfRestoreWarnings();
if (!$handle) {
// lock dir missing?
wfMkdirParents($this->lockDir);
$handle = fopen($this->getLockPath($path), 'a+');
// try again
}
if ($handle) {
// Either a shared or exclusive lock
$lock = $type == self::LOCK_SH ? LOCK_SH : LOCK_EX;
if (flock($handle, $lock | LOCK_NB)) {
// Record this lock as active
$this->locksHeld[$path][$type] = 1;
$this->handles[$path][$type] = $handle;
} else {
fclose($handle);
$status->fatal('lockmanager-fail-acquirelock', $path);
}
} else {
$status->fatal('lockmanager-fail-openlock', $path);
}
}
return $status;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:41,代码来源:FSLockManager.php
示例2: doTransform
function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0)
{
global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
if (!$this->normaliseParams($image, $params)) {
return new TransformParameterError($params);
}
$clientWidth = $params['width'];
$clientHeight = $params['height'];
$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight'];
$srcPath = $image->getPath();
if ($flags & self::TRANSFORM_LATER) {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
if (!wfMkdirParents(dirname($dstPath))) {
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, wfMsg('thumbnail_dest_directory'));
}
$status = $this->rasterize($srcPath, $dstPath, $physicalWidth, $physicalHeight);
if ($status === true) {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
} else {
return $status;
// MediaTransformError
}
}
开发者ID:amjadtbssm,项目名称:website,代码行数:25,代码来源:SVG.php
示例3: doTransform
function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0)
{
global $wgFLVConverters, $wgFLVConverter, $wgFLVConverterPath;
if (!$this->normaliseParams($image, $params)) {
return new TransformParameterError($params);
}
$clientWidth = $params['width'];
$clientHeight = $params['height'];
$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight'];
$srcPath = $image->getPath();
if ($flags & self::TRANSFORM_LATER) {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
if (!wfMkdirParents(dirname($dstPath), null, __METHOD__)) {
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, wfMsg('thumbnail_dest_directory'));
}
$err = false;
if (isset($wgFLVConverters[$wgFLVConverter])) {
$cmd = str_replace(array('$path/', '$width', '$height', '$input', '$output'), array($wgFLVConverterPath ? wfEscapeShellArg("{$wgFLVConverterPath}/") : "", intval($physicalWidth), intval($physicalHeight), wfEscapeShellArg($srcPath), wfEscapeShellArg($dstPath)), $wgFLVConverters[$wgFLVConverter]) . " 2>&1";
wfProfileIn('rsvg');
wfDebug(__METHOD__ . ": {$cmd}\n");
$err = wfShellExec($cmd, $retval);
wfProfileOut('rsvg');
}
$removed = $this->removeBadFile($dstPath, $retval);
if ($retval != 0 || $removed) {
wfDebugLog('thumbnail', sprintf('thumbnail failed on %s: error %d "%s" from "%s"', wfHostname(), $retval, trim($err), $cmd));
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, $err);
} else {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:FlvImageHandler.php
示例4: dataDirOKmaybeCreate
private static function dataDirOKmaybeCreate($dir, $create = false)
{
if (!is_dir($dir)) {
if (!is_writable(dirname($dir))) {
$webserverGroup = Installer::maybeGetWebserverPrimaryGroup();
if ($webserverGroup !== null) {
return Status::newFatal('config-sqlite-parent-unwritable-group', $dir, dirname($dir), basename($dir), $webserverGroup);
} else {
return Status::newFatal('config-sqlite-parent-unwritable-nogroup', $dir, dirname($dir), basename($dir));
}
}
# Called early on in the installer, later we just want to sanity check
# if it's still writable
if ($create) {
wfSuppressWarnings();
$ok = wfMkdirParents($dir, 0700);
wfRestoreWarnings();
if (!$ok) {
return Status::newFatal('config-sqlite-mkdir-error', $dir);
}
# Put a .htaccess file in in case the user didn't take our advice
file_put_contents("{$dir}/.htaccess", "Deny from all\n");
}
}
if (!is_writable($dir)) {
return Status::newFatal('config-sqlite-dir-unwritable', $dir);
}
# We haven't blown up yet, fall through
return Status::newGood();
}
开发者ID:GodelDesign,项目名称:Godel,代码行数:30,代码来源:SqliteInstaller.php
示例5: run
function run()
{
global $wgExtensionMessagesFiles, $wgMessageCache, $IP;
$nameHash = md5(implode("\n", array_keys($wgExtensionMessagesFiles)));
$dir = "{$IP}/cache/ext-msgs";
wfMkdirParents($dir);
$db = dba_open("{$dir}/{$nameHash}.cdb", 'n', 'cdb');
if (!$db) {
echo "Cannot open DB file\n";
exit(1);
}
# Load extension messages
foreach ($wgExtensionMessagesFiles as $file) {
$messages = $magicWords = array();
require $file;
foreach ($messages as $lang => $unused) {
$wgMessageCache->processMessagesArray($messages, $lang);
}
}
# Write them to the file
foreach ($wgMessageCache->mExtensionMessages as $lang => $messages) {
foreach ($messages as $key => $text) {
dba_insert("{$lang}:{$key}", $text, $db);
}
}
dba_close($db);
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:27,代码来源:makeMessageDB.php
示例6: execute
function execute() {
global $wgRequest;
if ( !$wgRequest->wasPosted() ) {
echo $this->dtd();
echo <<<EOT
<html>
<head><title>store.php Test Interface</title></head>
<body>
<form method="post" action="store.php" enctype="multipart/form-data" >
<p>File: <input type="file" name="file"/></p>
<p><input type="submit" value="OK"/></p>
</form></body></html>
EOT;
return true;
}
$srcFile = $wgRequest->getFileTempname( 'file' );
if ( !$srcFile ) {
$this->error( 400, 'webstore_no_file' );
return false;
}
// Use an hourly timestamped directory for easy cleanup
$now = time();
$this->cleanupTemp( $now );
$timestamp = gmdate( self::$tempDirFormat, $now );
if ( !wfMkdirParents( "{$this->tmpDir}/$timestamp", null, __METHOD__ ) ) {
$this->error( 500, 'webstore_dest_mkdir' );
return false;
}
// Get the extension of the upload, needs to be preserved for type detection
$name = $wgRequest->getFileName( 'file' );
$n = strrpos( $name, '.' );
if ( $n ) {
$extension = '.' . File::normalizeExtension( substr( $name, $n + 1 ) );
} else {
$extension = '';
}
// Pick a random temporary path
$destRel = $timestamp . '/' . md5( mt_rand() . mt_rand() . mt_rand() ) . $extension;
if ( !@move_uploaded_file( $srcFile, "{$this->tmpDir}/$destRel" ) ) {
$this->error( 400, 'webstore_move_uploaded', $srcFile, "{$this->tmpDir}/$destRel" );
return false;
}
// Succeeded, return temporary location
header( 'Content-Type: text/xml' );
echo <<<EOT
<?xml version="1.0" encoding="utf-8"?>
<response>
<location>$destRel</location>
</response>
EOT;
return true;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:59,代码来源:store.php
示例7: execute
public function execute()
{
global $wgCaptchaSecret, $wgCaptchaDirectoryLevels;
$instance = ConfirmEditHooks::getInstance();
if (!$instance instanceof FancyCaptcha) {
$this->error("\$wgCaptchaClass is not FancyCaptcha.\n", 1);
}
$backend = $instance->getBackend();
$countAct = $instance->estimateCaptchaCount();
$this->output("Estimated number of captchas is {$countAct}.\n");
$countGen = (int) $this->getOption('fill') - $countAct;
if ($countGen <= 0) {
$this->output("No need to generate anymore captchas.\n");
return;
}
$tmpDir = wfTempDir() . '/mw-fancycaptcha-' . time() . '-' . wfRandomString(6);
if (!wfMkdirParents($tmpDir)) {
$this->error("Could not create temp directory.\n", 1);
}
$e = null;
// exception
try {
$cmd = sprintf("python %s --key %s --output %s --count %s --dirs %s", wfEscapeShellArg(__DIR__ . '/../captcha.py'), wfEscapeShellArg($wgCaptchaSecret), wfEscapeShellArg($tmpDir), wfEscapeShellArg($countGen), wfEscapeShellArg($wgCaptchaDirectoryLevels));
foreach (array('wordlist', 'font', 'font-size', 'blacklist', 'verbose') as $par) {
if ($this->hasOption($par)) {
$cmd .= " --{$par} " . wfEscapeShellArg($this->getOption($par));
}
}
$this->output("Generating {$countGen} new captchas...\n");
$retVal = 1;
wfShellExec($cmd, $retVal, array(), array('time' => 0));
if ($retVal != 0) {
wfRecursiveRemoveDir($tmpDir);
$this->error("Could not run generation script.\n", 1);
}
$flags = FilesystemIterator::SKIP_DOTS;
$iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpDir, $flags), RecursiveIteratorIterator::CHILD_FIRST);
$this->output("Copying the new captchas to storage...\n");
foreach ($iter as $fileInfo) {
if (!$fileInfo->isFile()) {
continue;
}
list($salt, $hash) = $instance->hashFromImageName($fileInfo->getBasename());
$dest = $instance->imagePath($salt, $hash);
$backend->prepare(array('dir' => dirname($dest)));
$status = $backend->quickStore(array('src' => $fileInfo->getPathname(), 'dst' => $dest));
if (!$status->isOK()) {
$this->error("Could not save file '{$fileInfo->getPathname()}'.\n");
}
}
} catch (Exception $e) {
wfRecursiveRemoveDir($tmpDir);
throw $e;
}
$this->output("Removing temporary files...\n");
wfRecursiveRemoveDir($tmpDir);
$this->output("Done.\n");
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:58,代码来源:GenerateFancyCaptchas.php
示例8: inspectDirectory
/**
* Run PHP Storm's Code Inspect for a given directory
*
* Actually, PHP storm will be run for a given directory.
* XML reports will then be parsed to get issues for given file.
*
* @param string $dirName file to run Code Inspect for
* @return string output from Code Inspect
* @throws Exception
*/
protected function inspectDirectory($dirName)
{
global $wgPHPStormPath, $IP;
$start = microtime(true);
$dirName = realpath($dirName);
$isCached = $this->cache['directory'] !== '' && strpos($dirName, $this->cache['directory']) === 0;
if (!$isCached) {
$lintProfile = dirname(__FILE__) . '/php/profiles/phplint.xml';
$projectMetaData = dirname(__FILE__) . '/php/project';
// copy project meta data to trunk root
$copyCmd = "cp -rf {$projectMetaData}/.idea {$IP}";
echo "Copying project meta data <{$copyCmd}>...";
exec($copyCmd);
echo " [done]\n";
// create a temporary directory for Code Inspect results
$resultsDir = wfTempDir() . '/phpstorm/' . uniqid('lint');
echo "Creating temporary directory for results <{$resultsDir}>...";
if (wfMkdirParents($resultsDir)) {
echo " [done]\n";
} else {
echo " [err!]\n";
}
$cmd = sprintf('/bin/sh %s/inspect.sh %s %s %s -d %s -v2', $wgPHPStormPath, realpath($IP . '/includes/..'), $lintProfile, $resultsDir, $dirName);
echo "Running PHP storm <{$cmd}>...";
#echo "Running PhpStorm for <{$dirName}>...";
$retVal = 0;
$output = array();
exec($cmd, $output, $retVal);
if ($retVal !== 0) {
throw new Exception("{$cmd} ended with code #{$retVal}");
}
// get the version of PhpStorm
$tool = '';
foreach ($output as $line) {
if (strpos($line, 'Starting up JetBrains PhpStorm') !== false) {
preg_match('#JetBrains PhpStorm [\\d\\.]+#', $line, $matches);
$tool = $matches[0];
}
}
echo implode("\n", $output);
// debug
echo " [done]\n";
// format results
$output = array('problems' => $this->parseResults($resultsDir), 'tool' => $tool);
// update the cache
$this->cache = array('directory' => $dirName, 'output' => $output);
} else {
//echo "Got results from cache for <{$this->cache['directory']}>\n";
$output = $this->cache['output'];
}
$output['time'] = round(microtime(true) - $start, 4);
return $output;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:63,代码来源:CodeLintPhp.class.php
示例9: get
static function get( $options ){
global $wgFFmpegLocation, $wgOggThumbLocation;
// Set up lodal pointer to file
$file = $options['file'];
if( !is_dir( dirname( $options['dstPath'] ) ) ){
wfMkdirParents( dirname( $options['dstPath'] ), null, __METHOD__ );
}
wfDebug( "Creating video thumbnail at" . $options['dstPath'] . "\n" );
// Else try ffmpeg and return result:
return self::tryFfmpegThumb( $options );
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:TimedMediaThumbnail.php
示例10: generate
private function generate()
{
if (preg_match('/^\\s*(\\w+)\\s*{/', $this->source, $matches)) {
$diagram_type = $matches[1];
} else {
$diagram_type = 'blockdiag';
// blockdiag for default
}
$diagprog_path = $this->path_array[$diagram_type];
if (!is_file($diagprog_path)) {
return $this->error("{$diagram_type} is not found at the specified place.");
}
// temporary directory check
if (!file_exists($this->tmpDir)) {
if (!wfMkdirParents($this->tmpDir)) {
return $this->error('temporary directory is not found.');
}
} elseif (!is_dir($this->tmpDir)) {
return $this->error('temporary directory is not directory');
} elseif (!is_writable($this->tmpDir)) {
return $this->error('temporary directory is not writable');
}
// create temporary file
$dstTmpName = tempnam($this->tmpDir, 'blockdiag');
$srcTmpName = tempnam($this->tmpDir, 'blockdiag');
// write blockdiag source
$fp = fopen($srcTmpName, 'w');
fwrite($fp, $this->source);
fclose($fp);
// generate blockdiag image
$cmd = $diagprog_path . ' -T ' . escapeshellarg($this->imgType) . ' -o ' . escapeshellarg($dstTmpName) . ' ' . escapeshellarg($srcTmpName);
$res = `{$cmd}`;
if (filesize($dstTmpName) == 0) {
return $this->error('unknown error.');
}
// move to image directory
$hashpath = $this->getHashPath();
if (!file_exists($hashpath)) {
if (!@wfMkdirParents($hashpath, 0755)) {
return $this->error('can not make blockdiag image directory', $this->blockdiagDir);
}
} elseif (!is_dir($hashpath)) {
return $this->error('blockdiag image directory is already exists. but not directory');
} elseif (!is_writable($hashpath)) {
return $this->error('blockdiag image directory is not writable');
}
if (!rename("{$dstTmpName}", "{$hashpath}/{$this->hash}.png")) {
return $this->error('can not rename blockdiag image');
}
return $this->mkImageTag();
}
开发者ID:tentwentyfour,项目名称:blockdiag-mediawiki-extension,代码行数:51,代码来源:BlockdiagGenerator.php
示例11: __construct
/**
* Constructor
*/
function __construct($server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0)
{
global $wgOut, $wgSQLiteDataDir, $wgSQLiteDataDirMode;
if ("{$wgSQLiteDataDir}" == '') {
$wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']) . '/data';
}
if (!is_dir($wgSQLiteDataDir)) {
wfMkdirParents($wgSQLiteDataDir, $wgSQLiteDataDirMode);
}
$this->mFailFunction = $failFunction;
$this->mFlags = $flags;
$this->mDatabaseFile = "{$wgSQLiteDataDir}/{$dbName}.sqlite";
$this->open($server, $user, $password, $dbName);
}
开发者ID:amjadtbssm,项目名称:website,代码行数:17,代码来源:DatabaseSqlite.php
示例12: startWrite
public function startWrite($code)
{
if (!file_exists($this->directory)) {
if (!wfMkdirParents($this->directory, null, __METHOD__)) {
throw new MWException("Unable to create the localisation store " . "directory \"{$this->directory}\"");
}
}
// Close reader to stop permission errors on write
if (!empty($this->readers[$code])) {
$this->readers[$code]->close();
}
try {
$this->writer = Writer::open($this->getFileName($code));
} catch (Exception $e) {
throw new MWException($e->getMessage());
}
$this->currentLang = $code;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:LCStoreCDB.php
示例13: doTransform
function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0)
{
global $wgDjvuRenderer, $wgDjvuPostProcessor;
// Fetch XML and check it, to give a more informative error message than the one which
// normaliseParams will inevitably give.
$xml = $image->getMetadata();
if (!$xml) {
return new MediaTransformError('thumbnail_error', @$params['width'], @$params['height'], wfMsg('djvu_no_xml'));
}
if (!$this->normaliseParams($image, $params)) {
return new TransformParameterError($params);
}
$width = $params['width'];
$height = $params['height'];
$srcPath = $image->getPath();
$page = $params['page'];
if ($page > $this->pageCount($image)) {
return new MediaTransformError('thumbnail_error', $width, $height, wfMsg('djvu_page_error'));
}
if ($flags & self::TRANSFORM_LATER) {
return new ThumbnailImage($image, $dstUrl, $width, $height, $dstPath, $page);
}
if (!wfMkdirParents(dirname($dstPath))) {
return new MediaTransformError('thumbnail_error', $width, $height, wfMsg('thumbnail_dest_directory'));
}
# Use a subshell (brackets) to aggregate stderr from both pipeline commands
# before redirecting it to the overall stdout. This works in both Linux and Windows XP.
$cmd = '(' . wfEscapeShellArg($wgDjvuRenderer) . " -format=ppm -page={$page} -size={$width}x{$height} " . wfEscapeShellArg($srcPath);
if ($wgDjvuPostProcessor) {
$cmd .= " | {$wgDjvuPostProcessor}";
}
$cmd .= ' > ' . wfEscapeShellArg($dstPath) . ') 2>&1';
wfProfileIn('ddjvu');
wfDebug(__METHOD__ . ": {$cmd}\n");
$err = wfShellExec($cmd, $retval);
wfProfileOut('ddjvu');
$removed = $this->removeBadFile($dstPath, $retval);
if ($retval != 0 || $removed) {
wfDebugLog('thumbnail', sprintf('thumbnail failed on %s: error %d "%s" from "%s"', wfHostname(), $retval, trim($err), $cmd));
return new MediaTransformError('thumbnail_error', $width, $height, $err);
} else {
return new ThumbnailImage($image, $dstUrl, $width, $height, $dstPath, $page);
}
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:44,代码来源:DjVu.php
示例14: doJobLoop
function doJobLoop(){
global $wgJobTypeConfig, $wahJobDelay, $wahRunOnce, $wahStatusOutput;
//look for jobs (sleep for $wahJobDelay if none found)
$job = WahJobManager :: getNewJob(false, 'Internal');
if(!$job && $wahRunOnce == false){
if($wahStatusOutput)
print "no jobs found waiting $wahJobDelay \n";
sleep($wahJobDelay);
return doJobLoop();
}elseif(!$job && $wahRunOnce == true){
if($wahStatusOutput)
print "no job found \n";
return ;
}
$jobSet = WahJobManager ::getJobSetById( $job->job_set_id );
$jobDetails = FormatJson::decode( $job->job_json ) ;
//get the title (so we can access the source file)
$fTitle = Title::newFromText( $job->title, $job->ns );
$file = wfLocalFile( $fTitle );
$thumbPath = $file->getThumbPath( $jobSet->set_encodekey );
//make sure the directory is ready:
wfMkdirParents( $thumbPath, null, __METHOD__ );
$destTarget = $thumbPath . '.ogg';
//issue the encoding command
if($wahStatusOutput) print "Running Encode Command...\n";
wahDoEncode($file->getPath(), $destTarget, $jobDetails->encodeSettings );
//once done with encode update the status:
WahJobManager :: updateJobDone($job);
//update set done (if only one item in the set)
$wjm = WahJobManager::newFromSet( $jobSet );
$percDone = $wjm->getDonePerc();
if( $percDone == 1 ){
WahJobManager :: updateSetDone( $jobSet );
}else{
if($wahStatusOutput)
print "job not complete? (might be mixing chunkDuration types?) ";
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:43,代码来源:internalCmdLineEncoder.php
示例15: checkImageDirectory
/**
* checkImageDirectory
*
* check if target directory exists. if not create it. if not possible
* signalize it. We have to have id of target wiki
*
* @access public
* @author eloy@wikia
*
* @return boolean: status of operation
*/
public function checkImageDirectory()
{
$mRetVal = false;
if (empty($this->mTargetID)) {
return $mRetVal;
}
wfProfileIn(__METHOD__);
$UploadDirectory = WikiFactory::getVarValueByName("wgUploadDirectory", $this->mTargetID);
if (file_exists($UploadDirectory)) {
if (is_dir($UploadDirectory)) {
$this->addLog("Target {$UploadDirectory} exists and is directory.");
$mRetVal = true;
} else {
$this->addLog("Target {$UploadDirectory} exists but is not directory");
$mRetVal = false;
}
} else {
$mRetVal = wfMkdirParents($UploadDirectory);
}
wfProfileOut(__METHOD__);
return $mRetVal;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:33,代码来源:ImageImporterTask.php
示例16: create
/**
* main entry point, create wiki with given parameters
*
* @throw CreateWikiException an exception with status of operation set
*/
public function create()
{
global $wgExternalSharedDB, $wgSharedDB, $wgUser;
$then = microtime(true);
// Set this flag to ensure that all select operations go against master
// Slave lag can cause random errors during wiki creation process
global $wgForceMasterDatabase;
$wgForceMasterDatabase = true;
wfProfileIn(__METHOD__);
if (wfReadOnly()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('DB is read only', self::ERROR_READONLY);
}
// check founder
if ($this->mFounder->isAnon()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Founder is anon', self::ERROR_USER_IN_ANON);
}
// check executables
$status = $this->checkExecutables();
if ($status != 0) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('checkExecutables() failed', $status);
}
// check domains
$status = $this->checkDomain();
if ($status != 0) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Check domain failed', $status);
}
// prepare all values needed for creating wiki
$this->prepareValues();
// prevent domain to be registered more than once
if (!AutoCreateWiki::lockDomain($this->mDomain)) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Domain name taken', self::ERROR_DOMAIN_NAME_TAKEN);
}
// start counting time
$this->mCurrTime = wfTime();
// check and create database
$this->mDBw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
# central
///
// local database handled is handler to cluster we create new wiki.
// It doesn't have to be the same like wikifactory cluster or db cluster
// where Special:CreateWiki exists.
//
// @todo do not use hardcoded name, code below is only for test
//
// set $activeCluster to false if you want to create wikis on first
// cluster
//
$this->mClusterDB = self::ACTIVE_CLUSTER ? "wikicities_" . self::ACTIVE_CLUSTER : "wikicities";
$this->mNewWiki->dbw = wfGetDB(DB_MASTER, array(), $this->mClusterDB);
// database handler, old $dbwTarget
// check if database is creatable
// @todo move all database creation checkers to canCreateDatabase
if (!$this->canCreateDatabase()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('DB exists - ' . $this->mNewWiki->dbname, self::ERROR_DATABASE_ALREADY_EXISTS);
} else {
$this->mNewWiki->dbw->query(sprintf("CREATE DATABASE `%s`", $this->mNewWiki->dbname));
wfDebugLog("createwiki", "Database {$this->mNewWiki->dbname} created\n", true);
}
/**
* create position in wiki.factory
* (I like sprintf construction, so sue me)
*/
if (!$this->addToCityList()) {
wfDebugLog("createwiki", __METHOD__ . ": Cannot set data in city_list table\n", true);
wfProfileOut(__METHOD__);
throw new CreateWikiException('Cannot add wiki to city_list', self::ERROR_DATABASE_WRITE_TO_CITY_LIST_BROKEN);
}
// set new city_id
$this->mNewWiki->city_id = $this->mDBw->insertId();
if (empty($this->mNewWiki->city_id)) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Cannot set data in city_list table. city_id is empty after insert', self::ERROR_DATABASE_WIKI_FACTORY_TABLES_BROKEN);
}
wfDebugLog("createwiki", __METHOD__ . ": Row added added into city_list table, city_id = {$this->mNewWiki->city_id}\n", true);
/**
* add domain and www.domain to the city_domains table
*/
if (!$this->addToCityDomains()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Cannot set data in city_domains table', self::ERROR_DATABASE_WRITE_TO_CITY_DOMAINS_BROKEN);
}
wfDebugLog("createwiki", __METHOD__ . ": Row added into city_domains table, city_id = {$this->mNewWiki->city_id}\n", true);
/**
* create image folder
*/
global $wgEnableSwiftFileBackend;
if (empty($wgEnableSwiftFileBackend)) {
wfMkdirParents("{$this->mNewWiki->images_dir}");
wfDebugLog("createwiki", __METHOD__ . ": Folder {$this->mNewWiki->images_dir} created\n", true);
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:CreateWiki.php
示例17: checkCacheDirs
protected function checkCacheDirs()
{
$filename = $this->fileCacheName();
$mydir2 = substr($filename, 0, strrpos($filename, '/'));
# subdirectory level 2
$mydir1 = substr($mydir2, 0, strrpos($mydir2, '/'));
# subdirectory level 1
wfMkdirParents($mydir1);
wfMkdirParents($mydir2);
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:10,代码来源:HTMLFileCache.php
示例18: getDirectory
/**
* dump directory is created as
*
* <root>/<first letter>/<two first letters>/<database>
*/
function getDirectory($database, $hide = false)
{
global $wgDevelEnvironment;
$folder = empty($wgDevelEnvironment) ? "raid" : "tmp";
$subfolder = $hide ? "dumps-hidden" : "dumps";
$database = strtolower($database);
$directory = sprintf("/%s/%s/%s/%s/%s", $folder, $subfolder, substr($database, 0, 1), substr($database, 0, 2), $database);
if (!is_dir($directory)) {
Wikia::log(__METHOD__, "dir", "create {$directory}", true, true);
wfMkdirParents($directory);
}
return $directory;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:runBackups.php
示例19: saveUploadedFile
/** I BORROWED THIS FUNCTION FROM SpecialUpload.php!! CHECK FOR EACH VERSION OF MEDIAWIKI, IF
* THIS FUNCTION STILL MAKES SENSE!
*
* Move the uploaded file from its temporary location to the final
* destination. If a previous version of the file exists, move
* it into the archive subdirectory.
*
* @todo If the later save fails, we may have disappeared the original file.
*
* @param string $saveName
* @param string $tempName full path to the temporary file
* @param bool $useRename if true, doesn't check that the source file
* is a PHP-managed upload temporary
*/
function saveUploadedFile($saveName, $tempName, $useRename = false)
{
global $wgOut, $wgAllowCopyUploads;
$fname = "SpecialUpload::saveUploadedFile";
if (!$useRename && $wgAllowCopyUploads && $this->mSourceType == 'web') {
$useRename = true;
}
$dest = wfImageDir($saveName);
$archive = wfImageArchiveDir($saveName);
if (!is_dir($dest)) {
wfMkdirParents($dest);
}
if (!is_dir($archive)) {
wfMkdirParents($archive);
}
$this->mSavedFile = "{$dest}/{$saveName}";
if (is_file($this->mSavedFile)) {
$this->mUploadOldVersion = gmdate('YmdHis') . "!{$saveName}";
wfSuppressWarnings();
$success = rename($this->mSavedFile, "{$archive}/{$this->mUploadOldVersion}");
wfRestoreWarnings();
if (!$success) {
$wgOut->showFileRenameError($this->mSavedFile, "{$archive}/{$this->mUploadOldVersion}");
return false;
} else {
wfDebug("{$fname}: moved file " . $this->mSavedFile . " to {$archive}/{$this->mUploadOldVersion}\n");
}
} else {
$this->mUploadOldVersion = '';
}
wfSuppressWarnings();
$success = $useRename ? rename($tempName, $this->mSavedFile) : move_uploaded_file($tempName, $this->mSavedFile);
wfRestoreWarnings();
if (!$success) {
$wgOut->showFileCopyError($tempName, $this->mSavedFile);
return false;
} else {
wfDebug("{$fname}: wrote tempfile {$tempName} to " . $this->mSavedFile . "\n");
}
chmod($this->mSavedFile, 0644);
return true;
}
开发者ID:microcosmx,项目名称:experiments,代码行数:56,代码来源:AnyWikiDraw_body.php
示例20: getSchemaUpdates
/**
* Sets up requires directories
* @param DatabaseUpdater $updater Provided by MediaWikis update.php
* @return boolean Always true to keep the hook running
*/
public static function getSchemaUpdates($updater)
{
//TODO: Create abstraction in Core/Adapter
$sTmpDir = BSDATADIR . DS . 'UEModulePDF';
if (!file_exists($sTmpDir)) {
echo 'Directory "' . $sTmpDir . '" not found. Creating.' . "\n";
wfMkdirParents($sTmpDir);
} else {
echo 'Directory "' . $sTmpDir . '" found.' . "\n";
}
$sDefaultTemplateDir = BSDATADIR . DS . 'PDFTemplates';
if (!file_exists($sDefaultTemplateDir)) {
echo 'Default template directory "' . $sDefaultTemplateDir . '" not found. Copying.' . "\n";
BsFileSystemHelper::copyRecursive(__DIR__ . DS . 'data' . DS . 'PDFTemplates', $sDefaultTemplateDir);
}
return true;
}
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:22,代码来源:UEModulePDF.class.php
注:本文中的wfMkdirParents函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论