function fileSharingUpdate() { try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'FileSharing' WHERE `id` = 68"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=media&archive=FileSharing' WHERE `area_id` = 187"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('68', 'FileSharing', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'FileSharing' WHERE `module` = 'filesharing'"); //update section \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'FileSharing',`value` = 'on' WHERE\n `section` = 'filesharing' AND `name` = 'permission' AND `group` = 'config'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } $sourcePath = ASCMS_DOCUMENT_ROOT . '/media/filesharing'; $targetPath = ASCMS_DOCUMENT_ROOT . '/media/FileSharing'; try { if (file_exists($sourcePath) && !file_exists($targetPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath); if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) { return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'FileSharing updated successfully'; }
function calendarUpdate() { try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Calendar' WHERE `id` = 21"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Calendar' WHERE `area_id` = 16"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('21', 'Calendar', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Calendar' WHERE `module` = 'calendar'"); //following queries for changing the path from images/calendar into images/Calendar \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_calendar_event` SET `pic` = REPLACE(`pic`, 'images/calendar', 'images/Calendar'),\n `attach` = REPLACE(`attach`, 'images/calendar', 'images/Calendar'),\n `place_map` = REPLACE(`place_map`, 'images/calendar', 'images/Calendar')\n WHERE `pic` LIKE ('" . ASCMS_PATH_OFFSET . "/images/calendar%') "); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/calendar'; $targetPath = ASCMS_DOCUMENT_ROOT . '/images/Calendar'; try { if (file_exists($sourcePath) && !file_exists($targetPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath); if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) { return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Calendar Component Updated Successfully'; }
function forumUpdates() { //Update the database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Forum' WHERE `id` = 20"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Forum' WHERE `area_id` = 106"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('20', 'Forum', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Forum' WHERE `module` = 'forum'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $sourcePath = ASCMS_DOCUMENT_ROOT . '/media/forum'; $destinationPath = ASCMS_DOCUMENT_ROOT . '/media/Forum'; try { if (file_exists($sourcePath) && !file_exists($destinationPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath); if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $destinationPath)) { return 'Failed to move the folder from ' . $sourcePath . ' to ' . $destinationPath . '.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Forum updated successfully.'; }
function downloadsUpdate() { try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Downloads' WHERE `id` = 53"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Downloads' WHERE `area_id` = 132"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('53', 'Downloads', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Downloads' WHERE `module` = 'downloads'"); //following queries for changing the path from images/downloads into images/Downloads \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_downloads_download`\n SET `image` = REPLACE(`image`, 'images/downloads', 'images/Downloads')\n WHERE `image` LIKE ('" . ASCMS_PATH_OFFSET . "/images/downloads%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_downloads_category`\n SET `image` = REPLACE(`image`, 'images/downloads', 'images/Downloads')\n WHERE `image` LIKE ('" . ASCMS_PATH_OFFSET . "/images/downloads%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_downloads_download_locale`\n SET `source` = REPLACE(`source`, 'images/downloads', 'images/Downloads')\n WHERE `source` LIKE ('" . ASCMS_PATH_OFFSET . "/images/downloads%')"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/downloads'; $targetPath = ASCMS_DOCUMENT_ROOT . '/images/Downloads'; try { if (file_exists($sourcePath) && !file_exists($targetPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath); if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) { return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Downloads Updated successfully'; }
function galleryUpdate() { try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Gallery' WHERE `id` = 3"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Gallery' WHERE `area_id` = 12"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('3', 'Gallery', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Gallery' WHERE `module` = 'gallery'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/gallery'; $targetPath = ASCMS_DOCUMENT_ROOT . '/images/Gallery'; try { if (file_exists($sourcePath) && !file_exists($targetPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath); if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) { return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Gallery Component Updated Successfully'; }
function accessUpdates() { //Update the database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Access' WHERE `id` = 23"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Access', `module_id` = '23' WHERE `area_id` = 18"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Access' WHERE `area_id` = 208"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('23', 'Access', 'core_module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Access' WHERE `module` = 'access'"); //update module name for crm core settings \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'Access' WHERE `section` = 'access' AND `name` = 'providers' AND `group` = 'sociallogin'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $accessImgPath = ASCMS_DOCUMENT_ROOT . '/images'; try { if (file_exists($accessImgPath . '/access') && !file_exists($accessImgPath . '/Access')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($accessImgPath . '/access'); if (!\Cx\Lib\FileSystem\FileSystem::move($accessImgPath . '/access', $accessImgPath . '/Access')) { return 'Failed to move the folder from ' . $accessImgPath . '/access to ' . $accessImgPath . '/Access.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Access updated successfully.'; }
function marketUpdates() { //Update the database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Market' WHERE `id` = 33"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Market' WHERE `area_id` = 98"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('33', 'Market', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Market' WHERE `module` = 'market'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $marketMediaPath = ASCMS_DOCUMENT_ROOT . '/media'; try { if (file_exists($marketMediaPath . '/market') && !file_exists($marketMediaPath . '/Market')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($marketMediaPath . '/market'); if (!\Cx\Lib\FileSystem\FileSystem::move($marketMediaPath . '/market', $marketMediaPath . '/Market')) { return 'Failed to move the folder from ' . $marketMediaPath . '/market to ' . $marketMediaPath . '/Market.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Market updated successfully.'; }
function showNewsRefresh($id, $time, $path) { global $objDatabase; //delete old #01 $query = "SELECT link,\n filename\n FROM " . DBPREFIX . "module_feed_news\n WHERE id = '" . $id . "'"; $objResult = $objDatabase->Execute($query); $old_link = $objResult->fields['link']; $old_filename = $objResult->fields['filename']; if ($old_link != '') { $filename = 'feed_' . $time . '_' . \Cx\Lib\FileSystem\FileSystem::replaceCharacters(basename($old_link)); @copy($old_link, $path . $filename); //rss class $rss = new \XML_RSS($path . $filename); $rss->parse(); $content = ''; foreach ($rss->getStructure() as $array) { $content .= $array; } } if ($old_link == '') { $filename = $old_filename; } $query = "UPDATE " . DBPREFIX . "module_feed_news\n SET filename = '" . $filename . "',\n time = '" . $time . "'\n WHERE id = '" . $id . "'"; $objDatabase->Execute($query); //delete old #02 if ($old_link != '') { @unlink($path . $old_filename); } }
function _podcastUpdate() { global $objDatabase, $_ARRAYLANG, $objUpdate, $_CONFIG; //move podcast images directory $path = ASCMS_DOCUMENT_ROOT . '/images'; $oldImagesPath = '/content/podcast'; $newImagesPath = '/podcast'; if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '1.2.1')) { if (!file_exists($path . $newImagesPath) && file_exists($path . $oldImagesPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $oldImagesPath); if (!\Cx\Lib\FileSystem\FileSystem::copy_folder($path . $oldImagesPath, $path . $newImagesPath)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_TO_MOVE_DIRECTORY'], $path . $oldImagesPath, $path . $newImagesPath)); return false; } } \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath); \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath . '/youtube_thumbnails'); //change thumbnail paths $query = "UPDATE `" . DBPREFIX . "module_podcast_medium` SET `thumbnail` = REPLACE(`thumbnail`, '/images/content/podcast/', '/images/podcast/')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } //set new default settings $query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '50' WHERE `setname` = 'thumb_max_size' AND `setvalue` = ''"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '85' WHERE `setname` = 'thumb_max_size_homecontent' AND `setvalue` = ''"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } // only update if installed version is at least a version 2.0.0 // older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) { try { // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } // add missing placeholder {PODCAST_JAVASCRIPT} if (strpos($content, '{PODCAST_JAVASCRIPT}') === false) { $content .= "\n{PODCAST_JAVASCRIPT}"; } // add missing placeholder {PODCAST_PAGING} if (strpos($content, '{PODCAST_PAGING}') === false) { $content = preg_replace('/(\\s+)(<!--\\s+END\\s+podcast_media\\s+-->)/ms', '$1$2$1<div class="noMedium">$1 {PODCAST_PAGING}$1</div>', $content); } return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'podcast'), $search, $callback, array('content'), '3.0.1'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } return true; }
function Create() { $this->content = utf8_decode($this->_ParseHTML($this->content)); $pdf = new HTML2FPDF(); $pdf->ShowNOIMG_GIF(); $pdf->DisplayPreferences('HideWindowUI'); $pdf->AddPage(); $pdf->WriteHTML($this->content); $pdf->Output(\Cx\Lib\FileSystem\FileSystem::replaceCharacters($this->title)); }
/** * Constructor */ public function __construct() { $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $folderPath = $cx->getWebsiteTempPath() . '/Update'; if (!file_exists($folderPath)) { \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath); } if (!file_exists($folderPath . '/' . self::PENDING_DB_UPDATES_YML)) { \Cx\Lib\FileSystem\FileSystem::copy_file($cx->getCodeBaseCoreModulePath() . '/Update/Data/' . self::PENDING_DB_UPDATES_YML, $folderPath . '/' . self::PENDING_DB_UPDATES_YML); } parent::__construct($folderPath . '/' . self::PENDING_DB_UPDATES_YML); }
function ecardUpdates() { //Update database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Ecard' WHERE `id` = 49"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Ecard' WHERE `area_id` = 130"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('49', 'Ecard', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Ecard' WHERE `module` = 'ecard'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folders $imgModulesfolderPath = ASCMS_DOCUMENT_ROOT . '/images/modules/ecard'; $mediafolderPath = ASCMS_DOCUMENT_ROOT . '/media/Ecard'; try { if (!file_exists($mediafolderPath)) { \Cx\Lib\FileSystem\FileSystem::make_folder($mediafolderPath); \Cx\Lib\FileSystem\FileSystem::makeWritable($mediafolderPath); } //move the folder from '/images/modules/ecard/ecards_optimized' to '/media/Ecard/ecards_optimized' if (file_exists($imgModulesfolderPath . '/ecards_optimized') && !file_exists($mediafolderPath . '/ecards_optimized')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/ecards_optimized'); if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/ecards_optimized', $mediafolderPath . '/ecards_optimized')) { return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/ecards_optimized to ' . $mediafolderPath . '/ecards_optimized.'; } } //move the folder from '/images/modules/ecard/send_ecards' to '/media/Ecard/send_ecards' if (file_exists($imgModulesfolderPath . '/send_ecards') && !file_exists($mediafolderPath . '/send_ecards')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/send_ecards'); if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/send_ecards', $mediafolderPath . '/send_ecards')) { return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/send_ecards to ' . $mediafolderPath . '/send_ecards.'; } } //move the folder from '/images/modules/ecard/thumbnails' to '/media/Ecard/thumbnails' if (file_exists($imgModulesfolderPath . '/thumbnails') && !file_exists($mediafolderPath . '/thumbnails')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/thumbnails'); if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/thumbnails', $mediafolderPath . '/thumbnails')) { return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/thumbnails to ' . $mediafolderPath . '/thumbnails.'; } } return 'Successfully updated.'; } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } }
/** * Create all the thumbnails for a picture. * * @param string $path Path to the file. This can be a virtual path or a absolute path. * @param string $fileNamePlain Plain file name without extension * @param string $fileExtension Extension of the file * @param \ImageManager $imageManager * * <code> * <?php * \Cx\Core_Modules\MediaBrowser\Model\FileSystem::createThumbnail( * 'files/', * 'Django, * 'jpg', * new ImageManager() // Please recycle the instance and don't create a new anonymous instance for each call. * // This is just a simple example. * ); * ?> * </code> * * @return array With all thumbnail types and if they were generated successfully. */ public static function createThumbnail($path, $fileNamePlain, $fileExtension, \ImageManager $imageManager, $generateThumbnailByRatio = false) { $success = array(); foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) { if (\Cx\Lib\FileSystem\FileSystem::exists(MediaSourceManager::getAbsolutePath($path) . $fileNamePlain . $thumbnail['value'] . '.' . $fileExtension)) { $success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_NEUTRAL; continue; } if ($imageManager->_createThumb(MediaSourceManager::getAbsolutePath($path) . '/', '', $fileNamePlain . '.' . $fileExtension, $thumbnail['size'], $thumbnail['quality'], $fileNamePlain . $thumbnail['value'] . '.' . $fileExtension, $generateThumbnailByRatio)) { $success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_SUCCESS; continue; } $success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_FAIL; } return $success; }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { if (!$this->interface->yesNo('Removing workbench requires re-installing workbench to use it again. Are you sure?')) { return; } // Remove component from Db and FileSystem $component = new \Cx\Core\Core\Model\Entity\ReflectionComponent('Workbench', 'core_module'); $component->remove(); // Remove additional files (config, command line script) foreach ($this->interface->getWorkbench()->getFileList() as $file) { if (is_dir($file)) { \Cx\Lib\FileSystem\FileSystem::delete_folder(ASCMS_DOCUMENT_ROOT . $file, true); } else { \Cx\Lib\FileSystem\FileSystem::delete_file(ASCMS_DOCUMENT_ROOT . $file); } } $this->interface->show('Done'); }
protected function initContrexxCaching() { global $_CONFIG; // in case the request's origin is from a mobile devie // and this is the first request (the InitCMS object wasn't yet // able to determine of the mobile device wishes to be served // with the system's mobile view), we shall deactivate the caching system if (\InitCMS::_is_mobile_phone() && !\InitCMS::_is_tablet() && !isset($_REQUEST['smallscreen'])) { $this->boolIsEnabled = false; return; } if ($_CONFIG['cacheEnabled'] == 'off') { $this->boolIsEnabled = false; return; } if (isset($_REQUEST['caching']) && $_REQUEST['caching'] == '0') { $this->boolIsEnabled = false; return; } // TODO: Reimplement - see #1205 /*if ($this->isException()) { $this->boolIsEnabled = false; return; }*/ $this->boolIsEnabled = true; // check the cache directory if (!is_dir(ASCMS_CACHE_PATH)) { \Cx\Lib\FileSystem\FileSystem::make_folder(ASCMS_CACHE_PATH); } if (!is_writable(ASCMS_CACHE_PATH)) { \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_CACHE_PATH); } $this->strCachePath = ASCMS_CACHE_PATH . '/'; $this->intCachingTime = intval($_CONFIG['cacheExpiration']); // Use data of $_GET and $_POST to uniquely identify a request. // Important: You must not use $_REQUEST instead. $_REQUEST also contains // the data of $_COOKIE. Whereas the cookie information might // change in each request, which might break the caching- // system. $request = array_merge_recursive($_GET, $_POST); ksort($request); $this->arrPageContent = array('url' => $_SERVER['REQUEST_URI'], 'request' => $request); $this->strCacheFilename = md5(serialize($this->arrPageContent)); }
/** * @override */ public function handleRequest() { global $_FILES; //get a writable directory $targetDir = '/upload_' . $this->uploadId; $tempPath = $_SESSION->getTempPath(); $webTempPath = $_SESSION->getWebTempPath(); //make sure target directory exists if (!file_exists($tempPath . $targetDir)) { \Cx\Lib\FileSystem\FileSystem::make_folder($webTempPath . $targetDir); } //move all uploaded file to this upload's temp directory foreach ($_FILES["uploaderFiles"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmpName = $_FILES["uploaderFiles"]["tmp_name"][$key]; $name = $_FILES["uploaderFiles"]["name"][$key]; if (!\FWValidator::is_file_ending_harmless($name)) { die('Error:' . sprintf('The file %s was refused due to its file extension which is not allowed!', htmlentities($name, ENT_QUOTES, CONTREXX_CHARSET))); } //TODO: Uploader::addChunk does this also -> centralize in function // remember the "raw" file name, we want to store all original // file names in the session. $originalFileName = $name; // Clean the fileName for security reasons $name = preg_replace('/[^\\w\\._]+/', '', $name); $originalFileNames = array(); if (isset($_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'])) { $originalFileNames = $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames']; } $originalFileNames[$name] = $originalFileName; $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'] = $originalFileNames; //end of TODO-region //move file somewhere we know both the web- and normal path... @move_uploaded_file($tmpName, ASCMS_TEMP_PATH . '/' . $name); //...then do a safe-mode-safe (yeah) move operation \Cx\Lib\FileSystem\FileSystem::move(ASCMS_TEMP_WEB_PATH . '/' . $name, $webTempPath . $targetDir . '/' . $name, true); } } //and call back. $this->notifyCallback(); //redirect the user where he belongs $this->redirect(); }
function _ecardUpdate() { global $objDatabase, $_ARRAYLANG, $_CORELANG; try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_ecard_ecards', array('code' => array('type' => 'VARCHAR(35)', 'notnull' => true, 'default' => '', 'primary' => true), 'date' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'TTL' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'salutation' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'senderName' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'senderEmail' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'recipientName' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'recipientEmail' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'message' => array('type' => 'TEXT', 'notnull' => true))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_ecard_settings', array('setting_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'primary' => true), 'setting_value' => array('type' => 'TEXT', 'notnull' => true, 'default' => 0))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } $ins_tpl = "\n INSERT INTO " . DBPREFIX . "module_ecard_settings (setting_name, setting_value)\n VALUES ('%s', '%s')\n ON DUPLICATE KEY UPDATE `setting_name` = `setting_name`\n "; $insert_values = array(array('maxCharacters', '100'), array('maxLines', '50'), array('motive_0', 'Bild_001.jpg'), array('motive_1', 'Bild_002.jpg'), array('motive_2', ''), array('motive_3', ''), array('motive_4', ''), array('motive_5', ''), array('motive_6', ''), array('motive_7', ''), array('motive_8', ''), array('maxHeight', '300'), array('validdays', '30'), array('maxWidth', '300'), array('maxHeightThumb', '80'), array('maxWidthThumb', '80'), array('subject', 'Sie haben eine E-Card erhalten!'), array('emailText', "[[ECARD_SENDER_NAME]] hat Ihnen eine E-Card geschickt.<br />\n Sie können diese während den nächsten [[ECARD_VALID_DAYS]] Tagen unter [[ECARD_URL]] abrufen.")); foreach ($insert_values as $setting) { $query = sprintf($ins_tpl, addslashes($setting[0]), addslashes($setting[1])); if (!$objDatabase->Execute($query)) { return _databaseError($query, $objDatabase->ErrorMsg()); } } /* * ********************************************** * BUGFIX: Set write access to the image dir * * ********************************************** */ $arrImagePaths = array(array(ASCMS_DOCUMENT_ROOT . '/images/modules/ecard', ASCMS_PATH_OFFSET . '/images/modules/ecard'), array(ASCMS_ECARD_OPTIMIZED_PATH, ASCMS_ECARD_OPTIMIZED_WEB_PATH), array(ASCMS_ECARD_SEND_ECARDS_PATH, ASCMS_ECARD_SEND_ECARDS_WEB_PATH), array(ASCMS_ECARD_THUMBNAIL_PATH, ASCMS_ECARD_THUMBNAIL_WEB_PATH)); foreach ($arrImagePaths as $arrImagePath) { if (\Cx\Lib\FileSystem\FileSystem::makeWritable($arrImagePath[0])) { if ($mediaDir = @opendir($arrImagePath[0])) { while ($file = readdir($mediaDir)) { if ($file != '.' && $file != '..') { if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($arrImagePath[0] . '/' . $file)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], $arrImagePath[0] . '/' . $file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], $arrImagePath[0] . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], $arrImagePath[0] . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } return true; }
function crmUpdates() { //Update the database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Crm' WHERE `id` = 69"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=customers' WHERE `area_id` = 191"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=task' WHERE `area_id` = 192"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=deals' WHERE `area_id` = 193"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=settings' WHERE `area_id` = 195"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('69', 'Crm', 'module')"); //update module name for email templates \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_mail_template` SET `section` = 'Crm' WHERE `section` = 'crm'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_text` SET `section` = 'Crm' WHERE `section` = 'crm'"); //update module name for crm core settings \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'Crm' WHERE `section` = 'crm'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $crmImgPath = ASCMS_DOCUMENT_ROOT . '/images'; $crmMediaPath = ASCMS_DOCUMENT_ROOT . '/media'; try { if (file_exists($crmImgPath . '/crm') && !file_exists($crmImgPath . '/Crm')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($crmImgPath . '/crm'); if (!\Cx\Lib\FileSystem\FileSystem::move($crmImgPath . '/crm', $crmImgPath . '/Crm')) { return 'Failed to move the folder from ' . $crmImgPath . '/crm to ' . $crmImgPath . '/Crm.'; } } if (file_exists($crmMediaPath . '/crm') && !file_exists($crmMediaPath . '/Crm')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($crmMediaPath . '/crm'); if (!\Cx\Lib\FileSystem\FileSystem::move($crmMediaPath . '/crm', $crmMediaPath . '/Crm')) { return 'Failed to move the folder from ' . $crmMediaPath . '/crm to ' . $crmMediaPath . '/Crm.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Crm updated successfully.'; }
function shopUpdates() { //Update the database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Shop' WHERE `id` = 16"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Shop' WHERE `area_id` = 13"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('16', 'Shop', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Shop' WHERE `module` = 'shop'"); //update module name for crm core settings \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'Shop' WHERE `section` = 'shop'"); //update module name for email templates \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_mail_template` SET `section` = 'Shop' WHERE `section` = 'shop'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_text` SET `section` = 'Shop' WHERE `section` = 'shop'"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $shopImgPath = ASCMS_DOCUMENT_ROOT . '/images'; $shopMediaPath = ASCMS_DOCUMENT_ROOT . '/media'; try { if (file_exists($shopImgPath . '/shop') && !file_exists($shopImgPath . '/Shop')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($shopImgPath . '/shop'); if (!\Cx\Lib\FileSystem\FileSystem::move($shopImgPath . '/shop', $shopImgPath . '/Shop')) { return 'Failed to move the folder from ' . $shopImgPath . '/shop to ' . $shopImgPath . '/Shop.'; } } if (file_exists($shopMediaPath . '/shop') && !file_exists($shopMediaPath . '/Shop')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($shopMediaPath . '/shop'); if (!\Cx\Lib\FileSystem\FileSystem::move($shopMediaPath . '/shop', $shopMediaPath . '/Shop')) { return 'Failed to move the folder from ' . $shopMediaPath . '/shop to ' . $shopMediaPath . '/Shop.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Shop updated successfully.'; }
function mediaDirUpdate() { try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'MediaDir' WHERE `id` = 60"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=MediaDir' WHERE `area_id` = 153"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('60', 'MediaDir', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'MediaDir' WHERE `module` = 'mediadir'"); //update class name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'linkGroup' WHERE `name` = 'link_group'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'googleMap' WHERE `name` = 'google_map'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'addStep' WHERE `name` = 'add_step'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'fieldGroup' WHERE `name` = 'field_group'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'productAttributes' WHERE `name` = 'product_attributes'"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'googleWeather' WHERE `name` = 'google_weather'"); //following queries for changing the path from images/mediadir into images/MediaDir \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_categories` \n SET `picture` = REPLACE(`picture`, 'images/mediadir', 'images/MediaDir')\n WHERE `picture` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_forms` \n SET `picture` = REPLACE(`picture`, 'images/mediadir', 'images/MediaDir')\n WHERE `picture` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_levels` \n SET `picture` = REPLACE(`picture`, 'images/mediadir', 'images/MediaDir')\n WHERE `picture` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_rel_entry_inputfields` \n SET `value` = REPLACE(`value`, 'images/mediadir', 'images/MediaDir')\n WHERE `value` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_rel_entry_inputfields_clean1` \n SET `value` = REPLACE(`value`, 'images/mediadir', 'images/MediaDir')\n WHERE `value` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/mediadir'; $targetPath = ASCMS_DOCUMENT_ROOT . '/images/MediaDir'; try { if (file_exists($sourcePath) && !file_exists($targetPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath); if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) { return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Media Directory Updated Successfully'; }
function blogUpdates() { //Update the database changes try { //update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Blog' WHERE `id` = 47"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog' WHERE `area_id` = 119"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=manageEntry' WHERE `area_id` = 120"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=addEntry' WHERE `area_id` = 121"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=manageCategory' WHERE `area_id` = 122"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=addCategory' WHERE `area_id` = 123"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=settings' WHERE `area_id` = 124"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=networks' WHERE `area_id` = 125"); //Insert component entry \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('47', 'Blog', 'module')"); //update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Blog' WHERE `module` = 'blog'"); //following queries for changing the path from images/blog into images/Blog \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_blog_messages_lang` \n SET `image` = REPLACE(`image`, 'images/blog', 'images/Blog')\n WHERE `image` LIKE ('" . ASCMS_PATH_OFFSET . "/images/blog%')"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_blog_networks` \n SET `icon` = REPLACE(`icon`, 'images/blog', 'images/Blog')\n WHERE `icon` LIKE ('" . ASCMS_PATH_OFFSET . "/images/blog%')"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $blogImgPath = ASCMS_DOCUMENT_ROOT . '/images'; try { if (file_exists($blogImgPath . '/blog') && !file_exists($blogImgPath . '/Blog')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($blogImgPath . '/blog'); if (!\Cx\Lib\FileSystem\FileSystem::move($blogImgPath . '/blog', $blogImgPath . '/Blog')) { return 'Failed to move the folder from ' . $blogImgPath . '/blog to ' . $blogImgPath . '/Blog.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Blog updated successfully.'; }
function podcastUpdate() { try { // Update module name \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Podcast' WHERE `id` = 35"); // Update navigation url value \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Podcast' WHERE `area_id` = 93"); // Insert entry for component \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('35', 'Podcast', 'module')"); // Update module name for frontend pages \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Podcast' WHERE `module` = 'podcast'"); // Update the thumbnail path from images/podcast into images/Podcast \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_podcast_medium`\n SET `thumbnail` = REPLACE(`thumbnail`, 'images/podcast', 'images/Podcast')\n WHERE `thumbnail` LIKE ('" . ASCMS_PATH_OFFSET . "/images/podcast%')"); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } //Update script for moving the folder $imgPath = ASCMS_DOCUMENT_ROOT . '/images'; $mediaPath = ASCMS_DOCUMENT_ROOT . '/media'; try { if (file_exists($imgPath . '/podcast') && !file_exists($imgPath . '/Podcast')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($imgPath . '/podcast'); if (!\Cx\Lib\FileSystem\FileSystem::move($imgPath . '/podcast', $imgPath . '/Podcast')) { return 'Failed to move the folder from ' . $imgPath . '/podcast to ' . $imgPath . '/Podcast.'; } } if (file_exists($mediaPath . '/podcast') && !file_exists($mediaPath . '/Podcast')) { \Cx\Lib\FileSystem\FileSystem::makeWritable($mediaPath . '/podcast'); if (!\Cx\Lib\FileSystem\FileSystem::move($mediaPath . '/podcast', $mediaPath . '/Podcast')) { return 'Failed to move the folder from ' . $mediaPath . '/podcast to ' . $mediaPath . '/Podcast.'; } } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { return $e->getMessage(); } return 'Podcast Component database updated successfully'; }
function _memberdirUpdate() { global $objDatabase, $_ARRAYLANG, $_CORELANG; try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_directories', array('dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parentdir' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '1'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'displaymode' => array('type' => 'SET(\'0\',\'1\',\'2\')', 'notnull' => true, 'default' => '0'), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '1'), 'pic1' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'pic2' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')), array('memberdir_dir' => array('fields' => array('name', 'description'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_name', array('field' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'active' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => ''), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_settings', array('setid' => array('type' => 'INT(4)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_values', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'dirid' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'pic1' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'pic2' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), '0' => array('type' => 'SMALLINT(5)', 'notnull' => true, 'unsigned' => true, 'default' => '0'), '1' => array('type' => 'TEXT'), '2' => array('type' => 'TEXT'), '3' => array('type' => 'TEXT'), '4' => array('type' => 'TEXT'), '5' => array('type' => 'TEXT'), '6' => array('type' => 'TEXT'), '7' => array('type' => 'TEXT'), '8' => array('type' => 'TEXT'), '9' => array('type' => 'TEXT'), '10' => array('type' => 'TEXT'), '11' => array('type' => 'TEXT'), '12' => array('type' => 'TEXT'), '13' => array('type' => 'TEXT'), '14' => array('type' => 'TEXT'), '15' => array('type' => 'TEXT'), '16' => array('type' => 'TEXT'), '17' => array('type' => 'TEXT'), '18' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); $arrSettings = array('default_listing' => array('1', '1'), 'max_height' => array('400', '1'), 'max_width' => array('500', '1')); foreach ($arrSettings as $key => $arrSetting) { if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "module_memberdir_settings` WHERE `setname` = '" . $key . "'")->RecordCount()) { \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_memberdir_settings`\n SET `setname` = '" . $key . "',\n `setvalue` = '" . $arrSetting[0] . "',\n `lang_id` = '" . $arrSetting[1] . "'\n "); } } } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_MEDIA_PATH . '/memberdir')) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_MEDIA_PATH . '/memberdir/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } return true; }
/** * Saves the image to the path given as a jpeg file * @access public * @param string $file The path for the jpeg image file to be written * @param booelan $force Force overwriting existing files if true * @return boolean True on success, false otherwise */ function saveJpeg($image, $path, $quality = 90, $force = false) { if (File::exists($path) && !$force) { return false; } File::delete_file($path); if (imagejpeg($image, ASCMS_DOCUMENT_ROOT . '/' . $path, $quality)) { return \Cx\Lib\FileSystem\FileSystem::makeWritable($path); } return false; }
/** * Copy the Upload the image to the path * Note: validation should be done before calling this function * * @param string $filePath Temp path of the uploaded media * * @return boolean|string relative path of the uploaded file, false otherwise */ function uploadMedia($filePath) { if ($filePath == '' || !\FWValidator::is_file_ending_harmless($filePath)) { return false; } $fileName = basename($filePath); //get extension $arrFileInfo = pathinfo($fileName); $fileExtension = !empty($arrFileInfo['extension']) ? '.' . $arrFileInfo['extension'] : ''; $fileBasename = $arrFileInfo['filename']; $randomSum = rand(10, 99); //encode filename if ($this->arrSettings['settingsEncryptFilenames'] == 1) { $fileName = md5($randomSum . $fileBasename) . $fileExtension; } //check filename if (file_exists($this->imagePath . 'uploads/' . $fileName)) { $fileName = $fileBasename . '_' . time() . $fileExtension; } //upload file if (\Cx\Lib\FileSystem\FileSystem::copy_file($filePath, $this->imagePath . 'uploads/' . $fileName) !== false) { $objFile = new \File(); $objFile->setChmod($this->imagePath, $this->imageWebPath, 'uploads/' . $fileName); return $this->imageWebPath . 'uploads/' . $fileName; } else { return false; } }
public static function uploadFinished($tempPath, $tempWebPath, $data, $uploadId, $fileInfos) { $tup = self::getTemporaryUploadPath($data['submissionId'], $data['fieldId']); // in case uploader has been restricted to only allow one single file to be // uploaded, we'll have to clean up any previously uploaded files if ($data['singlefile']) { if (count($fileInfos['originalFileNames'])) { // new files have been uploaded -> remove existing files $contactUploadDestinationPath = $tup[0] . '/' . $tup[2]; if ($dh = opendir($contactUploadDestinationPath)) { while (($uploadedFile = readdir($dh)) !== false) { if ($uploadedFile == '..' || $uploadedFile == '.') { continue; } \Cx\Lib\FileSystem\FileSystem::delete_file($contactUploadDestinationPath . '/' . $uploadedFile); } closedir($dh); } } // remove additional files, in case more than one file has been uploaded if (count($fileInfos['originalFileNames']) > 1) { $firstUploadedFile = array_shift($fileInfos['originalFileNames']); if ($dh = opendir($tempPath)) { while (($uploadedFile = readdir($dh)) !== false) { if ($uploadedFile == '..' || $uploadedFile == '.' || $uploadedFile == $firstUploadedFile) { continue; } \Cx\Lib\FileSystem\FileSystem::delete_file($tempPath . '/' . $uploadedFile); } closedir($dh); } } } return array($tup[0] . '/' . $tup[2], $tup[1] . '/' . $tup[2]); }
/** * PHP5 constructor * @param string $objTemplate * @param array $_ARRAYLANG * @access public */ function __construct() { global $_ARRAYLANG, $_FTPCONFIG, $objTemplate, $objDatabase; // sigma template $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Media/View/Template/Backend'); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl); $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE); $this->arrPaths = array(ASCMS_MEDIA1_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIA2_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIA3_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIA4_PATH . DIRECTORY_SEPARATOR, ASCMS_FILESHARING_PATH . DIRECTORY_SEPARATOR, ASCMS_CONTENT_IMAGE_PATH . DIRECTORY_SEPARATOR, ASCMS_SHOP_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_THEMES_PATH . DIRECTORY_SEPARATOR, ASCMS_ATTACH_PATH . DIRECTORY_SEPARATOR, ASCMS_ACCESS_PATH . DIRECTORY_SEPARATOR, ASCMS_BLOG_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_CALENDAR_IMAGE_PATH . DIRECTORY_SEPARATOR, ASCMS_DOWNLOADS_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_GALLERY_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIADIR_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_PODCAST_IMAGES_PATH . DIRECTORY_SEPARATOR); $this->arrWebPaths = array('archive1' => ASCMS_MEDIA1_WEB_PATH . '/', 'archive2' => ASCMS_MEDIA2_WEB_PATH . '/', 'archive3' => ASCMS_MEDIA3_WEB_PATH . '/', 'archive4' => ASCMS_MEDIA4_WEB_PATH . '/', 'FileSharing' => ASCMS_FILESHARING_WEB_PATH . '/', 'content' => ASCMS_CONTENT_IMAGE_WEB_PATH . '/', 'Contact' => ASCMS_ATTACH_WEB_PATH . '/', 'Shop' => ASCMS_SHOP_IMAGES_WEB_PATH . '/', 'themes' => ASCMS_THEMES_WEB_PATH . '/', 'attach' => ASCMS_ATTACH_WEB_PATH . '/', 'Access' => ASCMS_ACCESS_WEB_PATH . '/', 'Blog' => ASCMS_BLOG_IMAGES_WEB_PATH . '/', 'Calendar' => ASCMS_CALENDAR_IMAGE_WEB_PATH . '/', 'Downloads' => ASCMS_DOWNLOADS_IMAGES_WEB_PATH . '/', 'Gallery' => ASCMS_GALLERY_WEB_PATH . '/', 'MediaDir' => ASCMS_MEDIADIR_IMAGES_WEB_PATH . '/', 'Podcast' => ASCMS_PODCAST_IMAGES_WEB_PATH . '/'); $moduleMatchTable = array('archive1' => 'Media1', 'archive2' => 'Media2', 'archive3' => 'Media3', 'archive4' => 'Media4', 'content' => 'core', 'themes' => 'core', 'attach' => 'core'); $license = \Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase); $license->check(); foreach ($this->arrWebPaths as $module => $path) { $moduleName = $module; if (isset($moduleMatchTable[$module])) { $moduleName = $moduleMatchTable[$module]; } if (!$license->isInLegalComponents($moduleName)) { \DBG::msg('Module "' . $module . '" is deactivated'); unset($this->arrWebPaths[$module]); } } if (empty($this->arrWebPaths)) { \Permission::noAccess(); } if (isset($_REQUEST['archive']) && array_key_exists($_REQUEST['archive'], $this->arrWebPaths)) { $this->archive = $_REQUEST['archive']; } else { $this->archive = 'content'; } // get variables $this->getAct = isset($_POST['deleteMedia']) && $_POST['deleteMedia'] ? 'delete' : (!empty($_GET['act']) ? trim($_GET['act']) : ''); $this->getPath = isset($_GET['path']) ? \Cx\Lib\FileSystem\FileSystem::sanitizePath($_GET['path']) : false; if ($this->getPath === false) { $this->getPath = $this->arrWebPaths[$this->archive]; } $this->getFile = isset($_REQUEST['file']) ? \Cx\Lib\FileSystem\FileSystem::sanitizeFile($_REQUEST['file']) : false; if ($this->getFile === false) { $this->getFile = ''; } $this->getData = !empty($_GET['data']) ? $_GET['data'] : ''; $this->sortBy = !empty($_GET['sort']) ? trim($_GET['sort']) : 'name'; $this->sortDesc = !empty($_GET['sort_desc']); $this->shopEnabled = $this->checkModule('Shop'); if ($this->archive == 'themes') { $_SESSION["skins"] = true; } else { $_SESSION["skins"] = false; } switch ($this->archive) { case 'themes': \Permission::checkAccess(21, 'static'); $objTemplate->setVariable("CONTENT_NAVIGATION", "<a href='index.php?cmd=Media&archive=content'>" . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . "</a>\n <a href='index.php?cmd=Media&archive=attach'>" . $_ARRAYLANG['TXT_MODULE'] . "</a>\n <a href='index.php?cmd=Media&archive=themes' class='active'>" . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . "</a>"); break; case 'content': \Permission::checkAccess(32, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content" class="active">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a>'); break; case 'Contact': \Permission::checkAccess(84, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Contact" title="' . $_ARRAYLANG['TXT_CONTACT_CONTACT_FORMS'] . '">' . $_ARRAYLANG['TXT_FORMS'] . '</a> <a hreF="index.php?cmd=Media&archive=Contact" title="' . $_ARRAYLANG['TXT_FILE_UPLOADS'] . '" class="active">' . $_ARRAYLANG['TXT_FILE_UPLOADS'] . '</a> <a href="index.php?cmd=Contact&act=settings" title="' . $_ARRAYLANG['TXT_CONTACT_SETTINGS'] . '">' . $_ARRAYLANG['TXT_CONTACT_SETTINGS'] . '</a> '); break; case 'FileSharing': \Permission::checkAccess(8, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=FileSharing"' . (!isset($_GET['act']) || $_GET['act'] == 'filesharing' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_FILESHARING_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=FileSharing&act=settings"' . (isset($_GET['act']) && $_GET['act'] == 'settings' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_SETTINGS'] . '</a> '); break; case 'attach': \Permission::checkAccess(84, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Access': \Permission::checkAccess(18, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Blog': \Permission::checkAccess(119, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Calendar': \Permission::checkAccess(16, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Downloads': \Permission::checkAccess(141, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Gallery': \Permission::checkAccess(12, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'MediaDir': \Permission::checkAccess(153, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Podcast': \Permission::checkAccess(87, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; case 'Shop': \Permission::checkAccess(13, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a> <a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a> <a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a> '); break; default: \Permission::checkAccess(7, 'static'); $objTemplate->setVariable('CONTENT_NAVIGATION', ' <a href="index.php?cmd=Media&archive=archive1" ' . ($this->archive == 'archive1' && !isset($_GET['act']) ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_ARCHIVE'] . ' #1</a> <a href="index.php?cmd=Media&archive=archive2" ' . ($this->archive == 'archive2' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_ARCHIVE'] . ' #2</a> <a href="index.php?cmd=Media&archive=archive3" ' . ($this->archive == 'archive3' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_ARCHIVE'] . ' #3</a> <a href="index.php?cmd=Media&archive=archive4" ' . ($this->archive == 'archive4' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_ARCHIVE'] . ' #4</a> <a href="index.php?cmd=Media&archive=archive1&act=settings" ' . ($this->archive == 'archive1' && $_GET['act'] == 'settings' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_SETTINGS'] . '</a> '); break; } $this->docRoot = \Env::get('cx')->getWebsiteDocumentRootPath(); // with path offset $this->docRoot = \Env::get('cx')->getWebsitePath(); // without path offset //paths $this->webPath = $this->_pathCheck($this->getPath); $this->path = $this->docRoot . $this->webPath; $this->_objImage = new \ImageManager(); }
/** * Writes the component.yml file with the data defined in component data array * * @param \Cx\Core\View\Model\Entity\Theme $theme the theme object */ public function saveComponentData(\Cx\Core\View\Model\Entity\Theme $theme) { global $_ARRAYLANG; if (!file_exists(\Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername())) { if (!\Cx\Lib\FileSystem\FileSystem::make_folder(\Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername())) { \Message::add($theme->getFoldername() . " : " . $_ARRAYLANG['TXT_THEME_UNABLE_TO_CREATE']); } } $filePath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername() . '/component.yml'; try { $file = new \Cx\Lib\FileSystem\File($filePath); $file->touch(); $yaml = new \Symfony\Component\Yaml\Yaml(); $file->write($yaml->dump(array('DlcInfo' => $theme->getComponentData()))); } catch (\Exception $e) { \DBG::log($e->getMessage()); throw new $e(); } }
/** * Handle the calendar image upload * * @param string $id unique form id * * @return string image path */ function _handleUpload($fieldName, $id) { $tup = self::getTemporaryUploadPath($fieldName, $id); $tmpUploadDir = \Env::get('cx')->getWebsitePath() . $tup[1] . '/' . $tup[2] . '/'; //all the files uploaded are in here $depositionTarget = $this->uploadImgPath; //target folder $pic = ''; //move all files if (!\Cx\Lib\FileSystem\FileSystem::exists($tmpUploadDir)) { throw new \Exception("could not find temporary upload directory '{$tmpUploadDir}'"); } $h = opendir($tmpUploadDir); if ($h) { while (false !== ($f = readdir($h))) { // skip folders and thumbnails if ($f == '..' || $f == '.' || preg_match("/(?:\\.(?:thumb_thumbnail|thumb_medium|thumb_large)\\.[^.]+\$)|(?:\\.thumb)\$/i", $f)) { continue; } //do not overwrite existing files. $prefix = ''; while (file_exists($depositionTarget . $prefix . $f)) { if (empty($prefix)) { $prefix = 0; } $prefix++; } // move file try { $objFile = new \Cx\Lib\FileSystem\File($tmpUploadDir . $f); $fileInfo = pathinfo($tmpUploadDir . $f); $objFile->move($depositionTarget . $prefix . $f, false); $imageName = $prefix . $f; if (in_array($fileInfo['extension'], array('gif', 'jpg', 'jpeg', 'png'))) { $objImage = new \ImageManager(); $objImage->_createThumb($this->uploadImgPath, $this->uploadImgWebPath, $imageName, 180); } $pic = contrexx_input2raw($this->uploadImgWebPath . $imageName); // abort after one file has been fetched, as all event upload // fields do allow a single file only anyway break; } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); } } } return $pic; }
/** * Upload handler. * * @param $params * * @return array * @throws UploaderException */ public function upload($params) { global $_ARRAYLANG; $id = null; if (isset($params['get']['id']) && preg_match('/^[a-z0-9]+$/i', $params['get']['id'])) { $id = $params['get']['id']; $uploadedFileCount = isset($params['get']['uploadedFileCount']) ? intval($params['get']['uploadedFileCount']) : 0; $path = $_SESSION->getTempPath() . '/' . $id . '/'; $tmpPath = $path; } elseif (isset($params['post']['path'])) { $path_part = explode("/", $params['post']['path'], 2); $mediaSourceManager = $this->cx->getMediaSourceManager(); $path = $mediaSourceManager->getMediaTypePathsbyNameAndOffset($path_part[0], 0) . '/' . $path_part[1]; $tmpPath = $_SESSION->getTempPath(); } else { return array('OK' => 0, 'error' => array('message' => 'No id specified')); } $allowedExtensions = false; if (isset($_SESSION['uploader']['handlers'][$id]['config']['allowed-extensions'])) { $allowedExtensions = $_SESSION['uploader']['handlers'][$id]['config']['allowed-extensions']->toArray(); } $uploader = UploaderController::handleRequest(array('allow_extensions' => is_array($allowedExtensions) ? explode(', ', $allowedExtensions) : $allowedExtensions, 'target_dir' => $path, 'tmp_dir' => $tmpPath)); $fileLocation = array($uploader['path'], str_replace($this->cx->getWebsitePath(), '', $uploader['path'])); $response = new UploadResponse(); if (isset($_SESSION['uploader']['handlers'][$id]['callback']) && $uploader !== true) { /** * @var $callback RecursiveArrayAccess * @var $data RecursiveArrayAccess */ $callback = $_SESSION['uploader']['handlers'][$id]['callback']; $data = $_SESSION['uploader']['handlers'][$id]['data']; if (isset($_SESSION['uploader']['handlers'][$id]['config']['upload-limit']) && $_SESSION['uploader']['handlers'][$id]['config']['upload-limit'] <= $uploadedFileCount) { return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_CORE_MODULE_UPLOADER_MAX_LIMIT_REACHED']); } if (!is_string($callback)) { $callback = $callback->toArray(); } if ($data) { $data = $data->toArray(); } $filePath = dirname($uploader['path']); if (!is_array($callback)) { $class = new \ReflectionClass($callback); if ($class->implementsInterface('\\Cx\\Core_Modules\\Uploader\\Model\\UploadCallbackInterface')) { /** * @var \Cx\Core_Modules\Uploader\Model\UploadCallbackInterface $callbackInstance */ $callbackInstance = $class->newInstance($this->cx); $fileLocation = $callbackInstance->uploadFinished($filePath, str_replace($this->cx->getWebsiteTempPath(), $this->cx->getWebsiteTempWebPath(), $filePath), $data, $id, $uploader, $response); } } else { $fileLocation = call_user_func(array($callback[1], $callback[2]), $filePath, str_replace($this->cx->getWebsiteTempPath(), $this->cx->getWebsiteTempWebPath(), $filePath), $data, $id, $uploader, $response); } $files = new \RegexIterator(new \DirectoryIterator($filePath . '/'), '/.*/'); $file = false; foreach ($files as $fileInfo) { if ($fileInfo->isFile()) { $file = $fileInfo->getRealPath(); break; } } if ($file) { \Cx\Lib\FileSystem\FileSystem::move($file, rtrim($fileLocation[0], '/') . '/' . pathinfo($file, PATHINFO_BASENAME), true); if (isset($fileLocation[2])) { $uploader['name'] = $fileLocation[2]; } $fileLocation = array(rtrim($fileLocation[0], '/') . '/' . pathinfo($file, PATHINFO_BASENAME), rtrim($fileLocation[1], '/') . '/' . pathinfo($file, PATHINFO_BASENAME)); } } if ($response->getWorstStatus()) { $result = $response->getResponse(); return array('OK' => 0, 'file' => $fileLocation[1], 'response' => $result['messages']); } if (isset($uploader['error'])) { throw new UploaderException(UploaderController::getErrorCode()); } else { return array('OK' => 1, 'file' => $fileLocation[1]); } }