本文整理匯總了PHP中is_link函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_link函數的具體用法?PHP is_link怎麽用?PHP is_link使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_link函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_file_object
/**
* Add info on the user who uploaded the file and the date it was uploaded, and create thumb if it doesn't exist
*/
protected function get_file_object($file_name)
{
// Create the thumb if it doesn't exist
$thumb = $this->options['upload_dir'] . 'thumb/' . $file_name;
if (!file_exists(jQueryUpload::thumbFilename($thumb))) {
$this->create_scaled_image($file_name, $this->options['image_versions']['thumbnail']);
}
// Call the parent method to create the file object
$file = parent::get_file_object($file_name);
// Add the meta data to the object
if (is_object($file)) {
$meta = $this->options['upload_dir'] . 'meta/' . $file_name;
$file->info = $file->desc = "";
// If the meta data file exists, extract and render the content
if (is_file($meta)) {
$data = unserialize(file_get_contents($meta));
$file->info = self::renderData($data);
$file->desc = array_key_exists(2, $data) ? $data[2] : '';
} elseif (is_link($this->options['upload_dir'] . $file_name)) {
$title = Title::newFromText($file_name, NS_FILE);
if (is_object($title) && $title->exists()) {
list($uid, $ts, $file->desc) = self::getUploadedFileInfo($title);
$file->info = self::renderData(array($uid, wfTimestamp(TS_UNIX, $ts)));
}
}
}
return $file;
}
示例2: chmod_r
function chmod_r($path, $filemode)
{
if (!is_dir($path)) {
return chmod($path, $filemode);
}
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$fullpath = $path . '/' . $file;
if (is_link($fullpath)) {
return FALSE;
} elseif (!is_dir($fullpath)) {
if (!chmod($fullpath, $filemode)) {
return FALSE;
} elseif (!chmod_r($fullpath, $filemode)) {
return FALSE;
}
}
}
}
closedir($dh);
if (chmod($path, $filemode)) {
return TRUE;
} else {
return FALSE;
}
}
示例3: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
parent::execute($arguments, $options);
$projectWebPath = sfConfig::get('sf_web_dir');
$filesystem = new dmFilesystem($this->dispatcher, $this->formatter);
foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) {
$this->logSection('plugin', 'Configuring plugin - ' . $plugin);
$this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin);
}
// remove useless doctrine assets
if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) {
if (!is_link($doctrineAssetPath)) {
$filesystem->deleteDirContent($doctrineAssetPath);
}
$filesystem->remove($doctrineAssetPath);
}
// remove web cache dir
$webCacheDir = sfConfig::get('sf_web_dir') . '/cache';
if (is_link($webCacheDir)) {
$filesystem->remove($webCacheDir);
}
// create web cache dir
$filesystem->mkdir($webCacheDir);
if (!file_exists(dmOs::join($projectWebPath, 'sf'))) {
$filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true);
}
}
示例4: setFileInformations
/**
* collect all fileinformations of given file and
* save them to the global fileinformation array
*
* @param string $file
* @return boolean is valid file?
*/
protected function setFileInformations($file)
{
$this->fileInfo = array();
// reset previously information to have a cleaned object
$this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
if (is_string($file) && !empty($file)) {
$this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
$this->fileInfo['mtime'] = filemtime($file);
$this->fileInfo['atime'] = fileatime($file);
$this->fileInfo['owner'] = fileowner($file);
$this->fileInfo['group'] = filegroup($file);
$this->fileInfo['size'] = filesize($file);
$this->fileInfo['type'] = filetype($file);
$this->fileInfo['perms'] = fileperms($file);
$this->fileInfo['is_dir'] = is_dir($file);
$this->fileInfo['is_file'] = is_file($file);
$this->fileInfo['is_link'] = is_link($file);
$this->fileInfo['is_readable'] = is_readable($file);
$this->fileInfo['is_uploaded'] = is_uploaded_file($file);
$this->fileInfo['is_writeable'] = is_writeable($file);
}
if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
$pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
$this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
}
return $this->fileInfo !== array();
}
示例5: add_dir
private function add_dir($base, $subdir = "")
{
global $page;
$list = "";
$dir = opendir("{$base}/{$subdir}");
while ($filename = readdir($dir)) {
$fullpath = "{$base}/{$subdir}/{$filename}";
if (is_link($fullpath)) {
// ignore
} else {
if (is_dir($fullpath)) {
if ($filename[0] != ".") {
$this->add_dir($base, "{$subdir}/{$filename}");
}
} else {
$tmpfile = $fullpath;
$tags = $subdir;
$tags = str_replace("/", " ", $tags);
$tags = str_replace("__", " ", $tags);
$list .= "<br>" . html_escape("{$subdir}/{$filename} (" . str_replace(" ", ",", $tags) . ")...");
$error = $this->add_image($tmpfile, $filename, $tags);
if (is_null($error)) {
$list .= "ok\n";
} else {
$list .= "failed: {$error}\n";
}
}
}
}
closedir($dir);
// $this->theme->add_status("Adding $subdir", $list);
}
示例6: copyr
/**
* Copy a file, or recursively copy a folder and its contents
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.1
* @link http://aidanlister.com/2004/04/recursively-copying-directories-in-php/
* @param string $source Source path
* @param string $dest Destination path
* @return bool Returns TRUE on success, FALSE on failure
*/
function copyr($source, $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);
}
// Loop through the folder
$dir = dir($source);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
copyr("{$source}/{$entry}", "{$dest}/{$entry}");
}
// Clean up
$dir->close();
return true;
}
示例7: get_root_path_and_environment
/**
* Determine the webroot for a site.
*
* Most of this is cribbed from drush's implementation.
*/
public function get_root_path_and_environment($start_path)
{
$root_path = FALSE;
$start_path = empty($start_path) ? getcwd() : $start_path;
foreach (array(TRUE, FALSE) as $follow_symlinks) {
$path = $start_path;
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
// Check the start path.
if ($this->determine_valid_root($path)) {
$root_path = $path;
break;
} else {
// Move up dir by dir and check each.
while ($path = $this->shift_path_up($path)) {
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
if ($this->determine_valid_root($path)) {
$root_path = $path;
break 2;
}
}
}
}
$this->root_path = $root_path;
}
示例8: locate_root
/**
* Locate the actual Drupal root. Based on drush_locate_root().
*/
function locate_root()
{
$drupal_root = FALSE;
$start_path = isset($_SERVER['PWD']) ? $_SERVER['PWD'] : '';
if (empty($start_path)) {
$start_path = getcwd();
}
foreach (array(TRUE, FALSE) as $follow_symlinks) {
$path = $start_path;
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
// Check the start path.
if (valid_root($path)) {
$drupal_root = $path;
break;
} else {
// Move up dir by dir and check each.
while ($path = shift_path_up($path)) {
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
if (valid_root($path)) {
$drupal_root = $path;
break 2;
}
}
}
}
return $drupal_root;
}
示例9: setUp
function setUp()
{
$this->fixDir = dirname(__FILE__) . '/_fixtures/big_dir';
$this->readPath = $this->fixDir . '/file_2.5GB';
// Generate big file
if (is_link($this->fixDir)) {
$parentPath = realpath($this->fixDir);
} else {
$parentPath = $this->fixDir;
}
if (!is_dir($parentPath)) {
mkdir($this->fixDir);
}
$cmd = '/bin/df --portability ' . escapeshellarg($parentPath) . ' | tail -1 | awk \'{print $4}\'';
//echo $cmd.PHP_EOL;
$spaceLeft = `{$cmd}`;
if ($spaceLeft < 5200000) {
trigger_error("No sufficient space to create " . $this->readPath . ". Cannot test big files. Tip: link " . $this->fixDir . " to a partition with more than 5GB available.", E_USER_WARNING);
} else {
$output = null;
$returnValue = null;
exec('dd if=/dev/urandom of=' . $this->readPath . ' bs=1M count=2500', $output, $returnValue);
if ($returnValue != 0) {
trigger_error('dd failed, unable to generate the big file');
}
}
}
示例10: failureDescription
/**
* {@inheritdoc}
*/
protected function failureDescription($other)
{
if (!is_string($other)) {
if (is_object($other)) {
$type = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : '');
} elseif (null === $other) {
$type = 'null';
} else {
$type = gettype($other) . '#' . $other;
}
return $type . ' ' . $this->toString();
}
if (!file_exists($other)) {
return 'not file or directory#' . $other . ' ' . $this->toString();
}
if (is_link($other)) {
$type = 'link';
$perms = lstat($other);
$perms = $perms['mode'];
} else {
$type = is_file($other) ? 'file' : (is_dir($other) ? 'directory' : 'other');
$perms = fileperms($other);
}
return sprintf('%s#%s %o %s %o', $type, $other, $perms, $this->toString(), $this->mask);
}
示例11: __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);
}
示例12: getTimeZone
/**
* https://bojanz.wordpress.com/2014/03/11/detecting-the-system-timezone-php/
*/
public function getTimeZone()
{
/*
* Mac OS X (and older Linuxes)
* /etc/localtime is a symlink to the
* timezone in /usr/share/zoneinfo.
*/
if (is_link('/etc/localtime')) {
$filename = readlink('/etc/localtime');
if (strpos($filename, '/usr/share/zoneinfo/') === 0) {
return substr($filename, 20);
}
/*
* Ubuntu / Debian.
*/
} elseif (file_exists('/etc/timezone')) {
$data = file_get_contents('/etc/timezone');
if ($data) {
return $data;
}
/*
* RHEL / CentOS
*/
} elseif (file_exists('/etc/sysconfig/clock')) {
$data = parse_ini_file('/etc/sysconfig/clock');
if (!empty($data['ZONE'])) {
return $data['ZONE'];
}
}
}
示例13: 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;
}
示例14: fstab
function fstab()
{
$sock = new sockets();
$unix = new unix();
$mkdir = $unix->find_program("mkdir");
$mount = $unix->find_program("mount");
$rm = $unix->find_program("rm");
$ln = $unix->find_program("ln");
if (!is_link("/run/shm")) {
if (!is_dir("/run/shm")) {
shell_exec("{$mkdir} -m 1777 /run/shm");
}
if (!is_link("/dev/shm")) {
shell_exec("{$rm} -rf /dev/shm");
shell_exec("{$ln} -s /run/shm /dev/shm");
}
}
echo "Starting......: " . date("H:i:s") . " [SMP] checking fstab...\n";
$datas = explode("\n", @file_get_contents("/etc/fstab"));
while (list($num, $val) = each($datas)) {
if (preg_match("#^shm.*?tmpfs#", $val, $re)) {
echo "Starting......: " . date("H:i:s") . " [SMP] checking fstab already set...\n";
return;
}
}
echo "Starting......: " . date("H:i:s") . " [SMP] Adding SHM mount point\n";
$datas[] = "shm\t/dev/shm\ttmpfs\tnodev,nosuid,noexec\t0\t0";
@file_put_contents("/etc/fstab", @implode("\n", $datas) . "\n");
echo "Starting......: " . date("H:i:s") . " [SMP] mounting shm point\n";
exec("{$mount} shm 2>&1", $results);
while (list($num, $val) = each($results)) {
echo "Starting......: " . date("H:i:s") . " [SMP] mounting shm `{$val}`\n";
}
}
示例15: run_files
function run_files($file)
{
if (is_link($file)) {
return;
}
if (is_dir($file . '/.')) {
$dh = opendir($file);
$files = array();
while (false !== ($f = readdir($dh))) {
if ($f[0] != '.') {
$files[] = $file . '/' . $f;
}
}
closedir($dh);
foreach ($files as $f) {
run_files($f);
}
} else {
if (basename($file) == __FILE__) {
echo "Skipping " . __FILE__ . "\n";
continue;
}
if (preg_match('/\\.php$/', $file)) {
fix_up_file($file);
}
}
}