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


PHP absPath函数代码示例

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


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

示例1: absPath

function absPath($inputPath, $baseDir = '.')
{
    // add basedir to inputPath if it's not absolute
    if (!isAbsPath($inputPath)) {
        if (!isAbsPath($baseDir)) {
            // make basedir absolute if it's not already
            $cwd = getcwd();
            if (!isAbsPath($cwd)) {
                die("getcwd() didn't return an absulte path '" . htmlencode($cwd) . "'!");
            }
            $baseDir = absPath($baseDir, $cwd);
        }
        $inputPath = "{$baseDir}/{$inputPath}";
    }
    // remove path prefixes: \\UNC-SERVER or C:
    $uncServerPrefix = '';
    $driveLetterPrefix = '';
    $uncServerRegexp = "|^\\\\\\\\[^\\\\/]+|";
    // matches \\SERVER-NAME UNC style prefixs
    $driveLetterRegexp = "|^[a-z]:(?=[\\\\/])|i";
    // matches W: windows drive letter prefixs
    if (preg_match($uncServerRegexp, $inputPath, $matches)) {
        // match prefix
        $uncServerPrefix = $matches[0];
        $inputPath = preg_replace($uncServerRegexp, '', $inputPath, 1);
        // remove prefix
    } elseif (preg_match($driveLetterRegexp, $inputPath, $matches)) {
        // match prefix
        $driveLetterPrefix = $matches[0];
        $inputPath = preg_replace($driveLetterRegexp, '', $inputPath, 1);
        // remove prefix
    }
    // normalize path components (replace backslashes, remove double-slashes, resolve . and ..)
    $inputPathComponents = preg_split("|[\\\\/]|", $inputPath, null, PREG_SPLIT_NO_EMPTY);
    $outputPathComponents = array();
    foreach ($inputPathComponents as $component) {
        if ($component == '.') {
            /* do nothing */
        } elseif ($component == '..') {
            array_pop($outputPathComponents);
        } else {
            array_push($outputPathComponents, $component);
        }
    }
    $outputPath = implode('/', $outputPathComponents);
    // re-add path prefixes and root slash
    $absPath = $uncServerPrefix . $driveLetterPrefix . '/' . $outputPath;
    //
    return $absPath;
}
开发者ID:afineedge,项目名称:thinkbeforeyoulaunch,代码行数:50,代码来源:common.php

示例2: dirlist

function dirlist(&$files, $dir)
{
    global $cfg;
    if ($handle = opendir($dir)) {
        while ($file = readdir($handle)) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $fullpath = str_replace('//', '/', $dir . '/' . $file);
            if (is_dir($fullpath)) {
                $indent = str_repeat(' ', count(explode('/', trim(str_replace($cfg['root_dir'], '', $dir), '/'))) * 2);
                $files[] = array('value' => absPath(str_replace($cfg['root_dir'], '', $fullpath) . '/'), 'text' => $indent . ucfirst(basename($fullpath)));
                dirlist($files, $fullpath);
            }
        }
        closedir($handle);
        asort($files);
        return true;
    }
    return false;
}
开发者ID:master3395,项目名称:CBPPlatform,代码行数:21,代码来源:rdirs.php

示例3: getItems

