本文整理汇总了PHP中getRealPath函数的典型用法代码示例。如果您正苦于以下问题:PHP getRealPath函数的具体用法?PHP getRealPath怎么用?PHP getRealPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getRealPath函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: call
public static function call($method, $args)
{
if ($method === 'info') {
list($dirname, $fname, $protocol) = getRealPath($args['filename']);
if (!class_exists('SimpleXMLElement')) {
throw new Exception("Cannot get media information -- No XML parser found");
}
if (!function_exists('exec')) {
throw new Exception("Cannot get media information -- Exec not allowed");
}
$cmd = sprintf("%s --Output=XML %s", MusicPlayerCommand, escapeshellcmd($fname));
@exec($cmd, $content);
if (!$content) {
throw new Exception("Cannot get media information -- Query failed");
}
try {
$xml = new SimpleXMLElement(implode("\n", preg_replace("/_+/", "", $content)));
} catch (Exception $e) {
$xml = $e;
}
if ($xml !== null) {
if (isset($xml->File[0]) && isset($xml->File[0]->track) && ($node = $xml->File->track)) {
return array('Artist' => isset($node->Performer) ? htmlspecialchars($node->Performer) : null, 'Album' => isset($node->Album) ? htmlspecialchars($node->Album) : null, 'Track' => isset($node->Track_name) ? htmlspecialchars($node->Track_name) : null);
}
}
}
return false;
}
开发者ID:AlexanderBrevig,项目名称:OS.js-v2,代码行数:28,代码来源:api.php
示例2: removeTrailingSlash
/**
* Returns a new file instance of a absolute path.
*
* @param String $abs_path Absolute file path.
* @param String $file_name Optional file name.
* @param String $type Optional file type.
* @return File File object instance based on absolute path.
*/
function &getFile($abs_path, $file_name = "", $type = MC_IS_FILE)
{
$rootPath = removeTrailingSlash(toUnixPath(getRealPath($this->_config, 'filesystem.rootpath')));
if (!$this->verifyPath($abs_path)) {
trigger_error("Trying to get out of defined root path. Root: " . $rootPath . ", Path: " . $abs_path, E_USER_ERROR);
die;
}
// Fix the absolute path
$abs_path = removeTrailingSlash(toUnixPath($abs_path));
$abs_path = $abs_path == "" ? "/" : $abs_path;
$file =& new $this->_config['filesystem']($this, $abs_path, $file_name, $type);
return $file;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:21,代码来源:FileFactory.php
示例3: init
/**
* Initializes the FileEventListener by the specified config.
*
* @param Array name/value array of config data.
*/
function init(&$config)
{
// Setup logger
$this->_logPath = getRealPath($config, "LoggingFileEventListener.path");
$this->_logPrefix = getConfigParam($config, "LoggingFileEventListener.prefix", "mcfilemanager");
$this->_logMaxSize = getConfigParam($config, "LoggingFileEventListener.max_size", "100k");
$this->_logMaxFiles = getConfigParam($config, "LoggingFileEventListener.max_files", "10");
// Fix log max size
$logMaxSizeBytes = intval(preg_replace("/[^0-9]/", "", $this->_logMaxSize));
// Is KB
if (strpos(strtolower($this->_logMaxSize), "k") > 0) {
$logMaxSizeBytes *= 1024;
}
// Is MB
if (strpos(strtolower($this->_logMaxSize), "m") > 0) {
$logMaxSizeBytes *= 1024 * 1024;
}
$this->_logMaxSizeBytes = $logMaxSizeBytes;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:24,代码来源:LoggingFileEventListener.class.php
示例4: addTrailingSlash
$selectedDocuments = $sessionAction->get();
$destFolderPath = addTrailingSlash(backslashToSlash($_GET['current_folder_path']));
if (sizeof($selectedDocuments)) {
//get all files within the destination folder
$allDocs = array();
if ($fh = @opendir($_GET['current_folder_path'])) {
while (($file = readdir($fh)) && $file != '.' && $file != '..') {
$allDocs[] = getRealPath($destFolderPath . $file);
}
}
include_once CLASS_FILE;
$file = new file();
//check if all files are allowed to cut or copy
foreach ($selectedDocuments as $doc) {
if (file_exists($doc) && isUnderRoot($doc)) {
if (array_search(getRealPath($doc), $allDocs) === false || CONFIG_OVERWRITTEN) {
if (CONFIG_OVERWRITTEN) {
$file->delete($doc);
}
if ($file->copyTo($doc, $_GET['current_folder_path'])) {
$finalPath = $destFolderPath . basename($doc);
$objFile = new file($finalPath);
$tem = $objFile->getFileInfo();
$obj = new manager($finalPath, false);
$fileType = $obj->getFileType($finalPath, is_dir($finalPath) ? true : false);
foreach ($fileType as $k => $v) {
$tem[$k] = $v;
}
/* foreach ($folderInfo as $k=>$v)
{
$tem['i_' . $k] = $v;
开发者ID:oanav,项目名称:closetshare,代码行数:31,代码来源:ajax_file_paste.php
示例5: exists
public static function exists($fname)
{
list($dirname, $root, $protocol, $fname) = getRealPath($fname);
return file_exists($fname);
}
开发者ID:AlexanderBrevig,项目名称:OS.js-v2,代码行数:5,代码来源:vfs.php
示例6: dirname
<?php
/**
* ajax preview
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/April/2007
*
*/
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
echo getRealPath($_GET['path']);
if (!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path'])) {
include_once CLASS_MANAGER;
$manager = new manager($_GET['path'], false);
$fileTypes = $manager->getFileType(basename($_GET['path']));
if ($fileTypes['preview']) {
switch ($fileTypes['fileType']) {
case "image":
$imageInfo = @getimagesize($_GET['path']);
if (!empty($imageInfo[0]) && !empty($imageInfo[1])) {
$thumInfo = getThumbWidthHeight($imageInfo[0], $imageInfo[1], 400, 135);
printf("<img src=\"%s\" width=\"%s\" height=\"%s\" />", getFileUrl($_GET['path']), $thumInfo['width'], $thumInfo['height']);
} else {
echo PREVIEW_IMAGE_LOAD_FAILED;
}
break;
case "txt":
if ($fp = @fopen($_GET['path'], 'r')) {
echo @fread($fp, @filesize($_GET['path']));
@fclose($fp);
} else {
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:31,代码来源:ajax_preview.php
示例7: array
/**
* fileprops.php
*
* @package MCFileManager.pages
* @author Moxiecode
* @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
*/
require_once "includes/general.php";
require_once "classes/FileSystems/FileFactory.php";
require_once "classes/FileSystems/LocalFileImpl.php";
require_once "classes/pclzip/pclzip.lib.php";
$data = array();
verifyAccess($mcFileManagerConfig);
$path = getRequestParam("path", "");
$rootpath = getRequestParam("rootpath", toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.rootpath')));
$fileFactory =& new FileFactory($mcFileManagerConfig, $rootpath);
$targetFile =& $fileFactory->getFile($path);
$config = $targetFile->getConfig();
addFileEventListeners($fileFactory);
$filename = getRequestParam("filename", false);
$submitted = getRequestParam("submitted", false);
$data['path'] = $path;
$data['submitted'] = $submitted;
$data['short_path'] = getUserFriendlyPath($path, 30);
$data['full_path'] = getUserFriendlyPath($path);
$data['errorMsg'] = "";
$data['filename'] = "";
$data['demo'] = checkBool($config['general.demo']) ? "true" : "false";
$data['demo_msg'] = $config['general.demo_msg'];
// Create zip
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:30,代码来源:zip.php
示例8: getRequestParam
$orgHeight = getRequestParam("orgheight");
$newWidth = getRequestParam("newwidth");
$newHeight = getRequestParam("newheight");
$left = getRequestParam("left");
$top = getRequestParam("top");
$action = getRequestParam("action");
$path = getRequestParam("path");
$orgpath = getRequestParam("orgpath", "");
$filename = getRequestParam("filename", "");
$msg = "";
if ($orgpath == "") {
$orgpath = $path;
}
$temp_image = "mcic_" . session_id() . "";
verifyAccess($mcImageManagerConfig);
$rootpath = removeTrailingSlash(getRequestParam("rootpath", toUnixPath(getRealPath($mcImageManagerConfig, 'filesystem.rootpath'))));
$fileFactory =& new FileFactory($mcImageManagerConfig, $rootPath);
addFileEventListeners($fileFactory);
$file =& $fileFactory->getFile($path);
$config = $file->getConfig();
$demo = checkBool($config['general.demo']) ? "true" : "false";
$imageutils = new $config['thumbnail']();
$tools = explode(',', $config['thumbnail.image_tools']);
if (!in_array("edit", $tools)) {
trigger_error("The thumbnail.image_tools needs to include edit.", WARNING);
}
// File info
$fileInfo = getFileType($file->getAbsolutePath());
$file_icon = $fileInfo['icon'];
$file_type = $fileInfo['type'];
$file_ext = $fileInfo['ext'];
开发者ID:stormlab,项目名称:Stormlab,代码行数:31,代码来源:process_image.php
示例9: array
/**
* edit_image.php
*
* @package MCImageManager.pages
* @author Moxiecode
* @copyright Copyright © 2006, Moxiecode Systems AB, All rights reserved.
*/
require_once "includes/general.php";
$data = array();
verifyAccess($mcImageManagerConfig);
$path = getRequestParam("path", "");
$orgpath = getRequestParam("orgpath", "");
$action = getRequestParam("action", "");
$status = getRequestParam("status", "");
$msg = getRequestParam("msg", "");
$rootpath = toUnixPath(getRealPath($mcImageManagerConfig, 'filesystem.rootpath'));
$fileFactory =& new FileFactory($mcImageManagerConfig, $rootpath);
$targetFile =& $fileFactory->getFile($path);
$config = $targetFile->getConfig();
$wwwroot = removeTrailingSlash(toUnixPath(getWWWRoot($config)));
$tools = explode(',', $config['thumbnail.image_tools']);
if (!in_array("edit", $tools)) {
trigger_error("The thumbnail.image_tools needs to include edit.", FATAL);
}
if ($targetFile->isDirectory()) {
trigger_error("You may not edit directories.", WARNING);
}
$dir = $targetFile->getParentFile();
if (!$dir->canWrite()) {
trigger_error("You don't have write access to the directory.", FATAL);
}
开发者ID:stormlab,项目名称:Stormlab,代码行数:31,代码来源:edit_image.php
示例10: getConfig
//.........这里部分代码省略.........
while (!feof($fp)) {
$line = trim(fgets($fp));
// Skip comments
if (substr($line, 0, 1) == "#") {
continue;
}
// Split rows
if (($pos = strpos($line, "=")) !== FALSE) {
$config[substr($line, 0, $pos)] = substr($line, $pos + 1);
}
}
fclose($fp);
}
// Handle local config values
$curDir = $this->isFile() ? $this->getParent() : $this->getAbsolutePath();
if ($accessFile->getParent() == $curDir) {
foreach ($config as $key => $value) {
if (substr($key, 0, 1) == '_') {
$localConfig[substr($key, 1)] = $value;
}
}
}
// Parse allow keys and deny keys
$denyOverrideKeys = array();
foreach ($config as $key => $value) {
$keyChunks = explode('.', $key);
$lastChunk = $keyChunks[count($keyChunks) - 1];
if ($lastChunk == "allow_override" || $lastChunk == "deny_override") {
foreach (explode(',', $value) as $keySuffix) {
$keyChunks[count($keyChunks) - 1] = $keySuffix;
$allowDenyKey = implode('.', $keyChunks);
if (in_array($allowDenyKey, $allowoverrideKeys)) {
if ($lastChunk == "allow_override") {
$allowoverrideKeys[] = $allowDenyKey;
} else {
$denyOverrideKeys[] = $allowDenyKey;
}
}
}
}
}
// Remove the denied keys from the allow list
/* foreach ($denyOverrideKeys as $denyKey) {
for ($i=0; $i<count($allowoverrideKeys); $i++) {
if ($denyKey == $allowoverrideKeys[$i])
unset($allowoverrideKeys[$i]);
}
}*/
// Add all overriden values
foreach ($config as $key => $value) {
$validAllKey = false;
foreach ($allowoverrideKeys as $allowkey) {
if (strpos($allowkey, "*") > 0) {
$allowkey = str_replace("*", "", $allowkey);
// echo $allowkey . "," . $key . strpos($allowkey, $key) . "<br>";
if (strpos($key, $allowkey) === 0) {
$validAllKey = true;
break;
}
}
}
if ((in_array($key, $allowoverrideKeys) || $validAllKey) && !in_array($key, $denyOverrideKeys)) {
if (strpos($value, '${') !== false) {
$value = str_replace('${configpath}', $accessFile->getParent(), $value);
}
$this->_config[$key] = $value;
}
}
}
// Variable substitute the values
foreach ($this->_config as $key => $value) {
if (!is_array($value) && strpos($value, '${') !== false) {
if ($this->isFile()) {
$path = $this->getAbsolutePath();
} else {
$path = $this->getParent();
}
$this->_config[$key] = str_replace('${path}', $path, $value);
$this->_config[$key] = str_replace('${rootpath}', toUnixPath(getRealPath($this->_config, 'filesystem.rootpath')), $value);
}
}
// Force local config
foreach ($localConfig as $key => $value) {
$this->_config[$key] = $value;
}
/* foreach ($this->_config as $key => $value) {
if (in_array($key, $allowoverrideKeys)) {
// Seems to be a variable
if (strpos($value, '${') !== false) {
$matches = array();
preg_match_all('/\${(.*)}/i', $value, $matches);
var_dump($matches);
foreach ($matches as $match)
$this->_config[$key] = str_replace('${' . $match . '}', $this->_config[$match], $this->_config[$key]);
}
}
}*/
}
return $this->_config;
}
开发者ID:stormlab,项目名称:Stormlab,代码行数:101,代码来源:LocalFileImpl.php
示例11: main
function main()
{
global $indexStyle;
$dir = $_SERVER['PATH_ROOT'] . $_SERVER['PATH_INFO'];
$files = array_diff(scandir($dir), array('.', '..'));
$files = filesGroupDir($dir, $files);
$html = "";
$html .= "<!DOCTYPE html>\n";
$html .= "<html>\n";
$html .= "<head>\n";
$html .= "<meta charset=\"UTF-8\">\n";
$html .= "<style>" . $indexStyle . "</style>\n";
$html .= "</head>\n";
$html .= "<body>\n";
$html .= "<h2>Index of " . $_SERVER['PATH_INFO'] . "</h2>\n";
$html .= "<table>\n";
$html .= "<tr>\n";
$html .= "<th>Name</th>\n";
$html .= "<th>Size</th>\n";
$html .= "<th>Time</th>\n";
$html .= "</tr>\n";
$html .= "<tr>\n";
$html .= '<td><a href="..">..</a></td>' . "\n";
$html .= "<td></td>\n";
$html .= "<td></td>\n";
$html .= "</tr>\n";
foreach ($files as $k => $v) {
$name = $v;
if (strlen($name) > 30) {
$name = substr($name, 0, 27) . '...';
}
$path = getRealPath($dir . $v);
$datemodified = date('Y\\-m\\-d H:i', getFileMTime($path));
$size = sizeFilter(getFileSize($path));
$hrefSuffix = '';
if (filetype($path) == 'dir') {
$hrefSuffix = '/';
$size = "-";
}
$html .= "<tr>\n";
$html .= '<td><a href="' . $v . $hrefSuffix . '">' . $name . $hrefSuffix . '</a></td>' . "\n";
$html .= "<td>" . $size . "</td>\n";
$html .= "<td>" . $datemodified . "</td>\n";
$html .= "</tr>\n";
}
$html .= "</table>\n";
$html .= "</body>\n";
$html .= "</html>\n";
echo $html;
}
开发者ID:nnnn20430,项目名称:ntofto-web,代码行数:50,代码来源:build_index.php
示例12: addFileEventListeners
// Invalid path, use root path
if (!$fileFactory->verifyPath($path)) {
$path = $rootPath;
}
// Get file and config
$targetFile =& $fileFactory->getFile($path);
$config = $targetFile->getConfig();
addFileEventListeners($fileFactory);
$previewpath = $path;
// Get parent dir if path points to a file
$fileFactory =& new FileFactory($mcFileManagerConfig, $rootPath);
$file =& $fileFactory->getFile($path);
if ($file->exists()) {
if ($file->isFile()) {
$path = $file->getParent();
}
$previewpath = $file->getAbsolutePath();
} else {
$path = toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.path'));
$previewpath = toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.path'));
}
$data['path'] = $path;
$data['previewpath'] = $previewpath;
$data['previewfilename'] = basename($previewpath);
$data['rootpath'] = $rootPath;
$data['showpreview'] = checkBool($mcFileManagerConfig['preview']);
$data['formname'] = getRequestParam("formname", "");
$data['elementnames'] = getRequestParam("elementnames", "");
$data['js'] = getRequestParam("js", "");
// Render output
renderPage("frameset.tpl.php", $data);
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:31,代码来源:frameset.php
示例13: FileGET
/**
* File Download Request
*/
public static function FileGET(APIRequest $req)
{
$result = false;
$error = false;
$headers = array();
$code = 0;
$root = "/";
if (($settings = Settings::get()) && !empty($settings['rooturi'])) {
$root = $settings['rooturi'];
}
$root = preg_quote($root, '/');
$url = preg_replace(sprintf("/^%sFS/", $root), "", urldecode($req->data));
call_user_func_array(array(API::$Handler, 'checkPrivilege'), array(APIUser::GROUP_VFS));
try {
if ($url) {
list($dirname, $root, $protocol, $file) = getRealPath($url);
if (file_exists($file)) {
session_write_close();
if ($data = FS::read($url, array("raw" => true))) {
list($mime, $etag, $length, $result) = $data;
$headers[] = "Etag: {$etag}";
$headers[] = "Content-type: {$mime}; charset=utf-8";
$headers[] = "Content-length: {$length}";
} else {
$code = 500;
$error = "File read error";
}
} else {
$code = 404;
$error = "File not found";
}
}
} catch (Exception $e) {
$error = $e->getMessage();
}
return new APIResponse(false, $result, $error, $code, $headers);
}
开发者ID:bobkingdom,项目名称:OS.js-v2,代码行数:40,代码来源:api.php
示例14: FileGET
/**
* File Download Request
*/
public static function FileGET(APIRequest $req)
{
$result = false;
$error = false;
$headers = array();
$code = 0;
$settings = Settings::get();
$url = preg_replace('/\\/(([^\\/]+\\/)+)?(FS)/', "", urldecode($req->data));
call_user_func_array(array(API::$Handler, 'checkPrivilege'), array(APIUser::GROUP_VFS));
try {
if ($url) {
if (preg_match('/^(ftp|https?)\\:\\/\\//', $url)) {
if (empty($settings['vfs']['proxy']) || $settings['vfs']['proxy'] == false) {
$error = "VFS Proxy is disabled";
$code = 500;
} else {
$result = file_get_contents($url);
}
} else {
list($dirname, $req->uri, $protocol, $file) = getRealPath($url);
if (file_exists($file)) {
session_write_close();
if (FS::read($url, array("raw" => true))) {
exit;
} else {
$code = 500;
$error = "File read error";
}
} else {
$code = 404;
$error = "File not found";
}
}
}
} catch (Exception $e) {
$error = $e->getMessage();
}
return new APIResponse(false, $result, $error, $code, $headers);
}
开发者ID:osuisumi,项目名称:OS.js,代码行数:42,代码来源:api.php
示例15: FileGET
/**
* File Download Request
*/
public static function FileGET(APIRequest $req)
{
$result = false;
$error = false;
$headers = array();
$code = 0;
$url = preg_replace('/\\/(([^\\/]+\\/)+)?(FS)/', "", urldecode($req->data));
call_user_func_array(array(API::$Handler, 'checkPrivilege'), array(APIUser::GROUP_VFS));
try {
if ($url) {
list($dirname, $req->uri, $protocol, $file) = getRealPath($url);
if (file_exists($file)) {
session_write_close();
if (FS::read($url, array("raw" => true))) {
exit;
} else {
$code = 500;
$error = "File read error";
}
} else {
$code = 404;
$error = "File not found";
}
}
} catch (Exception $e) {
$error = $e->getMessage();
}
return new APIResponse(false, $result, $error, $code, $headers);
}
开发者ID:marcinlimanski,项目名称:OS.js-v2,代码行数:32,代码来源:api.php
示例16: getParentFolderPath
/**
* get the parent path of the specified path
*
* @param string $path
* @return string
*/
function getParentFolderPath($path)
{
$realPath = addTrailingSlash(backslashToSlash(getRealPath($path)));
$parentRealPath = addTrailingSlash(backslashToSlash(dirname($realPath)));
$differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath)));
$parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath));
if(isUnderRoot($parentPath))
{
return $parentPath;
}else
{
return CONFIG_SYS_DEFAULT_PATH;
}
}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:20,代码来源:function.base.php
示例17: getWWWRoot
/**
* Returns the wwwroot or null string if it was impossible to get.
*
* @return String wwwroot or null string if it was impossible to get.
*/
function getWWWRoot($config)
{
if (isset($config['preview.wwwroot']) && $config['preview.wwwroot']) {
return getRealPath($config, 'preview.wwwroot');
}
// Check document root
if (isset($_SERVER['DOCUMENT_ROOT'])) {
return resolvePath($_SERVER['DOCUMENT_ROOT']);
}
// Try script file
if (isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"])) {
$path = str_replace(toUnixPath($_SERVER["SCRIPT_NAME"]), "", toUnixPath($_SERVER["SCRIPT_FILENAME"]));
if (is_dir($path)) {
return toOSPath($path);
}
}
// If all else fails, try this.
if (isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"])) {
$path = str_replace(toUnixPath($_SERVER["SCRIPT_NAME"]), "", str_replace("//", "/", toUnixPath($_SERVER["PATH_TRANSLATED"])));
if (is_dir($path)) {
return toOSPath($path);
}
}
die("Could not resolve WWWROOT path, please set an absolute path in preview.wwwroot config option.");
return null;
}
开发者ID:stormlab,项目名称:Stormlab,代码行数:31,代码来源:general.php
注:本文中的getRealPath函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论