本文整理汇总了PHP中wcf\util\FileUtil::isURL方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::isURL方法的具体用法?PHP FileUtil::isURL怎么用?PHP FileUtil::isURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\util\FileUtil
的用法示例。
在下文中一共展示了FileUtil::isURL方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* @see \wcf\form\IForm::validate()
*/
public function validate()
{
parent::validate();
// check if file is uploaded or linked
if (!empty($this->file['tmp_name'])) {
$this->backup = $this->file['tmp_name'];
} else {
if ($this->fileLink != '') {
//check if file is external url
if (FileUtil::isURL($this->fileLink)) {
try {
//download file
$this->backup = FileUtil::downloadFileFromHttp($this->fileLink, 'cms_backup');
} catch (SystemException $e) {
//download failed
throw new UserInputException('fileLink', 'downloadFailed');
}
} else {
//file not found
if (!file_exists($this->fileLink)) {
throw new UserInputException('fileLink', 'notFound');
} else {
$this->backup = $this->fileLink;
}
}
} else {
throw new UserInputException('file', 'empty');
}
}
}
示例2: validate
/**
* @see \cms\system\content\type\IContentType::validate()
*/
public function validate($data)
{
if (!isset($data['video'])) {
throw new UserInputException('data[video]');
}
if (!FileUtil::isURL($data['video'])) {
throw new UserInputException('data[video]', 'notValid');
}
}
示例3: __construct
/**
* Creates a new ActiveStyle object.
*
* @param Style $object
*/
public function __construct(Style $object)
{
parent::__construct($object);
// calculate page logo path
if (!empty($this->object->data['variables']['page.logo.image']) && !FileUtil::isURL($this->object->data['variables']['page.logo.image']) && StringUtil::substring($this->object->data['variables']['page.logo.image'], 0, 1) !== '/') {
$this->object->data['variables']['page.logo.image'] = RELATIVE_WCF_DIR . $this->object->data['variables']['page.logo.image'];
}
// load icon cache
$cacheName = 'icon-' . PACKAGE_ID . '-' . $this->styleID;
CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\IconCacheBuilder');
$this->iconCache = CacheHandler::getInstance()->get($cacheName);
}
示例4: getArchive
/**
* Returns current package archive.
*
* @return wcf\system\package\PackageArchive
*/
public function getArchive() {
if ($this->archive === null) {
$this->archive = new PackageArchive($this->queue->archive, $this->getPackage());
if (FileUtil::isURL($this->archive->getArchive())) {
// get return value and update entry in
// package_installation_queue with this value
$archive = $this->archive->downloadArchive();
$queueEditor = new PackageInstallationQueueEditor($this->queue);
$queueEditor->update(array(
'archive' => $archive
));
}
$this->archive->openArchive();
}
return $this->archive;
}
示例5: install
/**
* Installs the specified package.
*
* @param string $file
*/
private function install($file)
{
// PackageStartInstallForm::validateDownloadPackage()
if (FileUtil::isURL($file)) {
// download package
$archive = new PackageArchive($file, null);
try {
if (VERBOSITY >= 1) {
Log::info("Downloading '" . $file . "'");
}
$file = $archive->downloadArchive();
} catch (SystemException $e) {
$this->error('notFound', array('file' => $file));
}
} else {
// probably local path
if (!file_exists($file)) {
$this->error('notFound', array('file' => $file));
}
$archive = new PackageArchive($file, null);
}
// PackageStartInstallForm::validateArchive()
// try to open the archive
try {
// TODO: Exceptions thrown within openArchive() are discarded, resulting in
// the meaningless message 'not a valid package'
$archive->openArchive();
} catch (SystemException $e) {
$this->error('noValidPackage');
}
$errors = PackageInstallationDispatcher::validatePHPRequirements($archive->getPhpRequirements());
if (!empty($errors)) {
// TODO: Nice output
$this->error('phpRequirements', array('errors' => $errors));
}
// try to find existing package
$sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tpackage = ?";
$statement = CLIWCF::getDB()->prepareStatement($sql);
$statement->execute(array($archive->getPackageInfo('name')));
$row = $statement->fetchArray();
$package = null;
if ($row !== false) {
$package = new Package(null, $row);
}
// check update or install support
if ($package !== null) {
CLIWCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
$archive->setPackage($package);
if (!$archive->isValidUpdate()) {
$this->error('noValidUpdate');
}
} else {
CLIWCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
if (!$archive->isValidInstall()) {
$this->error('noValidInstall');
} else {
if ($archive->getPackageInfo('isApplication')) {
// applications cannot be installed via CLI
$this->error('cli.installIsApplication');
} else {
if ($archive->isAlreadyInstalled()) {
$this->error('uniqueAlreadyInstalled');
} else {
if ($archive->getPackageInfo('isApplication') && $this->archive->hasUniqueAbbreviation()) {
$this->error('noUniqueAbbrevation');
}
}
}
}
}
// PackageStartInstallForm::save()
$processNo = PackageInstallationQueue::getNewProcessNo();
// insert queue
$queue = PackageInstallationQueueEditor::create(array('processNo' => $processNo, 'userID' => CLIWCF::getUser()->userID, 'package' => $archive->getPackageInfo('name'), 'packageName' => $archive->getLocalizedPackageInfo('packageName'), 'packageID' => $package !== null ? $package->packageID : null, 'archive' => $file, 'action' => $package !== null ? 'update' : 'install'));
// PackageInstallationDispatcher::openQueue()
$parentQueueID = 0;
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("userID = ?", array(CLIWCF::getUser()->userID));
$conditions->add("parentQueueID = ?", array($parentQueueID));
if ($processNo != 0) {
$conditions->add("processNo = ?", array($processNo));
}
$conditions->add("done = ?", array(0));
$sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_queue\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tqueueID ASC";
$statement = CLIWCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
$packageInstallation = $statement->fetchArray();
if (!isset($packageInstallation['queueID'])) {
$this->error('internalOpenQueue');
return;
} else {
$queueID = $packageInstallation['queueID'];
}
// PackageInstallationConfirmPage::readParameters()
$queue = new PackageInstallationQueue($queueID);
//.........这里部分代码省略.........
示例6: validateDownloadPackage
/**
* Validates the download package input.
*/
protected function validateDownloadPackage() {
if (FileUtil::isURL($this->downloadPackage)) {
// download package
$this->archive = new PackageArchive($this->downloadPackage, $this->package);
try {
$this->downloadPackage = $this->archive->downloadArchive();
//$this->archive->downloadArchive();
}
catch (SystemException $e) {
throw new UserInputException('downloadPackage', 'notFound');
}
}
else {
// probably local path
if (!file_exists($this->downloadPackage)) {
throw new UserInputException('downloadPackage', 'notFound');
}
$this->archive = new PackageArchive($this->downloadPackage, $this->package);
}
$this->validateArchive('downloadPackage');
}
示例7: getBody
/**
* Creates the Body (Message, Attachments) for the Mail
* Returns the created Body to the function which invoke this class
*
* @return string mail body
*/
public function getBody()
{
$counter = 1;
$this->body = '';
if (count($this->getAttachments())) {
// add message
$this->body .= '--' . $this->getBoundary() . self::$crlf;
$this->body .= 'Content-Type: ' . $this->getContentType() . '; charset="UTF-8"' . self::$crlf;
$this->body .= 'Content-Transfer-Encoding: 8bit' . self::$crlf;
//$this->body .= self::$crlf.self::$crlf;
$this->body .= self::$crlf;
// wrap lines after 70 characters
$this->body .= wordwrap($this->getMessage(), 70);
$this->body .= self::$crlf . self::$crlf;
$this->body .= '--' . $this->getBoundary() . self::$crlf;
// add attachments
foreach ($this->getAttachments() as $attachment) {
$fileName = $attachment['name'];
$path = $attachment['path'];
// download file
if (FileUtil::isURL($path)) {
$tmpPath = FileUtil::getTemporaryFilename('mailAttachment_');
if (!@copy($path, $tmpPath)) {
continue;
}
$path = $tmpPath;
}
// get file contents
$data = @file_get_contents($path);
$data = chunk_split(base64_encode($data), 70, self::$crlf);
$this->body .= 'Content-Type: application/octetstream; name="' . $fileName . '"' . self::$crlf;
$this->body .= 'Content-Transfer-Encoding: base64' . self::$crlf;
$this->body .= 'Content-Disposition: attachment; filename="' . $fileName . '"' . self::$crlf . self::$crlf;
$this->body .= $data . self::$crlf . self::$crlf;
if ($counter < count($this->getAttachments())) {
$this->body .= '--' . $this->getBoundary() . self::$crlf;
}
$counter++;
}
$this->body .= self::$crlf . '--' . $this->getBoundary() . '--';
} else {
//$this->body .= self::$crlf;
$this->body .= $this->getMessage();
}
return $this->body;
}
示例8: validateDownloadPackage
/**
* Validates the download package input.
*/
protected function validateDownloadPackage()
{
$this->activeTabMenuItem = 'upload';
if (FileUtil::isURL($this->downloadPackage)) {
// download package
$this->archive = new PackageArchive($this->downloadPackage, $this->package);
try {
$this->downloadPackage = $this->archive->downloadArchive();
} catch (SystemException $e) {
throw new UserInputException('downloadPackage', 'downloadFailed');
}
} else {
// probably local path
if (!file_exists($this->downloadPackage)) {
throw new UserInputException('downloadPackage', 'downloadFailed');
}
}
if (!PackageValidationManager::getInstance()->validate($this->downloadPackage, false)) {
$exception = PackageValidationManager::getInstance()->getException();
if ($exception instanceof PackageValidationException) {
switch ($exception->getCode()) {
case PackageValidationException::INVALID_PACKAGE_NAME:
case PackageValidationException::MISSING_PACKAGE_XML:
throw new UserInputException('downloadPackage', 'noValidPackage');
break;
}
}
}
$this->package = PackageValidationManager::getInstance()->getPackageValidationArchive()->getPackage();
}
示例9: parseAdditionalStyles
private static function parseAdditionalStyles(&$variables)
{
self::$variables = $variables;
// fix images location
if (!empty(self::$variables['global.images.location']) && !FileUtil::isURL(self::$variables['global.images.location']) && substr(self::$variables['global.images.location'], 0, 1) != '/') {
self::$variables['global.images.location'] = '../' . self::$variables['global.images.location'];
}
// fix images location
if (!empty(self::$variables['global.icons.location']) && !FileUtil::isURL(self::$variables['global.icons.location']) && substr(self::$variables['global.icons.location'], 0, 1) != '/') {
self::$variables['global.icons.location'] = '../' . self::$variables['global.icons.location'];
}
// parse additional styles
if (!empty($variables['user.additional.style.input1.use'])) {
$variables['user.additional.style.input1.use'] = preg_replace_callback('/\\$([a-z0-9_\\-\\.]+)\\$/', array('self', 'parseAdditionalStylesCallback'), $variables['user.additional.style.input1.use']);
}
if (!empty($variables['user.additional.style.input2.use'])) {
$variables['user.additional.style.input2.use'] = preg_replace_callback('/\\$([a-z0-9_\\-\\.]+)\\$/', array('self', 'parseAdditionalStylesCallback'), $variables['user.additional.style.input2.use']);
}
}
示例10: getArchive
/**
* Returns current package archive.
*
* @return \wcf\system\package\PackageArchive
*/
public function getArchive()
{
if ($this->archive === null) {
$package = $this->getPackage();
// check if we're doing an iterative update of the same package
if ($this->previousPackageData !== null && $this->getPackage()->package == $this->previousPackageData['package']) {
if (Package::compareVersion($this->getPackage()->packageVersion, $this->previousPackageData['packageVersion'], '<')) {
// fake package to simulate the package version required by current archive
$this->getPackage()->setPackageVersion($this->previousPackageData['packageVersion']);
}
}
$this->archive = new PackageArchive($this->queue->archive, $this->getPackage());
if (FileUtil::isURL($this->archive->getArchive())) {
// get return value and update entry in
// package_installation_queue with this value
$archive = $this->archive->downloadArchive();
$queueEditor = new PackageInstallationQueueEditor($this->queue);
$queueEditor->update(array('archive' => $archive));
}
$this->archive->openArchive();
}
return $this->archive;
}
示例11: unzipPackageArchive
/**
* Unzips compressed package archives and returns the temporary file name.
*
* @param string $archive filename
* @return string
*/
public static function unzipPackageArchive($archive) {
if (!FileUtil::isURL($archive)) {
$tar = new Tar($archive);
$tar->close();
if ($tar->isZipped()) {
$tmpName = FileUtil::getTemporaryFilename('package_');
if (FileUtil::uncompressFile($archive, $tmpName)) {
return $tmpName;
}
}
}
return $archive;
}
示例12: exportSmilies
/**
* Exports smilies.
*/
public function exportSmilies($offset, $limit)
{
$sql = "SELECT\t\t*\n\t\t\tFROM\t\t" . $this->databasePrefix . "smilies\n\t\t\tORDER BY\tsmilieid";
$statement = $this->database->prepareStatement($sql, $limit, $offset);
$statement->execute();
while ($row = $statement->fetchArray()) {
// replace imagefolder
$row['smiliepath'] = str_replace('{imagefolder}', 'images', $row['smiliepath']);
// insert source path
if (!FileUtil::isURL($row['smiliepath'])) {
$row['smiliepath'] = $this->fileSystemPath . $row['smiliepath'];
}
ImportHandler::getInstance()->getImporter('com.woltlab.wcf.smiley')->import($row['smilieid'], array('smileyTitle' => $row['smilietitle'], 'smileyCode' => $row['smiliecode'], 'showOrder' => $row['smilieorder']), array('fileLocation' => $row['smiliepath']));
}
}
示例13: exportUserAvatars
/**
* Exports user avatars.
*/
public function exportUserAvatars($offset, $limit)
{
$sql = "(\n\t\t\t\tSELECT\t\tid_member, 'attachment' AS type, filename AS avatarName, (id_attach || '_' || file_hash) AS filename\n\t\t\t\tFROM\t\t" . $this->databasePrefix . "attachments\n\t\t\t\tWHERE\t\tid_member <> ?\n\t\t\t)\n\t\t\tUNION\n\t\t\t(\n\t\t\t\tSELECT\t\tid_member, 'user' AS type, avatar AS avatarName, avatar AS filename\n\t\t\t\tFROM\t\t" . $this->databasePrefix . "members\n\t\t\t\tWHERE\t\tavatar <> ?\n\t\t\t)";
$statement = $this->database->prepareStatement($sql, $limit, $offset);
$statement->execute(array('', 0));
while ($row = $statement->fetchArray()) {
switch ($row['type']) {
case 'attachment':
$fileLocation = $this->readOption('attachmentUploadDir') . '/' . $row['filename'];
break;
case 'user':
if (FileUtil::isURL($row['filename'])) {
return;
}
$fileLocation = $this->readOption('avatar_directory') . '/' . $row['filename'];
break;
}
ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user.avatar')->import(0, array('avatarName' => basename($row['avatarName']), 'avatarExtension' => pathinfo($row['avatarName'], PATHINFO_EXTENSION), 'userID' => $row['id_member']), array('fileLocation' => $fileLocation));
}
}