function getItems($path, $valid, $list)
{
    global $cfg;
    global $l;
    $path = str_replace('//', '/', $path);
    // remove double slash in path if any
    $retstr = '';
    if ($handle = @opendir($path)) {
        $files = array();
        $valids = implode('|', $valid);
        while (($file = readdir($handle)) !== false) {
            if (is_file($path . $file) && eregi('\\.(' . $valids . ')$', $file, $matches)) {
                $files[$path . $file] = $matches[0];
            }
        }
        closedir($handle);
        ksort($files);
        $dfmt = "m-d-Y";
        foreach ($files as $filename => $ext) {
            $size = @getimagesize($path . basename($filename));
            if ($size === false) {
                continue;
            }
            $fsize = filesize($path . basename($filename));
            $modified = date($dfmt, filemtime($path . basename($filename)));
            $created = date($dfmt, filectime($path . basename($filename)));
            $ctype = iType($size[2]);
            if ($list == true || $list == 1) {
                $retstr .= '<li class="cimgup" ifile="' . basename($filename) . '" iwidth="' . htmlentities($size[0], ENT_QUOTES) . '" iheight="' . htmlentities($size[1], ENT_QUOTES) . '" itype="' . htmlentities($size[2] . '|' . $ctype, ENT_QUOTES) . '" imdate="' . htmlentities($modified, ENT_QUOTES) . '" icdate="' . htmlentities($created, ENT_QUOTES) . '" isize="' . filesize_h($fsize, 2) . '">' . htmlentities(basename($filename), ENT_QUOTES, $l->getCharset()) . '</li>' . "\n";
            } else {
                $src = 'phpThumb/phpThumb.php?src=' . absPath(str_replace($cfg['root_dir'], '', $path)) . basename($filename) . '&w=48&h=48&far=1&bg=ffffff&f=jpg';
                $retstr .= '<li class="cimgup" ifile="' . basename($filename) . '" iwidth="' . htmlentities($size[0], ENT_QUOTES) . '" iheight="' . htmlentities($size[1], ENT_QUOTES) . '" itype="' . htmlentities($size[2] . '|' . $ctype, ENT_QUOTES) . '" imdate="' . htmlentities($modified, ENT_QUOTES) . '" icdate="' . htmlentities($created, ENT_QUOTES) . '" isize="' . filesize_h($fsize, 2) . '">' . '<img src="' . $src . '" width="48" height="48" alt="' . basename($filename) . '; ' . htmlentities($size[0], ENT_QUOTES) . ' x ' . htmlentities($size[1], ENT_QUOTES) . 'px;' . '" title="' . basename($filename) . '; ' . htmlentities($size[0], ENT_QUOTES) . ' x ' . htmlentities($size[1], ENT_QUOTES) . 'px;' . '"/>' . '</li>' . "\n";
            }
        }
        return $retstr;
    }
    echo $l->m('er_036');
    return false;
}
开发者ID:burak-tekin,项目名称:CMScout2,代码行数:39,代码来源:rfiles.php

