/**
  * Constructs a new Debug-Object.
  *
  * The first parameter has to be the file name with extension, but without directory.
  * Standard value is null, then the filename will be "internal.log".
  * The second parameter has to be a valid and existing directory with trailing slash.
  * Standard value is also null, then the directory will be "data/logs/" (make sure that it is writable).
  * If the specified file doesn't exist, it will created.
  * If it is not possible to create a file nn Exception will be thrown.
  *
  * @param string File for saving the logdata or null (filename is internal.log then)
  * @param string Directory for saving the logfile or null (directory is data/logs/ then)
  * @throws Exception
  */
 public function __construct($file = null, $dir = null)
 {
     if ($dir == null || is_dir($dir) == false) {
         $dir = 'data/logs/';
     }
     if ($file == null) {
         $file = 'internal.log';
     }
     $this->file = new File($dir . basename($file));
     if ($this->file->create() == false) {
         throw new Exception('Could not create log file in method Debug::__construct().');
     }
     if ($this->file->readable() == false || $this->file->writable() == false) {
         $writable = new CHMOD(666);
         $this->file->setChmod($writable);
     }
     $this->logs = array();
     $this->benchmarks = array();
     $this->temp = array();
 }
 /**
  * Constructor
  *
  * @access   public
  * @global    array
  * @global    InitCMS
  * @global    \Cx\Core\Html\Sigma
  * @global    ADONewConnection
  */
 function __construct()
 {
     global $objInit;
     $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_MODULE_PATH . '/Directory/View/Template/Backend');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $this->langId = $objInit->userFrontendLangId;
     $this->path = ASCMS_DIR_PATH . '/';
     $this->webPath = ASCMS_DIR_WEB_PATH . '/';
     $this->imagePath = ASCMS_DIR_PATH . '/View/Media';
     $this->imageWebPath = ASCMS_DIR_WEB_PATH . '/View/Media';
     $this->mediaPath = ASCMS_MODULE_MEDIA_PATH . '/';
     $this->mediaWebPath = ASCMS_MODULE_MEDIA_WEB_PATH . '/';
     $this->rssPath = \Env::get('cx')->getWebsiteFeedPath() . '/';
     $this->rssWebPath = ASCMS_FEED_WEB_PATH . '/';
     //check chmod
     $obj_file = new \File();
     $obj_file->setChmod(mediaPath, $this->mediaWebPath, "");
     //get settings
     $this->settings = $this->getSettings();
 }
 /**
  * Copy the Upload the image to the path
  * Note: validation should be done before calling this function
  *
  * @param string $filePath Temp path of the uploaded media
  *
  * @return boolean|string relative path of the uploaded file, false otherwise
  */
 function uploadMedia($filePath)
 {
     if ($filePath == '' || !\FWValidator::is_file_ending_harmless($filePath)) {
         return false;
     }
     $fileName = basename($filePath);
     //get extension
     $arrFileInfo = pathinfo($fileName);
     $fileExtension = !empty($arrFileInfo['extension']) ? '.' . $arrFileInfo['extension'] : '';
     $fileBasename = $arrFileInfo['filename'];
     $randomSum = rand(10, 99);
     //encode filename
     if ($this->arrSettings['settingsEncryptFilenames'] == 1) {
         $fileName = md5($randomSum . $fileBasename) . $fileExtension;
     }
     //check filename
     if (file_exists($this->imagePath . 'uploads/' . $fileName)) {
         $fileName = $fileBasename . '_' . time() . $fileExtension;
     }
     //upload file
     if (\Cx\Lib\FileSystem\FileSystem::copy_file($filePath, $this->imagePath . 'uploads/' . $fileName) !== false) {
         $objFile = new \File();
         $objFile->setChmod($this->imagePath, $this->imageWebPath, 'uploads/' . $fileName);
         return $this->imageWebPath . 'uploads/' . $fileName;
     } else {
         return false;
     }
 }
 /**
  * createXML: parse out the XML
  *
  * @global  ADONewConnection
  * @global  array
  * @return  void
  */
 function createFiles()
 {
     global $objDatabase, $_ARRAYLANG;
     $arrModules = array();
     $arrLanguages = array();
     $arrModulesPath = array();
     $arrModuleVariables = array();
     $arrErrorFiles = array();
     $objFile = new File();
     $strHeader = "/**\n* Contrexx CMS\n* generated date " . date('r', time()) . "\n**/\n\n";
     // generate the arrays $arrModulesPath and $arrModules
     $query = "SELECT id, name, is_core FROM " . DBPREFIX . "modules";
     $objResult = $objDatabase->Execute($query);
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             if (strlen($objResult->fields['name']) > 0) {
                 switch ($objResult->fields['name']) {
                     case 'core':
                         $arrModulesPath[$objResult->fields['name']]['sys'] = ASCMS_DOCUMENT_ROOT;
                         $arrModulesPath[$objResult->fields['name']]['web'] = ASCMS_PATH_OFFSET;
                         break;
                     case 'Media1':
                         $arrModulesPath['Media']['sys'] = ASCMS_CORE_MODULE_PATH . '/Media';
                         $arrModulesPath['Media']['web'] = ASCMS_CORE_MODULE_WEB_PATH . '/Media';
                         $objResult->fields['name'] = 'Media';
                         break;
                     case 'Media2':
                     case 'Media3':
                         $objResult->fields['name'] = "";
                         break;
                     default:
                         $arrModulesPath[$objResult->fields['name']]['sys'] = ($objResult->fields['is_core'] == 1 ? ASCMS_CORE_MODULE_PATH : ASCMS_MODULE_PATH) . '/' . $objResult->fields['name'];
                         $arrModulesPath[$objResult->fields['name']]['web'] = ($objResult->fields['is_core'] == 1 ? ASCMS_CORE_MODULE_WEB_PATH : ASCMS_MODULE_WEB_PATH) . '/' . $objResult->fields['name'];
                 }
                 if (!empty($objResult->fields['name'])) {
                     $arrModulesPath[$objResult->fields['name']]['sys'] .= '/lang/';
                     $arrModulesPath[$objResult->fields['name']]['web'] .= '/lang/';
                 }
             }
             $arrModules[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'name' => $objResult->fields['name']);
             $objResult->MoveNext();
         }
     }
     // get language array
     $query = "SELECT id, lang FROM " . DBPREFIX . "languages";
     $objResult = $objDatabase->Execute($query);
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $arrLanguages[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'lang' => $objResult->fields['lang']);
             $objResult->MoveNext();
         }
     }
     // get language variables
     $query = "SELECT vn.name, vn.module_id, vn.backend, vn.frontend, vc.content, vc.lang_id\n                    FROM " . DBPREFIX . "language_variable_names AS vn,\n                         " . DBPREFIX . "language_variable_content AS vc\n                   WHERE vn.id=vc.varid";
     // generate array $arrModuleVariables including the variables
     $objResult = $objDatabase->Execute($query);
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             if ($objResult->fields['module_id'] == 0) {
                 $moduleId = 1;
             } else {
                 $moduleId = $objResult->fields['module_id'];
             }
             if ($objResult->fields['backend'] == 1) {
                 $arrModuleVariables[$moduleId][$objResult->fields['lang_id']]['backend'][$objResult->fields['name']] = $objResult->fields['content'];
             }
             if ($objResult->fields['frontend'] == 1) {
                 $arrModuleVariables[$moduleId][$objResult->fields['lang_id']]['frontend'][$objResult->fields['name']] = $objResult->fields['content'];
             }
             $objResult->MoveNext();
         }
     }
     // generate array $arrOutput with the data to write into files
     foreach ($arrModuleVariables as $moduleId => $arrLanguageVariables) {
         foreach ($arrLanguageVariables as $langId => $arrModeVariables) {
             $filePath = $arrModulesPath[$arrModules[$moduleId]['name']]['sys'] . $arrLanguages[$langId]['lang'] . '/';
             $webFilePath = $arrModulesPath[$arrModules[$moduleId]['name']]['web'] . $arrLanguages[$langId]['lang'] . '/';
             if (!file_exists($filePath)) {
                 $objFile->mkDir($arrModulesPath[$arrModules[$moduleId]['name']]['sys'], $arrModulesPath[$arrModules[$moduleId]['name']]['web'], $arrLanguages[$langId]['lang'] . '/');
             }
             foreach ($arrModeVariables as $strMode => $arrVariables) {
                 $fileName = $strMode . ".php";
                 $arrOutput[$filePath . $fileName]['filename'] = $fileName;
                 $arrOutput[$filePath . $fileName]['path'] = $filePath;
                 $arrOutput[$filePath . $fileName]['webpath'] = $webFilePath;
                 foreach ($arrVariables as $strName => $strContent) {
                     //$strContent = stripslashes(stripslashes($strContent));
                     //$strContent = str_replace("\"", "\\\"", $strContent);
                     //$strContent = addslashes($strContent);
                     if (isset($arrOutput[$filePath . $fileName]['content'])) {
                         $arrOutput[$filePath . $fileName]['content'] .= "\$" . "_ARRAYLANG['" . $strName . "'] = \"" . $strContent . "\";\n";
                     } else {
                         $arrOutput[$filePath . $fileName]['content'] = "\$" . "_ARRAYLANG['" . $strName . "'] = \"" . $strContent . "\";\n";
                     }
                 }
             }
         }
     }
     unset($arrModuleVariables);
     // write variables to files
     foreach ($arrOutput as $file => $strOutput) {
         $objFile->setChmod($strOutput['path'], $strOutput['webpath'], '');
         $objFile->setChmod($strOutput['path'], $strOutput['webpath'], $strOutput['filename']);
         $fileHandle = fopen($file, "w");
         if ($fileHandle) {
             @fwrite($fileHandle, "<?php\n" . $strHeader . $strOutput['content'] . "?>\n");
             @fclose($fileHandle);
         } else {
             array_push($arrErrorFiles, $file);
         }
     }
     unset($arrOutput);
     if (count($arrErrorFiles) > 0) {
         foreach ($arrErrorFiles as $file) {
             $this->strErrMessage .= "<br />" . $_ARRAYLANG['TXT_COULD_NOT_WRITE_TO_FILE'] . " (" . $file . ")";
         }
     } else {
         $this->strOkMessage .= "<br />" . $_ARRAYLANG['TXT_SUCCESSFULLY_EXPORTED_TO_FILES'];
     }
 }
 /**
  * create xml
  *
  * create xml
  *
  * @access   public
  * @param    string  $link
  * @return   string  $filename
  */
 function createXML($link)
 {
     //copy
     $time = time();
     $filename = $time . "_" . basename($link);
     $rand = rand(10, 99);
     $arrSettings = $this->getSettings();
     if ($arrSettings['encodeFilename']['value'] == 1) {
         // TODO: $fileName is neither set nor used!
         //            $fileName = md5($rand.$filename)."xml";
         $filename = md5($rand . $filename) . "xml";
     }
     if (!@copy($link, $this->mediaPath . "ext_feeds/" . $filename)) {
         return "error";
     } else {
         //rss class
         $rss = new \XML_RSS($this->mediaPath . "ext_feeds/" . $filename);
         $rss->parse();
         $content = '';
         foreach ($rss->getStructure() as $array) {
             $content .= $array;
         }
         //set chmod
         $obj_file = new \File();
         $obj_file->setChmod($this->mediaPath, $this->mediaWebPath, "ext_feeds/" . $filename);
         if ($content == '') {
             //del xml
             @unlink($this->mediaPath . "ext_feeds/" . $filename);
             return "error";
         } else {
             return $filename;
         }
     }
 }
 function uploadMedia($intInputfieldId, $langId)
 {
     global $objDatabase;
     if (isset($_FILES)) {
         $tmpFile = $_FILES['fileUpload_' . $intInputfieldId]['tmp_name'][$langId];
         $fileName = $_FILES['fileUpload_' . $intInputfieldId]['name'][$langId];
         $fileType = $_FILES['fileUpload_' . $intInputfieldId]['type'][$langId];
         $fileSize = $_FILES['fileUpload_' . $intInputfieldId]['size'][$langId];
         if ($fileName != "") {
             //get extension
             $arrFileInfo = pathinfo($fileName);
             $fileExtension = !empty($arrFileInfo['extension']) ? '.' . $arrFileInfo['extension'] : '';
             $fileBasename = $arrFileInfo['filename'];
             $randomSum = rand(10, 99);
             //encode filename
             if ($this->arrSettings['settingsEncryptFilenames'] == 1) {
                 $fileName = md5($randomSum . $fileBasename) . $fileExtension;
             }
             //check filename
             if (file_exists($this->imagePath . 'uploads/' . $fileName)) {
                 $fileName = $fileBasename . '_' . time() . $fileExtension;
             }
             //upload file
             if (move_uploaded_file($tmpFile, $this->imagePath . 'uploads/' . $fileName)) {
                 $objFile = new \File();
                 $objFile->setChmod($this->imagePath, $this->imageWebPath, 'uploads/' . $fileName);
                 return $this->imageWebPath . 'uploads/' . $fileName;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #7
0
 /**
  * Process upload form
  *
  * @global     array    $_ARRAYLANG
  * @return     boolean  true if file uplod successfully and false if it failed
  */
 private function processFormUpload()
 {
     global $_ARRAYLANG;
     $objSession = \cmsSession::getInstance();
     $uploaderId = isset($_POST['media_upload_file']) ? contrexx_input2raw($_POST['media_upload_file']) : 0;
     if (empty($uploaderId)) {
         return false;
     }
     $tempPath = $objSession->getTempPath() . '/' . contrexx_input2raw($uploaderId);
     if (!\Cx\Lib\FileSystem\FileSystem::exists($tempPath)) {
         return false;
     }
     $errorMsg = array();
     foreach (glob($tempPath . '/*') as $file) {
         $i = 0;
         $fileName = basename($file);
         $path = $tempPath . '/' . $fileName;
         $file = $this->path . $fileName;
         $arrFile = pathinfo($file);
         while (file_exists($file)) {
             $suffix = '-' . (time() + ++$i);
             $file = $this->path . $arrFile['filename'] . $suffix . '.' . $arrFile['extension'];
         }
         if (!\FWValidator::is_file_ending_harmless($path)) {
             $errorMsg[] = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_EXTENSION_NOT_ALLOWED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET));
             continue;
         }
         try {
             $objFile = new \Cx\Lib\FileSystem\File($path);
             $objFile->move($file, false);
             $fileObj = new \File();
             $fileObj->setChmod($this->path, $this->webPath, basename($file));
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
             $errorMsg[] = sprintf($_ARRAYLANG['TXT_MEDIA_FILE_UPLOAD_FAILED'], htmlentities($fileName, ENT_QUOTES, CONTREXX_CHARSET));
         }
     }
     if (!empty($errorMsg)) {
         $this->_strErrorMessage = explode('<br>', $errorMsg);
         return false;
     }
     $this->_strOkMessage = $_ARRAYLANG['TXT_MEDIA_FILE_UPLOADED_SUCESSFULLY'];
     return true;
 }
 /**
  * Copy the Upload the image to the path
  * Note: validation should be done before calling this function
  * 
  * @param string $imagePath Temp path of the uploaded media
  * 
  * @return boolean|string relative path of the uploaded file, false otherwise
  */
 function uploadMedia($imagePath)
 {
     if ($imagePath == '' || !\FWValidator::is_file_ending_harmless($imagePath)) {
         return false;
     }
     // get extension
     $imageName = basename($imagePath);
     $arrImageInfo = pathinfo($imageName);
     $imageExtension = !empty($arrImageInfo['extension']) ? '.' . $arrImageInfo['extension'] : '';
     $imageBasename = $arrImageInfo['filename'];
     $randomSum = rand(10, 99);
     // encode filename
     if ($this->arrSettings['settingsEncryptFilenames'] == 1) {
         $imageName = md5($randomSum . $imageBasename) . $imageExtension;
     }
     // check filename
     if (file_exists($this->imagePath . 'images/' . $imageName)) {
         $imageName = $imageBasename . '_' . time() . $imageExtension;
     }
     // upload file
     if (\Cx\Lib\FileSystem\FileSystem::copy_file($imagePath, $this->imagePath . 'images/' . $imageName) === false) {
         return false;
     }
     $imageDimension = getimagesize($this->imagePath . 'images/' . $imageName);
     $intNewWidth = $imageDimension[0];
     $intNewHeight = $imageDimension[1];
     $imageFormat = $imageDimension[0] > $imageDimension[1] ? 1 : 0;
     $setNewSize = 0;
     if ($imageDimension[0] > 640 && $imageFormat == 1) {
         $doubleFactorDimension = 640 / $imageDimension[0];
         $intNewWidth = 640;
         $intNewHeight = round($doubleFactorDimension * $imageDimension[1], 0);
         $setNewSize = 1;
     } elseif ($imageDimension[1] > 480) {
         $doubleFactorDimension = 480 / $imageDimension[1];
         $intNewHeight = 480;
         $intNewWidth = round($doubleFactorDimension * $imageDimension[0], 0);
         $setNewSize = 1;
     }
     if ($setNewSize == 1) {
         $objImage = new \ImageManager();
         $objImage->loadImage($this->imagePath . 'images/' . $imageName);
         $objImage->resizeImage($intNewWidth, $intNewHeight, 100);
         $objImage->saveNewImage($this->imagePath . 'images/' . $imageName, true);
     }
     $objFile = new \File();
     $objFile->setChmod($this->imagePath, $this->imageWebPath, 'images/' . $imageName);
     // create thumbnail
     $this->checkThumbnail($this->imageWebPath . 'images/' . $imageName);
     return $this->imageWebPath . 'images/' . $imageName;
 }
 function _modifyTicker()
 {
     global $_ARRAYLANG, $objDatabase;
     $id = !empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $pos = !empty($_REQUEST['pos']) ? intval($_REQUEST['pos']) : 0;
     $defaultCharset = CONTREXX_CHARSET;
     if ($arrTicker = $this->_getTicker($id)) {
         $this->pageTitle = $_ARRAYLANG['TXT_NEWS_MODIFY_TICKER'];
         $name = $arrTicker['name'];
         $charset = $arrTicker['charset'];
         $urlencode = $arrTicker['urlencode'];
         $prefix = $arrTicker['prefix'];
     } else {
         $id = 0;
         $this->pageTitle = $_ARRAYLANG['TXT_NEWS_CREATE_TICKER'];
         $name = '';
         $charset = $defaultCharset;
         $content = '';
         $urlencode = 0;
         $prefix = '';
     }
     if (isset($_POST['news_save_ticker'])) {
         $newName = isset($_POST['news_ticker_filename']) ? contrexx_stripslashes(trim($_POST['news_ticker_filename'])) : '';
         $charset = isset($_POST['news_ticker_charset']) ? addslashes($_POST['news_ticker_charset']) : '';
         $content = isset($_POST['news_ticker_content']) ? contrexx_stripslashes($_POST['news_ticker_content']) : '';
         $urlencode = isset($_POST['news_ticker_urlencode']) ? intval($_POST['news_ticker_urlencode']) : 0;
         $prefix = isset($_POST['news_ticker_prefix']) ? contrexx_stripslashes($_POST['news_ticker_prefix']) : '';
         if (!empty($newName)) {
             if ($name != $newName && file_exists(\Env::get('cx')->getWebsiteFeedPath() . '/' . $newName)) {
                 $this->strErrMessage = sprintf($_ARRAYLANG['TXT_NEWS_FILE_DOES_ALREADY_EXIST'], htmlentities($newName, ENT_QUOTES, CONTREXX_CHARSET), \Env::get('cx')->getWebsiteFeedPath()) . '<br />';
                 $this->strErrMessage .= $_ARRAYLANG['TXT_NEWS_SELECT_OTHER_FILENAME'];
             } elseif ($name != $newName && !@touch(\Env::get('cx')->getWebsiteFeedPath() . '/' . $newName)) {
                 $this->strErrMessage = sprintf($_ARRAYLANG['TXT_NEWS_COULD_NOT_ATTACH_FILE'], htmlentities($newName, ENT_QUOTES, CONTREXX_CHARSET), \Env::get('cx')->getWebsiteFeedPath() . '/') . '<br />';
                 $this->strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWS_SET_CHMOD'], \Env::get('cx')->getWebsiteFeedPath() . '/');
             } else {
                 if ($objDatabase->Execute(($id > 0 ? "UPDATE" : "INSERT INTO") . " `" . DBPREFIX . "module_news_ticker` SET `name` = '" . addslashes($newName) . "', `charset` = '" . addslashes($charset) . "', `urlencode` = " . $urlencode . ", `prefix` = '" . addslashes($prefix) . "'" . ($id > 0 ? " WHERE `id` = " . $id : ''))) {
                     $objFile = new \File();
                     $objFile->setChmod(\Env::get('cx')->getWebsiteFeedPath(), ASCMS_FEED_WEB_PATH, $newName);
                     $fpTicker = @fopen(\Env::get('cx')->getWebsiteFeedPath() . '/' . $newName, 'wb');
                     if ($fpTicker) {
                         if ($defaultCharset != $charset) {
                             $content = iconv($defaultCharset, $charset, $content);
                             $prefix = iconv($defaultCharset, $charset, $prefix);
                         }
                         $content2w = $prefix . ($urlencode ? rawurlencode($content) : $content);
                         if (@fwrite($fpTicker, $content2w) !== false) {
                             $this->strOkMessage = $_ARRAYLANG['TXT_NEWS_NEWSTICKER_SUCCESSFULLY_UPDATED'];
                             if ($name != $newName && file_exists(\Env::get('cx')->getWebsiteFeedPath() . '/' . $name)) {
                                 @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/' . $name);
                             }
                             return $this->_tickerOverview();
                         } else {
                             $this->strErrMessage = sprintf($_ARRAYLANG['TXT_NEWS_UNABLE_TO_UPDATE_FILE'], htmlentities($newName, ENT_QUOTES, CONTREXX_CHARSET), \Env::get('cx')->getWebsiteFeedPath() . '/') . '<br />';
                             $this->strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWS_SET_CHMOD'], \Env::get('cx')->getWebsiteFeedPath() . '/' . $newName);
                         }
                     } else {
                         $this->strErrMessage = sprintf($_ARRAYLANG['TXT_NEWS_FILE_DOES_NOT_EXIST'], \Env::get('cx')->getWebsiteFeedPath() . '/' . $newName);
                     }
                 } else {
                     $this->strErrMessage = $_ARRAYLANG['TXT_NEWS_UNABLE_TO_RENAME_NEWSTICKER'];
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/' . $newName);
                 }
             }
         } else {
             $this->strErrMessage = $_ARRAYLANG['TXT_NEWS_YOU_MUST_SET_FILENAME'];
         }
         $name = $newName;
     } elseif ($id > 0) {
         if (!file_exists(\Env::get('cx')->getWebsiteFeedPath() . '/' . $name) && !@touch(\Env::get('cx')->getWebsiteFeedPath() . '/' . $name)) {
             $this->strErrMessage = sprintf($_ARRAYLANG['TXT_NEWS_COULD_NOT_ATTACH_FILE'], htmlentities($name, ENT_QUOTES, CONTREXX_CHARSET), \Env::get('cx')->getWebsiteFeedPath() . '/') . '<br />';
             $this->strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWS_SET_CHMOD'], \Env::get('cx')->getWebsiteFeedPath() . '/');
         } else {
             $content = file_get_contents(\Env::get('cx')->getWebsiteFeedPath() . '/' . $name);
             if (!empty($prefix) && strpos($content, $prefix) === 0) {
                 $content = substr($content, strlen($prefix));
             }
             if ($urlencode) {
                 $content = rawurldecode($content);
             }
             if ($charset != $defaultCharset) {
                 $content = iconv($charset, $defaultCharset, $content);
                 $prefix = iconv($charset, $defaultCharset, $prefix);
             }
         }
     }
     $this->_objTpl->addBlockfile('NEWS_TICKER_TEMPLATE', 'module_news_ticker_modify', 'module_news_ticker_modify.html');
     $this->_objTpl->setVariable(array('TXT_NEWS_FILENAME' => $_ARRAYLANG['TXT_NEWS_FILENAME'], 'TXT_NEWS_MODIFY_FILENAME' => $_ARRAYLANG['TXT_NEWS_MODIFY_FILENAME'], 'TXT_NEWS_CONTENT' => $_ARRAYLANG['TXT_NEWS_CONTENT'], 'TXT_NEWS_CHARSET' => $_ARRAYLANG['TXT_NEWS_CHARSET'], 'TXT_NEWS_SAVE' => $_ARRAYLANG['TXT_NEWS_SAVE'], 'TXT_NEWS_CANCEL' => $_ARRAYLANG['TXT_NEWS_CANCEL'], 'TXT_NEWS_URL_ENCODING' => $_ARRAYLANG['TXT_NEWS_URL_ENCODING'], 'TXT_NEWS_URL_ENCODING_TXT' => $_ARRAYLANG['TXT_NEWS_URL_ENCODING_TXT'], 'TXT_NEWS_PREFIX' => $_ARRAYLANG['TXT_NEWS_PREFIX'], 'TXT_NEWS_TICKER_PREFIX_MSG' => $_ARRAYLANG['TXT_NEWS_TICKER_PREFIX_MSG'], 'TXT_NEWS_GENERAL' => $_ARRAYLANG['TXT_NEWS_GENERAL'], 'TXT_NEWS_ADVANCED' => $_ARRAYLANG['TXT_NEWS_ADVANCED']));
     $this->_objTpl->setVariable(array('NEWS_MODIFY_TITLE_TXT' => $id > 0 ? $_ARRAYLANG['TXT_NEWS_MODIFY_TICKER'] : $_ARRAYLANG['TXT_NEWS_CREATE_TICKER'], 'NEWS_TICKER_ID' => $id, 'NEWS_TICKER_FILENAME' => htmlentities($name, ENT_QUOTES, CONTREXX_CHARSET), 'NEWS_TICKER_CHARSET_MENU' => $this->_getCharsetMenu($charset, 'name="news_ticker_charset"'), 'NEWS_TICKER_CONTENT' => htmlentities($content, ENT_QUOTES, CONTREXX_CHARSET), 'NEWS_TICKER_URLENCODE' => $urlencode ? 'checked="checked"' : '', 'NEWS_TICKER_POS' => $pos, 'NEWS_TICKER_PREFIX' => $prefix));
     $this->_objTpl->parse('module_news_ticker_modify');
 }
Example #10
0
 /**
  * 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;
 }
Example #11
0
 function copyPicture($fileName)
 {
     $fileNameOri = $fileName;
     if (!empty($fileName)) {
         $path = "pictures/";
         $info = pathinfo($fileName);
         $exte = $info['extension'];
         $exte = !empty($exte) ? '.' . $exte : '';
         $part1 = substr($fileName, 0, strlen($fileName) - strlen($exte));
         $rand = rand(10, 99);
         $fileName = md5($rand . $fileName) . $exte;
         //check file
         // TODO: $x is not defined
         $x = 0;
         if (file_exists($this->mediaPath . $path . $fileName)) {
             $fileName = $rand . $part1 . '_' . (time() + $x) . $exte;
             $fileName = md5($fileName) . $exte;
         }
         $objFile = new \File();
         $objFile->copyFile($this->mediaPath . $path, $fileNameOri, $this->mediaPath . $path, $fileName);
         $objFile->setChmod($this->mediaPath, $this->mediaWebPath, $path . $fileName);
         return $fileName;
     } else {
         return '';
     }
 }
 function uploadMedia($intInputfieldId, $langId)
 {
     if (empty($_FILES)) {
         return false;
     }
     $tmpImage = $_FILES['imageUpload_' . $intInputfieldId]['tmp_name'][$langId];
     $imageName = $_FILES['imageUpload_' . $intInputfieldId]['name'][$langId];
     //        $imageType  = $_FILES['imageUpload_'.$intInputfieldId]['type'];
     //        $imageSize  = $_FILES['imageUpload_'.$intInputfieldId]['size'];
     if ($imageName == '') {
         return false;
     }
     // get extension
     $arrImageInfo = pathinfo($imageName);
     $imageExtension = !empty($arrImageInfo['extension']) ? '.' . $arrImageInfo['extension'] : '';
     $imageBasename = $arrImageInfo['filename'];
     $randomSum = rand(10, 99);
     // encode filename
     if ($this->arrSettings['settingsEncryptFilenames'] == 1) {
         $imageName = md5($randomSum . $imageBasename) . $imageExtension;
     }
     // check filename
     if (file_exists($this->imagePath . 'images/' . $imageName)) {
         $imageName = $imageBasename . '_' . time() . $imageExtension;
     }
     // upload file
     if (!move_uploaded_file($tmpImage, $this->imagePath . 'images/' . $imageName)) {
         return false;
     }
     $imageDimension = getimagesize($this->imagePath . 'images/' . $imageName);
     $intNewWidth = $imageDimension[0];
     $intNewHeight = $imageDimension[1];
     $imageFormat = $imageDimension[0] > $imageDimension[1] ? 1 : 0;
     $setNewSize = 0;
     if ($imageDimension[0] > 640 && $imageFormat == 1) {
         $doubleFactorDimension = 640 / $imageDimension[0];
         $intNewWidth = 640;
         $intNewHeight = round($doubleFactorDimension * $imageDimension[1], 0);
         $setNewSize = 1;
     } elseif ($imageDimension[1] > 480) {
         $doubleFactorDimension = 480 / $imageDimension[1];
         $intNewHeight = 480;
         $intNewWidth = round($doubleFactorDimension * $imageDimension[0], 0);
         $setNewSize = 1;
     }
     if ($setNewSize == 1) {
         $objImage = new \ImageManager();
         $objImage->loadImage($this->imagePath . 'images/' . $imageName);
         $objImage->resizeImage($intNewWidth, $intNewHeight, 100);
         $objImage->saveNewImage($this->imagePath . 'images/' . $imageName, true);
     }
     $objFile = new \File();
     $objFile->setChmod($this->imagePath, $this->imageWebPath, 'images/' . $imageName);
     // create thumbnail
     $this->checkThumbnail($this->imageWebPath . 'images/' . $imageName);
     return $this->imageWebPath . 'images/' . $imageName;
 }