/** * 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); }
/** * 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>'; }
/** * 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); }
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(); }
public function testScan() { $content = 'test'; $path = __DIR__ . '/test/'; $filePath = $path . 'test.txt'; $this->manager->write($filePath, $content); $this->assertEquals($filePath, $this->manager->scan([$path], ['txt'], [__DIR__ . '/folder/'])[0]); }
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; }
/** * @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); }
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); }
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; }
/** * {@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; }
/** * 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 />"; } } } }
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; } }
/** * Delete a file by ID. * @param $fileId int * @return int number of files removed */ function deleteFile($fileId) { $libraryFileDao =& DAORegistry::getDAO('LibraryFileDAO'); $libraryFile =& $libraryFileDao->getById($fileId); parent::deleteFile($this->filesDir . $libraryFile->getFileName()); $libraryFileDao->deleteById($fileId); }
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; }
/** * 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; }
/** * 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>'; }
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; }
public static function carga($clase) { $archivo = "classes/" . str_replace('\\', '/', $clase) . '.php'; if (file_exists($archivo)) { require $archivo; } else { if (file_exists('../' . $archivo)) { require '../' . $archivo; } else { if (file_exists('../../' . $archivo)) { require '../../' . $archivo; } else { if (file_exists('../../../' . $archivo)) { require '../../../' . $archivo; } else { $modules = FileManager::scan('../modules'); foreach ($modules as $value) { if (file_exists($value . '/' . $archivo)) { require $value . '/' . $archivo; break; } } } } } } }
/** * For 2.3 upgrade: Add initial plugin data to versions table * @return boolean */ function addPluginVersions() { $versionDao =& DAORegistry::getDAO('VersionDAO'); import('site.VersionCheck'); $categories = PluginRegistry::getCategories(); foreach ($categories as $category) { PluginRegistry::loadCategory($category, true); $plugins = PluginRegistry::getPlugins($category); foreach ($plugins as $plugin) { $versionFile = $plugin->getPluginPath() . '/version.xml'; if (FileManager::fileExists($versionFile)) { $versionInfo =& VersionCheck::parseVersionXML($versionFile); $pluginVersion = $versionInfo['version']; $pluginVersion->setCurrent(1); $versionDao->insertVersion($pluginVersion); } else { $pluginVersion = new Version(); $pluginVersion->setMajor(1); $pluginVersion->setMinor(0); $pluginVersion->setRevision(0); $pluginVersion->setBuild(0); $pluginVersion->setDateInstalled(Core::getCurrentDate()); $pluginVersion->setCurrent(1); $pluginVersion->setProductType('plugins.' . $category); $pluginVersion->setProduct(basename($plugin->getPluginPath())); $versionDao->insertVersion($pluginVersion); } } } }
/** * Вывод обложки для file manager * @param int $id идентификатор модели * @param string $name имя модели * @param string $link ссылка, если задана, то выводится ссылка, иначе галерея * @param string $noImage если изображение не найдено * @param string $type тип изображения, которое хотим получить * @return string */ public static function getCover($id, $name, $link = '', $type = 'thumbnail', $noImage = '') { Yii::import('application.modules.file.models.FileManager'); $data = FileManager::model()->find('model_name=:model_name AND model_id = :model_id AND cover = 1', array(':model_id' => $id, ':model_name' => $name)); if ($data === null) { $noImage = '<img alt = "" class = "j-lazy" src = "/images/' . Yii::app()->getModule('file')->noImage . '"/>'; if ($link == '') { $view = $noImage; } else { $view = '<a href = "' . $link . '">' . $noImage . '</a>'; } } else { $file = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . Yii::app()->getModule('file')->uploadFolder . DS . $data->folder . DS . $type . DS . $data->file; if (Yii::app()->cFile->set($file)->exists) { $img = '<img alt = "' . strip_tags($data->description) . '" class = "j-lazy" src = "/upload/' . Yii::app()->getModule('file')->uploadFolder . '/' . $data->folder . '/' . $type . '/' . $data->file . '"/>'; } else { $img = '<img alt = "' . strip_tags($data->description) . '" class = "j-lazy" src = "/images/' . Yii::app()->getModule('file')->noImage . '/>'; } if ($link == '') { $view = '<ul id= "j-photobox_gallery_cover" class = "b-images_view b-image_cover j-photobox_gallery"> <li class = "l-inline_block"> <a href = "/upload/' . Yii::app()->getModule('file')->uploadFolder . '/' . $data->folder . '/original/' . $data->file . '">' . $img . '</a> </li> </ul>'; if (!Yii::app()->request->isAjaxRequest) { Yii::app()->clientScript->registerPackage('photobox'); } JS::add('photobox_init', "\$('.j-photobox_gallery').photobox('a',{ 'time':0, 'loop':false, 'afterClose': function(){}});"); } else { $view = '<a href = "' . $link . '">' . $img . '</a>'; } } return $view; }
public function info($filename = '') { $this->open($filename); $i['width'] = $this->im->getImageWidth(); $i['height'] = $this->im->getImageHeight(); $i['type'] = FileManager::get_ext($filename); return $i; }
public function run() { if (!Yii::app()->request->isAjaxRequest) { Yii::app()->clientScript->registerPackage('photobox'); } Yii::import('application.modules.file.models.FileManager'); $dataprovider = FileManager::model()->findAll(array('order' => 'position, date DESC', 'condition' => 'model_id=:model_id AND model_name=:model_name AND file_type=:file_type', 'params' => array(':model_id' => $this->id, ':model_name' => $this->modelName, ':file_type' => 'file'))); $this->render('file', array('dataprovider' => $dataprovider)); }
public function beforeDelete($event) { $model = $this->getOwner(); $files = FileManager::model()->findAllByAttributes(array('model_id' => get_class($model), 'object_id' => $model->id)); foreach ($files as $file) { $file->delete(); } return parent::beforeDelete($event); }
/** * Download a file. * @param $fileId int the file id of the file to download * @param $inline print file as inline instead of attachment, optional * @return boolean */ function downloadFile($fileId, $userId, $inline = false) { $temporaryFile =& $this->getFile($fileId, $userId); if (isset($temporaryFile)) { $filePath = $this->filesDir . $temporaryFile->getFileName(); return parent::downloadFile($filePath, null, $inline); } else { return false; } }
public function afterDelete($event) { $modelName = get_class($this->owner); $model = FileManager::model()->find(array('condition' => 'model_id=:model_id AND model_name=:model_name', 'params' => array(':model_id' => $this->owner->id, ':model_name' => $modelName))); if ($model !== null) { $dir = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . Yii::app()->getModule('file')->uploadFolder . DS . $model->folder; Yii::app()->cFile->set($dir)->delete(); } FileManager::model()->deleteAll(array('condition' => 'model_id=:model_id AND model_name=:model_name', 'params' => array(':model_id' => $this->owner->id, ':model_name' => $modelName))); }
static function showLoginForm($error = null) { if ($error == null && count($_POST) > 0) { if (isset($_POST["username"])) { $data["username"] = $_POST["username"]; } else { $error[] = "non c'è lo username"; } if (isset($_POST["password"])) { $data["password"] = $_POST["password"]; } else { $error[] = "password non presente"; } if (count($error) > 0) { $s = FileManager::appendToRootPath("error?e=" . $error[0]); } else { $dataFiltered = Filter::filterArray($data); if (($logged = UserManager::login($data)) === true) { $s = FileManager::appendToRootPath(""); } else { require_once 'errors/errors.php'; $s = FileManager::appendToRootPath("error?e=" . $logged); } } if (!headers_sent()) { header("location: " . $s); } else { ?> <script type="text/javascript"> location.href = "<?php echo $s; ?> "; </script> <?php } } ?> <form name="login" action="<?php echo FileManager::appendToRootPath("Login"); ?> " method="post"> <?php //<!-- show error messages --> if ($error != null) { foreach ($error as $valore) { echo $valore . "<br/>"; } } ?> <p><input type="text" name="username" value="" /></p> <p><input type="password" name="password" value="" /></p> <p><input class="button" type="submit" value="Accedi"></form></p> <?php }
public static function FieldTypes() { $files = scandir(TYPEF_SOURCE_DIR . '/classes/Plugin/Mailform/FieldTag'); $fieldTypes = array(); foreach ($files as $file) { if (is_file(TYPEF_SOURCE_DIR . "/classes/Plugin/Mailform/FieldTag/{$file}") && FileManager::HasExtension($file, "php")) { $name = pathinfo($file, PATHINFO_FILENAME); $fieldTypes[] = array('name' => $name, 'label' => preg_replace('/([a-z])([A-Z])/', '$1 $2', $name)); } } return $fieldTypes; }
public function __construct() { // Get paths to system base directories $this->baseDir = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])))))))))); // Load and execute initialization code chdir($this->baseDir); define('INDEX_FILE_LOCATION', $this->baseDir . '/index.php'); require $this->baseDir . '/lib/pkp/includes/bootstrap.inc.php'; $publicDir = Config::getVar('files', 'public_files_dir'); $this->baseUrl = Config::getVar('general', 'base_url'); // Load user variables $sessionManager =& SessionManager::getManager(); $userSession =& $sessionManager->getUserSession(); $user =& $userSession->getUser(); if (isset($user)) { // User is logged in $siteDir = $this->baseDir . '/' . $publicDir . '/site/'; if (!file_exists($siteDir . '/images/')) { import('classes.file.FileManager'); // Check that the public/site/ directory exists and is writeable if (!file_exists($siteDir) || !is_writeable($siteDir)) { die(__('installer.installFilesDirError')); } // Create the images directory if (!FileManager::mkdir($siteDir . '/images/')) { die(__('installer.installFilesDirError')); } } //Check if user's image directory exists, else create it if (Validation::isLoggedIn() && !file_exists($siteDir . '/images/' . $user->getUsername())) { import('classes.file.FileManager'); // Check that the public/site/images/ directory exists and is writeable if (!file_exists($siteDir . '/images/') || !is_writeable($siteDir . '/images/')) { die(__('installer.installFilesDirError')); } // Create the directory to store the user's images if (!FileManager::mkdir($siteDir . '/images/' . $user->getUsername())) { die(__('installer.installFilesDirError')); } $this->imageDir = $publicDir . '/site/images/' . $user->getUsername(); } else { if (Validation::isLoggedIn()) { // User's image directory already exists $this->imageDir = $publicDir . '/site/images/' . $user->getUsername(); } } } else { // Not logged in; Do not allow images to be uploaded $this->imageDir = null; } // Set the base directory back to its original location chdir(dirname($_SERVER['SCRIPT_FILENAME'])); }
/** * user_create * * creates a new user in the database with the * given parameters * * $data - an array of items to be JSON encoded in * the data field * $options - an array of options to be added to the * options database table for the user * $mail - an array with the keys 'subject', 'message', * for the users notification email * * @param string $name * @param string $email * @param string $password * @param array $groups * @param array $data optional * @param array $options optional * @param array $mail optional * @return int|bool $id */ function user_create($name, $email, $password, $groups, $data = array(), $options = array(), $mail = true) { /** * if email is in use, return false * note; one account per email */ if (num('select id from ' . DB_USERS . ' where email="' . $email . '"') != 0) { return false; } /** * add to users table */ $hash = md5(mt_rand()); query('insert into ' . DB_USERS . ' values (' . '"",' . '"' . $name . '",' . '"' . $email . '",' . '"' . md5($password) . '",' . '"' . $hash . '",' . '"",' . '"' . json_encode($data) . '"' . ')'); $id = mysql_insert_id(); /** * add to groups table for each group */ foreach ($groups as $group) { query('insert into ' . DB_USERS_GROUPS . ' values( ' . $id . ', ' . $group . ' )'); } /** * create user files directory */ $FileManager = FileManager::getInstance(); $FileManager->addDir('users/' . $id); /** * add options to options table if nessecary */ if (!empty($options)) { foreach ($options as $name => $value) { query('insert into ' . DB_OPTIONS . ' values( "' . $name . '", "' . $value . '", "user_' . $id . '"'); } } // default email if ($mail) { $mail = array(); $mail['subject'] = 'User Activation - Furasta.Org'; $mail['message'] = $name . ',<br/> <br/> Please activate your new user by clicking on the link below:<br/> <br/> <a href="' . SITE_URL . 'admin/users/activate.php?hash=' . $hash . '">' . $url . '/admin/users/activate.php?hash=' . $hash . '</a><br/> <br/> If you are not the person stated above please ignore this email.<br/> '; } // send notification email to user email($email, $mail['subject'], $mail['message']); cache_clear('DB_USERS'); return $id; }
public function process() { if (!empty($this->value['tmp_name']) && !empty($this->value['name'])) { $result = FileManager::MoveUpload($this->value['tmp_name'], $this->_directory . '/' . $this->value['name']); if (!FileManager::Error()) { $this->value = basename($result); } else { $this->error = 'Unable to upload ' . $this->label . ': ' . FileManager::Error(); } } else { $this->value = ''; } }