本文整理汇总了PHP中readlink函数的典型用法代码示例。如果您正苦于以下问题:PHP readlink函数的具体用法?PHP readlink怎么用?PHP readlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readlink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: env_copy
protected function env_copy($from, $to)
{
// Check for symlinks
if (is_link($from)) {
return symlink(readlink($from), $to);
}
// Simple copy for a file
if (is_file($from)) {
$this->stdout("Copying " . $from . "\n");
return copy($from, $to);
}
// Make destination directory
if (!is_dir($to)) {
$this->stdout("mkdir " . $to . "\n");
mkdir($to);
}
$dir = dir($from);
while (false !== ($entry = $dir->read())) {
if ($entry == '.' || $entry == '..' || $entry == '.git') {
continue;
}
// Deep copy directories
$this->env_copy($from . "/" . $entry, $to . "/" . $entry);
}
// Clean up
$dir->close();
}
示例2: __construct
public function __construct($environment, $debug)
{
if (!ini_get('date.timezone') || !date_default_timezone_get()) {
$timezone = "Europe/Berlin";
if (is_link('/etc/localtime')) {
// Mac OS X (and older Linuxes)
// /etc/localtime is a symlink to the
// timezone in /usr/share/zoneinfo.
$filename = readlink('/etc/localtime');
if (strpos($filename, '/usr/share/zoneinfo/') === 0) {
$timezone = substr($filename, 20);
}
} elseif (file_exists('/etc/timezone')) {
// Ubuntu / Debian.
$data = file_get_contents('/etc/timezone');
if ($data) {
$timezone = $data;
}
} elseif (file_exists('/etc/sysconfig/clock')) {
// RHEL / CentOS
$data = parse_ini_file('/etc/sysconfig/clock');
if (!empty($data['ZONE'])) {
$timezone = $data['ZONE'];
}
}
$timezone = preg_replace("/[\\n\\r]+/", "", $timezone);
date_default_timezone_set($timezone);
}
parent::__construct($environment, $debug);
}
示例3: cp_r
/**
* Recursive copy function
* @param str src source path
* @param str dst source path
* @return bool
*/
public static function cp_r($src, $dst)
{
if (is_link($src)) {
$l = readlink($src);
if (!symlink($l, $dst)) {
return false;
}
} elseif (is_dir($src)) {
if (!mkdir($dst)) {
return false;
}
$objects = scandir($src);
if ($objects === false) {
return false;
}
foreach ($objects as $file) {
if ($file == "." || $file == "..") {
continue;
}
if (!self::cp_r($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file)) {
return false;
}
}
} else {
if (!copy($src, $dst)) {
return false;
}
}
return true;
}
示例4: setDefaultTimezone
/**
* Set the default timezone.
*
* PHP 5.4 has removed the autodetection of the system timezone,
* so it needs to be done manually.
* UTC is the fallback in case autodetection fails.
*/
protected function setDefaultTimezone()
{
$timezone = 'UTC';
if (is_link('/etc/localtime')) {
// Mac OS X (and older Linuxes)
// /etc/localtime is a symlink to the timezone in /usr/share/zoneinfo.
$filename = readlink('/etc/localtime');
if (strpos($filename, '/usr/share/zoneinfo/') === 0) {
$timezone = substr($filename, 20);
}
} elseif (file_exists('/etc/timezone')) {
// Ubuntu / Debian.
$data = file_get_contents('/etc/timezone');
if ($data) {
$timezone = trim($data);
}
} elseif (file_exists('/etc/sysconfig/clock')) {
// RHEL/CentOS
$data = parse_ini_file('/etc/sysconfig/clock');
if (!empty($data['ZONE'])) {
$timezone = trim($data['ZONE']);
}
}
date_default_timezone_set($timezone);
}
示例5: generatePhpbbLink
public function generatePhpbbLink($varValue, DataContainer $dc)
{
if (is_link($dc->activeRecord->phpbb_alias) && readlink($dc->activeRecord->phpbb_alias) == $varValue) {
Message::addInfo("Path to forum already set");
return $varValue;
}
if (is_link($dc->activeRecord->phpbb_alias) !== false && readlink($dc->activeRecord->phpbb_alias) != $varValue) {
Message::addInfo("Removing old link");
unlink($dc->activeRecord->phpbb_alias);
}
Message::addInfo("Trying to set Forum Symlink");
if (file_exists($varValue . "/viewtopic.php")) {
Message::addInfo("Forum found. Setting Link");
$result = symlink($varValue, $dc->activeRecord->phpbb_alias);
if ($result === true) {
Message::addInfo("Link Set");
}
if (!is_link($dc->activeRecord->phpbb_alias . '/ext/ctsmedia') || readlink($dc->activeRecord->phpbb_alias . '/ext/ctsmedia') != "../../contao/vendor/ctsmedia/contao-phpbb-bridge-bundle/src/Resources/phpBB/ctsmedia") {
Message::addInfo("Setting Vendor Link");
symlink(TL_ROOT . "/vendor/ctsmedia/contao-phpbb-bridge-bundle/src/Resources/phpBB/ctsmedia", $dc->activeRecord->phpbb_alias . '/ext/ctsmedia');
}
Message::addInfo("Please activate the contao extension in the phpbb backend");
} else {
//Message::addError("Forum could not be found: ".$varValue . "/viewtopic.php");
throw new Exception("Forum could not be found: " . $varValue . "/viewtopic.php");
}
return $varValue;
}
示例6: absolutePath
function absolutePath($path)
{
$isEmptyPath = strlen($path) == 0;
$isRelativePath = $path[0] != '/';
$isWindowsPath = !(strpos($path, ':') === false);
if (($isEmptyPath || $isRelativePath) && !$isWindowsPath) {
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
// resolve path parts (single dot, double dot and double delimiters)
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
$pathParts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutePathParts = array();
foreach ($pathParts as $part) {
if ($part == '.') {
continue;
}
if ($part == '..') {
array_pop($absolutePathParts);
} else {
$absolutePathParts[] = $part;
}
}
$path = implode(DIRECTORY_SEPARATOR, $absolutePathParts);
// resolve any symlinks
if (file_exists($path) && is_link($path)) {
$path = readlink($path);
}
// put initial separator that could have been lost
$path = !$isWindowsPath ? '/' . $path : $path;
return $path;
}
示例7: make
public function make($object, $recursive = true)
{
$this->checkDirectory();
if (!$object) {
$this->safeClean();
return $this->directory;
}
$realDirectory = null;
if (is_link($this->directory)) {
$realDirectory = readlink($this->directory);
if ($realDirectory === false) {
throw new WrongStateException('invalid pointer: ' . $this->directory);
}
}
$reversePath = $this->identityMap->reverseLookup($object);
if (!$reversePath && is_link($this->directory)) {
throw new WrongStateException('you must always store your object somewhere ' . 'before you going to update pointer ' . $this->directory);
}
if ($reversePath && file_exists($this->directory) && !$realDirectory && $this->directory != $reversePath) {
throw new WrongStateException('you should relocate object ' . $this->directory . ' to ' . $reversePath . ' by yourself.' . ' cannot replace object with a link');
}
if ($reversePath && (!file_exists($this->directory) || $realDirectory)) {
if (!$realDirectory || $realDirectory != $reversePath) {
$this->safeClean();
$status = symlink($reversePath, $this->directory);
if ($status !== true) {
throw new WrongStateException('error creating symlink');
}
}
return $reversePath;
}
$result = parent::make($object, $recursive);
$this->identityMap->bind($result, $object);
return $result;
}
示例8: remove
/**
* Remove symlinks from each plugin to app/webroot
*
* @return void
*/
public function remove()
{
chdir(realpath(WWW_ROOT));
$paths = $this->_getPaths();
foreach ($paths as $plugin => $config) {
$this->out('Processing plugin: <info>' . $plugin . '</info>');
if (!file_exists($config['public'])) {
$this->out('--> <error>Skipping</error>, symlink does not exists (' . Nodes\Common::stripRealPaths($config['public']) . ')');
continue;
}
if (!is_link($config['public'])) {
$this->out('--> <error>Skipping, target is not a symlink</error>');
continue;
}
$symlinkTarget = readlink($config['public']);
$this->out('----> Current target is ' . $symlinkTarget);
if ($config['relative_private'] !== $symlinkTarget) {
$this->out('--> <error>Skipping, symlink source does not match ours</error>');
continue;
}
if (unlink($config['public'])) {
$this->out(sprintf('--> <info>OK</info>, symlink removed (%s => %s)', \Nodes\Common::stripRealPaths($config['private']), \Nodes\Common::stripRealPaths($config['public'])));
} else {
$this->out('--> <error>Error</error>');
}
}
}
示例9: symlink
public static function symlink()
{
/* WP FileSystem API does not support symlink creation
global $wp_filesystem;
*/
$muplugin = dirname(WPF2B_PATH) . self::$muplugin_rel;
$symlink = WPMU_PLUGIN_DIR . self::$symlink_rel;
if (!file_exists(WPMU_PLUGIN_DIR)) {
if (!mkdir(WPMU_PLUGIN_DIR, 0755, true)) {
return false;
}
}
if (is_link($symlink) || file_exists($symlink)) {
// Correct symbolic link
if (is_link($symlink) && readlink($symlink) === $muplugin) {
return true;
} else {
/* is_writable() does not detect broken symlinks, unlink() must be @muted
// Incorrect and unwritable
if ( ! is_writable( $symlink ) ) {
return false;
}
*/
// Remove symbolic link
if (!@unlink($symlink)) {
return false;
}
}
}
$linking = symlink($muplugin, $symlink);
return $linking;
}
示例10: convert
function convert ($format, $attr, $showMessages=false) {
$currentFormat = $this->format();
$format = strtolower(trim($format));
if ($format == '')
return false;
if ($currentFormat == $format)
return $this;
$name = file_strip_extension($this->fname); // remove file extension
$mo = MediaObjectFactory::createMediaObject($this->pagename, "$name.$format");
if (!$mo->exists() || $mo->olderThan($this)) {
if ($showMessages)
message("creating FIG image in ".strtoupper($format)." format", 'start');
// fig2dev doesn't like DOS/Win newlines => convert newlines to UNIX format
// if $this->path() is a symbolic link we convert the actual fig file (link target)
$path = $this->path();
if (is_link($path))
$path = readlink($path);
RunTool('dos2unix', "IN=$path");
$resfile = $this->fig2format($this->path(), $format);
return $resfile ? $mo : false;
}
return $mo;
}
示例11: recursiveCopy
/**
* Given /^I copy all files from "(?P<source>.*)" to "(?P<destination>.)*)"$/
*/
public function recursiveCopy($source, $dest, $permissions = 0755)
{
$this->_logger()->logInfo("Copying: {$source} to {$dest}");
// Check for symlinks
if (is_link($source)) {
return symlink(readlink($source), $dest);
}
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest, $permissions);
}
// Loop through the folder
$dir = dir($source);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if (!$this->recursiveCopy("{$source}/{$entry}", "{$dest}/{$entry}")) {
// Error!
return false;
}
}
// Clean up
$dir->close();
return true;
}
示例12: installCore
protected function installCore(PackageInterface $package)
{
$installPath = $this->getInstallPath($package);
// find core, might vary, depending on download type
if (file_exists($installPath . '/web/concrete')) {
// source
$coreSourcePath = $installPath . '/web/concrete';
} else {
// dist
$coreSourcePath = $installPath . '/concrete';
}
$coreInstallPath = $this->getCoreInstallPath($package);
// make sure we have absolute paths
$coreSourcePath = realpath($coreSourcePath);
$coreInstallPath = realpath('') . '/' . rtrim($coreInstallPath, '/');
// make sure parent core path exists
$parentPath = dirname($coreInstallPath);
$this->filesystem->ensureDirectoryExists($parentPath);
// check for existing core path
if (file_exists($coreInstallPath) && !is_link($coreInstallPath)) {
throw new \RuntimeException('Can\'t create concrete5 symlink as folder already exists. Please remove ' . $coreInstallPath);
} else {
if (is_link($coreInstallPath)) {
if (realpath(readlink($coreInstallPath)) == $coreSourcePath) {
// already has correct symlink, done here
return;
}
// remove existing incorrect symlink
$this->filesystem->unlink($coreInstallPath);
}
$this->io->write(sprintf(' Creating concrete5 symlink %s - %s', $coreInstallPath, $this->filesystem->relativeSymlink($coreSourcePath, $coreInstallPath) ? '<info>created</info>' : '<error>not created</error>'));
$this->io->write('');
}
}
示例13: xsymlink
public static function xsymlink($source, $dest, $permissions = 0755)
{
// Check for symlinks
if (is_link($source)) {
return symlink(readlink($source), $dest);
}
// Symlink file
if (is_file($source)) {
return symlink($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest, $permissions);
}
// Loop through the folder
$dir = dir($source);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
self::xsymlink("{$source}/{$entry}", "{$dest}/{$entry}", $permissions);
}
// Clean up
$dir->close();
return true;
}
示例14: list_mac
function list_mac()
{
global $sdir;
// Display client MAC address scripts
chdir($sdir);
$dir_handle = @opendir($sdir) or die("Unable to open {$sdir}");
$bgcolor = "#BDBDBD";
echo "<a href=\"?view=clients&add=true\">Add a MAC address</a><br>";
echo "<table border=\"0\" cellspacing=\"0\"><tr bgcolor=\"#1A73CC\"><td><b>MAC Address</b></td><td></td><td><b>Config File</b></td><td></td></tr><br>";
//running the while loop
while ($file = readdir($dir_handle)) {
if ("{$file}" == ".." or "{$file}" == "." or is_dir($file) or !is_link($file)) {
continue;
}
// Get the file sym-link target
$cfg = readlink($file);
$mac = strstr($file, '.cfg', true);
echo "<tr bgcolor=\"{$bgcolor}\" border=0><td>{$mac}</td><td> <b>></b> </td><td>{$cfg}</td><td> - <a href=\"?view=clients&del={$file}\">Remove</a></td>";
if ($bgcolor == "#BDBDBD") {
$bgcolor = "#FFFFFF";
} else {
$bgcolor = "#BDBDBD";
}
}
echo "</table>";
}
示例15: load
/**
* Autoloading logic
*
* @param String $class Class name
* @return Boolean Whether the loading succeded.
*/
public static function load($class)
{
clearstatcache();
// figure out namespace and halt process if not in our namespace
$namespace = self::discover_namespace($class);
if ($namespace === '') {
return;
}
$class = self::normalize_class($class, $namespace);
foreach (self::$directories[$namespace] as $dir) {
$file = $dir . DIRECTORY_SEPARATOR . $class;
// if( $dir === end(self::$directories) )
// {
// require $file;
// return true;
// }
if (is_link($file)) {
$file = readlink($file);
}
// $real = realpath($file);
// if($real) $file = $real;
if (is_file($file)) {
require $file;
return true;
}
}
}