• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfBaseName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testBasename

 function testBasename()
 {
     $sets = array('' => '', '/' => '', '\\' => '', '//' => '', '\\\\' => '', 'a' => 'a', 'aaaa' => 'aaaa', '/a' => 'a', '\\a' => 'a', '/aaaa' => 'aaaa', '\\aaaa' => 'aaaa', '/aaaa/' => 'aaaa', '\\aaaa\\' => 'aaaa', '\\aaaa\\' => 'aaaa', '/mnt/upload3/wikipedia/en/thumb/8/8b/Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg' => '93px-Zork_Grand_Inquisitor_box_cover.jpg', 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE' => 'VIEWER.EXE', 'Östergötland_coat_of_arms.png' => 'Östergötland_coat_of_arms.png');
     foreach ($sets as $from => $to) {
         $this->assertEquals($to, wfBaseName($from), "wfBaseName('{$from}') => '{$to}'");
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:7,代码来源:GlobalTest.php


示例2: wfStripIllegalFilenameChars

/**
 * Replace all invalid characters with '-'.
 * Additional characters can be defined in $wgIllegalFileChars (see T22489).
 * By default, $wgIllegalFileChars includes ':', '/', '\'.
 *
 * @param string $name Filename to process
 * @return string
 */
function wfStripIllegalFilenameChars($name)
{
    global $wgIllegalFileChars;
    $illegalFileChars = $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : '';
    $name = preg_replace("/[^" . Title::legalChars() . "]" . $illegalFileChars . "/", '-', $name);
    // $wgIllegalFileChars may not include '/' and '\', so we still need to do this
    $name = wfBaseName($name);
    return $name;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:17,代码来源:GlobalFunctions.php


示例3: makeThumbs

 private static function makeThumbs($local_file, $sample)
 {
     global $wgImageMagickConvertCommand, $wgUseOptiPng, $wgOptiPngCommand;
     $comment = 'Auto-uploaded for the Samples page.';
     $license = 'cc-by-sa-nc-2.5-self';
     //PNG the file name
     $img_file = preg_replace('@.pdf@', '.png', $local_file);
     //make an image out of a pdf (add an [0] so we only get the first page)
     $cmd = $wgImageMagickConvertCommand . ' ' . escapeshellarg($local_file) . '[0] ' . escapeshellarg($img_file);
     exec($cmd);
     //optimize that bad boy
     if ($wgUseOptiPng) {
         $cmd = $wgOptiPngCommand . ' ' . escapeshellarg($img_file);
         exec($cmd);
     }
     //put the new image into the system
     $title = Title::makeTitleSafe(NS_IMAGE, wfBaseName($img_file));
     if (!is_object($title)) {
         self::error_log($sample, 'Image could not be imported; a valid title cannot be produced.');
         return false;
     }
     $image = wfLocalFile($title);
     $archive = $image->publish($img_file);
     //remove the temp image file
     @unlink($img_file);
     if (WikiError::isError($archive) || !$archive->isGood()) {
         self::error_log($sample, 'Image archive publish failed.');
         return false;
     }
     if ($image->recordUpload($archive->value, $comment, $license)) {
         //yay!
         return true;
     } else {
         self::error_log($sample, 'Image record upload failed.');
         return false;
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:37,代码来源:SampleDocProcess.php


示例4: file_get_contents

if (isset($options['comment-file'])) {
    $comment = file_get_contents($options['comment-file']);
    if ($comment === false || $comment === null) {
        die("failed to read comment file: {$options['comment-file']}\n");
    }
} elseif (isset($options['comment'])) {
    $comment = $options['comment'];
}
$commentExt = isset($options['comment-ext']) ? $options['comment-ext'] : false;
# Get the license specifier
$license = isset($options['license']) ? $options['license'] : '';
# Batch "upload" operation
$count = count($files);
if ($count > 0) {
    foreach ($files as $file) {
        $base = wfBaseName($file);
        # Validate a title
        $title = Title::makeTitleSafe(NS_FILE, $base);
        if (!is_object($title)) {
            echo "{$base} could not be imported; a valid title cannot be produced\n";
            continue;
        }
        if ($from) {
            if ($from == $title->getDBkey()) {
                $from = null;
            } else {
                $ignored++;
                continue;
            }
        }
        if ($checkUserBlock && $processed % $checkUserBlock == 0) {
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:importImages.php


示例5: getLocalCopy

 /**
  * @see FileBackendStore::getLocalCopy()
  */
 public function getLocalCopy(array $params)
 {
     list($srcCont, $srcRel) = $this->resolveStoragePathReal($params['src']);
     if ($srcRel === null) {
         return null;
     }
     /*if ( !$this->fileExists( $params ) ) {
     			return null;
     		}*/
     $tmpFile = null;
     try {
         $sContObj = $this->getContainer($srcCont);
         $obj = new CF_Object($sContObj, $srcRel, false, false);
         // skip HEAD
         // Get source file extension
         $ext = FileBackend::extensionFromPath($srcRel);
         // Create a new temporary file...
         $tmpFile = TempFSFile::factory(wfBaseName($srcRel) . '_', $ext);
         if ($tmpFile) {
             $handle = fopen($tmpFile->getPath(), 'wb');
             if ($handle) {
                 $obj->stream($handle, $this->headersFromParams($params));
                 fclose($handle);
             } else {
                 $tmpFile = null;
                 // couldn't open temp file
             }
         }
     } catch (NoSuchContainerException $e) {
         $tmpFile = null;
         $this->logException($e, __METHOD__, $params);
     } catch (NoSuchObjectException $e) {
         $tmpFile = null;
         $this->logException($e, __METHOD__, $params);
     } catch (InvalidResponseException $e) {
         $tmpFile = null;
         $this->logException($e, __METHOD__, $params);
     } catch (Exception $e) {
         // some other exception?
         $tmpFile = null;
         $this->logException($e, __METHOD__, $params);
     }
     return $tmpFile;
 }
开发者ID:yusufchang,项目名称:app,代码行数:47,代码来源:SwiftFileBackend.php


示例6: wfStripIllegalFilenameChars

/**
 * Replace all invalid characters with -
 * Additional characters can be defined in $wgIllegalFileChars (see bug 20489)
 * By default, $wgIllegalFileChars = ':'
 *
 * @param string $name Filename to process
 * @return string
 */
function wfStripIllegalFilenameChars($name)
{
    global $wgIllegalFileChars;
    $illegalFileChars = $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : '';
    $name = wfBaseName($name);
    $name = preg_replace("/[^" . Title::legalChars() . "]" . $illegalFileChars . "/", '-', $name);
    return $name;
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:16,代码来源:GlobalFunctions.php


示例7: wfImageAuthMain

function wfImageAuthMain()
{
    global $wgImgAuthPublicTest, $wgRequest;
    // See if this is a public Wiki (no protections).
    if ($wgImgAuthPublicTest && in_array('read', User::getGroupPermissions(array('*')), true)) {
        // This is a public wiki, so disable this script (for private wikis only)
        wfForbidden('img-auth-accessdenied', 'img-auth-public');
        return;
    }
    // Get the requested file path (source file or thumbnail)
    $matches = WebRequest::getPathInfo();
    if (!isset($matches['title'])) {
        wfForbidden('img-auth-accessdenied', 'img-auth-nopathinfo');
        return;
    }
    $path = $matches['title'];
    if ($path && $path[0] !== '/') {
        // Make sure $path has a leading /
        $path = "/" . $path;
    }
    // Check for bug 28235: QUERY_STRING overriding the correct extension
    $whitelist = array();
    $dotPos = strrpos($path, '.');
    if ($dotPos !== false) {
        $whitelist[] = substr($path, $dotPos + 1);
    }
    if (!$wgRequest->checkUrlExtension($whitelist)) {
        return;
    }
    // Get the local file repository
    $repo = RepoGroup::singleton()->getRepo('local');
    // Get the full file storage path and extract the source file name.
    // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png).
    // This only applies to thumbnails, and all thumbnails should
    // be under a folder that has the source file name.
    if (strpos($path, '/thumb/') === 0) {
        $name = wfBaseName(dirname($path));
        // file is a thumbnail
        $filename = $repo->getZonePath('thumb') . substr($path, 6);
        // strip "/thumb"
    } else {
        $name = wfBaseName($path);
        // file is a source file
        $filename = $repo->getZonePath('public') . $path;
    }
    // Check to see if the file exists
    if (!$repo->fileExists($filename)) {
        wfForbidden('img-auth-accessdenied', 'img-auth-nofile', $filename);
        return;
    }
    $title = Title::makeTitleSafe(NS_FILE, $name);
    if (!$title instanceof Title) {
        // files have valid titles
        wfForbidden('img-auth-accessdenied', 'img-auth-badtitle', $name);
        return;
    }
    // Run hook for extension authorization plugins
    /** @var $result array */
    $result = null;
    if (!wfRunHooks('ImgAuthBeforeStream', array(&$title, &$path, &$name, &$result))) {
        wfForbidden($result[0], $result[1], array_slice($result, 2));
        return;
    }
    // Check user authorization for this title
    // Checks Whitelist too
    if (!$title->userCan('read')) {
        wfForbidden('img-auth-accessdenied', 'img-auth-noread', $name);
        return;
    }
    // Stream the requested file
    wfDebugLog('img_auth', "Streaming `" . $filename . "`.");
    $repo->streamFile($filename, array('Cache-Control: private', 'Vary: Cookie'));
}
开发者ID:mangowi,项目名称:mediawiki,代码行数:73,代码来源:img_auth.php


示例8: file_get_contents

    $comment = file_get_contents($options['comment-file']);
    if ($comment === false || $comment === null) {
        die("failed to read comment file: {$options['comment-file']}\n");
    }
} elseif (isset($options['comment'])) {
    $comment = $options['comment'];
}
$commentExt = isset($options['comment-ext']) ? $options['comment-ext'] : false;
$summary = isset($options['summary']) ? $options['summary'] : '';
# Get the license specifier
$license = isset($options['license']) ? $options['license'] : '';
# Batch "upload" operation
$count = count($files);
if ($count > 0) {
    foreach ($files as $file) {
        $base = UtfNormal\Validator::cleanUp(wfBaseName($file));
        # Validate a title
        $title = Title::makeTitleSafe(NS_FILE, $base);
        if (!is_object($title)) {
            echo "{$base} could not be imported; a valid title cannot be produced\n";
            continue;
        }
        if ($from) {
            if ($from == $title->getDBkey()) {
                $from = null;
            } else {
                $ignored++;
                continue;
            }
        }
        if ($checkUserBlock && $processed % $checkUserBlock == 0) {
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:importImages.php


示例9: checkMissingImage

 function checkMissingImage($fullpath)
 {
     $filename = wfBaseName($fullpath);
     if (is_dir($fullpath)) {
         return;
     }
     if (is_link($fullpath)) {
         $this->output("skipping symlink at {$fullpath}\n");
         return;
     }
     $row = $this->dbw->selectRow('image', array('img_name'), array('img_name' => $filename), __METHOD__);
     if ($row) {
         // already known, move on
         return;
     } else {
         $this->addMissingImage($filename, $fullpath);
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:18,代码来源:rebuildImages.php


示例10: __construct

 /**
  * Constructor
  *
  * @param $file String: filename.
  */
 function __construct($file)
 {
     /**
      * Page numbers here refer to pages in the EXIF 2.2 standard
      *
      * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification
      */
     $this->mExifTags = array('tiff' => array('structure' => array('ImageWidth' => Exif::SHORT . ',' . Exif::LONG, 'ImageLength' => Exif::SHORT . ',' . Exif::LONG, 'BitsPerSample' => Exif::SHORT, 'Compression' => Exif::SHORT, 'PhotometricInterpretation' => Exif::SHORT, 'Orientation' => Exif::SHORT, 'SamplesPerPixel' => Exif::SHORT, 'PlanarConfiguration' => Exif::SHORT, 'YCbCrSubSampling' => Exif::SHORT, 'YCbCrPositioning' => Exif::SHORT, 'XResolution' => Exif::RATIONAL, 'YResolution' => Exif::RATIONAL, 'ResolutionUnit' => Exif::SHORT), 'offset' => array('StripOffsets' => Exif::SHORT . ',' . Exif::LONG, 'RowsPerStrip' => Exif::SHORT . ',' . Exif::LONG, 'StripByteCounts' => Exif::SHORT . ',' . Exif::LONG, 'JPEGInterchangeFormat' => Exif::SHORT . ',' . Exif::LONG, 'JPEGInterchangeFormatLength' => Exif::SHORT . ',' . Exif::LONG), 'characteristics' => array('TransferFunction' => Exif::SHORT, 'WhitePoint' => Exif::RATIONAL, 'PrimaryChromaticities' => Exif::RATIONAL, 'YCbCrCoefficients' => Exif::RATIONAL, 'ReferenceBlackWhite' => Exif::RATIONAL), 'other' => array('DateTime' => Exif::ASCII, 'ImageDescription' => Exif::ASCII, 'Make' => Exif::ASCII, 'Model' => Exif::ASCII, 'Software' => Exif::ASCII, 'Artist' => Exif::ASCII, 'Copyright' => Exif::ASCII)), 'exif' => array('version' => array('ExifVersion' => Exif::UNDEFINED, 'FlashpixVersion' => Exif::UNDEFINED), 'characteristics' => array('ColorSpace' => Exif::SHORT), 'configuration' => array('ComponentsConfiguration' => Exif::UNDEFINED, 'CompressedBitsPerPixel' => Exif::RATIONAL, 'PixelYDimension' => Exif::SHORT . ',' . Exif::LONG, 'PixelXDimension' => Exif::SHORT . ',' . Exif::LONG), 'user' => array('MakerNote' => Exif::UNDEFINED, 'UserComment' => Exif::UNDEFINED), 'related' => array('RelatedSoundFile' => Exif::ASCII), 'dateandtime' => array('DateTimeOriginal' => Exif::ASCII, 'DateTimeDigitized' => Exif::ASCII, 'SubSecTime' => Exif::ASCII, 'SubSecTimeOriginal' => Exif::ASCII, 'SubSecTimeDigitized' => Exif::ASCII), 'conditions' => array('ExposureTime' => Exif::RATIONAL, 'FNumber' => Exif::RATIONAL, 'ExposureProgram' => Exif::SHORT, 'SpectralSensitivity' => Exif::ASCII, 'ISOSpeedRatings' => Exif::SHORT, 'OECF' => Exif::UNDEFINED, 'ShutterSpeedValue' => Exif::SRATIONAL, 'ApertureValue' => Exif::RATIONAL, 'BrightnessValue' => Exif::SRATIONAL, 'ExposureBiasValue' => Exif::SRATIONAL, 'MaxApertureValue' => Exif::RATIONAL, 'SubjectDistance' => Exif::RATIONAL, 'MeteringMode' => Exif::SHORT, 'LightSource' => Exif::SHORT, 'Flash' => Exif::SHORT, 'FocalLength' => Exif::RATIONAL, 'SubjectArea' => Exif::SHORT, 'FlashEnergy' => Exif::RATIONAL, 'SpatialFrequencyResponse' => Exif::UNDEFINED, 'FocalPlaneXResolution' => Exif::RATIONAL, 'FocalPlaneYResolution' => Exif::RATIONAL, 'FocalPlaneResolutionUnit' => Exif::SHORT, 'SubjectLocation' => Exif::SHORT, 'ExposureIndex' => Exif::RATIONAL, 'SensingMethod' => Exif::SHORT, 'FileSource' => Exif::UNDEFINED, 'SceneType' => Exif::UNDEFINED, 'CFAPattern' => Exif::UNDEFINED, 'CustomRendered' => Exif::SHORT, 'ExposureMode' => Exif::SHORT, 'WhiteBalance' => Exif::SHORT, 'DigitalZoomRatio' => Exif::RATIONAL, 'FocalLengthIn35mmFilm' => Exif::SHORT, 'SceneCaptureType' => Exif::SHORT, 'GainControl' => Exif::RATIONAL, 'Contrast' => Exif::SHORT, 'Saturation' => Exif::SHORT, 'Sharpness' => Exif::SHORT, 'DeviceSettingDescription' => Exif::UNDEFINED, 'SubjectDistanceRange' => Exif::SHORT), 'other' => array('ImageUniqueID' => Exif::ASCII)), 'gps' => array('GPSVersionID' => Exif::BYTE, 'GPSLatitudeRef' => Exif::ASCII, 'GPSLatitude' => Exif::RATIONAL, 'GPSLongitudeRef' => Exif::ASCII, 'GPSLongitude' => Exif::RATIONAL, 'GPSAltitudeRef' => Exif::BYTE, 'GPSAltitude' => Exif::RATIONAL, 'GPSTimeStamp' => Exif::RATIONAL, 'GPSSatellites' => Exif::ASCII, 'GPSStatus' => Exif::ASCII, 'GPSMeasureMode' => Exif::ASCII, 'GPSDOP' => Exif::RATIONAL, 'GPSSpeedRef' => Exif::ASCII, 'GPSSpeed' => Exif::RATIONAL, 'GPSTrackRef' => Exif::ASCII, 'GPSTrack' => Exif::RATIONAL, 'GPSImgDirectionRef' => Exif::ASCII, 'GPSImgDirection' => Exif::RATIONAL, 'GPSMapDatum' => Exif::ASCII, 'GPSDestLatitudeRef' => Exif::ASCII, 'GPSDestLatitude' => Exif::RATIONAL, 'GPSDestLongitudeRef' => Exif::ASCII, 'GPSDestLongitude' => Exif::RATIONAL, 'GPSDestBearingRef' => Exif::ASCII, 'GPSDestBearing' => Exif::RATIONAL, 'GPSDestDistanceRef' => Exif::ASCII, 'GPSDestDistance' => Exif::RATIONAL, 'GPSProcessingMethod' => Exif::UNDEFINED, 'GPSAreaInformation' => Exif::UNDEFINED, 'GPSDateStamp' => Exif::ASCII, 'GPSDifferential' => Exif::SHORT));
     $this->file = $file;
     $this->basename = wfBaseName($this->file);
     $this->makeFlatExifTags();
     $this->debugFile($this->basename, __FUNCTION__, true);
     wfSuppressWarnings();
     $data = exif_read_data($this->file);
     wfRestoreWarnings();
     /**
      * exif_read_data() will return false on invalid input, such as
      * when somebody uploads a file called something.jpeg
      * containing random gibberish.
      */
     $this->mRawExifData = $data ? $data : array();
     $this->makeFilteredData();
     $this->makeFormattedData();
     $this->debugFile(__FUNCTION__, false);
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:30,代码来源:Exif.php


示例11: internalProcessUpload

 function internalProcessUpload(&$resultDetails)
 {
     global $wgUser;
     /* Check for PHP error if any, requires php 4.2 or newer */
     if ($this->mCurlError == 1) {
         return self::LARGE_FILE_SERVER;
     }
     /**
      * If there was no filename or a zero size given, give up quick.
      */
     if (trim($this->mSrcName) == '' || empty($this->mFileSize)) {
         return self::EMPTY_FILE;
     }
     # Chop off any directories in the given filename
     if ($this->mDesiredDestName) {
         $basename = $this->mDesiredDestName . '.' . $this->mParameterExt;
         $this->mStoredDestName = $this->mDesiredDestName;
     } else {
         $basename = $this->mSrcName;
     }
     $filtered = wfBaseName($basename);
     /**
      * We'll want to blacklist against *any* 'extension', and use
      * only the final one for the whitelist.
      */
     list($partname, $ext) = $this->splitExtensions($filtered);
     if (count($ext)) {
         $finalExt = $ext[count($ext) - 1];
     } else {
         $finalExt = '';
     }
     # If there was more than one "extension", reassemble the base
     # filename to prevent bogus complaints about length
     if (count($ext) > 1) {
         for ($i = 0; $i < count($ext) - 1; $i++) {
             $partname .= '.' . $ext[$i];
         }
     }
     if (strlen($partname) < 1) {
         return self::MIN_LENGTH_PARTNAME;
     }
     /**
      * Filter out illegal characters, and try to make a legible name
      * out of it. We'll strip some silently that Title would die on.
      */
     $filtered = preg_replace("/[^" . Title::legalChars() . "]|:/", '-', $filtered);
     $nt = Title::makeTitleSafe(NS_IMAGE, $filtered);
     if (is_null($nt)) {
         $resultDetails = array('filtered' => $filtered);
         return self::ILLEGAL_FILENAME;
     }
     $this->mLocalFile = wfLocalFile($nt);
     $this->mDestName = $this->mLocalFile->getName();
     /**
      * If the image is protected, non-sysop users won't be able
      * to modify it by uploading a new revision.
      */
     if (!$nt->userCan('edit')) {
         return self::PROTECTED_PAGE;
     }
     /**
      * In some cases we may forbid overwriting of existing files.
      */
     // here starts the interesting part...
     // we overwrite mDestName and give it a new twist
     $timestamp = '';
     $img_found = wfFindFile($this->mDestName);
     if ($img_found) {
         // ehhh...
         // we'll do it hard way then...
         $timestamp = $this->mDestName;
     } else {
         // this timestamp should not repeat...
         $timestamp = 'invalid';
     }
     $tempname = '';
     $tmpcount = 0;
     while ($img_found && $timestamp != $this->mLastTimestamp) {
         $tmpcount++;
         $file_ext = explode('.', $this->mDestName);
         $file_ext = $file_ext[0];
         $tmpdestname = $file_ext;
         $tempname = $tmpdestname . $tmpcount . '.' . $this->mParameterExt;
         $timestamp = $tempname;
         $img_found = wfFindFile($tempname);
     }
     if ($tmpcount > 0) {
         wfLocalFile($title);
         $tempname = preg_replace("/[^" . Title::legalChars() . "]|:/", '-', $tempname);
         $nt = Title::makeTitleSafe(NS_FILE, $tempname);
         $this->mLocalFile = wfLocalFile($nt);
         $this->mDestName = $this->mLocalFile->getName();
         $this->mDesiredDestName = $this->mStoredDestName . $tmpcount . '.' . $this->mParameterExt;
     } else {
         // append the extension anyway
         $this->mDesiredDestName = $this->mStoredDestName . '.' . $this->mParameterExt;
     }
     $overwrite = $this->checkOverwrite($this->mDestName);
     if ($overwrite !== true) {
         $resultDetails = array('overwrite' => $overwrite);
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:CreatePageImageUploadForm.php


示例12: wfProfileIn

 * directory, and $wgUploadPath to point to this file. Also set $wgWhitelistRead
 * to an array of pages you want everyone to be able to access. Your server must
 * support PATH_INFO, CGI-based configurations generally don't.
 */
require_once './includes/WebStart.php';
wfProfileIn('img_auth.php');
require_once './includes/StreamFile.php';
if (!isset($_SERVER['PATH_INFO'])) {
    wfDebugLog('img_auth', "missing PATH_INFO");
    wfForbidden();
}
# Get filenames/directories
wfDebugLog('img_auth', "PATH_INFO is: " . $_SERVER['PATH_INFO']);
$filename = realpath($wgUploadDirectory . $_SERVER['PATH_INFO']);
$realUploadDirectory = realpath($wgUploadDirectory);
$imageName = $wgContLang->getNsText(NS_IMAGE) . ":" . wfBaseName($_SERVER['PATH_INFO']);
# Check if the filename is in the correct directory
if (substr($filename, 0, strlen($realUploadDirectory)) != $realUploadDirectory) {
    wfDebugLog('img_auth', "requested path not in upload dir: {$filename}");
    wfForbidden();
}
if (is_array($wgWhitelistRead) && !in_array($imageName, $wgWhitelistRead) && !$wgUser->getID()) {
    wfDebugLog('img_auth', "not logged in and requested file not in whitelist: {$imageName}");
    wfForbidden();
}
if (!file_exists($filename)) {
    wfDebugLog('img_auth', "requested file does not exist: {$filename}");
    wfForbidden();
}
if (is_dir($filename)) {
    wfDebugLog('img_auth', "requested file is a directory: {$filename}");
开发者ID:negabaro,项目名称:alfresco,代码行数:31,代码来源:img_auth.php


示例13: importImages

 /**
  * This method imports all images given in $images.
  * A page that reports the results and failures can be created if 
  * you call startReport() before and createReport() after this method. 
  * 
  * @param array(string) $images
  * 		Names of the images that will be imported from the source wiki. 
  * 		If no namespace is given it will be appended automatically.
  * @param bool $createReport (default: false)
  * 		If <true>, a report for this operation is created.
  * 
  * @throws
  * 		IAIException(IAIException::HTTP_ERROR) 
  * 			if the HTTP request fails
  *   
  */
 public function importImages($images)
 {
     // Add namespace if necessary
     global $wgContLang, $iaigTempDir;
     $imgNs = $wgContLang->getNsText(NS_IMAGE) . ":";
     foreach ($images as $k => $i) {
         if (strpos($i, $imgNs) === false) {
             $images[$k] = $imgNs . $i;
         }
     }
     $imageURLs = $this->getImageURLs($images);
     foreach ($imageURLs as $img) {
         $base = urldecode(wfBaseName($img));
         $title = Title::makeTitleSafe(NS_FILE, $base);
         if (!is_object($title)) {
             echo "{$base} could not be imported; a valid title cannot be produced\n";
             continue;
         }
         # Check existence
         $image = wfLocalFile($title);
         //TODO replace $options['overwrite'] with a field in this class
         if ($image->exists()) {
             //				if( isset( $options['overwrite'] ) ) {
             //					echo( "{$base} exists, overwriting..." );
             //				} else {
             echo "{$base} exists, skipping\n";
             $this->mSkippedImages[] = $base;
             continue;
             //				}
         } else {
             echo "Importing {$base}...";
         }
         // Read image from source wiki
         $contents = Http::get($img, self::HTTP_TIMEOUT);
         if ($contents === false) {
             // HTTP-Timeout
             $this->mSkippedImages[] = $base;
             echo "HTTP timeout for {$base}; skipping\n";
             continue;
             //				throw new IAIException(IAIException::HTTP_ERROR, $img);
         }
         $handle = fopen($iaigTempDir . $base, "wb");
         fwrite($handle, $contents);
         fclose($handle);
         $this->mImportedImages[] = $base;
         $archive = $image->publish($iaigTempDir . $base);
         if (WikiError::isError($archive) || !$archive->isGood()) {
             echo "failed.\n";
             continue;
         } else {
             echo "success.\n";
         }
         $image->recordUpload($archive->value, "Imported with IAI Article Importer", "No license information");
         unlink($iaigTempDir . $base);
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:72,代码来源:IAI_ArticleImporter.php


示例14: wfImageAuthMain

function wfImageAuthMain()
{
    global $wgImgAuthPublicTest, $wgImgAuthUrlPathMap, $wgRequest;
    // See if this is a public Wiki (no protections).
    if ($wgImgAuthPublicTest && in_array('read', User::getGroupPermissions(array('*')), true)) {
        // This is a public wiki, so disable this script (for private wikis only)
        wfForbidden('img-auth-accessdenied', 'img-auth-public');
        return;
    }
    // Get the requested file path (source file or thumbnail)
    $matches = WebRequest::getPathInfo();
    if (!isset($matches['title'])) {
        wfForbidden('img-auth-accessdenied', 'img-auth-nopathinfo');
        return;
    }
    $path = $matches['title'];
    if ($path && $path[0] !== '/') {
        // Make sure $path has a leading /
        $path = "/" . $path;
    }
    // Check for bug 28235: QUERY_STRING overriding the correct extension
    $whitelist = array();
    $extension = FileBackend::extensionFromPath($path, 'rawcase');
    if ($extension != '') {
        $whitelist[] = $extension;
    }
    if (!$wgRequest->checkUrlExtension($whitelist)) {
        return;
    }
    // Various extensions may have their own backends that need access.
    // Check if there is a special backend and storage base path for this file.
    foreach ($wgImgAuthUrlPathMap as $prefix => $storageDir) {
        $prefix = rtrim($prefix, '/') . '/';
        // implicit trailing slash
        if (strpos($path, $prefix) === 0) {
            $be = FileBackendGroup::singleton()->backendFromPath($storageDir);
            $filename = $storageDir . substr($path, strlen($prefix));
            // strip prefix
            // Check basic user authorization
            if (!RequestContext::getMain()->getUser()->isAllowed('read')) {
                wfForbidden('img-auth-accessdenied', 'img-auth-noread', $path);
                return;
            }
            if ($be->fileExists(array('src' => $filename))) {
                wfDebugLog('img_auth', "Streaming `" . $filename . "`.");
                $be->streamFile(array('src' => $filename), array('Cache-Control: private', 'Vary: Cookie'));
            } else {
                wfForbidden('img-auth-accessdenied', 'img-auth-nofile', $path);
            }
            return;
        }
    }
    // Get the local file repository
    $repo = RepoGroup::singleton()->getRepo('local');
    // Get the full file storage path and extract the source file name.
    // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png).
    // This only applies to thumbnails, and all thumbnails should
    // be under a folder that has the source file name.
    if (strpos($path, '/thumb/') === 0) {
        $name = wfBaseName(dirname($path));
        // file is a thumbnail
        $filename = $repo->getZonePath('thumb') . substr($path, 6);
        // strip "/thumb"
    } else {
        $name = wfBaseName($path);
        // file is a source file
        $filename = $repo->getZonePath('public') . $path;
    }
    // Check to see if the file exists
    if (!$repo->fileExists($filename)) {
        wfForbidden('img-auth-accessdenied', 'img-auth-nofile', $filename);
        return;
    }
    $title = Title::makeTitleSafe(NS_FILE, $name);
    if (!$title instanceof Title) {
        // files have valid titles
        wfForbidden('img-auth-accessdenied', 'img-auth-badtitle', $name);
        return;
    }
    // Run hook for extension authorization plugins
    /** @var $result array */
    $result = null;
    if (!wfRunHooks('ImgAuthBeforeStream', array(&$title, &$path, &$name, &$result))) {
        wfForbidden($result[0], $result[1], array_slice($result, 2));
        return;
    }
    // Check user authorization for this title
    // Checks Whitelist too
    if (!$title->userCan('read')) {
        wfForbidden('img-auth-accessdenied', 'img-auth-noread', $name);
        return;
    }
    if ($wgRequest->getCheck('download')) {
        header('Content-Disposition: attachment');
    }
    // Stream the requested file
    wfDebugLog('img_auth', "Streaming `" . $filename . "`.");
    $repo->streamFile($filename, array('Cache-Control: private', 'Vary: Cookie'));
}
开发者ID:spring,项目名称:spring-website,代码行数:99,代码来源:img_auth.php


示例15: checkMissingImage

 function checkMissingImage($fullpath)
 {
     $fname = 'ImageBuilder::checkMissingImage';
     $filename = wfBaseName($fullpath);
     if (is_dir($fullpath)) {
         return;
     }
     if (is_link($fullpath)) {
         $this->log("skipping symlink at {$fullpath}");
         return;
     }
     $row = $this->dbw->selectRow('image', array('img_name'), array('img_name' => $filename), $fname);
     if ($row) {
         // already known, move on
         return;
     } else {
         $this->addMissingImage($filename, $fullpath);
     }
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:19,代码来源:rebuildImages.php


示例16: testBaseName

 /**
  * @dataProvider providePaths
  */
 public function testBaseName($fullpath, $basename)
 {
     $this->assertEquals($basename, wfBaseName($fullpath), "wfBaseName('{$fullpath}') => '{$basename}'");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:wfBaseNameTest.php


示例17: wfDebugLog

    wfDebugLog('img_auth', 'Missing PATH_INFO');
    wfForbidden();
}
$path = $_SERVER['PATH_INFO'];
$filename = realpath($wgUploadDirectory . $_SERVER['PATH_INFO']);
$realUpload = realpath($wgUploadDirectory);
wfDebugLog('img_auth', "\$path is {$path}");
wfDebugLog('img_auth', "\$filename is {$filename}");
// Basic directory traversal check
if (substr($filename, 0, strlen($realUpload)) != $realUpload) {
    wfDebugLog('img_auth', 'Requested path not in upload directory');
    wfForbidden();
}
// Extract the file name and chop off the size specifier
// (e.g. 120px-Foo.png => Foo.png)
$name = wfBaseName($path);
if (preg_match('!\\d+px-(.*)!i', $name, $m)) {
    $name = $m[1];
}
wfDebugLog('img_auth', "\$name is {$name}");
$title = Title::makeTitleSafe(NS_FILE, $name);
if (!$title instanceof Title) {
    wfDebugLog('img_auth', "Unable to construct a valid Title from `{$name}`");
    wfForbidden();
}
$title = $title->getPrefixedText();
// Check the whitelist if needed
if (!$wgUser->getId() && (!is_array($wgWhitelistRead) || !in_array($title, $wgWhitelistRead))) {
    wfDebugLog('img_auth', "Not logged in and `{$title}` not in whitelist.");
    wfForbidden();
}
开发者ID:amjadtbssm,项目名称:website,代码行数:31,代码来源:img_auth.php


示例18: wfImageAuthMain

function wfImageAuthMain()
{
    global $wgImgAuthUrlPathMap;
    $request = RequestContext::getMain()->getRequest();
    $publicWiki = in_array('read', User::getGroupPermissions(array('*')), true);
    // Get the requested file path (source file or thumbnail)
    $matches = WebRequest::getPathInfo();
    if (!isset($matches['title'])) {
        wfForbidden('img-auth-accessdenied', 'img-auth-nopathinfo');
        return;
    }
    $path = $matches['title'];
    if ($path && $path[0] !== '/') {
        // Make sure $path has a leading /
        $path = "/" . $path;
    }
    // Check for bug 28235: QUERY_STRING overriding the correct extension
    $whitelist = array();
    $extension = FileBackend::extensionFromPath($path, 'rawcase');
    if ($extension != '') {
        $whitelist[] = $extension;
    }
    if (!$request->checkUrlExtension($whitelist)) {
        return;
    }
    // Various extensions may have their own backends that need access.
    // Check if there is a special backend and storage base path for this file.
    foreach ($wgImgAuthUrlPathMap as $prefix => $storageDir) {
        $prefix = rtrim($prefix, '/') . '/';
        // implicit trailing slash
        if (strpos($path, $prefix) === 0) {
            $be = FileBackendGroup::singleton()->backendFromPath($storageDir);
            $filename = $storageDir . substr($path, strlen($prefix));
            // strip prefix
            // Check basic user authorization
            if (!RequestContext::getMain()->getUser()->isAllowed('read')) {
                wfForbidden('img-auth-accessdenied', 'img-auth-noread', $path);
                return;
            }
            if ($be->fileExists(array('src' => $filename))) {
                wfDebugLog('img_auth', "Streaming `" . $filename . "`.");
                $be->streamFile(array('src' => $filename), array('Cache-Control: private', 'Vary: Cookie'));
            } else {
                wfForbidden('img-auth-accessdenied', 'img-auth-nofile', $path);
            }
            return;
        }
    }
    // Get the local file repository
    $repo = RepoGroup::singleton()->getRepo('local');
    $zone = strstr(ltrim($path, '/'), '/', true);
    // Get the full file storage path and extract the source file name.
    // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png).
    // This only applies to thumbnails/transcoded, and each of them should
    // be under a folder that has the source file name.
    if ($zone === 'thumb' || $zone === 'transcoded') {
        $name = wfBaseName(dirname($path));
        $filename = $repo->getZonePath($zone) . substr($path, strlen("/" . $zone));
        // Check to see if the file exists
        if (!$repo->fileExists($filename)) {
            wfForbidden('img-auth-accessdenied', 'img-auth-nofile', $filename);
            return;
        }
    } else {
        $name = wfBaseName($path);
        // file is a source file
        $filename = $repo->getZonePath('public') . $path;
        // Check to see if the file exists and is not deleted
        $bits = explode('!', $name, 2);
        if (substr($path, 0, 9) === '/archive/' && count($bits) == 2) {
            $file = $repo->newFromArchiveName($bits[1], $name);
        } else {
            $file = $repo->newFile($name);
        }
        if (!$file->exists() || $file->isDeleted(File::DELETED_FILE)) {
            wfForbidden('img-auth-accessdenied', 'img-auth-nofile', $filename);
            return;
        }
    }
    $headers = array();
    // extra HTTP headers to send
    if (!$publicWiki) {
        // For private wikis, run extra auth checks and set cache control headers
        $headers[] = 'Cache-Control: private';
        $headers[] = 'Vary: Cookie';
        $title = Title::makeTitleSafe(NS_FILE, $name);
        if (!$title instanceof Title) {
            // files have valid titles
            wfForbidden('img-auth-accessdenied', 'img-auth-badtitle', $name);
            return;
        }
        // Run hook for extension authorization plugins
        /** @var $result array */
        $result = null;
        if (!wfRunHooks('ImgAuthBeforeStream', array(&$title, &$path, &$name, &$result))) {
            wfForbidden($result[0], $result[1], array_slice($result, 2));
            return;
        }
        // Check user authorization for this title
        // Checks Whitelist too
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:img_auth.php


示例19: __construct

 /**
  * Constructor
  *
  * @param string $file filename.
  * @param string $byteOrder Type of byte ordering either 'BE' (Big Endian) or 'LE' (Little Endian). Default ''.
  * @throws MWException
  * @todo FIXME: The following are broke:
  * SubjectArea. Need to test the more obscure tags.
  *
  * DigitalZoomRatio = 0/0 is rejected. need to determine if that's valid.
  * possibly should treat 0/0 = 0. need to read exif spec on that.
  */
 function __construct($file, $byteOrder = '')
 {
     /**
      * Page numbers here refer to pages in the Exif 2.2 standard
      *
      * Note, Exif::UNDEFINED is treated as a string, not as an array of bytes
      * so don't put a count parameter for any UNDEFINED values.
      *
      * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification
      */
     $this->mExifTags = array('IFD0' => array('ImageWidth' => Exif::SHORT_OR_LONG, 'ImageLength' => Exif::SHORT_OR_LONG, 'BitsPerSample' => array(Exif::SHORT, 3), 'Compression' => Exif::SHORT, 'PhotometricInterpretation' => Exif::SHORT, 'Orientation' => Exif::SHORT, 'SamplesPerPixel' => Exif::SHORT, 'PlanarConfiguration' => Exif::SHORT, 'YCbCrSubSampling' => array(Exif::SHORT, 2), 'YCbCrPositioning' => Exif::SHORT, 'XResolution' => Exif::RATIONAL, 'YResolution' => Exif::RATIONAL, 'ResolutionUnit' => Exif::SHORT, 'StripOffsets' => Exif::SHORT_OR_LONG, 'RowsPerStrip' => Exif::SHORT_OR_LONG, 'StripByteCounts' => Exif::SHORT_OR_LONG, 'JPEGInterchangeFormat' => Exif::SHORT_OR_LONG, 'JPEGInterchangeFormatLength' => Exif::SHORT_OR_LONG, 'TransferFunction' => Exif::IGNORE, 'WhitePoint' => array(Exif::RATIONAL, 2), 'PrimaryChromaticities' => array(Exif::RATIONAL, 6), 'YCbCrCoefficients' => array(Exif::RATIONAL, 3), 'ReferenceBlackWhite' => array(Exif::RATIONAL, 6), 'DateTime' => Exif::ASCII, 'ImageDescription' => Exif::ASCII, 'Make' => Exif::ASCII, 'Model' => Exif::ASCII, 'Software' => Exif::ASCII, 'Artist' => Exif::ASCII, 'Copyright' => Exif::ASCII), 'EXIF' => array('ExifVersion' => Exif::UNDEFINED, 'Fla 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfBlankImgUrl函数代码示例发布时间:2022-05-23
下一篇:
PHP wfBaseConvert函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap