Пример #1
0
 /**
  * Get the default language.
  *
  * @param boolean guessFromNavigator : try to guess default user language from HTTP_ACCEPT_LANGUAGE (default : false)
  * @return CMS_language The default language
  * @access public
  */
 static function getDefaultLanguage($guessFromNavigator = false)
 {
     if ($guessFromNavigator) {
         //load language object from get value if any
         if (isset($_GET["language"]) && SensitiveIO::isInSet($_GET["language"], array_keys(CMS_languagesCatalog::getAllLanguages()))) {
             $language = CMS_languagesCatalog::getByCode($_GET["language"]);
             if ($language) {
                 return $language;
             }
         } elseif (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && SensitiveIO::isInSet(io::substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2), array_keys(CMS_languagesCatalog::getAllLanguages()))) {
             $language = CMS_languagesCatalog::getByCode(io::substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2));
             if ($language) {
                 return $language;
             }
         }
     }
     return CMS_languagesCatalog::getByCode(APPLICATION_DEFAULT_LANGUAGE);
 }
Пример #2
0
 public static function getNewsletterContent($pageId)
 {
     $page = CMS_tree::getPageByID($pageId);
     if ($page->hasError()) {
         return;
     }
     $website = $page->getWebsite();
     $websiteUrl = $website->getURL();
     $language = CMS_languagesCatalog::getByCode($page->getLanguage());
     $content = $page->getContent($language, PAGE_VISUALMODE_HTML_PUBLIC);
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $page);
     $modulesTreatment->setDefinition($content);
     $content = $modulesTreatment->treatContent(true);
     //eval all php code in page
     $php_evalued_content = io::evalPHPCode($content);
     //change all relative URL in page
     $parsed_content = self::prepareHTML($php_evalued_content, $websiteUrl);
     return $parsed_content;
 }