示例4: getItems

	function getItems($dir, $valid) {			
		global $clib; // current library 			
		global $cfg;
		global $l;		
		$retstr = ''; 			                           
		if ($handle = opendir($dir)) {			
			$files = array();
			$valids = implode('|', $valid);			
			while (($file = readdir($handle)) !== false) {                                                            
				if (is_file($dir . $file) && eregi('\.(' . $valids . ')$', $file, $matches)) {                                                                                   
					$files[$dir . $file] = $matches[0];
				}
			}
			closedir($handle);                                               
			ksort($files);
			$path  = str_replace('//', '/', $cfg['root_dir'] . $clib); // remove double slash in path				
			foreach ($files as $filename => $ext) {										
				$size     = getimagesize($path . basename($filename));				
				$src      = 'phpThumb/phpThumb.php?src=' . absPath(str_replace($cfg['root_dir'],'', $path)) . basename($filename) . '&w=32&h=32&zc=1'; 				
				$retstr  .= '<div class="ovBtnUp" ifile="' . absPath(str_replace($cfg['root_dir'] ,'', $path)) . basename($filename) . '" >' . '<img src="' . $src . '" width="32" height="32" alt="' . basename($filename) . '; ' . htmlentities($size[0], ENT_QUOTES) . ' x ' . htmlentities($size[1], ENT_QUOTES) . 'px;' . '" title="' . basename($filename) . '; ' . htmlentities($size[0], ENT_QUOTES) . ' x ' . htmlentities($size[1], ENT_QUOTES) . 'px;' . '"/>' . '</div>' .  "\n";
			}			
			return $retstr;
		}
		echo $l->m('er_044');		
		return false;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:26,代码来源:ov_rfiles.php

示例5: liboptions

	function liboptions($arr, $prefix = '', $sel = '', $type = '') {
  		global $cfg;
		global $l;
		$retval = '';
				
		if ($type == 'ov') { // called from overlay
			if (isset($cfg['olay']) && $cfg['olay'] != '') {									
				$ovDir = absPath($cfg['olay']);					
				$arr[] = array ( // add overlay image directory to libraries					
					'value'	=> absPath($cfg['olay']),								
					'text' 	=> $l->m('ov_001'),
				);		
			};
		};
		
  		foreach($arr as $lib) {			
    		$retval .= '<option value="' . absPath($lib['value']) . '"' . (($lib['value'] == $sel) ? ' selected="selected"' : '') . '>' . $prefix . $lib['text'] . '</option>' . "\n";
  		}
  		return $retval;
	}	
开发者ID:hungnv0789,项目名称:vhtm,代码行数:20,代码来源:imanager.php

示例6: liboptions

function liboptions($arr, $prefix = '', $sel = '')
{
    $retval = '';
    foreach ($arr as $lib) {
        $retval .= '<option value="' . absPath($lib['value']) . '"' . ($lib['value'] == $sel ? ' selected="selected"' : '') . '>' . $prefix . $lib['text'] . '</option>' . "\n";
    }
    return $retval;
}
开发者ID:pongi1987,项目名称:PEJ,代码行数:8,代码来源:ibrowser.php

示例7: tar

    } else {
        if ($impname != "") {
            $file_temp = $REX[INCLUDE_PATH] . "/addons/{$page}/files/{$impname}";
        } else {
            $file_temp = $REX[INCLUDE_PATH] . "/addons/{$page}/files/tar.temp";
        }
        if ($impname != "" || @move_uploaded_file($_FILES['FORM']['tmp_name']['importfile'], $file_temp)) {
            $tar = new tar();
            $tar->openTAR($file_temp);
            if (!$tar->extractTar()) {
                $msg = $I18N_ADDON->msg("problem_when_extracting") . "<br>";
                if (count($tar->message) > 0) {
                    $msg .= $I18N_ADDON->msg("create_dirs_manually") . "<br>";
                    reset($tar->message);
                    for ($fol = 0; $fol < count($tar->message); $fol++) {
                        $msg .= absPath(str_replace("'", "", key($tar->message))) . "<br>";
                        next($tar->message);
                    }
                }
            } else {
                $msg = $I18N_ADDON->msg("file_imported") . "<br>";
            }
            if ($impname == "") {
                @unlink($file_temp);
            }
        } else {
            $msg = $I18N_ADDON->msg("file_could_not_be_uploaded") . " " . $I18N_ADDON->msg("you_have_no_write_permission_in", "addons/{$page}/files/") . " <br>";
        }
    }
} elseif ($function == "export") {
    // ------------------------------ FUNC EXPORT
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:index.inc.php

示例8: array

    if (version_compare(phpversion(), "4.1.0", "<") == 1) {
        $MSG[err] .= $I18N->msg("setup_010") . "<br>";
    }
    // -------------------------- SCHREIBRECHTE
    $WRITEABLE = array($REX[INCLUDE_PATH] . "/master.inc.php", $REX[INCLUDE_PATH] . "/addons.inc.php", $REX[INCLUDE_PATH] . "/clang.inc.php", $REX[INCLUDE_PATH] . "/ctype.inc.php", $REX[INCLUDE_PATH] . "/generated", $REX[INCLUDE_PATH] . "/generated/articles", $REX[INCLUDE_PATH] . "/generated/templates", $REX[INCLUDE_PATH] . "/addons/stats/logs", $REX[INCLUDE_PATH] . "/generated/cache/", $REX[INCLUDE_PATH] . "/generated/cache/cache.php", $REX[INCLUDE_PATH] . "/generated/files/", $REX[INCLUDE_PATH] . "/addons/import_export/files", $REX[INCLUDE_PATH] . "/addons/stats/logs", $REX[INCLUDE_PATH] . "/../../files/");
    foreach ($WRITEABLE as $item) {
        if (is_dir($item)) {
            if (!@is_writable($item . "/.")) {
                $MSG[err] .= $I18N->msg("setup_012", absPath($item)) . "<br>";
            }
        } elseif (is_file($item)) {
            if (!@is_writable($item)) {
                $MSG[err] .= $I18N->msg("setup_014", absPath($item)) . "<br>";
            }
        } else {
            $MSG[err] .= $I18N->msg("setup_015", absPath($item)) . "<br>";
        }
    }
}
if ($MSG[err] == "" && $checkmodus == 1) {
    setuptitle($I18N->msg("setup_step1"));
    echo $I18N->msg("setup_016");
    echo "<br><br><a href=index.php?page=setup&checkmodus=2&lang={$lang}>&raquo; " . $I18N->msg("setup_017") . "</a><br><br>";
} elseif ($MSG[err] != "") {
    setuptitle($I18N->msg("setup_step1"));
    echo "<b>" . $I18N->msg("setup_headline1") . "</b><br><br>" . $MSG[err] . "\r\n\r\n\t<br>" . $I18N->msg("setup_018") . "<br><br>\r\n\t<a href=index.php?page=setup&checkmodus=1&lang={$lang}>&raquo; " . $I18N->msg("setup_017") . "</a><br><br>";
}
// ---------------------------------- MODUS 2 | master.inc.php - Datenbankcheck
if ($checkmodus == 2 && $send == 1) {
    $h = @fopen($REX[INCLUDE_PATH] . "/master.inc.php", "r");
    $cont = fread($h, filesize("include/master.inc.php"));
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:setup.inc.php

示例9: eht

        <tr>
          <td width="200"><?php 
eht('Overview & Setup');
?>
</td>
          <td height="22" style="line-height: 125%">
            <?php 
echo nl2br(t("Background tasks allow programs to run in the background at specific times for tasks such as maintenance, email alerts, etc.\n" . "You don't need to enable this feature unless you have a plugin that requires it."));
?>
<br/><br/>
            <?php 
et("To setup Background Tasks, add a server cronjob or 'scheduled task' to execute the following command every minute:");
?>
<br/>
            <pre>php -q <?php 
echo absPath($GLOBALS['PROGRAM_DIR'] . "/cron.php");
?>
</pre><br/>
          </td>
        </tr>
        <tr>
          <td width="200"><?php 
eht("Status");
?>
</td>
          <td height="22" style="line-height: 150%">
            <?php 
$prettyDate = prettyDate($SETTINGS['bgtasks_lastRun']);
$dateString = $SETTINGS['bgtasks_lastRun'] ? date("D, M j, Y - g:i:s A", $SETTINGS['bgtasks_lastRun']) : $prettyDate;
$logCount = mysql_count('_cron_log');
$failCount = mysql_count('_cron_log', array('completed' => '0'));
开发者ID:afineedge,项目名称:thinkbeforeyoulaunch,代码行数:31,代码来源:general.php

示例10: getUploadDirAndUrl

function getUploadDirAndUrl($fieldSchema, $settingsUploadDir = null, $settingsUploadUrl = null, $returnOnErrors = false)
{
    if ($settingsUploadDir === null) {
        $settingsUploadDir = $GLOBALS['SETTINGS']['uploadDir'];
    }
    if ($settingsUploadUrl === null) {
        $settingsUploadUrl = $GLOBALS['SETTINGS']['uploadUrl'];
    }
    // get upload dir and url
    if (@$fieldSchema['useCustomUploadDir']) {
        // if field is configured to use custom upload paths, use them
        $uploadDir = $fieldSchema['customUploadDir'];
        $uploadUrl = $fieldSchema['customUploadUrl'];
        list($baseDir, $baseUrl) = getUploadDirAndUrl(array());
        // path for resolving CUSTOM dirs/urls: Uses upload dir/url from general settings made absolute using CMS dir/url
    } else {
        // default to using global SETTINGS upload paths
        $uploadDir = $settingsUploadDir;
        $uploadUrl = $settingsUploadUrl;
        $baseDir = SCRIPT_DIR;
        // paths for resolving relative dirs and urls (CMS Script Dir)
        $baseUrl = dirname(@$GLOBALS['SETTINGS']['adminUrl']) . '/';
        // paths for resolving relative dirs and urls (CMS Script Dir URL)
    }
    $uploadDir = applyFilters('upload_uploadDir', $uploadDir, $fieldSchema);
    $uploadUrl = applyFilters('upload_uploadUrl', $uploadUrl, $fieldSchema);
    doAction('upload_dirAndUrl', $uploadDir, $uploadUrl);
    // make path absolute (and format/normalize it)
    $uploadDir = absPath($uploadDir, $baseDir);
    if (!endsWith('/', $uploadDir)) {
        $uploadDir .= '/';
    }
    // absPath doesn't return trailing slash, but we require that for user entered values and expect it in the code
    // make urls absolute, starting with either http:// or /
    if (!isAbsoluteUrl($uploadUrl) && !preg_match("|^/|", $uploadUrl)) {
        $uploadUrl = coalesce($uploadUrl, './');
        // added ./ so blank upload url gets DIR of $baseUrl, not baseurl with admin.php on the end
        $uploadUrl = realUrl($uploadUrl, $baseUrl);
        $uploadUrl = preg_replace("|^\\w+://[^/]+|", '', $uploadUrl);
        // remove scheme://hostname
    }
    if (!endsWith('/', $uploadUrl)) {
        $uploadUrl .= '/';
    }
    //
    return array($uploadDir, $uploadUrl);
}
开发者ID:afineedge,项目名称:thinkbeforeyoulaunch,代码行数:47,代码来源:upload_functions.php

示例11: getAbsolutePath

function getAbsolutePath($relativePath, $baseDir = '.')
{
    if (!$baseDir || $baseDir == '.') {
        $baseDir = getcwd();
    }
    $absPath = absPath($relativePath, $baseDir);
    return file_exists($absPath) ? $absPath : '';
    // emulate old behaviour, absPath now normalizes paths even if they don't exist
}
开发者ID:afineedge,项目名称:thinkbeforeyoulaunch,代码行数:9,代码来源:old_alias_functions.php


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