本文整理汇总了PHP中FileManager类的典型用法代码示例。如果您正苦于以下问题:PHP FileManager类的具体用法?PHP FileManager怎么用?PHP FileManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deposits
/**
* Provide an endpoint for the PLN staging server to retrieve a deposit
* @param array $args
* @param Request $request
*/
function deposits($args, &$request)
{
$journal =& $request->getJournal();
$depositDao =& DAORegistry::getDAO('DepositDAO');
$fileManager = new FileManager();
$dispatcher = $request->getDispatcher();
$depositUuid = !isset($args[0]) || empty($args[0]) ? null : $args[0];
// sanitize the input
if (!preg_match('/^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$/', $depositUuid)) {
error_log(__("plugins.generic.pln.error.handler.uuid.invalid"));
$dispatcher->handle404();
return FALSE;
}
$deposit =& $depositDao->getDepositByUUID($journal->getId(), $depositUuid);
if (!$deposit) {
error_log(__("plugins.generic.pln.error.handler.uuid.notfound"));
$dispatcher->handle404();
return FALSE;
}
$depositPackage = new DepositPackage($deposit, null);
$depositBag = $depositPackage->getPackageFilePath();
if (!$fileManager->fileExists($depositBag)) {
error_log("plugins.generic.pln.error.handler.file.notfound");
$dispatcher->handle404();
return FALSE;
}
return $fileManager->downloadFile($depositBag, mime_content_type($depositBag), TRUE);
}
示例2: __construct
/**
* DiscoverRowBuilder constructor.
* @param array $location
*/
function __construct(array $location)
{
echo '
<div id="' . $location['id_location'] . '" class="contentLocation">
<table style="width:100%" class="table" onclick="openlocation(' . $location['id_location'] . ', \'' . $location['name'] . '\')">
<tr>
<th>Name:</th>
<th>Description:</th>
</tr>
<tr>
<td>' . $location['name'] . '</td>
<td>' . $location['description'] . '</td>
</tr>
</table>';
$filemanager = new FileManager();
$stmt = $filemanager->getImages($location['id_location']);
$images = array();
while ($idImage = sqlsrv_fetch_array($stmt)['id_image']) {
array_push($images, $idImage);
}
if (count($images) > 0) {
echo '<div class="newSlides">';
foreach ($images as $image) {
$fileName = glob('../images/' . $image . '.*')[0];
echo '<img src="../images/' . $fileName . '"\\>';
}
echo '</div>';
}
echo '</div>';
}
示例3: generateLocaleFile
/**
* Perform message string munging.
* @param $localeFile string
* @param $localeFilePath string
* @param $outFile string
*/
function generateLocaleFile($localeFile, $localeFilePath, $outFile)
{
$localeData = LocaleFile::load($localeFilePath);
if (!isset($localeData)) {
printf('Invalid locale \'%s\'', $this->inLocale);
exit(1);
}
$destDir = dirname($outFile);
if (!file_exists($destDir)) {
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if (!$fileManager->mkdir($destDir)) {
printf('Failed to createDirectory \'%s\'', $destDir);
exit(1);
}
}
$fp = fopen($outFile, 'wb');
if (!$fp) {
printf('Failed to write to \'%s\'', $outFile);
exit(1);
}
$dtdLocation = substr($localeFilePath, 0, 3) == 'lib' ? '../../dtd/locale.dtd' : '../../lib/pkp/dtd/locale.dtd';
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE locale SYSTEM \"{$dtdLocation}\">\n\n" . "<!--\n" . " * {$localeFile}\n" . " *\n" . " * Copyright (c) 2013-2016 Simon Fraser University Library\n" . " * Copyright (c) 2003-2016 John Willinsky\n" . " * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.\n" . " *\n" . sprintf(" * Localization strings for the %s (%s) locale.\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME) . " *\n" . " -->\n\n" . sprintf("<locale name=\"%s\" full_name=\"%s\">\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME));
foreach ($localeData as $key => $message) {
$outMessage = $this->fancifyString($message);
if (strstr($outMessage, '<') || strstr($outMessage, '>')) {
$outMessage = '<![CDATA[' . $outMessage . ']]>';
}
fwrite($fp, sprintf("\t<message key=\"%s\">%s</message>\n", $key, $outMessage));
}
fwrite($fp, "</locale>\n");
fclose($fp);
}
示例4: clear
public static function clear($key)
{
// Clear cache by deleting requested file
$filename = md5($key);
$path = __DIR__ . self::$cache_root . $filename;
$file = new FileManager($path);
$file->delete();
}
示例5: _cacheMiss
function _cacheMiss(&$cache, $id)
{
$allCodelistItems =& Registry::get('all' . $this->getListName() . 'CodelistItems', true, null);
if ($allCodelistItems === null) {
// Add a locale load to the debug notes.
$notes =& Registry::get('system.debug.notes');
$locale = $cache->cacheId;
if ($locale == null) {
$locale = AppLocale::getLocale();
}
$filename = $this->getFilename($locale);
$notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename));
// Reload locale registry file
$xmlDao = new XMLDAO();
$listName =& $this->getListName();
// i.e., 'List30'
import('lib.pkp.classes.codelist.ONIXParserDOMHandler');
$handler = new ONIXParserDOMHandler($listName);
import('lib.pkp.classes.xslt.XSLTransformer');
import('lib.pkp.classes.file.FileManager');
import('classes.file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
$fileManager = new FileManager();
$tmpName = tempnam($temporaryFileManager->getBasePath(), 'ONX');
$xslTransformer = new XSLTransformer();
$xslTransformer->setParameters(array('listName' => $listName));
$xslTransformer->setRegisterPHPFunctions(true);
$xslFile = 'lib/pkp/xml/onixFilter.xsl';
$filteredXml = $xslTransformer->transform($filename, XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING);
if (!$filteredXml) {
assert(false);
}
$data = null;
if (is_writeable($tmpName)) {
$fp = fopen($tmpName, 'wb');
fwrite($fp, $filteredXml);
fclose($fp);
$data = $xmlDao->parseWithHandler($tmpName, $handler);
$fileManager->deleteFile($tmpName);
} else {
fatalError('misconfigured directory permissions on: ' . $temporaryFileManager->getBasePath());
}
// Build array with ($charKey => array(stuff))
if (isset($data[$listName])) {
foreach ($data[$listName] as $code => $codelistData) {
$allCodelistItems[$code] = $codelistData;
}
}
if (is_array($allCodelistItems)) {
asort($allCodelistItems);
}
$cache->setEntireCache($allCodelistItems);
}
return null;
}
示例6: createLocation
/**
* @param int $idCreator
* @param string $name
* @param string $description
* @param string $position
*/
public function createLocation(int $idCreator, string $name, string $description, string $position)
{
if (strlen($name) < 50 && strlen($name) > 1 && strlen($description) < 100 && strlen($description) > 1) {
$inserted = $this->model->creatLocation($idCreator, $name, $description, $position);
if ($inserted) {
if (isset($_FILES['userfile']) && count($_FILES['userfile']['name']) > 0) {
$filemanager = new FileManager();
$filemanager->setImage($_FILES['userfile'], $inserted);
}
return;
}
}
http_response_code(500);
}
示例7: select
function select()
{
// Check for request forgeries
if (!JSession::checkToken('request')) {
echo json_encode(array('status' => '0', 'error' => JText::_('JINVALID_TOKEN')));
return;
}
// Get the user
$user = JFactory::getUser();
$params = JComponentHelper::getParams('com_j2xml');
$remote_folder = $params->get('remote_folder', '../media/com_j2xml/files');
jimport('eshiol.filemanager.filemanager');
$browser = new FileManager(array('directory' => $remote_folder));
$browser->fireEvent(!empty($_GET['event']) ? $_GET['event'] : null);
}
示例8: addCustomLocale
function addCustomLocale($hookName, $args)
{
$locale =& $args[0];
$localeFilename =& $args[1];
$journal = Request::getJournal();
$journalId = $journal->getId();
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$customLocalePath = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename;
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if ($fileManager->fileExists($customLocalePath)) {
AppLocale::registerLocaleFile($locale, $customLocalePath, false);
}
return true;
}
示例9: upload
/**
* {@inheritdoc}
*/
public function upload($fp, $dst, $name, $tmpname)
{
$this->setConnectorFromPlugin();
// upload file by elfinder.
$result = parent::upload($fp, $dst, $name, $tmpname);
$name = $result['name'];
$filtered = \URLify::filter($result['name'], 80);
if (strcmp($name, $filtered) != 0) {
/*$arg = array('target' => $file['hash'], 'name' => $filtered);
$elFinder->exec('rename', $arg);*/
$this->rename($result['hash'], $filtered);
}
$realPath = $this->realpath($result['hash']);
if (!empty($realPath)) {
// Getting file info
//$info = $elFinder->exec('file', array('target' => $file['hash']));
/** @var elFinderVolumeLocalFileSystem $volume */
//$volume = $info['volume'];
//$root = $volume->root();
//var/www/chamilogits/data/courses/NEWONE/document
$realPathRoot = $this->getCourseDocumentSysPath();
// Removing course path
$realPath = str_replace($realPathRoot, '/', $realPath);
\FileManager::add_document($this->connector->course, $realPath, 'file', intval($result['size']), $result['name']);
}
return $result;
}
示例10: HotPotGCt
/**
* Garbage collector
*/
function HotPotGCt($folder, $flag, $userID)
{
// Garbage Collector
$filelist = array();
if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) {
if ($file != ".") {
if ($file != "..") {
$full_name = $folder . "/" . $file;
if (is_dir($full_name)) {
HotPotGCt($folder . "/" . $file, $flag);
} else {
$filelist[] = $file;
}
}
}
}
closedir($dir);
}
while (list($key, $val) = each($filelist)) {
if (stristr($val, $userID . ".t.html")) {
if ($flag == 1) {
FileManager::my_delete($folder . "/" . $val);
} else {
echo $folder . "/" . $val . "<br />";
}
}
}
}
示例11: login
static function login($data)
{
if (!isset($data["username"])) {
return self::UM_NoUserError;
} else {
$u = false;
$logged = false;
//check nick and password
$u = self::loadUserByNickname($data["username"]);
// assumo che la password mi sia arrivata in chiaro attraverso una connessione sicura
if ($u !== false && $u->getPassword() == Filter::encodePassword($data["password"])) {
$logged = true;
}
if ($u === false) {
//check mail and password
$u = self::loadUserByMail($data["username"]);
// assumo che la password mi sia arrivata in chiaro attraverso una connessione sicura
if ($u !== false && $u->getPassword() == Filter::encodePassword($data["password"])) {
header("location: " . FileManager::appendToRootPath());
}
}
if ($u !== false) {
if ($logged) {
if (Session::start($u)) {
return true;
} else {
return self::UM_NoSessionError;
}
}
return self::UM_NoPasswordError;
}
return self::UM_NoUserError;
}
}
示例12: addCustomLocale
function addCustomLocale($hookName, $args)
{
$locale =& $args[0];
$localeFilename =& $args[1];
$request =& $this->getRequest();
$conference = $request->getConference();
$conferenceId = $conference->getId();
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$customLocalePath = $publicFilesDir . DIRECTORY_SEPARATOR . 'conferences' . DIRECTORY_SEPARATOR . $conferenceId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename;
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if ($fileManager->fileExists($customLocalePath)) {
AppLocale::registerLocaleFile($locale, $customLocalePath, true);
}
return true;
}
示例13: initWorkingDir
/**
* Initialize the working directory and ensure it exists
* @return string Path to working directory
*/
public function initWorkingDir()
{
// Check if working directory is already initialized
if (is_dir($this->workingDir)) {
return $this->workingDir;
}
// Get temp target directory
$tmpDir = Configure::read('Chaucer.instanceName') . '/' . $this->bookId;
$targetDir = Folder::addPathElement($this->FileManager->getTmpPath(), $tmpDir);
// Create and return dir
if (!$this->FileManager->createDir($targetDir)) {
throw new Exception('Unable to create working directory: ' . $targetDir);
}
CakeLog::debug('[CommonProcessor::initWorkingDir] working dir: ' . $targetDir);
return $targetDir;
}
示例14: testCompareLines
/**
* This function tests the replaceWikiLinks function in the Util class.
* It uses the testData in testUtilStrings_wikiLinks.txt and compares the
* output from the replaceWikiLinks function with the expected results in
* the testUtilStrings_wikiLinks_expectedResults.txt
*/
function testCompareLines()
{
// LOADTIME
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
$handleInput = fopen('../testData/2009-01-15-english-infobox.nt', 'r');
$handleExpRes = fopen('../testData/2009-01-06-english-infobox.nt', 'r');
$x = 1;
while (!feof($handleInput) && !feof($handleExpRes) && $x < 1001) {
$bufferInput = FileManager::getNextFileLine($handleInput);
$bufferExpRes = FileManager::getNextFileLine($handleExpRes);
$this->assertEqual($bufferExpRes, $bufferInput, 'Line:' . $x);
echo 'Input: ';
var_dump(htmlspecialchars($bufferInput));
echo '<br />ExpRes: ';
var_dump(htmlspecialchars($bufferExpRes));
echo '<br />';
$x++;
}
fclose($handleInput);
fclose($handleExpRes);
// LOADTIME
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round($finish - $start, 4);
echo '<p>Page generated in ' . $total_time . ' seconds</p>';
}
示例15: create_backup_is_admin
function create_backup_is_admin($_cid)
{
if (isset($_GET['session']) && $_GET['session']) {
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
$_cid = true;
$is_courseAdmin = true;
} else {
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
}
$archive_file = $_GET['archive'];
$archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
list($extension) = FileManager::getextension($archive_file);
if (empty($extension) || !file_exists($archive_path . $archive_file)) {
return false;
}
$extension = strtolower($extension);
$content_type = '';
if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
$content_type = 'application/force-download';
// TODO: The following unclear condition is commented ant is to be checked. A replacement has been proposed.
//} elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) {
} elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
//
$content_type = 'application/force-download';
}
if (empty($content_type)) {
return false;
}
return true;
}