本文整理汇总了PHP中Cx\Lib\FileSystem\FileSystem::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::exists方法的具体用法?PHP FileSystem::exists怎么用?PHP FileSystem::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Lib\FileSystem\FileSystem
的用法示例。
在下文中一共展示了FileSystem::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createThumbnail
/**
* 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;
}
示例2: handleSignUp
function handleSignUp($objUser)
{
global $_ARRAYLANG, $_CONFIG, $_LANGID;
$objFWUser = \FWUser::getFWUserObject();
$objUserMail = $objFWUser->getMail();
$arrSettings = \User_Setting::getSettings();
if ($arrSettings['user_activation']['status']) {
$mail2load = 'reg_confirm';
$mail2addr = $objUser->getEmail();
} else {
$mail2load = 'new_user';
$mail2addr = $arrSettings['notification_address']['value'];
}
if (($objUserMail->load($mail2load, $_LANGID) || $objUserMail->load($mail2load)) && \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php') && ($objMail = new \PHPMailer()) !== false) {
if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
$objMail->IsSMTP();
$objMail->Host = $arrSmtp['hostname'];
$objMail->Port = $arrSmtp['port'];
$objMail->SMTPAuth = true;
$objMail->Username = $arrSmtp['username'];
$objMail->Password = $arrSmtp['password'];
}
}
$objMail->CharSet = CONTREXX_CHARSET;
$objMail->SetFrom($objUserMail->getSenderMail(), $objUserMail->getSenderName());
$objMail->Subject = $objUserMail->getSubject();
$isTextMail = in_array($objUserMail->getFormat(), array('multipart', 'text'));
$isHtmlMail = in_array($objUserMail->getFormat(), array('multipart', 'html'));
$searchTerms = array('[[HOST]]', '[[USERNAME]]', '[[ACTIVATION_LINK]]', '[[HOST_LINK]]', '[[SENDER]]', '[[LINK]]');
$replaceTextTerms = array($_CONFIG['domainUrl'], $objUser->getUsername(), 'http://' . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . '?section=Access&cmd=signup&u=' . $objUser->getId() . '&k=' . $objUser->getRestoreKey(), 'http://' . $_CONFIG['domainUrl'], $objUserMail->getSenderName(), 'http://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/index.php?cmd=Access&act=user&tpl=modify&id=' . $objUser->getId());
$replaceHtmlTerms = array($_CONFIG['domainUrl'], contrexx_raw2xhtml($objUser->getUsername()), 'http://' . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . '?section=Access&cmd=signup&u=' . $objUser->getId() . '&k=' . $objUser->getRestoreKey(), 'http://' . $_CONFIG['domainUrl'], contrexx_raw2xhtml($objUserMail->getSenderName()), 'http://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/index.php?cmd=Access&act=user&tpl=modify&id=' . $objUser->getId());
if ($mail2load == 'reg_confirm') {
$imagePath = 'http://' . $_CONFIG['domainUrl'] . \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesAccessProfileWebPath() . '/';
$objUser->objAttribute->first();
while (!$objUser->objAttribute->EOF) {
$objAttribute = $objUser->objAttribute->getById($objUser->objAttribute->getId());
$placeholderName = strtoupper($objUser->objAttribute->getId());
$searchTerms[] = '[[USER_' . $placeholderName . ']]';
$placeholderValue = $this->parseAttribute($objUser, $objAttribute->getId(), 0, false, true);
if ($objAttribute->getType() == 'image' && $objAttribute->getId() == 'picture') {
$path = $imagePath . '0_noavatar.gif';
$imgName = $objUser->getProfileAttribute($objAttribute->getId());
if (\Cx\Lib\FileSystem\FileSystem::exists($imagePath . $imgName)) {
$path = $imagePath . $imgName;
}
$replaceHtmlTerms[] = \Html::getImageByPath($path, 'alt="' . $objUser->getEmail() . '"');
$replaceTextTerms[] = $path;
} else {
if (in_array($objUser->objAttribute->getType(), array('text', 'menu'))) {
$replaceTextTerms[] = html_entity_decode($placeholderValue, ENT_QUOTES, CONTREXX_CHARSET);
$replaceHtmlTerms[] = html_entity_decode($placeholderValue, ENT_QUOTES, CONTREXX_CHARSET);
} else {
$replaceTextTerms[] = $placeholderValue;
$replaceHtmlTerms[] = $placeholderValue;
}
}
$objUser->objAttribute->next();
}
}
if ($isTextMail) {
$objUserMail->getFormat() == 'text' ? $objMail->IsHTML(false) : false;
$objMail->{($objUserMail->getFormat() == 'text' ? '' : 'Alt') . 'Body'} = str_replace($searchTerms, $replaceTextTerms, $objUserMail->getBodyText());
}
if ($isHtmlMail) {
$objUserMail->getFormat() == 'html' ? $objMail->IsHTML(true) : false;
$objMail->Body = str_replace($searchTerms, $replaceHtmlTerms, $objUserMail->getBodyHtml());
}
$objMail->AddAddress($mail2addr);
if ($objMail->Send()) {
$this->arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_ACCESS_ACCOUNT_SUCCESSFULLY_CREATED'];
if ($arrSettings['user_activation']['status']) {
$timeoutStr = '';
if ($arrSettings['user_activation_timeout']['status']) {
if ($arrSettings['user_activation_timeout']['value'] > 1) {
$timeoutStr = $arrSettings['user_activation_timeout']['value'] . ' ' . $_ARRAYLANG['TXT_ACCESS_HOURS_IN_STR'];
} else {
$timeoutStr = ' ' . $_ARRAYLANG['TXT_ACCESS_HOUR_IN_STR'];
}
$timeoutStr = str_replace('%TIMEOUT%', $timeoutStr, $_ARRAYLANG['TXT_ACCESS_ACTIVATION_TIMEOUT']);
}
$this->arrStatusMsg['ok'][] = str_replace('%TIMEOUT%', $timeoutStr, $_ARRAYLANG['TXT_ACCESS_ACTIVATION_BY_USER_MSG']);
} else {
$this->arrStatusMsg['ok'][] = str_replace("%HOST%", $_CONFIG['domainUrl'], $_ARRAYLANG['TXT_ACCESS_ACTIVATION_BY_SYSTEM']);
}
return true;
}
}
$mailSubject = str_replace("%HOST%", "http://" . $_CONFIG['domainUrl'], $_ARRAYLANG['TXT_ACCESS_COULD_NOT_SEND_ACTIVATION_MAIL']);
$adminEmail = '<a href="mailto:' . $_CONFIG['coreAdminEmail'] . '?subject=' . $mailSubject . '" title="' . $_CONFIG['coreAdminEmail'] . '">' . $_CONFIG['coreAdminEmail'] . '</a>';
$this->arrStatusMsg['error'][] = str_replace("%EMAIL%", $adminEmail, $_ARRAYLANG['TXT_ACCESS_COULD_NOT_SEND_EMAIL']);
return false;
}
示例3: _handleUpload
/**
* 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;
}
示例4: _getThumbs
/**
* Get thumbnails
*
* Get the thumbnails from a day in the archive.
* Create the thumbnails if they don't already exists.
*
* @return boolean TRUE if the thumbs have been loaded, otherwise FALSE
*/
protected function _getThumbs()
{
// set and sanitize the archive path
$path = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $this->camSettings['archivePath'] . '/' . $this->date . '/';
$path = \Cx\Lib\FileSystem\FileSystem::sanitizePath($path);
// set and sanitize the thumbnail path
$thumbPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $this->camSettings['thumbnailPath'];
$thumbPath = \Cx\Lib\FileSystem\FileSystem::sanitizePath($thumbPath);
if (!$path || !$thumbPath) {
return false;
}
$objDirectory = @opendir($path);
$chmoded = false;
if (!$objDirectory) {
return false;
}
while ($file = readdir($objDirectory)) {
if ($file != "." && $file != "..") {
//check and create thumbs
$thumb = $thumbPath . '/tn_' . $this->date . '_' . $file;
if (!\Cx\Lib\FileSystem\FileSystem::exists($thumb)) {
if (!$chmoded) {
\Cx\Lib\FileSystem\FileSystem::makeWritable($this->camSettings['thumbnailPath']);
$chmoded = true;
}
//create thumb
$im1 = @imagecreatefromjpeg($path . $file);
//erstellt ein Abbild im Speicher
if ($im1) {
/* Pr�fen, ob fehlgeschlagen */
// check_jpeg($thumb, $fix=false );
$size = getimagesize($path . $file);
//ermittelt die Gr��e des Bildes
$breite = $size[0];
//die Breite des Bildes
$hoehe = $size[1];
//die H�he des Bildes
$breite_neu = $this->camSettings['thumbMaxSize'];
//die breite des Thumbnails
$factor = $breite / $this->camSettings['thumbMaxSize'];
//berechnungsfaktor
$hoehe_neu = $size[1] / $factor;
//die H�he des Thumbnails
//$im2=imagecreate($breite_neu,$hoehe_neu); //Thumbnail im Speicher erstellen
$im2 = @imagecreatetruecolor($breite_neu, $hoehe_neu);
imagecopyresized($im2, $im1, 0, 0, 0, 0, $breite_neu, $hoehe_neu, $breite, $hoehe);
imagejpeg($im2, $thumb);
//Thumbnail speichern
imagedestroy($im1);
//Speicherabbild wieder l�schen
imagedestroy($im2);
//Speicherabbild wieder l�schen
}
}
//show pictures
$minHour = date('G', $this->camSettings['showFrom']);
$minMinutes = date('i', $this->camSettings['showFrom']);
$maxHour = date('G', $this->camSettings['showTill']);
$maxMinutes = date('i', $this->camSettings['showTill']);
$hour = substr($file, 4, 2);
$min = substr($file, 13, 2);
$min = !empty($min) ? $min : "00";
$time = $hour . ":" . $min . " Uhr";
$minTime = mktime($minHour, $minMinutes);
$maxTime = mktime($maxHour, $maxMinutes);
$nowTime = mktime($hour, $min);
/*
* only show archive images if they are in range
*/
if ($nowTime <= $maxTime && $nowTime >= $minTime) {
if ($this->camSettings['shadowboxActivate'] == 1) {
$linkUrl = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . $this->camSettings['archivePath'] . '/' . $this->date . '/' . $file;
} else {
$linkUrl = '[[NODE_LIVECAM]]?file=' . $this->date . '/' . $file;
}
$arrThumbnail = array('link_url' => $linkUrl, 'image_url' => $this->camSettings['thumbnailPath'] . "/tn_" . $this->date . "_" . $file, 'time' => $time);
array_push($this->_arrArchiveThumbs, $arrThumbnail);
}
}
}
closedir($objDirectory);
return true;
}
示例5: _getThumbs
/**
* Get thumbnails
*
* Get the thumbnails from a day in the archive.
* Create the thumbnails if they don't already exists.
*
* @access private
*/
function _getThumbs()
{
$path = ASCMS_DOCUMENT_ROOT . "/" . $this->camSettings['archivePath'] . '/' . $this->date . '/';
$objDirectory = @opendir($path);
$chmoded = false;
if ($objDirectory) {
while ($file = readdir($objDirectory)) {
if ($file != "." && $file != "..") {
//check and create thumbs
$thumb = ASCMS_DOCUMENT_ROOT . $this->camSettings['thumbnailPath'] . '/tn_' . $this->date . '_' . $file;
if (!\Cx\Lib\FileSystem\FileSystem::exists($thumb)) {
if (!$chmoded) {
\Cx\Lib\FileSystem\FileSystem::chmod($this->camSettings['thumbnailPath'], '777');
$chmoded = true;
}
//create thumb
$im1 = @imagecreatefromjpeg($path . $file);
//erstellt ein Abbild im Speicher
if ($im1) {
/* Pr�fen, ob fehlgeschlagen */
// check_jpeg($thumb, $fix=false );
$size = getimagesize($path . $file);
//ermittelt die Gr��e des Bildes
$breite = $size[0];
//die Breite des Bildes
$hoehe = $size[1];
//die H�he des Bildes
$breite_neu = $this->camSettings['thumbMaxSize'];
//die breite des Thumbnails
$factor = $breite / $this->camSettings['thumbMaxSize'];
//berechnungsfaktor
$hoehe_neu = $size[1] / $factor;
//die H�he des Thumbnails
//$im2=imagecreate($breite_neu,$hoehe_neu); //Thumbnail im Speicher erstellen
$im2 = @imagecreatetruecolor($breite_neu, $hoehe_neu);
imagecopyresized($im2, $im1, 0, 0, 0, 0, $breite_neu, $hoehe_neu, $breite, $hoehe);
imagejpeg($im2, $thumb);
//Thumbnail speichern
imagedestroy($im1);
//Speicherabbild wieder l�schen
imagedestroy($im2);
//Speicherabbild wieder l�schen
}
}
//show pictures
$minHour = date('G', $this->camSettings['showFrom']);
$minMinutes = date('i', $this->camSettings['showFrom']);
$maxHour = date('G', $this->camSettings['showTill']);
$maxMinutes = date('i', $this->camSettings['showTill']);
$hour = substr($file, 4, 2);
$min = substr($file, 13, 2);
$min = !empty($min) ? $min : "00";
$time = $hour . ":" . $min . " Uhr";
$minTime = mktime($minHour, $minMinutes);
$maxTime = mktime($maxHour, $maxMinutes);
$nowTime = mktime($hour, $min);
/*
* only show archive images if they are in range
*/
if ($nowTime <= $maxTime && $nowTime >= $minTime) {
if ($this->camSettings['shadowboxActivate'] == 1) {
$linkUrl = ASCMS_PATH_OFFSET . $this->camSettings['archivePath'] . '/' . $this->date . '/' . $file;
} else {
$linkUrl = '?section=Livecam&file=' . $this->date . '/' . $file;
}
$arrThumbnail = array('link_url' => $linkUrl, 'image_url' => $this->camSettings['thumbnailPath'] . "/tn_" . $this->date . "_" . $file, 'time' => $time);
array_push($this->_arrArchiveThumbs, $arrThumbnail);
}
}
}
closedir($objDirectory);
}
}
示例6: showCams
/**
* Show the cameras
*
* @access private
* @global array
* @global array
* @global array
*/
function showCams()
{
global $_ARRAYLANG, $_CONFIG, $_CORELANG;
$this->_pageTitle = $_ARRAYLANG['TXT_SETTINGS'];
$this->_objTpl->loadTemplateFile('module_livecam_cams.html');
$amount = $this->arrSettings['amount_of_cams'];
$cams = $this->getCamSettings();
$this->_objTpl->setGlobalVariable(array('TXT_SETTINGS' => $_ARRAYLANG['TXT_SETTINGS'], 'TXT_CURRENT_IMAGE_URL' => $_ARRAYLANG['TXT_CURRENT_IMAGE_URL'], 'TXT_ARCHIVE_PATH' => $_ARRAYLANG['TXT_ARCHIVE_PATH'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_THUMBNAIL_PATH' => $_ARRAYLANG['TXT_THUMBNAIL_PATH'], 'TXT_SHADOWBOX_ACTIVE' => $_CORELANG['TXT_ACTIVATED'], 'TXT_SHADOWBOX_INACTIVE' => $_CORELANG['TXT_DEACTIVATED'], 'TXT_ACTIVATE_SHADOWBOX' => $_ARRAYLANG['TXT_ACTIVATE_SHADOWBOX'], 'TXT_ACTIVATE_SHADOWBOX_INFO' => $_ARRAYLANG['TXT_ACTIVATE_SHADOWBOX_INFO'], 'TXT_MAKE_A_FRONTEND_PAGE' => $_ARRAYLANG['TXT_MAKE_A_FRONTEND_PAGE'], 'TXT_CURRENT_IMAGE_MAX_SIZE' => $_ARRAYLANG['TXT_CURRENT_IMAGE_MAX_SIZE'], 'TXT_THUMBNAIL_MAX_SIZE' => $_ARRAYLANG['TXT_THUMBNAIL_MAX_SIZE'], 'TXT_CAM' => $_ARRAYLANG['TXT_CAM'], 'TXT_SUCCESS' => $_CORELANG['TXT_SETTINGS_UPDATED'], 'TXT_TO_MODULE' => $_ARRAYLANG['TXT_LIVECAM_TO_MODULE'], 'TXT_SHOWFROM' => $_ARRAYLANG['TXT_LIVECAM_SHOWFROM'], 'TXT_SHOWTILL' => $_ARRAYLANG['TXT_LIVECAM_SHOWTILL'], 'TXT_OCLOCK' => $_ARRAYLANG['TXT_LIVECAM_OCLOCK']));
for ($i = 1; $i <= $amount; $i++) {
if ($cams[$i]['shadowboxActivate'] == 1) {
$shadowboxActive = 'checked="checked"';
$shadowboxInctive = '';
} else {
$shadowboxActive = '';
$shadowboxInctive = 'checked="checked"';
}
try {
// fetch CMD specific livecam page
$camUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Livecam', $i, FRONTEND_LANG_ID, array(), '', false);
} catch (\Cx\Core\Routing\UrlException $e) {
// fetch generic livecam page
$camUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Livecam');
}
$this->_objTpl->setVariable(array('CAM_NUMBER' => $i, 'LIVECAM_CAM_URL' => $camUrl, 'CURRENT_IMAGE_URL' => $cams[$i]['currentImagePath'], 'ARCHIVE_PATH' => $cams[$i]['archivePath'], 'THUMBNAIL_PATH' => $cams[$i]['thumbnailPath'], 'SHADOWBOX_ACTIVE' => $shadowboxActive, 'SHADOWBOX_INACTIVE' => $shadowboxInctive, 'CURRENT_IMAGE_MAX_SIZE' => $cams[$i]['maxImageWidth'], 'THUMBNAIL_MAX_SIZE' => $cams[$i]['thumbMaxSize'], 'HOUR_FROM' => $this->getHourOptions($cams[$i]['showFrom']), 'MINUTE_FROM' => $this->getMinuteOptions($cams[$i]['showFrom']), 'HOUR_TILL' => $this->getHourOptions(!empty($cams[$i]['showTill']) ? $cams[$i]['showTill'] : mktime(23)), 'MINUTE_TILL' => $this->getMinuteOptions(!empty($cams[$i]['showTill']) ? $cams[$i]['showTill'] : mktime(0, 59))));
if (preg_match("/^https{0,1}:\\/\\//", $cams[$i]['currentImagePath'])) {
$filepath = $cams[$i]['currentImagePath'];
$this->_objTpl->setVariable("PATH", $filepath);
$this->_objTpl->parse("current_image");
} else {
$filepath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $cams[$i]['currentImagePath'];
if (\Cx\Lib\FileSystem\FileSystem::exists($filepath) && is_file($filepath)) {
$this->_objTpl->setVariable("PATH", $cams[$i]['currentImagePath']);
$this->_objTpl->parse("current_image");
} else {
$this->_objTpl->hideBlock("current_image");
}
}
$this->_objTpl->parse("cam");
/*
$this->_objTpl->setVariable('BLOCK_USE_BLOCK_SYSTEM', $_CONFIG['blockStatus'] == '1' ? 'checked="checked"' : '');
*/
}
}
示例7: generateThumbnail
/**
* Regenerate the thumbnails
*
* @param array $post $_POST values
*/
protected function generateThumbnail($post)
{
// release the locks, session not needed
$session = \cmsSession::getInstance();
$session->releaseLocks();
session_write_close();
$cx = Cx::instanciate();
$key = $_GET['key'];
if (!preg_match("/[A-Z0-9]{5}/i", $key)) {
die;
}
$processFile = $session->getTempPath() . '/progress' . $key . '.txt';
if (\Cx\Lib\FileSystem\FileSystem::exists($processFile)) {
die;
}
try {
$objProcessFile = new \Cx\Lib\FileSystem\File($processFile);
$objProcessFile->touch();
} catch (\Cx\Lib\FileSystem\FileSystemException $ex) {
die;
}
$recursiveIteratorIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($cx->getWebsiteImagesPath() . '/'), \RecursiveIteratorIterator::SELF_FIRST);
$jsonFileArray = array();
$thumbnailList = UploaderConfiguration::getInstance()->getThumbnails();
$imageManager = new \ImageManager();
$fileCounter = 0;
$generalSuccess = true;
$imageFiles = array();
foreach ($recursiveIteratorIterator as $file) {
/**
* @var $file \SplFileInfo
*/
$extension = 'Dir';
if (!$file->isDir()) {
$extension = ucfirst(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
}
$filePathinfo = pathinfo($file->getRealPath());
$fileNamePlain = $filePathinfo['filename'];
// set preview if image
$preview = 'none';
$fileInfos = array('filepath' => mb_strcut($file->getPath() . '/' . $file->getFilename(), mb_strlen($cx->getCodeBasePath())), 'name' => $file->getFilename(), 'cleansize' => $file->getSize(), 'extension' => ucfirst(mb_strtolower($extension)), 'type' => $file->getType());
// filters
if ($fileInfos['name'] == '.' || preg_match('/\\.thumb/', $fileInfos['name']) || $fileInfos['name'] == 'index.php' || 0 === strpos($fileInfos['name'], '.')) {
continue;
}
if (!preg_match("/(jpg|jpeg|gif|png)/i", ucfirst($extension))) {
continue;
}
$imageFiles[] = $file;
}
$imageFilesCount = count($imageFiles);
if ($imageFilesCount == 0) {
$objProcessFile->write(100);
die;
}
foreach ($imageFiles as $file) {
/**
* @var $file \SplFileInfo
*/
$extension = 'Dir';
if (!$file->isDir()) {
$extension = ucfirst(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
}
$filePathinfo = pathinfo($file->getRealPath());
$fileNamePlain = $filePathinfo['filename'];
$fileInfos = array('filepath' => mb_strcut($file->getPath() . '/' . $file->getFilename(), mb_strlen(ASCMS_PATH)), 'name' => $file->getFilename(), 'cleansize' => $file->getSize(), 'extension' => ucfirst(mb_strtolower($extension)), 'type' => $file->getType());
$filePathinfo = pathinfo($file->getRealPath());
$fileExtension = isset($filePathinfo['extension']) ? $filePathinfo['extension'] : '';
$preview = $cx->getCodeBaseOffsetPath() . str_replace($cx->getCodeBaseDocumentRootPath(), '', $file->getRealPath());
$previewList = array();
foreach ($thumbnailList as $thumbnail) {
$previewList[] = str_replace('.' . lcfirst($extension), $thumbnail['value'] . '.' . lcfirst($extension), $preview);
}
$allThumbnailsExists = true;
foreach ($previewList as $previewImage) {
if (!FileSystem::exists($previewImage)) {
$allThumbnailsExists = false;
}
}
if (!$allThumbnailsExists) {
if ($imageManager->_isImage($file->getRealPath())) {
ThumbnailGenerator::createThumbnail($file->getPath(), $fileNamePlain, $fileExtension, $imageManager, true);
}
}
$fileCounter++;
$objProcessFile->write($fileCounter / $imageFilesCount * 100);
}
$objProcessFile->write(100);
die;
}
示例8: cmsSessionDestroy
/**
* Callable on session destroy
*
* @param type $aKey
* @param type $destroyCookie
* @return boolean
*/
function cmsSessionDestroy($aKey, $destroyCookie = true)
{
$query = "DELETE FROM " . DBPREFIX . "sessions WHERE sessionid = '" . $aKey . "'";
\Env::get('db')->Execute($query);
$query = "DELETE FROM " . DBPREFIX . "session_variable WHERE sessionid = '" . $aKey . "'";
\Env::get('db')->Execute($query);
if (\Cx\Lib\FileSystem\FileSystem::exists($this->sessionPath)) {
\Cx\Lib\FileSystem\FileSystem::delete_folder($this->sessionPath, true);
}
if ($destroyCookie) {
setcookie("PHPSESSID", '', time() - 3600, '/');
}
// do not write the session data
$this->discardChanges = true;
return true;
}
示例9: getUploadedFilePath
/**
* Get uploaded file path by using uploader id and file name
*
* @param string $uploaderId Uploader id
* @param string $fileName File name
*
* @return boolean|string File path when File exists, false otherwise
*/
public function getUploadedFilePath($uploaderId, $fileName)
{
global $sessionObj;
if (empty($uploaderId) || empty($fileName)) {
return false;
}
if (empty($sessionObj)) {
$sessionObj = \cmsSession::getInstance();
}
$uploaderFolder = $sessionObj->getTempPath() . '/' . $uploaderId;
if (!\Cx\Lib\FileSystem\FileSystem::exists($uploaderFolder)) {
return false;
}
$filePath = $uploaderFolder . '/' . $fileName;
if (!\Cx\Lib\FileSystem\FileSystem::exists($filePath)) {
return false;
}
return $filePath;
}
示例10: uploadMedia
/**
* Upload the media files
*
* @param string $fileName name of the media file
* @param string $path folder path
* @param string $uploaderId uploader id
*
* @return string $status name of the uploaded file / error
*/
function uploadMedia($fileName, $path, $uploaderId)
{
if (empty($uploaderId) || empty($fileName)) {
return 'error';
}
$cx = \Cx\Core\Core\Controller\Cx::instanciate();
$objSession = $cx->getComponent('Session')->getSession();
$tempPath = $objSession->getTempPath() . '/' . $uploaderId . '/' . $fileName;
//Check the uploaded file exists in /tmp folder
if (!\Cx\Lib\FileSystem\FileSystem::exists($tempPath)) {
//If the file still exists in the mediaPath then return the filename
if (\Cx\Lib\FileSystem\FileSystem::exists($this->mediaPath . $path . $fileName)) {
return $fileName;
}
return 'error';
}
$info = pathinfo($fileName);
$exte = $info['extension'];
$extension = !empty($exte) ? '.' . $exte : '';
$file = substr($fileName, 0, strlen($fileName) - strlen($extension));
$rand = rand(10, 99);
$arrSettings = $this->getSettings();
if ($arrSettings['encodeFilename']['value'] == 1) {
$fileName = md5($rand . $file) . $extension;
}
//Rename the file if the filename already exists
while (\Cx\Lib\FileSystem\FileSystem::exists($this->mediaPath . $path . $fileName)) {
$fileName = $file . '_' . time() . $extension;
}
$filePath = $this->mediaPath . $path . $fileName;
if (!\FWValidator::is_file_ending_harmless($filePath)) {
return 'error';
}
//Move the file from /tmp folder into mediaPath and set the permission
try {
$objFile = new \Cx\Lib\FileSystem\File($tempPath);
if ($objFile->move($filePath, false)) {
$fileObj = new \File();
$fileObj->setChmod($this->mediaPath, $this->mediaWebPath, $path . $fileName);
$status = $fileName;
}
} catch (\Cx\Lib\FileSystem\FileSystemException $e) {
\DBG::msg($e->getMessage());
$status = 'error';
}
//make the thumb
if (($exte == "gif" || $exte == "jpeg" || $exte == "jpg" || $exte == "png") && $path != "uploads/") {
$this->createThumb($fileName, $path);
}
return $status;
}
示例11: notifyCallback
/**
* Notifies the callback. Invoked on upload completion.
*/
public function notifyCallback()
{
//temporary path where files were uploaded
$tempDir = '/upload_' . $this->uploadId;
$tempPath = $_SESSION->getTempPath() . $tempDir;
$tempWebPath = $_SESSION->getWebTempPath() . $tempDir;
//we're going to call the callbck, so the data is not needed anymore
//well... not quite sure. need it again in contact form.
//TODO: code session cleanup properly if time.
//$this->cleanupCallbackData();
$classFile = $this->callbackData[0];
//call the callback, get return code
if ($classFile != null) {
if (!file_exists($classFile)) {
throw new UploaderException("Class file '{$classFile}' specified for callback does not exist!");
}
require_once $this->callbackData[0];
}
$originalFileNames = array();
if (isset($_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'])) {
$originalFileNames = $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'];
}
//various file infos are passed via this array
$fileInfos = array('originalFileNames' => $originalFileNames);
$response = null;
//the response data.
if (isset($_SESSION['upload']['handlers'][$this->uploadId]['response_data'])) {
$response = UploadResponse::fromSession($_SESSION['upload']['handlers'][$this->uploadId]['response_data']);
} else {
$response = new UploadResponse();
}
$ret = call_user_func(array($this->callbackData[1], $this->callbackData[2]), $tempPath, $tempWebPath, $this->getData(), $this->uploadId, $fileInfos, $response);
//clean up session: we do no longer need the array with the original file names
unset($_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames']);
//same goes for the data
//if(isset($_SESSION['upload']['handlers'][$this->uploadId]['data']))
// TODO: unset this when closing the uploader dialog, but not before
// unset($_SESSION['upload']['handlers'][$this->uploadId]['data']);
if (\Cx\Lib\FileSystem\FileSystem::exists($tempWebPath)) {
//the callback could have returned a path where he wants the files moved to
// check that $ret[1] is not empty is VERY important!!!
if (!is_null($ret) && !empty($ret[1])) {
//we need to move the files
//gather target information
$path = pathinfo($ret[0]);
$pathWeb = pathinfo($ret[1]);
//make sure the target directory is writable
\Cx\Lib\FileSystem\FileSystem::makeWritable($pathWeb['dirname'] . '/' . $path['basename']);
//revert $path and $pathWeb to whole path instead of pathinfo path for copying
$path = $path['dirname'] . '/' . $path['basename'] . '/';
$pathWeb = $pathWeb['dirname'] . '/' . $pathWeb['basename'] . '/';
//trailing slash needed for File-class calls
$tempPath .= '/';
$tempWebPath .= '/';
//move everything uploaded to target dir
$h = opendir($tempPath);
$im = new \ImageManager();
while (false != ($f = readdir($h))) {
//skip . and ..
if ($f == '.' || $f == '..') {
continue;
}
//TODO: if return value = 'error' => react
\Cx\Lib\FileSystem\FileSystem::move($tempWebPath . $f, $pathWeb . $f, true);
if ($im->_isImage($path . $f)) {
$im->_createThumb($path, $pathWeb, $f);
}
$response->increaseUploadedFilesCount();
}
closedir($h);
} else {
// TODO: what now????
}
//delete the folder
\Cx\Lib\FileSystem\FileSystem::delete_folder($tempWebPath, true);
} else {
// TODO: output error message to user that no files had been uploaded!!!
}
$response->uploadFinished();
$_SESSION['upload']['handlers'][$this->uploadId]['response_data'] = $response->toSessionValue();
}
示例12: getUploadedFileFromUploader
/**
* Get uploaded zip file by using uploader id
*
* @param string $uploaderId Uploader id
*
* @return boolean|string File path when file exists, false otherwise
*/
public function getUploadedFileFromUploader($uploaderId)
{
global $sessionObj;
if (empty($uploaderId)) {
\DBG::log('Uploader id is empty');
return false;
}
if (empty($sessionObj)) {
$sessionObj = \cmsSession::getInstance();
}
$uploaderFolder = $sessionObj->getTempPath() . '/' . $uploaderId;
if (!\Cx\Lib\FileSystem\FileSystem::exists($uploaderFolder)) {
\DBG::log('The Uploader Folder path is invalid/not exists');
return false;
}
foreach (glob($uploaderFolder . '/*.zip') as $file) {
return $file;
}
return false;
}
示例13: _import
/**
* Import and Export data from/to csv
* @author Reto Kohli <reto.kohli@comvation.com> (parts)
*/
function _import()
{
global $_ARRAYLANG, $objDatabase;
self::$pageTitle = $_ARRAYLANG['TXT_SHOP_IMPORT_TITLE'];
self::$objTemplate->loadTemplateFile('module_shop_import.html');
self::$objTemplate->setGlobalVariable(array('TXT_SHOP_IMPORT_CATEGORIES_TIPS' => contrexx_raw2xhtml($_ARRAYLANG['TXT_SHOP_IMPORT_CATEGORIES_TIPS']), 'TXT_SHOP_IMPORT_CHOOSE_TEMPLATE_TIPS' => contrexx_raw2xhtml($_ARRAYLANG['TXT_SHOP_IMPORT_CHOOSE_TEMPLATE_TIPS'])));
$objCSVimport = new CsvImport();
// Delete template
if (isset($_REQUEST['deleteImg'])) {
$query = "\n DELETE FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_importimg\n WHERE img_id=" . $_REQUEST['img'];
if ($objDatabase->Execute($query)) {
\Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_DELETED']);
} else {
\Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_ERROR_DELETE']);
}
}
// Save template
if (isset($_REQUEST['SaveImg'])) {
$query = "\n INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_importimg (\n img_name, img_cats, img_fields_file, img_fields_db\n ) VALUES (\n '" . $_REQUEST['ImgName'] . "',\n '" . $_REQUEST['category'] . "',\n '" . $_REQUEST['pairs_left_keys'] . "',\n '" . $_REQUEST['pairs_right_keys'] . "'\n )";
if ($objDatabase->Execute($query)) {
\Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_SAVED']);
} else {
\Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_ERROR_SAVE']);
}
}
$objCSVimport->initTemplateArray();
$fileExists = false;
$fileName = isset($_POST['csvFile']) ? contrexx_input2raw($_POST['csvFile']) : '';
$uploaderId = isset($_POST['importCsvUploaderId']) ? contrexx_input2raw($_POST['importCsvUploaderId']) : '';
if (!empty($fileName) && !empty($uploaderId)) {
$objSession = \cmsSession::getInstance();
$tmpFile = $objSession->getTempPath() . '/' . $uploaderId . '/' . $fileName;
$fileExists = \Cx\Lib\FileSystem\FileSystem::exists($tmpFile);
}
// Import Categories
// This is not subject to change, so it's hardcoded
if (isset($_REQUEST['ImportCategories']) && $fileExists) {
// delete existing categories on request only!
// mind that this necessarily also clears all products and
// their associated attributes!
if (!empty($_POST['clearCategories'])) {
Products::deleteByShopCategory(0, false, true);
ShopCategories::deleteAll();
// NOTE: Removing Attributes is now disabled. Optionally enable this.
// Attributes::deleteAll();
}
$objCsv = new CsvBv($tmpFile);
$importedLines = 0;
$arrCategoryLevel = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$line = $objCsv->NextLine();
while ($line) {
$level = 0;
foreach ($line as $catName) {
++$level;
if (!empty($catName)) {
$parentCatId = $objCSVimport->getCategoryId($catName, $arrCategoryLevel[$level - 1]);
$arrCategoryLevel[$level] = $parentCatId;
}
}
++$importedLines;
$line = $objCsv->NextLine();
}
\Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_IMPORTED_CATEGORIES'] . ': ' . $importedLines);
}
// Import
if (isset($_REQUEST['importFileProducts']) && $fileExists) {
if (isset($_POST['clearProducts']) && $_POST['clearProducts']) {
Products::deleteByShopCategory(0, false, true);
// The categories need not be removed, but it is done by design!
ShopCategories::deleteAll();
// NOTE: Removing Attributes is now disabled. Optionally enable this.
// Attributes::deleteAll();
}
$arrFileContent = $objCSVimport->GetFileContent($tmpFile);
$query = '
SELECT img_id, img_name, img_cats, img_fields_file, img_fields_db
FROM ' . DBPREFIX . 'module_shop' . MODULE_INDEX . '_importimg
WHERE img_id=' . $_REQUEST['ImportImage'];
$objResult = $objDatabase->Execute($query);
$arrCategoryName = preg_split('/;/', $objResult->fields['img_cats'], null, PREG_SPLIT_NO_EMPTY);
$arrFirstLine = $arrFileContent[0];
$arrCategoryColumnIndex = array();
for ($x = 0; $x < count($arrCategoryName); ++$x) {
foreach ($arrFirstLine as $index => $strColumnName) {
if ($strColumnName == $arrCategoryName[$x]) {
$arrCategoryColumnIndex[] = $index;
}
}
}
$arrTemplateFieldName = preg_split('/;/', $objResult->fields['img_fields_file'], null, PREG_SPLIT_NO_EMPTY);
$arrDatabaseFieldIndex = array();
for ($x = 0; $x < count($arrTemplateFieldName); ++$x) {
foreach ($arrFirstLine as $index => $strColumnName) {
if ($strColumnName == $arrTemplateFieldName[$x]) {
$arrDatabaseFieldIndex[] = $index;
}
//.........这里部分代码省略.........
示例14: show_section
//.........这里部分代码省略.........
$element = \Html::getInputFileupload($name, $value ? $name : false, Filetype::MAXIMUM_UPLOAD_FILE_SIZE, $arrSetting['values'], 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''), true, $value ? $value : 'media/' . (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'other'));
// File uploads must be multipart encoded
$enctype = 'enctype="multipart/form-data"';
break;
case self::TYPE_BUTTON:
// The button is only available to trigger some event.
$event = 'onclick=\'' . 'if (confirm("' . $_ARRAYLANG[$prefix . strtoupper($name) . '_CONFIRM'] . '")) {' . 'document.getElementById("' . $name . '").value=1;' . 'document.formSettings_' . self::$tab_index . '.submit();' . '}\'';
//DBG::log("\Cx\Core\Setting\Controller\Setting::show_section(): Event: $event");
$element = \Html::getInputButton('__' . $name, $_ARRAYLANG[strtoupper($prefix . $name) . '_LABEL'], 'button', false, $event . ($readOnly ? \Html::ATTRIBUTE_DISABLED : '')) . \Html::getHidden($name, 0, '');
//DBG::log("\Cx\Core\Setting\Controller\Setting::show_section(): Element: $element");
break;
case self::TYPE_TEXTAREA:
$element = \Html::getTextarea($name, $value, 80, 8, $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
// 'style="width: '.self::DEFAULT_INPUT_WIDTH.'px;'.$value_align.'"');
break;
case self::TYPE_CHECKBOX:
$arrValues = self::splitValues($arrSetting['values']);
$value_true = current($arrValues);
$element = \Html::getCheckbox($name, $value_true, false, in_array($value, $arrValues), '', $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
break;
case self::TYPE_CHECKBOXGROUP:
$checked = self::splitValues($value);
$element = \Html::getCheckboxGroup($name, $values, $values, $checked, '', '', '<br />', $readOnly ? \Html::ATTRIBUTE_DISABLED : '', '');
break;
// 20120508 UNTESTED!
// 20120508 UNTESTED!
case self::TYPE_RADIO:
$checked = $value;
$element = \Html::getRadioGroup($name, $values, $checked, '', $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
break;
case self::TYPE_PASSWORD:
$element = \Html::getInputPassword($name, $value, 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
break;
//datepicker
//datepicker
case self::TYPE_DATE:
$element = \Html::getDatepicker($name, array('defaultDate' => $value), 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"');
break;
//datetimepicker
//datetimepicker
case self::TYPE_DATETIME:
$element = \Html::getDatetimepicker($name, array('defaultDate' => $value), 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"');
break;
case self::TYPE_IMAGE:
$cx = \Cx\Core\Core\Controller\Cx::instanciate();
if (!empty($arrSetting['value']) && \Cx\Lib\FileSystem\FileSystem::exists($cx->getWebsitePath() . '/' . $arrSetting['value'])) {
$element .= \Html::getImageByPath($cx->getWebsitePath() . '/' . $arrSetting['value'], 'id="' . $name . 'Image" ') . ' ';
}
$element .= \Html::getHidden($name, $arrSetting['value'], $name);
$mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
$mediaBrowser->setCallback($name . 'Callback');
$mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'filebrowser'));
$element .= $mediaBrowser->getXHtml($_ARRAYLANG['TXT_BROWSE']);
\JS::registerCode('
function ' . $name . 'Callback(data) {
if (data.type === "file" && data.data[0]) {
var filePath = data.data[0].datainfo.filepath;
jQuery("#' . $name . '").val(filePath);
jQuery("#' . $name . 'Image").attr("src", filePath);
}
}
jQuery(document).ready(function(){
var imgSrc = jQuery("#' . $name . 'Image").attr("src");
jQuery("#' . $name . 'Image").attr("src", imgSrc + "?t=" + new Date().getTime());
});
');
break;
// Default to text input fields
// Default to text input fields
case self::TYPE_TEXT:
case self::TYPE_EMAIL:
default:
$element = \Html::getInputText($name, $value, false, 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;' . (is_numeric($value) ? 'text-align: right;' : '') . '"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
}
//add Tooltip
$toolTips = '';
$toolTipsHelp = '';
if (isset($_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP'])) {
// generate tooltip for configuration option
$toolTips = ' <span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP'] . '</span>';
}
if (isset($_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP_HELP'])) {
// generate tooltip for configuration option
$toolTipsHelp = ' <span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP_HELP'] . '</span>';
}
$objTemplateLocal->setVariable(array('CORE_SETTING_NAME' => (isset($_ARRAYLANG[$prefix . strtoupper($name)]) ? $_ARRAYLANG[$prefix . strtoupper($name)] : $name) . $toolTips, 'CORE_SETTING_VALUE' => $element . $toolTipsHelp, 'CORE_SETTING_ROWCLASS2' => ++$i % 2 ? '1' : '2'));
$objTemplateLocal->parseCurrentBlock();
//echo("\Cx\Core\Setting\Controller\Setting::show(objTemplateLocal, $prefix): shown $name => $value<br />");
}
// Set form encoding to multipart if necessary
if (!empty($enctype)) {
$objTemplateLocal->setVariable('CORE_SETTING_ENCTYPE', $enctype);
}
if (!empty($section) && $objTemplateLocal->blockExists('core_setting_section')) {
//echo("\Cx\Core\Setting\Controller\Setting::show(objTemplateLocal, $header, $prefix): creating section $header<br />");
$objTemplateLocal->setVariable(array('CORE_SETTING_SECTION' => $section));
//$objTemplateLocal->parse('core_setting_section');
}
return true;
}
示例15: isFileValidToShow
/**
* Return whether file is valid to show or not
*
* @param string $filePath Folder path to the file
* @param string $fileName File name
*
* @return boolean True when file is valid to show, False otherwise
*/
public function isFileValidToShow($filePath, $fileName)
{
if (empty($filePath) || empty($fileName) || self::isIllegalFileName($fileName)) {
return false;
}
if (preg_match("/(?:\\.(?:thumb_thumbnail|thumb_medium|thumb_large)\\.[^.]+\$)|(?:\\.thumb)\$/i", $fileName)) {
$originalFileName = preg_replace("/(?:\\.(?:thumb_thumbnail|thumb_medium|thumb_large)(\\.[^.]+)\$)|(?:\\.thumb)\$/mi", "\$1", $fileName);
if (!\Cx\Lib\FileSystem\FileSystem::exists($filePath . '/' . $originalFileName)) {
\Cx\Lib\FileSystem\FileSystem::delete_file($filePath . '/' . $fileName);
}
return false;
}
return true;
}