本文整理汇总了PHP中link函数的典型用法代码示例。如果您正苦于以下问题:PHP link函数的具体用法?PHP link怎么用?PHP link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了link函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 . ')');
}
开发者ID:sutromedia,项目名称:ios-travel-guide,代码行数:25,代码来源:download_screenshots.php
示例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);
}
}
}
开发者ID:Gladhon,项目名称:symfony,代码行数:27,代码来源:FilesystemTestCase.php
示例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();
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:35,代码来源:exec.cas-server.php
示例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";
}
}
}
开发者ID:Coyotejld,项目名称:buildfiles,代码行数:40,代码来源:systemlink.php
示例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);
}
}
开发者ID:nemein,项目名称:openpsa,代码行数:7,代码来源:quick_init.php
示例6: link
public static function link($from, $to)
{
if (is_dir($from) && PHP_OS == "WINNT") {
exec("mklink /J {$to} {$from}");
return;
}
link($from, $to);
}
开发者ID:amptools-net,项目名称:midori-php,代码行数:8,代码来源:File.php
示例7: cross_symlink
function cross_symlink($sourcePath, $targetPath)
{
if (PHP_OS == "WINNT") {
return link($sourcePath, $targetPath);
} else {
return symlink($sourcePath, $targetPath);
}
}
开发者ID:appleboy,项目名称:LazyRecord,代码行数:8,代码来源:BuildConfCommand.php
示例8: link
public static function link($source, $dest)
{
if (self::isProduction()) {
return link($source, $dest);
} else {
return copy($source, $dest);
}
}
开发者ID:indynagpal,项目名称:MateCat,代码行数:8,代码来源:EnvWrap.php
示例9: hardlink_file
function hardlink_file($from, $to)
{
if (defined('AKEEBA_RELINK_WINDOWS')) {
$cmd = 'mklink /H "' . $to . '" "' . $from . '"';
exec($cmd);
} else {
@link($from, $to);
}
}
开发者ID:mybo,项目名称:com_lts,代码行数:9,代码来源:relink.php
示例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);
}
开发者ID:shsrain,项目名称:ypyzApi,代码行数:16,代码来源:FileSystem.php
示例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);
}
}
开发者ID:nbuy,项目名称:xoops-modules-eguide,代码行数:51,代码来源:duplicate.php
示例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);
}
开发者ID:RobertoMalatesta,项目名称:neard,代码行数:47,代码来源:class.bin.filezilla.php
示例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';
}
}
}
开发者ID:jleagle,项目名称:link-sync,代码行数:17,代码来源:LinkSync.php
示例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);
}
}
开发者ID:Coyotejld,项目名称:buildfiles,代码行数:17,代码来源:relink.php
示例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);
}
开发者ID:hochla-simon,项目名称:Pitter,代码行数:43,代码来源:TestImage.php
示例16: createLink
public function createLink($media_file, $media_id, $proto = '')
{
$this->user->checkHome();
preg_match("/([\\S\\s]+)\\.(" . $this->media_ext_str . ")\$/i", $media_file, $arr);
$ext = $arr[2];
$from = KARAOKE_STORAGE_DIR . '/' . $media_file;
$to = NFS_HOME_PATH . $this->user->getMac() . '/' . $media_id . '.' . $ext;
if ($proto == 'http') {
$link_result = @symlink($from, $to);
} else {
$link_result = @link($from, $to);
}
if (!$link_result) {
throw new IOException('Could not create link ' . $from . ' to ' . $to . ' on ' . $this->storage_name);
}
if (!is_readable($to)) {
throw new IOException('File ' . $to . ' is not readable on ' . $this->storage_name);
}
return true;
}
开发者ID:Eugen1985,项目名称:stalker_portal,代码行数:20,代码来源:karaoke.class.php
示例17: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
}
$this->requireFixtureFiles($input);
$this->setIncludePathAsInTestBootstrap();
$host = Url::getHost();
if (empty($host)) {
$host = 'localhost';
Url::setHost('localhost');
}
$configDomainToSave = $input->getOption('save-config');
if (!empty($configDomainToSave)) {
$pathToDomainConfig = PIWIK_INCLUDE_PATH . '/config/' . $host . '.config.ini.php';
if (!file_exists($pathToDomainConfig)) {
link(PIWIK_INCLUDE_PATH . '/config/config.ini.php', $pathToDomainConfig);
}
}
$fixture = $this->createFixture($input);
$this->setupDatabaseOverrides($input, $fixture);
// perform setup and/or teardown
if ($input->getOption('teardown')) {
$fixture->getTestEnvironment()->save();
$fixture->performTearDown();
} else {
$fixture->performSetUp();
}
if ($input->getOption('set-phantomjs-symlinks')) {
$this->createSymbolicLinksForUITests();
}
$this->writeSuccessMessage($output, array("Fixture successfully setup!"));
$sqlDumpPath = $input->getOption('sqldump');
if ($sqlDumpPath) {
$this->createSqlDump($sqlDumpPath, $output);
}
if (!empty($configDomainToSave)) {
Config::getInstance()->forceSave();
}
}
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:41,代码来源:TestsSetupFixture.php
示例18: test_link
function test_link($linkedfile, $toLinkTo, $tounlink, $softlink)
{
if ($softlink == true) {
symlink($toLinkTo, $linkedfile);
$msg = "soft link";
} else {
link($toLinkTo, $linkedfile);
$msg = "hard link";
}
echo "-- unlinking {$msg} {$tounlink} --\n";
$res = unlink($tounlink);
if ($res === true) {
if (file_exists($tounlink) === false) {
echo "file unlinked\n";
} else {
echo "FAILED: file not unlinked\n";
}
} else {
unlink($linkedfile);
}
}
开发者ID:badlamer,项目名称:hhvm,代码行数:21,代码来源:unlink_variation8.php
示例19: test_link
function test_link($linkedDir, $toLinkTo, $tounlink, $softlink)
{
if ($softlink == true) {
symlink($toLinkTo, $linkedDir);
$msg = "soft link";
} else {
link($toLinkTo, $linkedDir);
$msg = "hard link";
}
echo "-- unlinking {$msg} {$tounlink} --\n";
$res = unlink($tounlink);
if ($res === true) {
if (is_link($tounlink) === false) {
echo "directory unlinked\n";
} else {
echo "FAILED: directory not unlinked\n";
}
} else {
unlink($linkedDir);
}
}
开发者ID:badlamer,项目名称:hhvm,代码行数:21,代码来源:unlink_variation10.php
示例20: combineAssets
public function combineAssets(\Twig_Environment $twig, $combinedresultName, array $assetPaths, array $attributes, $foreReload = false)
{
$this->registerWidgetTemplates($twig);
if ($this->debug) {
$assetManager = $this->assetManager;
$assetPaths = array_map(function ($assetPath) use($assetManager) {
if (@file_get_contents($assetPath)) {
return $assetPath;
}
foreach ($assetManager->importFolders as $namespace => $importFolder) {
if (file_exists($importFolder . $assetPath)) {
$importFolderAccessible = strpos($importFolder, $assetManager->webroot) === 0;
if ($importFolderAccessible) {
$importPath = substr($importFolder, strlen($assetManager->webroot));
return $importPath;
}
// Symlink the otherwise inaccessible assets, and present their new path
$namespacedLocation = $assetManager->webroot . 'vendor/' . $namespace . '/';
$namespacedPath = 'vendor/' . $namespace . '/';
if (!file_exists($namespacedLocation . $assetPath)) {
if (!(file_exists($namespacedLocation) && is_dir($namespacedLocation))) {
mkdir($namespacedLocation, 0777, true);
}
link($importFolder . $assetPath, $assetManager->webroot . 'vendor/' . $namespace . '/' . $assetPath);
}
return $namespacedPath . $assetPath;
}
}
if (strpos($assetPath, $assetManager->exportPath) == false) {
return $assetManager->exportPath . $assetPath;
}
return $assetPath;
}, $assetPaths);
return $twig->render('@assetwidgets/combineAssetsList.twig', ['attributes' => $attributes, 'jsPaths' => $assetPaths]);
} else {
$combinedresult = $this->assetManager->combineLibsFromPaths($assetPaths, $combinedresultName, $foreReload);
return $twig->render('@assetwidgets/combineAssets.twig', ['attributes' => $attributes, 'jsPath' => $combinedresult]);
}
}
开发者ID:jandc,项目名称:asset-manager,代码行数:39,代码来源:CombineFunction.php
注:本文中的link函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论