/** * @override */ public function getXHtml($backend = false) { global $objInit; $uploadPath = $this->getUploadPath('jump'); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('jump.html'); $basePath = 'index.php?'; $basePath .= $this->isBackendRequest ? 'cmd=Upload&act' : 'section=Upload&cmd'; //act and cmd vary $appletPath = $basePath . '=jumpUploaderApplet'; $l10nPath = $basePath . '=jumpUploaderL10n'; $langId; if (!$this->isBackendRequest) { $langId = $objInit->getFrontendLangId(); } else { //backend $langId = $objInit->getBackendLangId(); } $langCode = \FWLanguage::getLanguageCodeById($langId); if (!file_exists(ASCMS_CORE_MODULE_PATH . '/Upload/ressources/uploaders/jump/messages_' . $langCode . '.zip')) { $langCode = 'en'; } $l10nPath .= '&lang=' . $langCode; $tpl->setVariable('UPLOAD_CHUNK_LENGTH', \FWSystem::getMaxUploadFileSize() - 1000); $tpl->setVariable('UPLOAD_APPLET_URL', $appletPath); $tpl->setVariable('UPLOAD_LANG_URL', $l10nPath); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('UPLOAD_ID', $this->uploadId); return $tpl->get(); }
public function getFileList($directory, $recursive = false, $readonly = false) { $recursiveIteratorIterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(rtrim($this->rootPath . '/' . $directory, '/')), \RecursiveIteratorIterator::SELF_FIRST), '/^((?!thumb(_[a-z]+)?).)*$/'); $jsonFileArray = array(); $thumbnailList = $this->cx->getMediaSourceManager()->getThumbnailGenerator()->getThumbnails(); foreach ($recursiveIteratorIterator as $file) { /** * @var $file \SplFileInfo */ $extension = 'Dir'; if (!$file->isDir()) { $extension = ucfirst(pathinfo($file->getFilename(), PATHINFO_EXTENSION)); } // filters if ($file->getFilename() == '.' || $file->getFilename() == 'index.php' || 0 === strpos($file->getFilename(), '.')) { continue; } // set preview if image $preview = 'none'; $hasPreview = false; $thumbnails = array(); if ($this->isImage($extension)) { $hasPreview = true; $thumbnails = $this->getThumbnails($thumbnailList, $extension, $file, $thumbnails); $preview = current($thumbnails); if (!file_exists($this->cx->getWebsitePath() . $preview)) { $hasPreview = false; } } $size = \FWSystem::getLiteralSizeFormat($file->getSize()); $fileInfos = array('filepath' => mb_strcut($file->getPath() . '/' . $file->getFilename(), mb_strlen($this->cx->getWebsitePath())), 'name' => $file->getFilename(), 'size' => $size ? $size : '0 B', 'cleansize' => $file->getSize(), 'extension' => ucfirst(mb_strtolower($extension)), 'preview' => $preview, 'hasPreview' => $hasPreview, 'active' => false, 'type' => $file->getType(), 'thumbnail' => $thumbnails); if ($readonly) { $fileInfos['readonly'] = true; } // filters if ($fileInfos['name'] == '.' || preg_match('/\\.thumb/', $fileInfos['name']) || $fileInfos['name'] == 'index.php' || 0 === strpos($fileInfos['name'], '.')) { continue; } $path = array($file->getFilename() => array('datainfo' => $fileInfos)); for ($depth = $recursiveIteratorIterator->getDepth() - 1; $depth >= 0; $depth--) { $path = array($recursiveIteratorIterator->getSubIterator($depth)->current()->getFilename() => $path); } $jsonFileArray = $this->array_merge_recursive($jsonFileArray, $path); } $jsonFileArray = $this->utf8EncodeArray($jsonFileArray); return $jsonFileArray; }
/** * @override */ public function getXHtml() { global $_CORELANG; // CSS dependencies \JS::activate('cx'); $uploadPath = $this->getUploadPath('pl'); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('pl.html'); $tpl->setVariable('UPLOAD_FLASH_URL', ASCMS_CORE_MODULE_WEB_PATH . '/Upload/ressources/uploaders/pl/plupload.flash.swf'); $tpl->setVariable('UPLOAD_CHUNK_LENGTH', \FWSystem::getLiteralSizeFormat(\FWSystem::getMaxUploadFileSize() - 1000)); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('UPLOAD_ID', $this->uploadId); //I18N $tpl->setVariable(array('UPLOAD' => $_CORELANG['UPLOAD'], 'OTHER_UPLOADERS' => $_CORELANG['OTHER_UPLOADERS'], 'FORM_UPLOADER' => $_CORELANG['FORM_UPLOADER'], 'PL_UPLOADER' => $_CORELANG['PL_UPLOADER'], 'JUMP_UPLOADER' => $_CORELANG['JUMP_UPLOADER'], 'SELECT_FILES' => $_CORELANG['SELECT_FILES'], 'ADD_INSTRUCTIONS' => $_CORELANG['ADD_INSTRUCTIONS'], 'FILENAME' => $_CORELANG['FILENAME'], 'STATUS' => $_CORELANG['STATUS'], 'SIZE' => $_CORELANG['SIZE'], 'ADD_FILES' => $_CORELANG['ADD_FILES'], 'STOP_CURRENT_UPLOAD' => $_CORELANG['STOP_CURRENT_UPLOAD'], 'DRAG_FILES_HERE' => $_CORELANG['DRAG_FILES_HERE'])); return $tpl->get(); }
public function preFinalize(\Cx\Core\Html\Sigma $template) { if (count($this->uploaderInstances) == 0) { return; } global $_ARRAYLANG; \Env::get('init')->loadLanguageData('Uploader'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/UPLOADER(_[A-Za-z0-9]+)?/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $appendix = ""; foreach ($this->uploaderInstances as $uploader) { if ($uploader->getType() == Uploader::UPLOADER_TYPE_MODAL) { $appendix .= $uploader->getContainer(); } } $template->_blocks["__global__"] = preg_replace("/<\\/body>/", $appendix . '</body>', $template->_blocks["__global__"]); \ContrexxJavascript::getInstance()->setVariable('chunk_size', min(floor((\FWSystem::getMaxUploadFileSize() - 1000000) / 1000000), 20) . 'mb', 'uploader'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/Uploader/View/Script/Uploader.js'); }
/** * Checking memory limit * * @staticvar integer $memoryLimit * @staticvar integer $MiB2 * * @param integer $crawlerId * * @return boolean */ function checkMemoryLimit($crawlerId) { static $memoryLimit, $MiB2; if (!isset($memoryLimit)) { $memoryLimit = \FWSystem::getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); if (empty($memoryLimit)) { // set default php memory limit of 8MiBytes $memoryLimit = 8 * pow(1024, 2); } $MiB2 = 2 * pow(1024, 2); } $potentialRequiredMemory = memory_get_usage() + $MiB2; if ($potentialRequiredMemory > $memoryLimit) { // try to set a higher memory_limit if (!@ini_set('memory_limit', $potentialRequiredMemory)) { $this->updateCrawlerStatus($crawlerId, self::RUN_STATUS_INCOMPLETE); die('The link spider script is interrupted due to insufficient memory is available.'); } } return true; }
public function getFrameXHtml() { global $_CORELANG; if (!empty($_SESSION['upload']['handlers'][$this->uploadId]['singleFileMode'])) { \ContrexxJavascript::getInstance()->setVariable('restrictUpload2SingleFile', true, "upload/widget_{$this->uploadId}"); } //JS / CSS dependencies \JS::activate('cx'); \JS::registerCSS('core_modules/Upload/css/uploaders/form/formUploader.css'); \JS::registerJS('core_modules/Upload/js/uploaders/form/formUploader.js'); $uploadPath = $this->getUploadPath('form'); $redirectUrl = ''; if ($this->isBackendRequest) { $redirectUrl = ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=Upload&act=formUploaderFrameFinished&uploadId=' . $this->uploadId; } else { $url = clone \Env::get('cx')->getRequest()->getUrl(); $url->removeAllParams(); $url->setParams(array('section' => 'Upload', 'cmd' => 'formUploaderFrameFinished', 'uploadId' => $this->uploadId)); $redirectUrl = (string) $url; } $this->setRedirectUrl($redirectUrl); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('formFrame.html'); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('INCLUDES', \JS::getCode()); $tpl->setVariable('CXJS_INIT_JS', \ContrexxJavascript::getInstance()->initJs()); $tpl->setVariable('UPLOAD_FORM_ADD', $_CORELANG['UPLOAD_FORM_ADD']); $tpl->setVariable('UPLOAD', $_CORELANG['UPLOAD']); $tpl->setVariable('UPLOAD_ID', $this->uploadId); $tpl->setVariable('MAX_FILE_SIZE', \FWSystem::getMaxUploadFileSize() - 1000); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $ls = new \LinkSanitizer($cx, $cx->getCodeBaseOffsetPath(), $tpl->get()); return $ls->replace(); }
/** * @param Sigma $template */ public function preFinalize(Sigma $template) { if (count($this->mediaBrowserInstances) == 0) { return; } global $_ARRAYLANG; /** * @var $init \InitCMS */ $init = \Env::get('init'); $init->loadLanguageData('MediaBrowser'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $thumbnailsTemplate = new Sigma(); $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html'); $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE'])); foreach ($this->cx->getMediaSourceManager()->getThumbnailGenerator()->getThumbnails() as $thumbnail) { $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size'])); $thumbnailsTemplate->parse('thumbnails'); } \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('chunk_size', min(floor((\FWSystem::getMaxUploadFileSize() - 1000000) / 1000000), 20) . 'mb', 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('languages', \FWLanguage::getActiveFrontendLanguages(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('language', \FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId()), 'mediabrowser'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/MediaBrowser/View/Script/MediaBrowser.js'); }
/** * Upload submitted files * * Move all files that are allowed to be uploaded in the folder that * has been specified in the configuration option "File upload deposition path" * @access private * @global array * @param array Files that have been submited * @see getSettings(), _cleanFileName(), errorMsg, FWSystem::getMaxUploadFileSize() * @return array A list of files that have been stored successfully in the system */ function _uploadFilesLegacy($arrFields) { global $_ARRAYLANG; $arrSettings = $this->getSettings(); $arrFiles = array(); if (isset($_FILES) && is_array($_FILES)) { foreach (array_keys($_FILES) as $file) { $fileName = !empty($_FILES[$file]['name']) ? $this->_cleanFileName($_FILES[$file]['name']) : ''; $fileTmpName = !empty($_FILES[$file]['tmp_name']) ? $_FILES[$file]['tmp_name'] : ''; switch ($_FILES[$file]['error']) { case UPLOAD_ERR_INI_SIZE: //Die hochgeladene Datei überschreitet die in der Anweisung upload_max_filesize in php.ini festgelegte Grösse. $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_SIZE_EXCEEDS_LIMIT'], $fileName, \FWSystem::getMaxUploadFileSize()) . '<br />'; break; case UPLOAD_ERR_FORM_SIZE: //Die hochgeladene Datei überschreitet die in dem HTML Formular mittels der Anweisung MAX_FILE_SIZE angegebene maximale Dateigrösse. $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_TOO_LARGE'], $fileName) . '<br />'; break; case UPLOAD_ERR_PARTIAL: //Die Datei wurde nur teilweise hochgeladen. $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_CORRUPT'], $fileName) . '<br />'; break; case UPLOAD_ERR_NO_FILE: //Es wurde keine Datei hochgeladen. continue; break; default: if (!empty($fileTmpName)) { $arrFile = pathinfo($fileName); $i = ''; $suffix = ''; $documentRootPath = \Env::get('cx')->getWebsiteDocumentRootPath(); $filePath = $arrSettings['fileUploadDepositionPath'] . '/' . $arrFile['filename'] . $suffix . '.' . $arrFile['extension']; while (file_exists($documentRootPath . $filePath)) { $suffix = '-' . ++$i; $filePath = $arrSettings['fileUploadDepositionPath'] . '/' . $arrFile['filename'] . $suffix . '.' . $arrFile['extension']; } $arrMatch = array(); if (\FWValidator::is_file_ending_harmless($fileName)) { if (@move_uploaded_file($fileTmpName, $documentRootPath . $filePath)) { $id = intval(substr($file, 17)); $arrFiles[$id] = array('path' => $filePath, 'name' => $fileName); } else { $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_UPLOAD_FAILED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)) . '<br />'; } } else { $this->errorMsg .= sprintf($_ARRAYLANG['TXT_CONTACT_FILE_EXTENSION_NOT_ALLOWED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)) . '<br />'; } } break; } } } return $arrFiles; }
/** * Creates an image from an image file * @access private * @param string $file The path of the image * @return resource The image on success, the empty string otherwise */ function _imageCreateFromFile($file) { $arrSizeInfo = getimagesize($file); if (!is_array($arrSizeInfo)) { return false; } $type = $this->_isImage($file); $potentialRequiredMemory = $arrSizeInfo[0] * $arrSizeInfo[1] * 1.8; switch ($type) { case self::IMG_TYPE_GIF: $function = 'imagecreatefromgif'; break; case self::IMG_TYPE_JPEG: $function = 'imagecreatefromjpeg'; $potentialRequiredMemory *= $arrSizeInfo['bits'] / 8 * ($arrSizeInfo['channels'] < 3 ? 3 : $arrSizeInfo['channels']); break; case self::IMG_TYPE_PNG: $function = 'imagecreatefrompng'; $potentialRequiredMemory *= 4; break; default: return ''; } require_once ASCMS_FRAMEWORK_PATH . '/System.class.php'; $objSystem = new FWSystem(); if ($objSystem === false) { return false; } $memoryLimit = $objSystem->getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); if (empty($memoryLimit)) { // set default php memory limit of 8 MBytes $memoryLimit = 8 * pow(1024, 2); } if (function_exists('memory_get_usage')) { $potentialRequiredMemory += memory_get_usage(); } else { // add a default of 3 MBytes $potentialRequiredMemory += 3 * pow(1024, 2); } if ($potentialRequiredMemory > $memoryLimit) { // try to set a higher memory_limit if (!ini_set('memory_limit', $potentialRequiredMemory) || $memoryLimit == $objSystem->getBytesOfLiteralSizeFormat(ini_get('memory_limit'))) { return ''; } } return $function($file); }
/** * Get files by search term * * @param string $path Path to search files * @param string $searchTerm Search term * @param array $result Result files and directory array * @param boolean $recursive True to search recursive * * @return array Files array by given search term */ public function getDirectoryTree($path = '', $searchTerm = '', &$result = array(), $recursive = false) { if (empty($path)) { return array(); } if (!is_dir($path)) { return array(); } if (empty($result)) { $result = array('dir' => array(), 'file' => array()); } $mediaArray = glob($path . '*'); foreach ($mediaArray as $media) { $mediaName = basename($media); if (!\FWSystem::detectUtf8($mediaName)) { $mediaName = utf8_encode($mediaName); } if (!empty($searchTerm) && !preg_match('/' . preg_quote($searchTerm) . '/i', $mediaName)) { continue; } $mediaType = is_dir($media) ? 'dir' : 'file'; $mediaPath = dirname($media); if ($mediaType == 'file' && !$this->isFileValidToShow($mediaPath, $mediaName)) { continue; } $result[$mediaType]['icon'][] = self::getFileTypeIconWebPath($media); $result[$mediaType]['name'][] = $mediaName; $result[$mediaType]['size'][] = $this->_getSize($media); $result[$mediaType]['type'][] = $this->_getType($media); $result[$mediaType]['date'][] = $this->_getDate($media); $result[$mediaType]['perm'][] = $this->_getPerm($media); $result[$mediaType]['path'][] = $mediaPath; } if ($recursive) { foreach (glob($path . '*', GLOB_ONLYDIR | GLOB_MARK) as $dir) { $this->getDirectoryTree($dir, $searchTerm, $result, $recursive); } } return $result; }
function _dirTree($path) { $dir = array(); $file = array(); $forbidden_files = array('.', '..', '.svn', '.htaccess', 'index.php'); if (is_dir($path)) { $fd = @opendir($path); $name = @readdir($fd); while ($name !== false) { if (!in_array($name, $forbidden_files)) { if (is_dir($path . $name)) { $dirName = $name; if (!\FWSystem::detectUtf8($dirName)) { $dirName = utf8_encode($dirName); } $dir['icon'][] = self::getFileTypeIconWebPath($path . $name); $dir['name'][] = $dirName; $dir['size'][] = $this->_getSize($path . $name); $dir['type'][] = $this->_getType($path . $name); $dir['date'][] = $this->_getDate($path . $name); $dir['perm'][] = $this->_getPerm($path . $name); } elseif (is_file($path . $name)) { // TODO // This won't work for .jpg thumbnails made from .png images and other // ways to create thumbnail file names. See the Image class. if (preg_match("/(?:\\.(?:thumb_thumbnail|thumb_medium|thumb_large)\\.[^.]+\$)|(?:\\.thumb)\$/i", $name)) { $originalFileName = preg_replace("/(?:\\.(?:thumb_thumbnail|thumb_medium|thumb_large)(\\.[^.]+)\$)|(?:\\.thumb)\$/mi", "\$1", $name); if (!file_exists($path . $originalFileName)) { @unlink($path . $name); } } else { $fileName = $name; if (!\FWSystem::detectUtf8($fileName)) { $fileName = utf8_encode($fileName); } $file['icon'][] = self::getFileTypeIconWebPath($path . $name); $file['name'][] = $fileName; $file['size'][] = $this->_getSize($path . $name); $file['type'][] = $this->_getType($path . $name); $file['date'][] = $this->_getDate($path . $name); $file['perm'][] = $this->_getPerm($path . $name); } } } $name = @readdir($fd); } @closedir($fd); clearstatcache(); } $dirTree['dir'] = $dir; $dirTree['file'] = $file; return $dirTree; }
/** * This method has two purposes (see param $return): * 1. Parse the \Cx\Core\Html\Sigma template block of a specific profile attribute * 2. Generate the HTML code of a specific profile attribute and return it * * @param User User object of whoem's profile attribute shall be parsed * @param integer ID of the profile attribute to be parsed * @param integer History version of the profile attribute to be parsed * @param boolean If the profile attribute's value shall be modifyable (set to TRUE) * or not (set to FALSE) * @param boolean If the profile attribute's \Cx\Core\Html\Sigma template block * shall be parsed (set to FALSE) or the HTML code of the profile * attribute shall be generated and returned instead (set to TRUE). * @param boolean In case the profile attribute to be parsed is an other profile * attribute's child, set this to TRUE, otherwise to FALSE * @param boolean In case the profile attribute to be parsed is located within an * other profile attribute of the type frame, set this to TRUE, * otherwise to FALSE * @param boolean The method can use the magic block \Cx\Core\Html\Sigma template * block access_profile_attribute_list (set to TRUE), instead of using * the profile attribute specific block like for instance * access_profile_attribute_firstname (set to FALSE) * @param array Pass additional, preparsed placeholders. The array must be an associated * array, where the key represents the \Cx\Core\Html\Sigma variable suffix * and the value the placeholder's value. * For instance: array('_CSS' => 'someSpecialCSSClass'); */ public function parseAttribute($objUser, $attributeId, $historyId = 0, $edit = false, $return = false, $isChild = false, $inFrame = false, $useMagicBlock = true, $arrAdditionalPlaceholders = null) { global $_CORELANG; $objAttribute = $objUser->objAttribute->getById($attributeId); $attributeName = $this->attributeNamePrefix . '[' . $attributeId . '][' . $historyId . ']'; $block = strtolower($this->attributeNamePrefix . '_' . $attributeId); $attributeIdUC = strtoupper($attributeId); $parentIdUC = strtoupper($objAttribute->getParent()); if ($edit && $objAttribute->isProtected() && !\Permission::checkAccess($objAttribute->getAccessId(), 'dynamic', true) && !$objAttribute->checkModifyPermission()) { $edit = false; } if ($return) { return $this->_getAtrributeCode($objUser, $attributeId, $historyId, $edit); } $arrPlaceholders = array('' => $this->_getAtrributeCode($objUser, $attributeId, $historyId, $edit), '_DESC' => htmlentities($objAttribute->getName(), ENT_QUOTES, CONTREXX_CHARSET), '_NAME' => $attributeName, '_ID' => $attributeId, '_HISTORY_ID' => $historyId); if (is_array($arrAdditionalPlaceholders)) { $arrPlaceholders = array_merge($arrPlaceholders, $arrAdditionalPlaceholders); } switch ($objAttribute->getType()) { case 'date': $value = $objUser->getProfileAttribute($attributeId, $historyId); $arrPlaceholders['_VALUE'] = $value !== false && $value !== '' ? htmlentities(date(ASCMS_DATE_FORMAT_DATE, intval($value)), ENT_QUOTES, CONTREXX_CHARSET) : ''; $arrPlaceholders['_MONTH'] = $this->getDateMonthMenu($attributeName, date('m', intval($objUser->getProfileAttribute($attributeId, $historyId)))); $arrPlaceholders['_DAY'] = $this->getDateDayMenu($attributeName, date('d', intval($objUser->getProfileAttribute($attributeId, $historyId)))); $arrPlaceholders['_YEAR'] = $this->getDateYearMenu($attributeName, date('Y', intval($objUser->getProfileAttribute($attributeId, $historyId)))); break; case 'text': case 'mail': $arrPlaceholders['_VALUE'] = $edit ? htmlentities($objUser->getProfileAttribute($attributeId, $historyId), ENT_QUOTES, CONTREXX_CHARSET) : html_entity_decode(nl2br($objUser->getProfileAttribute($attributeId, $historyId)), ENT_QUOTES, CONTREXX_CHARSET); break; case 'uri': $uri = $objUser->getProfileAttribute($attributeId, $historyId); if (empty($uri)) { $arrPlaceholders['_VALUE'] = ''; /*if ($this->_objTpl->blockExists($block.'_no_link')) { $this->_objTpl->setVariable('TXT_ACCESS_NO_SPECIFIED', $_CORELANG['TXT_ACCESS_NO_SPECIFIED']); $this->_objTpl->touchBlock($block.'_no_link'); }*/ if ($this->_objTpl->blockExists($block . '_link')) { $this->_objTpl->hideBlock($block . '_link'); } } else { $arrPlaceholders['_VALUE'] = htmlentities($objUser->getProfileAttribute($attributeId, $historyId), ENT_QUOTES, CONTREXX_CHARSET); if ($this->_objTpl->blockExists($block . '_link')) { $this->_objTpl->setVariable(array('TXT_ACCESS_URL_OPEN_RISK_MSG' => $_CORELANG['TXT_ACCESS_URL_OPEN_RISK_MSG'], 'TXT_ACCESS_CONFIRM_OPEN_URL' => $_CORELANG['TXT_ACCESS_CONFIRM_OPEN_URL'], 'TXT_ACCESS_VISIT_WEBSITE' => $_CORELANG['TXT_ACCESS_VISIT_WEBSITE'])); $this->_objTpl->touchBlock($block . '_link'); } if ($this->_objTpl->blockExists($block . '_no_link')) { $this->_objTpl->hideBlock($block . '_no_link'); } } break; case 'image': $arrSettings = \User_Setting::getSettings(); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $image = $objUser->getProfileAttribute($objAttribute->getId(), $historyId); $imageRepoWeb = $attributeId == 'picture' ? $cx->getWebsiteImagesAccessProfileWebPath() : $cx->getWebsiteImagesAccessPhotoWebPath(); $imageRepoPath = $attributeId == 'picture' ? $cx->getWebsiteImagesAccessProfilePath() : $cx->getWebsiteImagesAccessPhotoPath(); if (!$edit || file_exists($imageRepoPath . '/' . $image)) { $arrPlaceholders['_VALUE'] = htmlentities($objUser->getProfileAttribute($objAttribute->getId(), $historyId), ENT_QUOTES, CONTREXX_CHARSET); } $arrPlaceholders['_SRC'] = $imageRepoWeb . '/' . (!empty($arrPlaceholders['_VALUE']) ? $arrPlaceholders['_VALUE'] : ($attributeId == 'picture' ? \User_Profile::$arrNoAvatar['src'] : \User_Profile::$arrNoPicture['src'])); if (empty($arrPlaceholders['_VALUE'])) { $arrPlaceholders['_VALUE'] = $_CORELANG['TXT_ACCESS_NO_PICTURE']; } $arrPlaceholders['_THUMBNAIL'] = $this->getImageAttributeCode($objUser, $attributeName, $image, $attributeId, '', $historyId, $edit, true); $arrPlaceholders['_THUMBNAIL_SRC'] = \ImageManager::getThumbnailFilename($arrPlaceholders['_SRC']); $arrPlaceholders['_UPLOAD_NAME'] = $this->attributeNamePrefix . '_images[' . $objAttribute->getId() . '][' . $historyId . ']'; $arrPlaceholders['_MAX_FILE_SIZE'] = \FWSystem::getLiteralSizeFormat($arrSettings['max_' . ($attributeId == 'picture' ? 'profile_' : '') . 'pic_size']['value']); $arrPlaceholders['_MAX_WIDTH'] = $arrSettings['max_' . ($attributeId == 'picture' ? 'profile_' : '') . 'pic_width']['value']; $arrPlaceholders['_MAX_HEIGHT'] = $arrSettings['max_' . ($attributeId == 'picture' ? 'profile_' : '') . 'pic_height']['value']; $arrPlaceholders['_CHOOSE_FILE'] = $_CORELANG['TXT_ACCESS_USER_CHOOSE_FILE']; // if ($attributeId == 'picture') { // $arrPlaceholders['_DESC'] = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET); // } break; case 'checkbox': $arrPlaceholders['_CHECKED'] = $objUser->getProfileAttribute($attributeId, $historyId) ? 'checked="checked"' : ''; $arrPlaceholders['_VALUE'] = $objUser->getProfileAttribute($attributeId, $historyId); break; case 'menu': $arrPlaceholders['_VALUE'] = htmlentities($objUser->getProfileAttribute($objAttribute->getId(), $historyId), ENT_QUOTES, CONTREXX_CHARSET); if ($arrPlaceholders['_VALUE'] == '0' || $arrPlaceholders['_VALUE'] == 'gender_undefined') { $arrPlaceholders['_VALUE'] = ''; } if ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $attributeId . '_children')) { foreach ($objAttribute->getChildren() as $childAttributeId) { $this->parseAttribute($objUser, $childAttributeId, $historyId, $edit, false, true, false, $useMagicBlock); } } break; case 'frame': foreach ($objAttribute->getChildren() as $childAttributeId) { $this->parseAttribute($objUser, $childAttributeId, $historyId, $edit, false, true, true, $useMagicBlock); } $arrPlaceholders['_VALUE'] = $objAttribute->getMenuOptionValue(); break; case 'menu_option': $arrPlaceholders['_VALUE'] = $objAttribute->getMenuOptionValue(); $arrPlaceholders['_SELECTED'] = $objAttribute->getMenuOptionValue() == $objUser->getProfileAttribute($objAttribute->getParent(), $historyId) ? 'selected="selected"' : ''; if ($objAttribute->isCoreAttribute() && $objAttribute->isUnknownOption()) { $objParentAttribute = $objAttribute->getById($objAttribute->getParent()); if ($objParentAttribute->isMandatory()) { $arrPlaceholders['_DESC'] = $_CORELANG['TXT_ACCESS_PLEASE_SELECT']; } } break; case 'group': if ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $attributeId . '_children')) { foreach ($objAttribute->getChildren() as $childAttributeId) { $this->parseAttribute($objUser, $childAttributeId, $historyId, $edit, false, true, true, $useMagicBlock); } } break; case 'history': if (!isset($objUser->arrAttributeHistories[$objUser->getId()][$attributeId])) { $objUser->arrAttributeHistories[$objUser->getId()][$attributeId] = array(); } sort($objUser->arrAttributeHistories[$objUser->getId()][$attributeId]); if ($edit && !in_array(0, $objUser->arrAttributeHistories[$objUser->getId()][$attributeId])) { $objUser->arrAttributeHistories[$objUser->getId()][$attributeId][] = 0; } foreach ($objUser->arrAttributeHistories[$objUser->getId()][$attributeId] as $attributeHistoryId) { if ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $attributeId . '_history_list') || $this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $attributeId . '_history_' . $attributeHistoryId)) { foreach ($objAttribute->getChildren() as $childAttributeId) { $this->parseAttribute($objUser, $childAttributeId, $attributeHistoryId, $edit, false, false, false, $useMagicBlock); } $this->_objTpl->setVariable($this->modulePrefix . 'PROFILE_ATTRIBUTE_' . $attributeIdUC . '_HISTORY_ID', $attributeHistoryId); if ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $attributeId . '_history_' . $attributeHistoryId)) { $this->_objTpl->parse($this->attributeNamePrefix . '_' . $attributeId . '_history_' . $attributeHistoryId); } else { $this->_objTpl->parse($this->attributeNamePrefix . '_' . $attributeId . '_history_list'); } } } break; } if (!$edit && isset($arrPlaceholders['_VALUE']) && $arrPlaceholders['_VALUE'] == '') { return false; } if ($inFrame) { $objFrameAttribute = $objAttribute->getById($objAttribute->getParent()); } $parsed = false; $frameParsed = false; $arrPostfix = array('_history_' . $historyId, ''); foreach ($arrPostfix as $historyPostfix) { if (!$parsed) { $parsed = true; if ($inFrame && $this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $objFrameAttribute->getParent() . '_frame_' . $objAttribute->getParent() . '_child_' . $attributeId . $historyPostfix)) { // specified child of a specified frame $this->parseAttributePlaceholders($arrPlaceholders, true, strtoupper($objFrameAttribute->getParent()), $parentIdUC, $attributeIdUC, true, true); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $objFrameAttribute->getParent() . '_frame_' . $objAttribute->getParent() . '_child_' . $attributeId . $historyPostfix); } elseif ($inFrame && $this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $objFrameAttribute->getParent() . '_frame_' . $objAttribute->getParent() . '_children' . $historyPostfix)) { // children of a specified frame $this->parseAttributePlaceholders($arrPlaceholders, true, $objFrameAttribute->getParent(), $parentIdUC, 0, true, true); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $objFrameAttribute->getParent() . '_frame_' . $objAttribute->getParent() . '_children' . $historyPostfix); } elseif ($inFrame && $this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $objFrameAttribute->getParent() . '_frame_children' . $historyPostfix)) { // children of a frame $this->parseAttributePlaceholders($arrPlaceholders, true, $objFrameAttribute->getParent(), 0, 0, true, true); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $objFrameAttribute->getParent() . '_frame_children' . $historyPostfix); } elseif ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $attributeId . $historyPostfix)) { // attribute $this->parseAttributePlaceholders($arrPlaceholders, true, $isChild ? $parentIdUC : $attributeIdUC, 0, 0, false, $isChild); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $attributeId . $historyPostfix); } elseif ($objAttribute->getParent() && $this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $objAttribute->getParent() . '_children' . $historyPostfix)) { // children of an attrbiute $this->parseAttributePlaceholders($arrPlaceholders, true, $parentIdUC, 0, 0, false, true); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $objAttribute->getParent() . '_children' . $historyPostfix); } elseif ($useMagicBlock && !$isChild && $this->_objTpl->blockExists($this->attributeNamePrefix . '_list' . $historyPostfix)) { // magic block attribute_list $this->parseAttributePlaceholders($arrPlaceholders, false, $isChild ? $parentIdUC : $attributeIdUC, 0, 0); $this->_objTpl->parse($this->attributeNamePrefix . '_list' . $historyPostfix); } elseif (!$useMagicBlock) { $this->parseAttributePlaceholders($arrPlaceholders, true, $attributeIdUC, 0, 0); $parsed = empty($historyPostfix); } else { $parsed = false; } } if (!$frameParsed) { $frameParsed = true; if ($objAttribute->getType() == 'frame') { if ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $objAttribute->getParent() . '_frame_' . $attributeId . $historyPostfix)) { // current attribute is a frame which has been especially defined $this->parseAttributePlaceholders($arrPlaceholders, true, $parentIdUC, $attributeIdUC, 0, true, false); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $objAttribute->getParent() . '_frame_' . $attributeId . $historyPostfix); } elseif ($this->_objTpl->blockExists($this->attributeNamePrefix . '_' . $objAttribute->getParent() . '_frames' . $historyPostfix)) { // current attributeis a frame $this->parseAttributePlaceholders($arrPlaceholders, true, $parentIdUC, 0, 0, true, false); $this->_objTpl->parse($this->attributeNamePrefix . '_' . $objAttribute->getParent() . '_frames' . $historyPostfix); } else { $frameParsed = false; } } else { $frameParsed = false; } } } return true; }
private function parseUploadForm($objCategory) { global $_CONFIG, $_ARRAYLANG; if (!$this->objTemplate->blockExists('downloads_simple_file_upload') && !$this->objTemplate->blockExists('downloads_advanced_file_upload')) { return; } // check for upload permissiosn if ($objCategory->getAddFilesAccessId() && !\Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) { if ($this->objTemplate->blockExists('downloads_simple_file_upload')) { $this->objTemplate->hideBlock('downloads_simple_file_upload'); } if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) { $this->objTemplate->hideBlock('downloads_advanced_file_upload'); } return; } if ($this->objTemplate->blockExists('downloads_simple_file_upload')) { $objFWSystem = new \FWSystem(); //Uploader button handling \JS::activate('cx'); \Env::get('ClassLoader')->loadFile(ASCMS_CORE_MODULE_PATH . '/Upload/Controller/UploadFactory.class.php'); //paths we want to remember for handling the uploaded files $data = array('path' => ASCMS_DOWNLOADS_IMAGES_PATH, 'webPath' => ASCMS_DOWNLOADS_IMAGES_WEB_PATH, 'category_id' => $objCategory->getId()); $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo'); $comboUp->setFinishedCallback(array(ASCMS_MODULE_PATH . '/Downloads/Controller/Downloads.class.php', '\\Cx\\Modules\\Downloads\\Controller\\Downloads', 'uploadFinished')); $comboUp->setData($data); //set instance name to combo_uploader so we are able to catch the instance with js $comboUp->setJsInstanceName('exposed_combo_uploader'); $this->objTemplate->setVariable(array('COMBO_UPLOADER_CODE' => $comboUp->getXHtml(true), 'DOWNLOADS_UPLOAD_REDIRECT_URL' => \Env::get('Resolver')->getURL()->toString(), 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_UPLOAD_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE'], 'TXT_DOWNLOADS_MAX_FILE_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_MAX_FILE_SIZE'], 'TXT_DOWNLOADS_ADD_NEW_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_ADD_NEW_FILE'], 'DOWNLOADS_MAX_FILE_SIZE' => $this->getFormatedFileSize($objFWSystem->getMaxUploadFileSize()))); $this->objTemplate->parse('downloads_simple_file_upload'); if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) { $this->objTemplate->hideBlock('downloads_advanced_file_upload'); } } }
private function parseUploadForm($objCategory) { global $_CONFIG, $_ARRAYLANG; if (!$this->objTemplate->blockExists('downloads_simple_file_upload') && !$this->objTemplate->blockExists('downloads_advanced_file_upload')) { return; } // check for upload permissiosn if ($objCategory->getAddFilesAccessId() && !\Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) { if ($this->objTemplate->blockExists('downloads_simple_file_upload')) { $this->objTemplate->hideBlock('downloads_simple_file_upload'); } if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) { $this->objTemplate->hideBlock('downloads_advanced_file_upload'); } return; } if ($this->objTemplate->blockExists('downloads_simple_file_upload')) { $objFWSystem = new \FWSystem(); //Uploader button handling $cx = \Cx\Core\Core\Controller\Cx::instanciate(); //paths we want to remember for handling the uploaded files $data = array('path' => $cx->getWebsiteImagesDownloadsPath(), 'webPath' => $cx->getWebsiteImagesDownloadsWebPath(), 'category_id' => $objCategory->getId()); $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Downloads/Controller/Downloads.class.php', '\\Cx\\Modules\\Downloads\\Controller\\Downloads', 'uploadFinished')); $uploader->setCallback('uploadFinishedCallbackJs'); $uploader->setData($data); $this->objTemplate->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE']), 'DOWNLOADS_UPLOAD_REDIRECT_URL' => \Env::get('Resolver')->getURL(), 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_UPLOAD_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE'], 'TXT_DOWNLOADS_MAX_FILE_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_MAX_FILE_SIZE'], 'TXT_DOWNLOADS_ADD_NEW_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_ADD_NEW_FILE'], 'DOWNLOADS_MAX_FILE_SIZE' => $this->getFormatedFileSize($objFWSystem->getMaxUploadFileSize()))); $this->objTemplate->parse('downloads_simple_file_upload'); if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) { $this->objTemplate->hideBlock('downloads_advanced_file_upload'); } } }
/** * Process upload form * * @global array $_ARRAYLANG * @return boolean true if file uplod successfully and false if it failed */ private function processFormUpload() { global $_ARRAYLANG; $inputField = 'media_upload_file'; if (!isset($_FILES[$inputField]) || !is_array($_FILES[$inputField])) { return false; } $fileName = !empty($_FILES[$inputField]['name']) ? contrexx_stripslashes($_FILES[$inputField]['name']) : ''; $fileTmpName = !empty($_FILES[$inputField]['tmp_name']) ? $_FILES[$inputField]['tmp_name'] : ''; if (MediaLibrary::isIllegalFileName($fileName)) { $this->_strErrorMessage = $_ARRAYLANG['TXT_MEDIA_FILE_DONT_CREATE']; return false; } switch ($_FILES[$inputField]['error']) { case UPLOAD_ERR_INI_SIZE: $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_SIZE_EXCEEDS_LIMIT'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET), $this->getFormatedFileSize(\FWSystem::getMaxUploadFileSize())); break; case UPLOAD_ERR_FORM_SIZE: $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_TOO_LARGE'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); break; case UPLOAD_ERR_PARTIAL: $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_CORRUPT'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); break; case UPLOAD_ERR_NO_FILE: $this->_strErrorMessage = $_ARRAYLANG['TXT_MEDIA_NO_FILE']; continue; break; default: if (!empty($fileTmpName)) { $suffix = ''; $file = $this->path . $fileName; $arrFile = pathinfo($file); $i = 0; while (file_exists($file)) { $suffix = '-' . (time() + ++$i); $file = $this->path . $arrFile['filename'] . $suffix . '.' . $arrFile['extension']; } if (\FWValidator::is_file_ending_harmless($fileName)) { $fileExtension = $arrFile['extension']; if (@move_uploaded_file($fileTmpName, $file)) { $fileName = $arrFile['filename']; $obj_file = new \File(); $obj_file->setChmod($this->path, $this->webPath, $fileName); $this->_strOkMessage = $_ARRAYLANG['TXT_MEDIA_FILE_UPLOADED_SUCESSFULLY']; return true; } else { $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_UPLOAD_FAILED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); } } else { $this->_strErrorMessage = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_EXTENSION_NOT_ALLOWED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET)); } } break; } return false; }
/** * Shows the upload-form in the filebrowser */ function _setUploadForm() { global $_ARRAYLANG, $_CONFIG; //data we want to remember for handling the uploaded files $data = array(); if (array_key_exists($this->_mediaType, $this->mediaTypePaths)) { $data['path'] = $this->mediaTypePaths[$this->_mediaType][0] . $this->_path; $data['webPath'] = $this->mediaTypePaths[$this->_mediaType][1] . $this->_path; } else { $data['path'] = ASCMS_CONTENT_IMAGE_PATH . $this->_path; $data['webPath'] = ASCMS_CONTENT_IMAGE_WEB_PATH . $this->_path; } $comboUp = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance()->newUploader('exposedCombo'); $comboUp->setFinishedCallback(array(ASCMS_CORE_MODULE_PATH . '/FileBrowser/Controller/FileBrowser.class.php', '\\Cx\\Core_Modules\\FileBrowser\\Controller\\FileBrowser', 'uploadFinished')); $comboUp->setData($data); //set instance name to combo_uploader so we are able to catch the instance with js $comboUp->setJsInstanceName('exposed_combo_uploader'); $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE' => $comboUp->getXHtml(true))); //end of uploader button handling //check if a finished upload caused reloading of the page. //if yes, we know the added files and want to highlight them if (!empty($_GET['highlightUploadId'])) { $key = 'filebrowser_upload_files_' . intval($_GET['highlightUploadId']); if (isset($_SESSION[$key])) { $sessionHighlightCandidates = $_SESSION[$key]; //an array with the filenames, set in FileBrowser::uploadFinished } //clean up session; we do only highlight once unset($_SESSION[$key]); if (is_array($sessionHighlightCandidates)) { //make sure we don't cause any unexpected behaviour if we lost the session data $this->highlightedFiles = $sessionHighlightCandidates; } } $objFWSystem = new \FWSystem(); // cannot upload or mkdir in webpages view if ($this->_mediaType == "webpages") { return; } $this->_objTpl->addBlockfile('FILEBROWSER_UPLOAD', 'fileBrowser_upload', 'module_fileBrowser_upload.html'); $this->_objTpl->setVariable(array('FILEBROWSER_UPLOAD_TYPE' => $this->_mediaType, 'FILEBROWSER_UPLOAD_PATH' => $this->_path, 'FILEBROWSER_MAX_FILE_SIZE' => $objFWSystem->getMaxUploadFileSize(), 'TXT_CREATE_DIRECTORY' => $_ARRAYLANG['TXT_FILEBROWSER_CREATE_DIRECTORY'], 'TXT_UPLOAD_FILE' => $_ARRAYLANG['TXT_FILEBROWSER_UPLOAD_FILE'], 'JAVASCRIPT' => \JS::getCode())); $this->_objTpl->parse('fileBrowser_upload'); }
function _configGeneral() { global $_ARRAYLANG, $_CORELANG; $status = true; $arrSettings = \User_Setting::getSettings(); $this->_objTpl->addBlockfile('ACCESS_CONFIG_TEMPLATE', 'module_access_config_general', 'module_access_config_general.html'); $this->_objTpl->setVariable(array('TXT_ACCESS_PROFILE' => $_ARRAYLANG['TXT_ACCESS_PROFILE'], 'TXT_ACCESS_PROFILE_AVATAR_PIC' => $_ARRAYLANG['TXT_ACCESS_PROFILE_AVATAR_PIC'], 'TXT_ACCESS_PERMISSIONS' => $_ARRAYLANG['TXT_ACCESS_PERMISSIONS'], 'TXT_ACCESS_YES' => $_ARRAYLANG['TXT_ACCESS_YES'], 'TXT_ACCESS_NO' => $_ARRAYLANG['TXT_ACCESS_NO'], 'TXT_ACCESS_ALLOW_USERS_DELETE_ACCOUNT' => $_ARRAYLANG['TXT_ACCESS_ALLOW_USERS_DELETE_ACCOUNT'], 'TXT_ACCESS_ALLOW_USERS_SET_PROFILE_ACCESS' => $_ARRAYLANG['TXT_ACCESS_ALLOW_USERS_SET_PROFILE_ACCESS'], 'TXT_ACCESS_ALLOW_USERS_SET_EMAIL_ACCESS' => $_ARRAYLANG['TXT_ACCESS_ALLOW_USERS_SET_EMAIL_ACCESS'], 'TXT_ACCESS_FRONTEND_BLOCK_FUNCTIONS' => $_ARRAYLANG['TXT_ACCESS_FRONTEND_BLOCK_FUNCTIONS'], 'TXT_ACCESS_CURRENTLY_ONLINE' => $_ARRAYLANG['TXT_ACCESS_CURRENTLY_ONLINE'], 'TXT_ACCESS_LAST_ACTIVE' => $_ARRAYLANG['TXT_ACCESS_LAST_ACTIVE'], 'TXT_ACCESS_LATEST_REGISTERED_USERS' => $_ARRAYLANG['TXT_ACCESS_LATEST_REGISTERED_USERS'], 'TXT_ACCESS_BIRTHDAYS' => $_ARRAYLANG['TXT_ACCESS_BIRTHDAYS'], 'TXT_ACCESS_ACTIVATE_BLOCK_FUNCTION' => $_ARRAYLANG['TXT_ACCESS_ACTIVATE_BLOCK_FUNCTION'], 'TXT_ACCESS_SHOW_USERS_ONLY_WITH_PHOTO' => $_ARRAYLANG['TXT_ACCESS_SHOW_USERS_ONLY_WITH_PHOTO'], 'TXT_ACCESS_MAX_USER_COUNT' => $_ARRAYLANG['TXT_ACCESS_MAX_USER_COUNT'], 'TXT_ACCESS_SAVE' => $_ARRAYLANG['TXT_ACCESS_SAVE'], 'TXT_ACCESS_PROFILE_PIC' => $_CORELANG['TXT_ACCESS_PROFILE_PIC'], 'TXT_ACCESS_MAX_WIDTH' => $_ARRAYLANG['TXT_ACCESS_MAX_WIDTH'], 'TXT_ACCESS_MAX_HEIGHT' => $_ARRAYLANG['TXT_ACCESS_MAX_HEIGHT'], 'TXT_ACCESS_MAX_FILE_SIZE' => $_ARRAYLANG['TXT_ACCESS_MAX_FILE_SIZE'], 'TXT_ACCESS_THUMBNAIL_WIDTH' => $_ARRAYLANG['TXT_ACCESS_THUMBNAIL_WIDTH'], 'TXT_ACCESS_THUMBNAIL_HEIGHT' => $_ARRAYLANG['TXT_ACCESS_THUMBNAIL_HEIGHT'], 'TXT_ACCESS_MAX_THUMBNAIL_WIDTH' => $_ARRAYLANG['TXT_ACCESS_MAX_THUMBNAIL_WIDTH'], 'TXT_ACCESS_MAX_THUMBNAIL_HEIGHT' => $_ARRAYLANG['TXT_ACCESS_MAX_THUMBNAIL_HEIGHT'], 'TXT_ACCESS_PICTURES' => $_ARRAYLANG['TXT_ACCESS_PICTURES'], 'TXT_ACCESS_OTHER_PICTURES' => $_ARRAYLANG['TXT_ACCESS_OTHER_PICTURES'], 'TXT_ACCESS_MISCELLANEOUS' => $_ARRAYLANG['TXT_ACCESS_MISCELLANEOUS'], 'TXT_ACCESS_STANDARD' => $_ARRAYLANG['TXT_ACCESS_STANDARD'], 'TXT_ACCESS_EMAIL' => $_ARRAYLANG['TXT_ACCESS_EMAIL'], 'TXT_ACCESS_SESSION_ON_INTERVAL' => $_ARRAYLANG['TXT_ACCESS_SESSION_ON_INTERVAL'], 'TXT_ACCESS_SESSION_DESCRIPTION' => $_ARRAYLANG['TXT_ACCESS_SESSION_DESCRIPTION'], 'TXT_ACCESS_SESSION_TITLE' => $_ARRAYLANG['TXT_ACCESS_SESSION_TITLE'], 'TXT_ACCESS_USE_SELECTED_ACCESS_FOR_EVERYONE' => $_ARRAYLANG['TXT_ACCESS_USE_SELECTED_ACCESS_FOR_EVERYONE'], 'TXT_ACCESS_CROP_THUMBNAIL_TXT' => $_ARRAYLANG['TXT_ACCESS_CROP_THUMBNAIL_TXT'], 'TXT_ACCESS_SCALE_THUMBNAIL_TXT' => $_ARRAYLANG['TXT_ACCESS_SCALE_THUMBNAIL_TXT'], 'TXT_ACCESS_BACKGROUND_COLOR' => $_ARRAYLANG['TXT_ACCESS_BACKGROUND_COLOR'], 'TXT_ACCESS_THUMBNAIL_GENERATION' => $_ARRAYLANG['TXT_ACCESS_THUMBNAIL_GENERATION'], 'TXT_ACCESS_USE_USERNAMES' => $_ARRAYLANG['TXT_ACCESS_USE_USERNAMES'], 'TXT_ACCESS_USE_USERNAMES_TOOLTIP' => $_ARRAYLANG['TXT_ACCESS_USE_USERNAMES_TOOLTIP'], 'TXT_ACCESS_SOCIALLOGIN_INFORMATION_TITLE' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_INFORMATION_TITLE'], 'TXT_ACCESS_DESCRIPTION' => $_ARRAYLANG['TXT_ACCESS_DESCRIPTION'], 'TXT_ACCESS_SOCIALLOGIN_DESCRIPTION' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_DESCRIPTION'], 'TXT_ACCESS_SOCIALLOGIN' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN'], 'TXT_ACCESS_ENABLE_SOCIALLOGIN' => $_ARRAYLANG['TXT_ACCESS_ENABLE_SOCIALLOGIN'], 'TXT_ACCESS_SOCIALLOGIN_PROVIDERS' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_PROVIDERS'], 'TXT_ACCESS_SOCIALLOGIN_SHOW_SIGN_UP' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_SHOW_SIGN_UP'], 'TXT_ACCESS_SOCIALLOGIN_SHOW_SIGN_UP_TOOLTIP' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_SHOW_SIGN_UP_TOOLTIP'], 'TXT_ACCESS_GROUP_ASSOCIATION_TEXT' => $_ARRAYLANG['TXT_ACCESS_GROUP_ASSOCIATION_TEXT'], 'TXT_ACCESS_AVAILABLE_GROUPS' => $_ARRAYLANG['TXT_ACCESS_AVAILABLE_GROUPS'], 'TXT_ACCESS_CHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_CHECK_ALL'], 'TXT_ACCESS_UNCHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_UNCHECK_ALL'], 'TXT_ACCESS_ASSOCIATED_GROUPS' => $_ARRAYLANG['TXT_ACCESS_ASSOCIATED_GROUPS'], 'TXT_ACCESS_USER_ACCOUNT_ACTIVATION_METHOD_TEXT' => $_ARRAYLANG['TXT_ACCESS_USER_ACCOUNT_ACTIVATION_METHOD_TEXT'], 'TXT_ACCESS_SOCIALLOGIN_ACTIVATED_AUTOMATICALLY' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_ACTIVATED_AUTOMATICALLY'], 'TXT_ACCESS_SOCIALLOGIN_ACTIVATED_NOT_AUTOMATICALLY' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_ACTIVATED_NOT_AUTOMATICALLY'], 'TXT_ACCESS_SOCIALLOGIN_ACTIVATION_TIME' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_ACTIVATION_TIME'], 'TXT_ACCESS_SOCIALLOGIN_UNCOMPLETED_SIGN_UP' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_UNCOMPLETED_SIGN_UP'], 'TXT_ACCESS_USER_ACCOUNT_VERIFICATION' => $_ARRAYLANG['TXT_ACCESS_USER_ACCOUNT_VERIFICATION'], 'TXT_ACCESS_USER_ACCOUNT_VERIFICATION_TEXT' => $_ARRAYLANG['TXT_ACCESS_USER_ACCOUNT_VERIFICATION_TEXT'])); $this->_objTpl->setGlobalVariable(array('TXT_ACCESS_SOCIALLOGIN_MANUAL' => sprintf($_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_MANUAL'], "http://www.cloudrexx.com/wiki/de/index.php?title=Social_Login"))); if (isset($_POST['access_save_settings'])) { // only administrators are allowed to modify the config if (!\Permission::hasAllAccess()) { \Permission::noAccess(); } $arrSettings['user_delete_account']['status'] = !empty($_POST['access_permissions_delete_account']) ? intval($_POST['access_permissions_delete_account']) : 0; $arrSettings['user_config_profile_access']['status'] = !empty($_POST['access_permissions_profile_access']) ? intval($_POST['access_permissions_profile_access']) : 0; $arrSettings['user_config_email_access']['status'] = !empty($_POST['access_permissions_email_access']) ? intval($_POST['access_permissions_email_access']) : 0; $arrSettings['sociallogin']['status'] = function_exists('curl_init') && !empty($_POST['access_sociallogin_activate']) ? intval($_POST['access_sociallogin_activate']) : 0; $arrSettings['use_usernames']['status'] = !empty($_POST['access_permissions_use_usernames']) ? intval($_POST['access_permissions_use_usernames']) : 0; $arrSettings['sociallogin_show_signup']['status'] = !empty($_POST['access_sociallogin_show_signup']) ? intval($_POST['access_sociallogin_show_signup']) : 0; $arrSettings['sociallogin_assign_to_groups']['value'] = isset($_POST['access_user_associated_groups']) ? implode(',', $_POST['access_user_associated_groups']) : ''; $arrSettings['sociallogin_active_automatically']['status'] = !empty($_POST['sociallogin_active_automatically']) ? intval($_POST['sociallogin_active_automatically']) : 0; $arrSettings['sociallogin_activation_timeout']['value'] = !empty($_POST['sociallogin_activation_timeout']) ? intval($_POST['sociallogin_activation_timeout']) : 10; $arrSettings['default_profile_access']['value'] = isset($_POST['access_user_profile_access']) && in_array($_POST['access_user_profile_access'], array('everyone', 'members_only', 'nobody')) ? $_POST['access_user_profile_access'] : 'members_only'; $arrSettings['default_email_access']['value'] = isset($_POST['access_user_email_access']) && in_array($_POST['access_user_email_access'], array('everyone', 'members_only', 'nobody')) ? $_POST['access_user_email_access'] : 'members_only'; if (!empty($_POST['access_blocks_currently_online_users'])) { $arrSettings['block_currently_online_users']['status'] = 1; $arrSettings['block_currently_online_users']['value'] = !empty($_POST['access_blocks_currently_online_users_user_count']) ? intval($_POST['access_blocks_currently_online_users_user_count']) : 0; $arrSettings['block_currently_online_users_pic']['status'] = !empty($_POST['access_blocks_currently_online_users_only_with_photo']) && intval($_POST['access_blocks_currently_online_users_only_with_photo']); } else { $arrSettings['block_currently_online_users']['status'] = 0; } if (!empty($_POST['access_blocks_last_active_users'])) { $arrSettings['block_last_active_users']['status'] = 1; $arrSettings['block_last_active_users']['value'] = !empty($_POST['access_blocks_last_active_users_user_count']) ? intval($_POST['access_blocks_last_active_users_user_count']) : 0; $arrSettings['block_last_active_users_pic']['status'] = !empty($_POST['access_blocks_last_active_users_only_with_photo']) && intval($_POST['access_blocks_last_active_users_only_with_photo']); } else { $arrSettings['block_last_active_users']['status'] = 0; } if (!empty($_POST['access_blocks_latest_registered_users'])) { $arrSettings['block_latest_reg_users']['status'] = 1; $arrSettings['block_latest_reg_users']['value'] = !empty($_POST['access_blocks_latest_registered_users_user_count']) ? intval($_POST['access_blocks_latest_registered_users_user_count']) : 0; $arrSettings['block_latest_reg_users_pic']['status'] = !empty($_POST['access_blocks_latest_registered_users_only_with_photo']) && intval($_POST['access_blocks_latest_registered_users_only_with_photo']); } else { $arrSettings['block_latest_reg_users']['status'] = 0; } if (!empty($_POST['access_blocks_birthday_users'])) { $arrSettings['block_birthday_users']['status'] = 1; $arrSettings['block_birthday_users']['value'] = !empty($_POST['access_blocks_birthday_users_user_count']) ? intval($_POST['access_blocks_birthday_users_user_count']) : 0; $arrSettings['block_birthday_users_pic']['status'] = !empty($_POST['access_blocks_birthday_users_only_with_photo']) && intval($_POST['access_blocks_birthday_users_only_with_photo']); } else { $arrSettings['block_birthday_users']['status'] = 0; } if (!empty($_POST['accessMaxProfilePicWidth'])) { $arrSettings['max_profile_pic_width']['value'] = intval($_POST['accessMaxProfilePicWidth']); } if (!empty($_POST['accessMaxProfilePicHeight'])) { $arrSettings['max_profile_pic_height']['value'] = intval($_POST['accessMaxProfilePicHeight']); } if (!empty($_POST['accessProfileThumbnailPicWidth'])) { $arrSettings['profile_thumbnail_pic_width']['value'] = intval($_POST['accessProfileThumbnailPicWidth']); } if (!empty($_POST['accessProfileThumbnailPicHeight'])) { $arrSettings['profile_thumbnail_pic_height']['value'] = intval($_POST['accessProfileThumbnailPicHeight']); } if (!empty($_POST['accessMaxProfilePicSize'])) { // TODO // if (\FWSystem::getBytesOfLiteralSizeFormat($_POST['accessMaxProfilePicSize']) != $arrSettings['max_profile_pic_size']['value']) { // // resize profile pics // } $arrSettings['max_profile_pic_size']['value'] = \FWSystem::getBytesOfLiteralSizeFormat($_POST['accessMaxProfilePicSize']); } if (isset($_POST['accessProfileThumbnailMethod']) && $_POST['accessProfileThumbnailMethod'] == 'scale') { $arrSettings['profile_thumbnail_method']['value'] = 'scale'; $color = !empty($_POST['accessProfileThumbnailScaleColor']) ? contrexx_input2raw($_POST['accessProfileThumbnailScaleColor']) : NULL; $arrSettings['profile_thumbnail_scale_color']['value'] = $this->validateHexRGBColor($color); } else { $arrSettings['profile_thumbnail_method']['value'] = 'crop'; } if (!empty($_POST['accessMaxPicWidth'])) { $arrSettings['max_pic_width']['value'] = intval($_POST['accessMaxPicWidth']); } if (!empty($_POST['accessMaxPicHeight'])) { $arrSettings['max_pic_height']['value'] = intval($_POST['accessMaxPicHeight']); } if (!empty($_POST['accessMaxThumbnailPicWidth'])) { $arrSettings['max_thumbnail_pic_width']['value'] = intval($_POST['accessMaxThumbnailPicWidth']); } if (!empty($_POST['accessMaxThumbnailPicHeight'])) { $arrSettings['max_thumbnail_pic_height']['value'] = intval($_POST['accessMaxThumbnailPicHeight']); } // user_account_verification is a checkbox, if this is not set, its not checked. If it is set, it is checked // 0 = unchecked, false, 1 = checked, active, true $arrSettings['user_account_verification']['value'] = 0; if (isset($_POST['user_account_verification'])) { $arrSettings['user_account_verification']['value'] = 1; } if (!empty($_POST['accessMaxPicSize'])) { // TODO // if (\FWSystem::getBytesOfLiteralSizeFormat($_POST['accessMaxPicSize']) != $arrSettings['max_pic_size']['value']) { // // resize pics // } $arrSettings['max_pic_size']['value'] = \FWSystem::getBytesOfLiteralSizeFormat($_POST['accessMaxPicSize']); } $session_on_interval = intval($_POST['sessioninterval']); if (trim($session_on_interval) != null) { if ($session_on_interval >= 0 && $session_on_interval <= 300) { $arrSettings['session_user_interval']['value'] = $session_on_interval; } } if (!empty($_POST["sociallogin_providers"])) { \Cx\Lib\SocialLogin::updateProviders($_POST["sociallogin_providers"]); } if ($status) { if (\User_Setting::setSettings($arrSettings)) { self::$arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_ACCESS_CONFIG_SUCCESSFULLY_SAVED']; if (!empty($_POST['access_force_selected_profile_access'])) { if (!\User::forceDefaultProfileAccess()) { self::$arrStatusMsg['error'][] = $_ARRAYLANG['TXT_ACCESS_SET_DEFAULT_PROFILE_ACCESS_FAILED']; } } if (!empty($_POST['access_force_selected_email_access'])) { if (!\User::forceDefaultEmailAccess()) { self::$arrStatusMsg['error'][] = $_ARRAYLANG['TXT_ACCESS_SET_DEFAULT_EMAIL_ACCESS_FAILED']; } } } else { self::$arrStatusMsg['error'][] = $_ARRAYLANG['TXT_ACCESS_CONFIG_FAILED_SAVED']; self::$arrStatusMsg['error'][] = $_ARRAYLANG['TXT_ACCESS_TRY_TO_REPEAT_OPERATION']; } } } $curlAvailable = true; try { $socialloginProviders = \Cx\Lib\SocialLogin::getProviders(); } catch (\Exception $e) { if (!function_exists('curl_init')) { $this->_objTpl->setVariable('TXT_ACCESS_SOCIALLOGIN_WARNING', $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_NEED_CURL']); $this->_objTpl->parse('sociallogin_need_curl'); $curlAvailable = false; } } if ($curlAvailable) { $this->_objTpl->touchBlock('access_sociallogin_settings'); } else { $this->_objTpl->hideBlock('access_sociallogin_settings'); } // if the current user is no admin, show a message $currentUserIsAdmin = \FWUser::getFWUserObject()->objUser->getAdminStatus(); if (!$currentUserIsAdmin) { $this->_objTpl->setVariable('TXT_ACCESS_SOCIALLOGIN_PERMISSION_DENIED', $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_PERMISSION_DENIED']); $this->_objTpl->parse('access_sociallogin_permission_denied'); } $socialloginProviderRow = 0; foreach ($socialloginProviders as $socialloginProviderName => $providerObject) { $settings = $providerObject->getApplicationData(); $paramId = 0; if ($currentUserIsAdmin) { foreach (call_user_func(\Cx\Lib\SocialLogin::getClassByProvider($socialloginProviderName) . '::configParams') as $configParam) { $this->_objTpl->setVariable(array('TXT_ACCESS_SOCIALLOGIN_PROVIDER_PARAM_TITLE' => $_ARRAYLANG[$configParam], 'ACCESS_SOCIALLOGIN_PROVIDER_PARAM_VALUE' => contrexx_raw2xhtml(!empty($settings[$paramId]) ? $settings[$paramId] : ''), 'ACCESS_SOCIALLOGIN_PROVIDER_TOGGLE' => $providerObject->isActive() ? '' : 'none', 'ACCESS_SOCIALLOGIN_PROVIDER_NAME' => contrexx_raw2xhtml($socialloginProviderName), 'ACCESS_SOCIALLOGIN_PROVIDER_NAME_UPPER' => contrexx_raw2xhtml(ucfirst($socialloginProviderName)))); $this->_objTpl->parse('access_sociallogin_provider_params'); $paramId++; } } $this->_objTpl->setVariable(array('ACCESS_SOCIALLOGIN_PROVIDER_ROW' => $socialloginProviderRow % 2 == 0 ? 1 : 2, 'ACCESS_SOCIALLOGIN_PROVIDER_NAME' => contrexx_raw2xhtml($socialloginProviderName), 'ACCESS_SOCIALLOGIN_PROVIDER_NAME_UPPER' => contrexx_raw2xhtml(ucfirst($socialloginProviderName)), 'TXT_ACCESS_SOCIALLOGIN_PROVIDER_ENABLED' => $_ARRAYLANG['TXT_ACCESS_SOCIALLOGIN_PROVIDER_ENABLED'], 'ACCESS_SOCIALLOGIN_PROVIDER_ENABLED_CHECKED' => $currentUserIsAdmin && $providerObject->isActive() ? 'checked="checked"' : '', 'ACCESS_SOCIALLOGIN_PROVIDER_DISABLED' => $currentUserIsAdmin ? '' : 'disabled="disabled"')); $this->_objTpl->parse('access_sociallogin_provider'); $socialloginProviderRow++; } $this->_objTpl->setVariable(array('ACCESS_SOCIALLOGIN_TOGGLE' => $arrSettings['sociallogin']['status'] ? '' : 'none')); $arrAssignedGroups = explode(',', $arrSettings['sociallogin_assign_to_groups']['value']); $notAssignedGroups = ''; $assignedGroups = ''; $objFWUser = \FWUser::getFWUserObject(); $objGroup = $objFWUser->objGroup->getGroups(); while (!$objGroup->EOF) { $groupVar = in_array($objGroup->getId(), $arrAssignedGroups) ? 'assignedGroups' : 'notAssignedGroups'; ${$groupVar} .= '<option value="' . $objGroup->getId() . '">' . contrexx_raw2xhtml($objGroup->getName()) . ' [' . $objGroup->getType() . ']</option>'; $objGroup->next(); } $this->_objTpl->setVariable(array('ACCESS_USER_NOT_ASSOCIATED_GROUPS' => $notAssignedGroups, 'ACCESS_USER_ASSOCIATED_GROUPS' => $assignedGroups)); $this->parseAccountAttribute(null, 'profile_access', true, $arrSettings['default_profile_access']['value']); $this->parseAccountAttribute(null, 'email_access', true, $arrSettings['default_email_access']['value']); $this->_objTpl->setVariable(array('ACCESS_ALLOW_USERS_DELETE_ACCOUNT' => $arrSettings['user_delete_account']['status'] ? 'checked="checked"' : '', 'ACCESS_DONT_ALLOW_USERS_DELETE_ACCOUNT' => $arrSettings['user_delete_account']['status'] ? '' : 'checked="checked"', 'ACCESS_ALLOW_USERS_SET_PROFILE_ACCESS' => $arrSettings['user_config_profile_access']['status'] ? 'checked="checked"' : '', 'ACCESS_DONT_ALLOW_USERS_SET_PROFILE_ACCESS' => $arrSettings['user_config_profile_access']['status'] ? '' : 'checked="checked"', 'ACCESS_ALLOW_USERS_SET_EMAIL_ACCESS' => $arrSettings['user_config_email_access']['status'] ? 'checked="checked"' : '', 'ACCESS_DONT_ALLOW_USERS_SET_EMAIL_ACCESS' => $arrSettings['user_config_email_access']['status'] ? '' : 'checked="checked"', 'ACCESS_BLOCKS_CURRENTLY_ONLINE_USERS' => $arrSettings['block_currently_online_users']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_CURRENTLY_ONLINE_USERS_DISPLAY' => $arrSettings['block_currently_online_users']['status'] ? '' : 'none', 'ACCESS_BLOCKS_CURRENTLY_ONLINE_USERS_USER_COUNT' => $arrSettings['block_currently_online_users']['value'], 'ACCESS_BLOCKS_CURRENTLY_ONLINE_USERS_ONLY_WITH_PHOTO' => $arrSettings['block_currently_online_users_pic']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_LAST_ACTIVE_USERS' => $arrSettings['block_last_active_users']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_LAST_ACTIVE_USERS_DISPLAY' => $arrSettings['block_last_active_users']['status'] ? '' : 'none', 'ACCESS_BLOCKS_LAST_ACTIVE_USERS_USER_COUNT' => $arrSettings['block_last_active_users']['value'], 'ACCESS_BLOCKS_LAST_ACTIVE_USERS_ONLY_WITH_PHOTO' => $arrSettings['block_last_active_users_pic']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_LATEST_REGISTERED_USERS' => $arrSettings['block_latest_reg_users']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_LATEST_REGISTERED_USERS_DISPLAY' => $arrSettings['block_latest_reg_users']['status'] ? '' : 'none', 'ACCESS_BLOCKS_LATEST_REGISTERED_USERS_USER_COUNT' => $arrSettings['block_latest_reg_users']['value'], 'ACCESS_BLOCKS_LATEST_REGISTERED_USERS_ONLY_WITH_PHOTO' => $arrSettings['block_latest_reg_users_pic']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_BIRTHDAY_USERS' => $arrSettings['block_birthday_users']['status'] ? 'checked="checked"' : '', 'ACCESS_BLOCKS_BIRTHDAY_USERS_DISPLAY' => $arrSettings['block_birthday_users']['status'] ? '' : 'none', 'ACCESS_BLOCKS_BIRTHDAY_USERS_USER_COUNT' => $arrSettings['block_birthday_users']['value'], 'ACCESS_BLOCKS_BIRTHDAY_USERS_ONLY_WITH_PHOTO' => $arrSettings['block_birthday_users_pic']['status'] ? 'checked="checked"' : '', 'ACCESS_MAX_PROFILE_PIC_WIDTH' => $arrSettings['max_profile_pic_width']['value'], 'ACCESS_MAX_PROFILE_PIC_HEIGHT' => $arrSettings['max_profile_pic_height']['value'], 'ACCESS_PROFILE_THUMBNAIL_PIC_WIDTH' => $arrSettings['profile_thumbnail_pic_width']['value'], 'ACCESS_PROFILE_THUMBNAIL_PIC_HEIGHT' => $arrSettings['profile_thumbnail_pic_height']['value'], 'ACCESS_MAX_PROFILE_PIC_SIZE' => \FWSystem::getLiteralSizeFormat($arrSettings['max_profile_pic_size']['value']), 'ACCESS_MAX_PIC_WIDTH' => $arrSettings['max_pic_width']['value'], 'ACCESS_MAX_PIC_HEIGHT' => $arrSettings['max_pic_height']['value'], 'ACCESS_MAX_THUMBNAIL_PIC_WIDTH' => $arrSettings['max_thumbnail_pic_width']['value'], 'ACCESS_MAX_THUMBNAIL_PIC_HEIGHT' => $arrSettings['max_thumbnail_pic_height']['value'], 'ACCESS_SESSION_USER_INTERVAL' => $arrSettings['session_user_interval']['value'], 'ACCESS_MAX_PIC_SIZE' => \FWSystem::getLiteralSizeFormat($arrSettings['max_pic_size']['value']), 'ACCESS_PROFILE_THUMBNAIL_CROP' => $arrSettings['profile_thumbnail_method']['value'] == 'crop' ? 'selected="selected"' : '', 'ACCESS_PROFILE_THUMBNAIL_SCALE' => $arrSettings['profile_thumbnail_method']['value'] == 'scale' ? 'selected="selected"' : '', 'ACCESS_PROFILE_THUMBNAIL_SCALE_BOX' => $arrSettings['profile_thumbnail_method']['value'] == 'scale' ? 'inline' : 'none', 'ACCESS_PROFILE_THUMBNAIL_SCALE_COLOR' => $arrSettings['profile_thumbnail_scale_color']['value'], 'ACCESS_USE_USERNAMES' => $arrSettings['use_usernames']['status'] ? 'checked="checked"' : '', 'ACCESS_DONT_USE_USERNAMES' => $arrSettings['use_usernames']['status'] ? '' : 'checked="checked"', 'ACCESS_SOCIALLOGIN_ENABLED' => $arrSettings['sociallogin']['status'] ? 'checked="checked"' : '', 'ACCESS_SOCIALLOGIN_NOT_ENABLED' => $arrSettings['sociallogin']['status'] ? '' : 'checked="checked"', 'ACCESS_SOCIALLOGIN_SHOW_SIGNUP_ENABLED' => $arrSettings['sociallogin_show_signup']['status'] ? 'checked="checked"' : '', 'ACCESS_SOCIALLOGIN_SHOW_SIGNUP_NOT_ENABLED' => $arrSettings['sociallogin_show_signup']['status'] ? '' : 'checked="checked"', 'ACCESS_SOCIALLOGIN_ACTIVATED_AUTOMATICALLY_ENABLED' => $arrSettings['sociallogin_active_automatically']['status'] ? 'checked="checked"' : '', 'ACCESS_SOCIALLOGIN_ACTIVATED_AUTOMATICALLY_NOT_ENABLED' => $arrSettings['sociallogin_active_automatically']['status'] ? '' : 'checked="checked"', 'ACCESS_SOCIALLOGIN_ACTIVATION_TIMEOUT' => intval($arrSettings['sociallogin_activation_timeout']['value']), 'ACCESS_USSER_ACCOUNT_VERIFICATION_CHECKED' => $arrSettings['user_account_verification']['value'] == 1 ? 'checked' : '')); $this->_objTpl->parse('module_access_config_general'); }
function checkMemoryLimit() { global $_CORELANG; static $memoryLimit, $MiB2; if (!isset($memoryLimit)) { @(include UPDATE_PATH . '/lib/FRAMEWORK/System.class.php'); $objSystem = new FWSystem(); if ($objSystem === false) { setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_API_LOAD_FAILED'], UPDATE_PATH . '/lib/FRAMEWORK/System.class.php')); return false; } $memoryLimit = $objSystem->getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); if (empty($memoryLimit)) { // set default php memory limit of 8MiBytes $memoryLimit = 8 * pow(1024, 2); } $MiB2 = 2 * pow(1024, 2); } $potentialRequiredMemory = memory_get_usage() + $MiB2; if ($potentialRequiredMemory > $memoryLimit) { // try to set a higher memory_limit if (!@ini_set('memory_limit', $potentialRequiredMemory)) { setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED'], 'title'); setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED_RAM_MSG'] . '<br /><br />', 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); return false; } } return true; }
/** * Checking memory limit * * @param type $requiredMemoryLimit required memory limit * * @return boolean */ function checkMemoryLimit($requiredMemoryLimit) { if (empty($this->memoryLimit)) { $memoryLimit = \FWSystem::getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); //if memory limit is empty then set default php memory limit of 8MiBytes $this->memoryLimit = !empty($memoryLimit) ? $memoryLimit : self::MiB2 * 4; } $potentialRequiredMemory = memory_get_usage() + $requiredMemoryLimit; if ($potentialRequiredMemory > $this->memoryLimit) { // try to set a higher memory_limit if (!@ini_set('memory_limit', $potentialRequiredMemory)) { \DBG::log('The link spider script is interrupted due to insufficient memory is available.'); return false; } } return true; }
/** * Load the image from the given file path * * Based on the ImageManager methods _imageCreateFromFile() and * _isImage() * @param string $file_path The image file path * @return resource The image resource on success, * false otherwise */ static function load($file_path) { if (!File::exists($file_path)) { return false; } $arrInfo = getimagesize(ASCMS_DOCUMENT_ROOT . '/' . $file_path); if (!is_array($arrInfo)) { //echo("load(): failed to determine image size<br />"); return false; } // 1: GIF, 2: JPG, 3: PNG, others are not accepted if ($arrInfo[2] == 1 && !function_exists('imagecreatefromgif')) { return false; } switch ($arrInfo[2]) { case 1: $function = 'imagecreatefromgif'; break; case 2: $function = 'imagecreatefromjpeg'; break; case 3: $function = 'imagecreatefrompng'; break; default: //echo("load(): unknown file type<br />"); return false; } $memoryLimit = FWSystem::getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); if (empty($memoryLimit)) { $memoryLimit = Image::MAXIMUM_UPLOAD_FILE_SIZE; } $potentialRequiredMemory = intval($arrInfo[0] * $arrInfo[1] * ($arrInfo['bits'] / 8) * $arrInfo['channels'] * 1.8); if (function_exists('memory_get_usage')) { $potentialRequiredMemory += memory_get_usage(); } else { // add a default of 3 MB $potentialRequiredMemory += 3 * pow(1024, 2); } //echo("load(): potentialRequiredMemory $potentialRequiredMemory, memoryLimit $memoryLimit<br />"); if ($potentialRequiredMemory > $memoryLimit) { // try to set a higher memory_limit if (!@ini_set('memory_limit', $potentialRequiredMemory)) { //echo("load(): failed to set memory limit<br />"); return false; } } //echo("load(): calling $function($file_path)...<br />"); return $function(ASCMS_DOCUMENT_ROOT . '/' . $file_path); }
/** * Create an Image * @param string $strPathOld: The old path of the image * @param string $strPathNew: The new path for the created image * @param string $strFileOld: The name of the old file * @param string $strFileNew: The name of the new file * @param integer $intNewWidth: Width of the new image * @param integer $intNewHeight: Height of the new image * @param integer $intQuality: Quality of the new image */ function createImages_JPG_GIF_PNG($strPathOld, $strPathNew, $strFileOld, $strFileNew, $intNewWidth, $intNewHeight, $intQuality) { global $_ARRAYLANG; //TODO: sometimes, strings are passed... this is a workaround $intNewWidth = intval($intNewWidth); $intNewHeight = intval($intNewHeight); //copy image $intSize = getimagesize($strPathOld . $strFileOld); //ermittelt die Gr��e des Bildes $intWidth = $intSize[0]; //die Breite des Bildes $intHeight = $intSize[1]; //die H�he des Bildes $strType = $intSize[2]; //type des Bildes if (file_exists($strPathNew . $strFileNew)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($strPathNew . $strFileNew); } else { try { $objFile = new \Cx\Lib\FileSystem\File($strPathNew . $strFileNew); $objFile->touch(); $objFile->makeWritable(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); } } // TODO: Unfortunately, the functions imagegif(), imagejpeg() and imagepng() can't use the Cloudrexx FileSystem wrapper, // therefore we need to set the global write access image files. // This issue might be solved by using the output-buffer and write the image manually afterwards. // // IMPORTANT: In case something went wrong (see bug #1441) and the path $strPathNew.$strFileNew refers to a directory // we must abort the operation here, otherwise we would remove the execution flag on a directory, which would // cause to remove any browsing access to the directory. if (is_dir($strPathNew . $strFileNew)) { return false; } \Cx\Lib\FileSystem\FileSystem::chmod($strPathNew . $strFileNew, 0666); //\Cx\Lib\FileSystem\FileSystem::CHMOD_FILE); //fix cases of zeroes if ($intNewWidth == 0) { if ($intNewHeight == 0) { $intNewHeight = $this->arrSettings['standard_height_abs']; } if ($intNewHeight == 0) { //set a standard value if the settings default to 0 $intNewHeight = 100; } $intNewWidth = round($intWidth * $intNewHeight / $intHeight, 0); } else { if ($intNewHeight == 0) { $intNewHeight = round($intHeight * $intNewWidth / $intWidth, 0); } } $objSystem = new \FWSystem(); if ($objSystem === false) { return false; } if (is_array($intSize)) { $memoryLimit = $objSystem->getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); // a $memoryLimit of zero means that there is no limit. so let's try it and hope that the host system has enough memory if (!empty($memoryLimit)) { $potentialRequiredMemory = $intSize[0] * $intSize[1] * ($intSize['bits'] / 8) * $intSize['channels'] * 1.8 * 2; if (function_exists('memory_get_usage')) { $potentialRequiredMemory += memory_get_usage(); } else { // add a default of 10 MBytes $potentialRequiredMemory += 10 * pow(1024, 2); } if ($potentialRequiredMemory > $memoryLimit) { // try to set a higher memory_limit @ini_set('memory_limit', $potentialRequiredMemory); $curr_limit = $objSystem->getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); if ($curr_limit < $potentialRequiredMemory) { return false; } } } } else { return false; } switch ($strType) { case 1: //GIF if ($this->boolGifEnabled) { $handleImage1 = ImageCreateFromGif($strPathOld . $strFileOld); $handleImage2 = @ImageCreateTrueColor($intNewWidth, $intNewHeight); ImageCopyResampled($handleImage2, $handleImage1, 0, 0, 0, 0, $intNewWidth, $intNewHeight, $intWidth, $intHeight); ImageGif($handleImage2, $strPathNew . $strFileNew); ImageDestroy($handleImage1); ImageDestroy($handleImage2); } else { $this->strErrMessage = $_ARRAYLANG['TXT_GALLERY_NO_GIF_SUPPORT']; } break; case 2: //JPG if ($this->boolJpgEnabled) { $handleImage1 = ImageCreateFromJpeg($strPathOld . $strFileOld); $handleImage2 = ImageCreateTrueColor($intNewWidth, $intNewHeight); ImageCopyResampled($handleImage2, $handleImage1, 0, 0, 0, 0, $intNewWidth, $intNewHeight, $intWidth, $intHeight); ImageJpeg($handleImage2, $strPathNew . $strFileNew, $intQuality); ImageDestroy($handleImage1); ImageDestroy($handleImage2); } else { $this->strErrMessage = $_ARRAYLANG['TXT_GALLERY_NO_JPG_SUPPORT']; } break; case 3: //PNG if ($this->boolPngEnabled) { $handleImage1 = ImageCreateFromPNG($strPathOld . $strFileOld); $handleImage2 = @ImageCreateTrueColor($intNewWidth, $intNewHeight); ImageAlphaBlending($handleImage2, false); ImageSaveAlpha($handleImage2, true); ImageCopyResampled($handleImage2, $handleImage1, 0, 0, 0, 0, $intNewWidth, $intNewHeight, $intWidth, $intHeight); ImagePNG($handleImage2, $strPathNew . $strFileNew); ImageDestroy($handleImage1); ImageDestroy($handleImage2); } else { $this->strErrMessage = $_ARRAYLANG['TXT_GALLERY_NO_PNG_SUPPORT']; } break; } return true; }