Пример #3
0
 /**
  * Gets the data in HTML mode.
  *
  * @param CMS_language &$language The language of the administration frontend
  * @param CMS_page &$page The page which contains the client space
  * @param CMS_clientSpace &$clientSpace The client space which contains the row
  * @param CMS_row &$row The row which contains the block
  * @param integer $visualizationMode The visualization mode used
  * @return string the HTML data
  * @access public
  */
 function getData(&$language, &$page, &$clientSpace, &$row, $visualizationMode)
 {
     parent::getData($language, $page, $clientSpace, $row, $visualizationMode);
     //get the data
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, true);
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, false);
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_FORM:
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_EDITION, false);
             break;
     }
     //build the HTML
     $html_attributes = "";
     foreach ($this->_attributes as $name => $value) {
         if ($name != "module" && $name != "type") {
             $html_attributes .= ' ' . $name . '="' . $value . '"';
         }
     }
     $src = '';
     $this->_hasContent = $data && $data["file"] ? true : false;
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             if ($this->_hasContent) {
                 $language = CMS_languagesCatalog::getByCode($page->getLanguage(true));
                 $src = PATH_MODULES_FILES_STANDARD_WR . '/public/' . $data["file"];
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             if ($this->_hasContent) {
                 $language = CMS_languagesCatalog::getByCode($page->getLanguage(false));
                 $src = PATH_MODULES_FILES_STANDARD_WR . '/edited/' . $data["file"];
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
             if ($this->_hasContent) {
                 $language = CMS_languagesCatalog::getByCode($page->getLanguage(false));
                 $src = PATH_MODULES_FILES_STANDARD_WR . '/edition/' . $data["file"];
             }
             break;
         case PAGE_VISUALMODE_FORM:
             $this->_editable = true;
             if ($this->_hasContent) {
                 $language = CMS_languagesCatalog::getByCode($page->getLanguage(false));
                 $src = PATH_MODULES_FILES_STANDARD_WR . '/edition/' . $data["file"];
             } else {
                 $html = '<img src="' . PATH_MODULES_FILES_STANDARD_WR . '/flash.gif" alt="X" title="X" />';
                 $form_data = str_replace("{{data}}", $html, $this->_definition);
                 return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             }
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $this->_hasContent = false;
             $this->_editable = false;
             $html = '<img src="' . PATH_MODULES_FILES_STANDARD_WR . '/flash.gif" alt="X" title="X" />';
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
     if (!$src) {
         return '';
     }
     $id = $data["name"] ? 'flash-' . sensitiveIO::sanitizeHTMLString($data["name"]) : 'flash-' . md5(mt_rand() . microtime());
     $html = '<div>' . "\n" . '	<script type="text/javascript">' . "\n" . '		swfobject.embedSWF(\'' . $src . '\', \'' . $id . '\', \'' . $data['width'] . '\', \'' . $data['height'] . '\', \'' . $data['version'] . '\', "' . PATH_MAIN_WR . '/swfobject/expressInstall.swf", {' . sensitiveIO::sanitizeJSString($data['flashvars'], false, false) . '}, {' . sensitiveIO::sanitizeJSString($data['params'], false, false) . '}, {' . sensitiveIO::sanitizeJSString($data['attributes'], false, false) . '});' . "\n" . '	</script>' . "\n" . '	<div id="' . $id . '" class="atm-blockflash" style="width:' . $data["width"] . 'px;height:' . $data["height"] . 'px;">' . "\n" . '		<noscript>' . $language->getMessage(self::MESSAGE_PAGE_JAVASCRIPT_MANDATORY) . '</noscript>' . "\n" . '		<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>' . "\n" . '	</div>' . '</div>' . "\n";
     $blockinfos = array('blockflash' => array());
     $blockinfos['blockflash'] = true;
     CMS_module::moduleUsage($page->getID(), MOD_STANDARD_CODENAME, $blockinfos);
     if ($visualizationMode != PAGE_VISUALMODE_FORM) {
         return str_replace("{{data}}", $html, $this->_definition);
     } else {
         $form_data = str_replace("{{data}}", $html, $this->_definition);
         return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
     }
 }
Пример #4
0
}
if (!$action) {
    $view->setContent($content);
    CMS_grandFather::raiseError('Unknown action ... ' . $action);
    $view->show();
}
if (!$code && !$selectedCode) {
    CMS_grandFather::raiseError('Missing language code ... ');
    $view->setContent($content);
    $view->show();
}
$cms_message = '';
switch ($action) {
    case 'save':
        if ($code) {
            $language = CMS_languagesCatalog::getByCode($code);
            if (!$language || $language->hasError()) {
                CMS_grandFather::raiseError('Unknown language code : ' . $code);
                $view->setContent($content);
                $view->show();
            }
        } else {
            $language = new CMS_language();
            $language->setCode($selectedCode);
            $languagesCodes = CMS_languagesCatalog::getAllLanguagesCodes();
            $language->setLabel($languagesCodes[$selectedCode]);
        }
        $language->setDateFormat($dateFormat);
        if ($modulesDenied) {
            $modulesDenied = array_map('trim', explode(',', $modulesDenied));
            $language->setModulesDenied($modulesDenied);
Пример #5
0
 /**
  * Constructor.
  * Loads all Id variables if
  *
  * @param integer $id id of profile in DB
  * @return  void
  * @access public
  */
 function __construct($id = false)
 {
     // Initiate Stack objects
     $this->_alerts = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tprofilesUsers,\n\t\t\t\t\tcontactDatas,\n\t\t\t\t\tprofiles\n\t\t\t\twhere\n\t\t\t\t\tid_pru='{$id}' and\n\t\t\t\t\tid_cd=contactData_pru and\n\t\t\t\t\tid_pr=profile_pru\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
         } else {
             $this->raiseError("Unknown DB ID : " . $id);
             $this->_language = new CMS_language();
             $this->_contactData = CMS_contactDatas_catalog::getByUser(array());
             // Initialize super class
             parent::__construct();
         }
         if (isset($data) && is_array($data)) {
             $this->_userId = $id;
             $this->_login = $data["login_pru"];
             $this->_password = $data["password_pru"];
             $this->_firstName = $data["firstName_pru"];
             $this->_lastName = $data["lastName_pru"];
             parent::__construct($data);
             $this->_language = CMS_languagesCatalog::getByCode($data["language_pru"]);
             $this->_active = $data["active_pru"];
             $this->_deleted = $data["deleted_pru"];
             $this->_favorites = $data["favorites_pru"] ? explode(',', $data["favorites_pru"]) : array();
             $this->_alerts->setTextDefinition($data["alerts_pru"]);
             $this->_contactData = CMS_contactDatas_catalog::getByUser($data);
         }
     } else {
         $this->_language = new CMS_language();
         $this->_contactData = CMS_contactDatas_catalog::getByUser(array());
         // Initialize super class
         parent::__construct();
     }
 }
