本文整理汇总了PHP中link函数的典型用法代码示例。如果您正苦于以下问题:PHP link函数的具体用法?PHP link怎么用?PHP link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadFile
function downloadFile($url, $installFile, $archivedFile)
{
$tmpFile = $installFile . '.tmp';
if (!file_exists($archivedFile) || filesize($archivedFile) == 0) {
if (file_exists($installFile)) {
unlink($archivedFile);
}
if (file_exists($tmpFile)) {
unlink($tmpFile);
}
$ch = curl_init($url);
$fp = fopen($tmpFile, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
rename($tmpFile, $archivedFile);
}
if (file_exists($installFile)) {
unlink($installFile);
}
link($archivedFile, $installFile);
kdebug('link(' . $archivedFile . ', ' . $installFile . ')');
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
if ('\\' === DIRECTORY_SEPARATOR) {
self::$linkOnWindows = true;
$originFile = tempnam(sys_get_temp_dir(), 'li');
$targetFile = tempnam(sys_get_temp_dir(), 'li');
if (true !== @link($originFile, $targetFile)) {
$report = error_get_last();
if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
self::$linkOnWindows = false;
}
} else {
@unlink($targetFile);
}
self::$symlinkOnWindows = true;
$originDir = tempnam(sys_get_temp_dir(), 'sl');
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
if (true !== @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
self::$symlinkOnWindows = false;
}
} else {
@unlink($targetDir);
}
}
}
示例3: build
function build()
{
$webappFile = null;
$tomcatDir = "/var/lib/tomcat6/webapps";
if (!is_dir($tomcatDir)) {
echo "Starting......: " . date("H:i:s") . " C.A.S server failed `{$tomcatDir}` no such directory...\n";
return;
}
$unix = new unix();
$dirfiles = $unix->DirFiles("/usr/share/cas-server/modules", "cas-server-webapp-.*?\\.war");
echo "Starting......: " . date("H:i:s") . " C.A.S server checking libraries...\n";
echo "Starting......: " . date("H:i:s") . " C.A.S server TomCat webapps `{$tomcatDir}`\n";
while (list($num, $line) = each($dirfiles)) {
$webappFile = "/usr/share/cas-server/modules/{$num}";
}
if ($webappFile == null) {
echo "Starting......: " . date("H:i:s") . " C.A.S server failed to retrive cas-server-webapp war file\n";
return;
}
if (is_file("{$tomcatDir}/cas.war")) {
@unlink("{$tomcatDir}/cas.war");
}
echo "Starting......: " . date("H:i:s") . " C.A.S server installing {$webappFile} into {$tomcatDir}..\n";
@link($webappFile, "{$tomcatDir}/cas.war");
writesettings();
maven2();
tomcat_config();
log4jxml();
if (is_file("/etc/init.d/tomcat6")) {
echo "Starting......: " . date("H:i:s") . " C.A.S server restarting tomcat server...\n";
shell_exec("/etc/init.d/tomcat6 restart >/dev/null 2>&1");
}
WEB_INF_deployerConfigContext();
log4jxml();
}
示例4: systemlink_createLink
/**
* @param string $realFrom
* @param string $realTo
* @param string $type
*
* @throws Exception
*/
function systemlink_createLink($realFrom, $realTo, $type = 'symlink')
{
if (IS_WINDOWS) {
// Windows doesn't play nice with paths containing UNIX path separators
$realTo = TranslateWinPath($realTo);
$realFrom = TranslateWinPath($realFrom);
// Windows doesn't play nice with relative paths in symlinks
$realFrom = realpath($realFrom);
}
if (is_file($realTo) || is_dir($realTo) || is_link($realTo) || file_exists($realTo)) {
if (IS_WINDOWS && is_dir($realTo)) {
// Windows can't unlink() directory symlinks; it needs rmdir() to be used instead
$res = @rmdir($realTo);
} else {
$res = @unlink($realTo);
}
if (!$res) {
echo "FAILED UNLINK : {$realTo}\n";
}
}
if ($type == 'symlink') {
$res = @symlink($realFrom, $realTo);
} elseif ($type == 'link') {
$res = @link($realFrom, $realTo);
}
if (!$res) {
if ($type == 'symlink') {
echo "FAILED SYMLINK : {$realTo}\n";
} elseif ($type == 'link') {
echo "FAILED LINK : {$realTo}\n";
}
}
}
示例5: _link_file
protected function _link_file($path, $target, $link_directory)
{
$this->_check_dir($link_directory);
if (!file_exists($link_directory . '/' . $target) && !link(dirname(__FILE__) . '/' . $path . '/' . $target, $link_directory . '/' . $target)) {
$this->fail("Failed to create link " . $link_directory . '/' . $target);
}
}
示例6: link
public static function link($from, $to)
{
if (is_dir($from) && PHP_OS == "WINNT") {
exec("mklink /J {$to} {$from}");
return;
}
link($from, $to);
}
示例7: cross_symlink
function cross_symlink($sourcePath, $targetPath)
{
if (PHP_OS == "WINNT") {
return link($sourcePath, $targetPath);
} else {
return symlink($sourcePath, $targetPath);
}
}
示例8: link
public static function link($source, $dest)
{
if (self::isProduction()) {
return link($source, $dest);
} else {
return copy($source, $dest);
}
}
示例9: hardlink_file
function hardlink_file($from, $to)
{
if (defined('AKEEBA_RELINK_WINDOWS')) {
$cmd = 'mklink /H "' . $to . '" "' . $from . '"';
exec($cmd);
} else {
@link($from, $to);
}
}
示例10: hardSymLink
/**
* @param string $original
* @param string $alias
* @return bool
* @throws Exceptions\FileSystemException
*/
public static function hardSymLink($original, $alias)
{
if (!file_exists($original)) {
throw new \Sonrisa\Component\FileSystem\Exceptions\FileSystemException("Cannot link {$original} because it does not exist.");
}
if (file_exists($alias)) {
throw new \Sonrisa\Component\FileSystem\Exceptions\FileSystemException("Cannot create link {$alias} because a file, directory or link with this name already exists.");
}
return link($original, $alias);
}
示例11: duplicate
function duplicate($dir, $writable, $files, $verb = false)
{
$base = '../' . $dir;
$id = preg_replace('/^\\D+/', '', $dir);
if (!empty($id)) {
$id = intval($id);
}
if (!is_dir($base)) {
mkdir($base);
}
$base .= '/';
foreach (find_file() as $name) {
if ($verb) {
echo " dup: {$name}\n";
}
if (is_dir($name)) {
if (!@mkdir($base . $name)) {
echo "mkdir error: {$name}\n";
}
} elseif (!@link($name, $base . $name)) {
echo "link error: {$name}\n";
}
}
foreach ($writable as $i) {
$f = $base . $i;
if ($verb) {
echo " writable: {$f}\n";
}
if (is_dir($f)) {
chmod($f, 0777);
} else {
chmod($f, 0666);
}
}
foreach ($files as $file => $dest) {
$newfile = $base . preg_replace('/{prefix}/', $dir, $dest);
$body = file_get_contents($file);
if (preg_match('/\\.sql$/', $file)) {
if ($verb) {
echo " {$file} -> {$newfile}\n";
}
$body = preg_replace('/\\s' . preg_quote(ORIGIN_NAME) . '([\\s_])/', " {$dir}\$1", $body);
} elseif (preg_match('/\\.html$/', $file)) {
$body = preg_replace('/' . preg_quote(ORIGIN_NAME) . '_/', $dir . "_", $body);
if ($verb) {
echo " {$file} -> {$newfile}\n";
}
}
file_put_contents($newfile, $body);
}
}
示例12: reload
public function reload($rootPath = null)
{
global $neardBs, $neardConfig, $neardLang;
$this->name = $neardLang->getValue(Lang::FILEZILLA);
$this->version = $neardConfig->getRaw(self::ROOT_CFG_VERSION);
$this->launchStartup = $neardConfig->getRaw(self::ROOT_CFG_LAUNCH_STARTUP) == Config::ENABLED;
$this->rootPath = $rootPath == null ? $this->rootPath : $rootPath;
$this->currentPath = $this->rootPath . '/filezilla' . $this->version;
$this->neardConf = $this->currentPath . '/neard.conf';
$this->logsPath = $this->currentPath . '/Logs';
$this->log = $neardBs->getLogsPath() . '/filezilla.log';
if (!is_dir($this->currentPath)) {
Util::logError(sprintf($neardLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
}
if (!is_file($this->neardConf)) {
Util::logError(sprintf($neardLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->neardConf));
}
// Create log hard link
$log = $this->logsPath . '/FileZilla Server.log';
if (!file_exists($this->log) && file_exists($log)) {
@link($log, $this->log);
}
$this->neardConfRaw = parse_ini_file($this->neardConf);
if ($this->neardConfRaw !== false) {
$this->exe = $this->currentPath . '/' . $this->neardConfRaw[self::LOCAL_CFG_EXE];
$this->conf = $this->currentPath . '/' . $this->neardConfRaw[self::LOCAL_CFG_CONF];
$this->port = $this->neardConfRaw[self::LOCAL_CFG_PORT];
$this->sslPort = $this->neardConfRaw[self::LOCAL_CFG_SSL_PORT];
}
if (!is_file($this->exe)) {
Util::logError(sprintf($neardLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
}
if (!is_file($this->conf)) {
Util::logError(sprintf($neardLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
}
if (!is_numeric($this->port) || $this->port <= 0) {
Util::logError(sprintf($neardLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_PORT, $this->port));
}
if (!is_numeric($this->sslPort) || $this->sslPort <= 0) {
Util::logError(sprintf($neardLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_SSL_PORT, $this->sslPort));
}
$this->service = new Win32Service(self::SERVICE_NAME);
$this->service->setDisplayName(APP_TITLE . ' ' . $this->getName() . ' ' . $this->version);
$this->service->setBinPath($this->exe);
$this->service->setStartType(Win32Service::SERVICE_DEMAND_START);
$this->service->setErrorControl(Win32Service::SERVER_ERROR_NORMAL);
}
示例13: run
public function run($overwrite = true)
{
foreach ($this->_links as $key => $link) {
if (file_exists($link['to'])) {
if ($overwrite) {
unlink($link['to']);
link($link['fr'], $link['to']);
$this->_links[$key]['message'] = 'sucess (removed old file)';
} else {
$this->_links[$key]['message'] = 'file exists';
}
} else {
link($link['fr'], $link['to']);
$this->_links[$key]['message'] = 'success';
}
}
}
示例14: hardlink_file
function hardlink_file($from, $to)
{
if (file_exists($to)) {
if (defined('AKEEBA_RELINK_WINDOWS')) {
$cmd = 'del /f /q "' . $to . '"';
} else {
$cmd = 'rm -f "' . $to . '"';
}
exec($cmd);
}
if (defined('AKEEBA_RELINK_WINDOWS')) {
$cmd = 'mklink /H "' . $to . '" "' . $from . '"';
exec($cmd);
} else {
@link($from, $to);
}
}
示例15: testDelete
public function testDelete()
{
// Initialization
$_SESSION['id'] = 1;
$phpunit = array('isTest' => true);
include dirname(__FILE__) . '/../index.php';
//Test delete photo from one album
$db->query('INSERT INTO images (ownerId, name, filename, extension, created, description) VALUES ("1", "", "flamingo","jpg", CURRENT_TIMESTAMP(),"")');
$newImageId = mysql_insert_id();
$db->query('INSERT INTO imagesToAlbums (albumId, imageId, positionInAlbum) VALUES ("1", "' . $newImageId . '", "1")');
$target = dirname(__FILE__) . '/data/uploadTest/flamingos.jpg';
// Ceci est le fichier qui existe actuellement
$link = dirname(__FILE__) . '/../data/images/' . $newImageId . '.jpg';
// Ceci sera le nom du fichier que vous voulez lier
@link($target, $link);
$_GET = array('id' => $newImageId);
$_POST = array('Delete' => true, 'album' => array(1));
include dirname(__FILE__) . '/../pages/view/photoDelete.php';
$results = mysql_num_rows($db->query('SELECT * FROM images'));
$this->assertEquals('1', $results);
//Test delete photo from one album but existing in two
$db->query('INSERT INTO images (ownerId, name, filename, extension, created, description) VALUES ("1", "", "flamingo","jpg", CURRENT_TIMESTAMP(),"")');
$newImageId = mysql_insert_id();
$db->query('INSERT INTO imagesToAlbums (albumId, imageId, positionInAlbum) VALUES ("1", "' . $newImageId . '", "1")');
$db->query('INSERT INTO imagesToAlbums (albumId, imageId, positionInAlbum) VALUES ("3", "' . $newImageId . '", "1")');
$target = dirname(__FILE__) . '/data/uploadTest/flamingos.jpg';
// Ceci est le fichier qui existe actuellement
$link = dirname(__FILE__) . '/../data/images/' . $newImageId . '.jpg';
// Ceci sera le nom du fichier que vous voulez lier
@link($target, $link);
$_GET = array('id' => $newImageId);
$_POST = array('Delete' => true, 'album' => array(1));
include dirname(__FILE__) . '/../pages/view/photoDelete.php';
$results = mysql_num_rows($db->query('SELECT * FROM images'));
$this->assertEquals('2', $results);
//Test delete photo from two album, photo in only two albums
$db->query('INSERT INTO imagesToAlbums (albumId, imageId, positionInAlbum) VALUES ("1", "' . $newImageId . '", "1")');
$_GET = array('id' => $newImageId);
$_POST = array('Delete' => true, 'album' => array(1, 3));
include dirname(__FILE__) . '/../pages/view/photoDelete.php';
$results = mysql_num_rows($db->query('SELECT * FROM images'));
$this->assertEquals('1', $results);
}