Пример #6
0
        $body .= 'User : '******'REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . ')' . "\n\n";
    } else {
        $body .= 'User : '******'REMOTE_ADDR'] . "\n\n";
    }
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $body .= 'Browser : ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n";
    }
    $body .= 'Host : ' . $_SERVER['HTTP_HOST'] . ' (' . $_SERVER['SERVER_ADDR'] . ")\n\n";
    $body .= 'This email is automaticaly sent from your website. You can stop this sending with the parameter ERROR404 EMAIL ALERT.';
    $mail = new CMS_email();
    $mail->setSubject("404 Error in " . APPLICATION_LABEL);
    $mail->setBody($body);
    $mail->setEmailFrom(APPLICATION_POSTMASTER_EMAIL . "<" . APPLICATION_POSTMASTER_EMAIL . ">");
    $mail->setEmailTo(APPLICATION_MAINTAINER_EMAIL);
    $mainURL = CMS_websitesCatalog::getMainURL();
    $cms_language = CMS_languagesCatalog::getByCode('en');
    $mail->setFooter($cms_language->getMessage(CMS_emailsCatalog::MESSAGE_EMAIL_BODY_URLS, array(APPLICATION_LABEL, $mainURL . "/", $mainURL . PATH_ADMIN_WR . "/")));
    $mail->setTemplate(PATH_MAIL_TEMPLATES_FS);
    $mail->sendEmail();
}
//try to get website by path to serve specific 404 page
$path = pathinfo(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), PATHINFO_DIRNAME);
$website = null;
if ($path && $path != '/') {
    $websites = CMS_websitesCatalog::getAll('order');
    foreach ($websites as $website) {
        if ($website->getPagesPath(PATH_RELATIVETO_WEBROOT)) {
            if (strpos($path, $website->getPagesPath(PATH_RELATIVETO_WEBROOT)) === 0 && is_object($website->get404())) {
                break;
            }
        }
Пример #7
0
 /**
  * get object HTML description for admin search detail. Usually, the label.
  *
  * @return string : object HTML description
  * @access public
  */
 function getHTMLDescription()
 {
     if (!$this->_subfieldValues[0]->getValue()) {
         return '';
     }
     $language = CMS_languagesCatalog::getByCode($this->_subfieldValues[0]->getValue());
     if (!$language) {
         return '';
     }
     return $language->getLabel();
 }
Пример #8
0
/***************************************\
*            SEARCH ENGINES             *
\***************************************/
$description = sensitiveIO::sanitizeJSString($cms_page->getDescription());
$keywords = sensitiveIO::sanitizeJSString($cms_page->getKeywords());
$category = sensitiveIO::sanitizeJSString($cms_page->getCategory());
$robots = sensitiveIO::sanitizeJSString($cms_page->getRobots());
/***************************************\
*              META-DATAS               *
\***************************************/
if (!NO_PAGES_EXTENDED_META_TAGS) {
    $author = sensitiveIO::sanitizeJSString($cms_page->getAuthor());
    $replyTo = sensitiveIO::sanitizeJSString($cms_page->getReplyto());
    $copyright = sensitiveIO::sanitizeJSString($cms_page->getCopyright());
}
$language = CMS_languagesCatalog::getByCode($cms_page->getLanguage());
$pageLanguage = sensitiveIO::sanitizeJSString($language->getLabel());
$languageValue = $language->getCode();
$pragmaValue = $cms_page->getPragma() != '' ? 'true' : 'false';
$languages = CMS_languagesCatalog::getAllLanguages(MOD_STANDARD_CODENAME);
$languagesDatas = array();
foreach ($languages as $aLanguage) {
    $languagesDatas[] = array($aLanguage->getCode(), $aLanguage->getLabel());
}
$languagesDatas = sensitiveIO::jsonEncode($languagesDatas);
$metas = sensitiveIO::sanitizeJSString($cms_page->getMetas(), false, true, true);
//this is a textarea, we must keep cariage return
/***************************************\
*               SUB-PAGES               *
\***************************************/
$siblings = '';
Пример #9
0
 /**
  * Import module datas
  * 
  * @param mixed $datas, the import datas
  * @param string $format, the import format in : php (default), xml
  * @param CMS_language $cms_language, the current cms_language to use. Passed by reference to temporary overwrite it with import language
  * @param string $infos (reference), the returned import infos
  * @return boolean : the import status
  */
 function import($datas, $format = 'php', &$cms_language, &$infos)
 {
     $infos = '';
     $return = true;
     switch ($format) {
         case 'xml':
             //convert XML to PHP array
             $xml2Array = new CMS_xml2Array($datas, CMS_xml2Array::XML_ARRAY2XML_FORMAT);
             $importedArray = $xml2Array->getParsedArray();
             break;
         case 'php':
             //try to eval PHP Array
             if (!is_array($datas)) {
                 $infos .= 'Error : PHP datas must be a valid PHP array ... ' . "\n";
                 return false;
             } else {
                 $importedArray = $datas;
             }
             break;
         default:
             $infos .= 'Error : Unknown import format ... ' . $format . "\n";
             return false;
             break;
     }
     if (!isset($importedArray) || !is_array($importedArray)) {
         $infos .= 'Error : no datas to import or incorrect datas ...' . "\n";
         return false;
     }
     if (isset($importedArray['version'])) {
         $version = $importedArray['version'];
         unset($importedArray['version']);
     } else {
         $version = '';
     }
     //Check for version compliance
     if ($version && version_compare(AUTOMNE_VERSION, $version, '<')) {
         $infos .= 'Error: Automne version below the version of imported datas' . "\n";
         return false;
     }
     if (isset($importedArray['language'])) {
         //force import language to overwrite user language because imported datas refer to this language
         $oldLanguage = $cms_language->getCode();
         $cms_language = CMS_languagesCatalog::getByCode($importedArray['language']);
         if (!$cms_language || $cms_language->hasError()) {
             //reload user language
             $cms_language = CMS_languagesCatalog::getByCode($oldLanguage);
         }
         unset($importedArray['language']);
     }
     //return import description if exists
     if (isset($importedArray['description']) && $importedArray['description']) {
         $infos .= '--------------------------------------------------------------------------------------------------------' . "\n";
         $infos .= 'Import description: ' . "\n";
         $infos .= io::htmlspecialchars($importedArray['description']) . "\n";
         $infos .= '--------------------------------------------------------------------------------------------------------' . "\n";
         unset($importedArray['description']);
     }
     foreach ($importedArray as $type => $data) {
         switch ($type) {
             case 'modules':
                 $idsRelation = array();
                 $importInfos = '';
                 if (CMS_modulesCatalog::fromArray($data, $this->_parameters, $cms_language, $idsRelation, $importInfos)) {
                     $infos .= 'Import completed successfully' . ($importInfos ? ': ' . "\n" . $importInfos : '') . "\n";
                 } else {
                     $infos .= 'Error: ' . "\n" . $importInfos . "\n";
                     $return &= false;
                 }
                 break;
             default:
                 $infos .= 'Error: Unknown data type to import : ' . $type . "\n";
                 $return &= false;
                 break;
         }
     }
     if (isset($importedArray['language'])) {
         //reload user language
         $cms_language = CMS_languagesCatalog::getByCode($oldLanguage);
     }
     return $return;
 }
Пример #10
0
				<input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_EXPORT_MODULE) . '" />
			</form>';
switch (io::post('action')) {
    case 'export':
        if (io::post('desc')) {
            $options['description'] = io::post('desc');
        }
        //set export parameters
        $export->setParameters($options);
        //force default language loading to overwrite user language because datas is more accurate in default language
        $oldLanguage = $cms_language->getCode();
        $cms_language = CMS_languagesCatalog::getDefaultLanguage(false);
        //export datas
        $exportDatas = $export->export($format);
        //reload user language
        $cms_language = CMS_languagesCatalog::getByCode($oldLanguage);
        switch ($format) {
            case 'php':
                $content .= '
				<br /><a name="exportDatas"></a>
				<fieldset>
					<legend>' . $cms_language->getMessage(MESSAGE_PAGE_EXPORTED_DATAS) . '</legend>
					<textarea style="width:100%;height:300px;">' . htmlspecialchars(var_export($exportDatas, true)) . '</textarea>
				</fielset>';
                break;
            case 'xml':
                $content .= '
				<br /><a name="exportDatas"></a>
				<fieldset>
					<legend>' . $cms_language->getMessage(MESSAGE_PAGE_EXPORTED_DATAS) . '</legend>
					<textarea style="width:100%;height:300px;">' . htmlspecialchars($exportDatas) . '</textarea>
Пример #11
0
 //firstname
 $user->setFirstName(ucfirst($firstname));
 //login
 if ($login && CMS_profile_usersCatalog::loginExists($login, $user)) {
     $cms_message .= $cms_language->getMessage(MESSAGE_LOGIN_EXISTS, array($login)) . "\n";
 } elseif ($login && !$user->setLogin($login)) {
     $cms_message .= $cms_language->getMessage(MESSAGE_INCORRECT_FIELD_VALUE, array($cms_language->getMessage(MESSAGE_FIELD_LOGIN))) . "\n";
 }
 //Check password fields
 if ($pass1 && $pass2 && $pass1 == $pass2 && $user->getLogin() != $pass1) {
     $user->setPassword($pass1);
 } elseif ($pass1 || $pass2) {
     $cms_message .= $cms_language->getMessage(MESSAGE_INCORRECT_PASSWORD_VALUES) . "\n";
 }
 //Update new language if necessary
 if ($newlanguage = CMS_languagesCatalog::getByCode($language)) {
     $user->setLanguage($newlanguage);
     if ($personalProfile) {
         $cms_language = $newlanguage;
         //TODOV4 : reload cms_user and user interface
         $reloadAll = true;
     }
 }
 // Check if any errors when updating user datas
 if (!$cms_message) {
     $user->writeToPersistence();
     $log = new CMS_log();
     if (!$userCreation) {
         $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_USER_EDIT, $cms_user, "User : "******" (edit personal data)");
     } else {
         $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_USER_EDIT, $cms_user, "User : "******" (user creation)");