Example #1
0
                $configFile->setContent($configContent);
                $configFile->writeToPersistence();
                $actionsDone .= '- Add HTML directory constant PATH_PAGES_HTML_WR in config.php file <br/>';
            }
        }
    } else {
        $actionsTodo .= '- Add the following config in config.php file <br/>';
        $actionsTodo .= 'define("PATH_PAGES_HTML_WR", "' . PATH_REALROOT_WR . '/html");<br/>';
    }
}
# Create config for /automne_modules_files
if (is_dir(PATH_REALROOT_FS . '/automne_modules_files') && PATH_MODULES_FILES_FS == PATH_REALROOT_FS . '/files') {
    if ($configWritable) {
        $configFile = new CMS_file(PATH_REALROOT_FS . '/config.php');
        if ($configFile->exists()) {
            $configContent = $configFile->getContent();
            if (strpos($configContent, 'PATH_MODULES_FILES_WR') === false) {
                $configContent = str_replace('?>', '//Modules files dir (DO NOT CHANGE)' . "\n" . 'define("PATH_MODULES_FILES_WR", "' . PATH_REALROOT_WR . '/automne_modules_files");' . "\n" . '?>', $configContent);
                $configFile->setContent($configContent);
                $configFile->writeToPersistence();
                $actionsDone .= '- Add modules files directory constant PATH_MODULES_FILES_WR in config.php file <br/>';
            }
        }
    } else {
        $actionsTodo .= '- Add the following config in config.php file <br/>';
        $actionsTodo .= 'define("PATH_MODULES_FILES_WR", "' . PATH_REALROOT_WR . '/automne_modules_files");<br/>';
    }
}
if ($actionsTodo) {
    $content .= '<fieldset style="padding:3px;margin:3px;"><legend>/!\\ Warning : Remaining actions to be done manually to complete update :</legend>' . $actionsTodo . '</fieldset><br />';
}
Example #2
0
 /**
  * Regenerate the page file, either from scratch or from the linx file.
  * If linx file doesn't exists, the file is regenerated from scratch (obviously).
  *
  * @param boolean $fromScratch If false, regenerate from the linx file, otherwise regenerate linx file first.
  * @return boolean true on success, false on failure
  * @access public
  */
 function regenerate($fromScratch = false)
 {
     //regenerate don't work on pages that are not public or which not have website
     if ($this->getPublication() != RESOURCE_PUBLICATION_PUBLIC || !$this->_checkWebsite()) {
         return true;
     }
     //need pageTemplate for regeneration
     $this->_checkTemplate();
     //get linx file path
     $linxFile = new CMS_file($this->getLinxFilePath());
     //should we regenerate the linx file ?
     if ($fromScratch || !$linxFile->exists()) {
         if (!$this->_template) {
             $this->raiseError('Can\'t find page template for page ' . $this->getID());
             return false;
         }
         if (!$this->writeLinxFile()) {
             return false;
         }
         //reload linx file
         $linxFile = new CMS_file($this->getLinxFilePath());
     }
     //unregister all linxes
     CMS_linxesCatalog::deleteLinxes($this);
     //instanciate modules treatments for page linx tags
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $this);
     $modulesTreatment->setDefinition($linxFile->getContent());
     if ($content = $modulesTreatment->treatContent(true)) {
         $pageHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getHTMLFilename();
         $pageFile = new CMS_file($pageHTMLPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         $pageFile->setContent($content);
         $pageFile->writeToPersistence();
         $this->_lastFileCreation->setNow();
         $this->writeToPersistence();
         //if the page is a website root, create the index page redirecting to this one
         if ($fromScratch && CMS_websitesCatalog::isWebsiteRoot($this->getID())) {
             CMS_websitesCatalog::writeRootRedirection();
         }
     } else {
         $this->raiseError('Malformed linx file');
         return false;
     }
     //write significant url page
     $pagePath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getFilename();
     $redirectionFile = new CMS_file($pagePath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
     $redirectionFile->setContent($this->redirectionCode($pageHTMLPath));
     $redirectionFile->writeToPersistence(true, true);
     //write website index
     if (CMS_websitesCatalog::isWebsiteRoot($this->getID())) {
         $ws = $this->getWebsite();
         if ($ws && !$ws->isMain()) {
             $wsPath = $ws->getPagesPath(PATH_RELATIVETO_FILESYSTEM) . '/index.php';
             $redirectionFile = new CMS_file($wsPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
             $redirectionFile->setContent($this->redirectionCode($pageHTMLPath));
             $redirectionFile->writeToPersistence(true, true);
         }
     }
     //write print page if any
     if (USE_PRINT_PAGES && $this->_template->getPrintingClientSpaces()) {
         //reload linx file
         $printLinxFile = new CMS_file($this->getLinxFilePath() . '.print', CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         if ($printLinxFile->exists()) {
             $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_PRINT, $this);
             $modulesTreatment->setDefinition($printLinxFile->getContent());
             if ($content = $modulesTreatment->treatContent(true)) {
                 $printHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getHTMLFilename();
                 $printFile = new CMS_file($printHTMLPath);
                 $printFile->setContent($content);
                 $printFile->writeToPersistence();
             } else {
                 $this->raiseError('Malformed print linx file');
                 return false;
             }
             //write significant url print page
             $printPath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getFilename();
             $redirectionFile = new CMS_file($printPath);
             $redirectionFile->setContent($this->redirectionCode($printHTMLPath));
             $redirectionFile->writeToPersistence();
         } else {
             $this->raiseError('Malformed print linx file');
             return false;
         }
     }
     return true;
 }
Example #3
0
 /**
  * Gets the definition as string data, taken from the definition file
  *
  * @return string the definition
  * @access public
  */
 function getDefinition()
 {
     if ($filename = $this->getDefinitionFile()) {
         $file = new CMS_file(PATH_TEMPLATES_FS . "/" . $filename);
         $definition = $file->getContent();
         //check if rows use a polymod block, if so pass to module for variables conversion
         foreach ($this->getModules(false) as $moduleCodename) {
             if (CMS_modulesCatalog::isPolymod($moduleCodename)) {
                 $module = CMS_modulesCatalog::getByCodename($moduleCodename);
                 $definition = $module->convertDefinitionString($definition, true);
             }
         }
         return $definition;
     }
     return false;
 }
Example #4
0
                         report($line['text'], true);
                         $installError = true;
                         break;
                 }
                 break;
         }
     }
     if ($installError) {
         report('Error during installation process :');
         report($installError, true);
     } else {
         report('-> Patch installation done without error.');
     }
 } elseif ($exportFile->exists()) {
     //Module datas to import
     $importDatas = $exportFile->getContent();
     if (!$importDatas) {
         report('Error: no content to import or invalid content...', true);
     }
     $import = new CMS_module_import();
     if (!$import->import($importDatas, 'xml', $cms_language, $importLog)) {
         report('Error during datas importation...');
     }
     if (isset($importLog) && $importLog) {
         verbose('Import log: ');
         verbose($importLog);
     }
 } else {
     report('Error : File ' . PATH_TMP_FS . '/patch does not exists ... This file is not a valid Automne patch.', true);
 }
 //remove temporary files
 /**
  * Parse the content of a template for module parameters and returns the content.
  * Usually used by the getData() function to handle template files and feed them with module parameters
  *
  * @param string $filename The filename of the template, located in the templates directory
  * @return string the data from the rows.
  * @access private
  */
 protected function _parseTemplateForParameters($filename)
 {
     $module = CMS_modulesCatalog::getByCodename($this->_attributes["module"]);
     if (!$module instanceof CMS_module) {
         $this->raiseError("No module defined for the clientspace");
         return false;
     }
     $parameters = $module->getParameters();
     $templateFile = new CMS_file(PATH_TEMPLATES_FS . "/" . $filename);
     if ($templateFile->exists()) {
         $cdata = $templateFile->getContent();
         //no need to be complicated if no parameters
         if (!$parameters) {
             return $cdata;
         }
         //"parse" template for parameters. No XML parsing (PHP code produces strange results)
         //MUST wipe out the linefeeds, because pcre's stop at them !!!
         $cdata_pcre = str_replace("\n", "§§", $cdata);
         while (true) {
             unset($regs);
             preg_match('/(.*)(<module-param [^>]*\\/>)(.*)/', $cdata_pcre, $regs);
             if (isset($regs[2])) {
                 $param_value = '';
                 $domdocument = new CMS_DOMDocument();
                 try {
                     $domdocument->loadXML('<dummy>' . $regs[2] . '</dummy>');
                 } catch (DOMException $e) {
                     $this->raiseError('Parse error during search for module-param parameters : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($regs[2]));
                     return false;
                 }
                 $paramsTags = $domdocument->getElementsByTagName('module-param');
                 foreach ($paramsTags as $paramTag) {
                     $param_value = str_replace("\n", "§§", $parameters[$paramTag->getAttribute("name")]);
                 }
                 $cdata_pcre = $regs[1] . $param_value . $regs[3];
             } else {
                 break;
             }
         }
         $cdata = str_replace("§§", "\n", $cdata_pcre);
         return $cdata;
     } else {
         $this->raiseError("Template " . $filename . " isn't readable");
         return false;
     }
 }
Example #6
0
         $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_ERROR_FILE_EXTRACT, array($filename)) . "\n";
         break;
     }
     if (!$archive->hasError()) {
         $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_MODULE_EXTRACT_DONE) . "\n";
     } else {
         $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_MODULE_EXTRACT_ERROR) . "\n";
         break;
     }
     unset($archive);
     $file = new CMS_file(PATH_TMP_FS . '/export.xml');
     if (!$file->exists()) {
         $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_MODULE_NO_EXPORT) . "\n";
         break;
     }
     $importDatas = $file->getContent();
     $format = 'xml';
 } elseif (io::post('import')) {
     $importDatas = io::post('import');
     if ($format == 'php') {
         //try to eval PHP Array
         try {
             $importDatas = eval('return ' . $importDatas . ';');
         } catch (Exception $e) {
         }
     }
 } else {
     $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_MODULE_ERROR_NO_IMPORT_DATA) . "\n";
     break;
 }
 if (!$importDatas) {
Example #7
0
 /**
  * Send the mail
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function sendEmail()
 {
     if ($this->hasError()) {
         $this->raiseError('Cannot send email, error appened');
         return false;
     }
     $emailSent = true;
     if (!$this->_emailTo) {
         $this->raiseError('emailTo can not be null');
         return false;
     }
     $OB = "----=_OuterBoundary_000";
     $IB = "----=_InnerBoundery_001";
     $encoding = $this->_emailEncoding ? $this->_emailEncoding : APPLICATION_DEFAULT_ENCODING;
     if ($this->_template) {
         //if template is provided for email HTML, use it
         $template = new CMS_file($this->_template);
         $templateContent = $template->getContent();
         $replace = array('{{subject}}' => $this->_subject, '{{body}}' => $this->_emailHTML ? $this->_emailHTML : $this->convertTextToHTML($this->_body), '{{footer}}' => $this->convertTextToHTML($this->_footer), '{{href}}' => CMS_websitesCatalog::getMainURL(), '{{charset}}' => strtoupper($encoding));
         $Html = str_replace(array_keys($replace), $replace, $templateContent);
     } elseif ($this->_emailHTML) {
         //if HTML content is provided for email, use it
         //if this mail contain relative link, append default website address
         if (io::strpos($this->_emailHTML, 'href="/') !== false || io::strpos($this->_emailHTML, 'src="/') !== false) {
             $url = CMS_websitesCatalog::getMainURL();
             $this->_emailHTML = str_replace(array('href="/', 'src="/'), array('href="' . $url . '/', 'src="' . $url . '/'), $this->_emailHTML);
         }
         $Html = $this->_emailHTML;
     } else {
         //else use text content converted to HTML
         $Html = $this->convertTextToHTML($this->_body . ($this->_footer ? "\n\n" . $this->_footer : ''));
     }
     $Text = $this->_body ? $this->_body . ($this->_footer ? "\n\n" . $this->_footer : '') : "Sorry, but you need an HTML compatible mailer to read this mail...";
     $From = $this->_emailFrom ? $this->_emailFrom : APPLICATION_POSTMASTER_EMAIL;
     $FromName = $this->_fromName ? $this->_fromName : '';
     $toUsers = is_array($this->_emailTo) && $this->_emailTo ? $this->_emailTo : array($this->_emailTo);
     $cc = is_array($this->_cc) && $this->_cc ? $this->_cc : ($this->_cc ? array($this->_cc) : '');
     $bcc = is_array($this->_bcc) && $this->_bcc ? $this->_bcc : ($this->_bcc ? array($this->_bcc) : '');
     $toNames = is_array($this->_toName) && $this->_toName ? $this->_toName : array($this->_toName);
     $Error = $this->_error ? $this->_error : '';
     $Subject = $this->_subject;
     $AttmFiles = $this->_files;
     //Messages start with text/html alternatives in OB
     $Msg = "This is a multi-part message in MIME format.\n";
     $Msg .= "\n--" . $OB . "\n";
     $Msg .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $IB . "\"\n\n";
     //plaintext section
     $Msg .= "\n--" . $IB . "\n";
     $Msg .= "Content-Type: text/plain;\n\tcharset=\"" . $encoding . "\"\n";
     $Msg .= "Content-Transfer-Encoding: 8bit\n\n";
     // plaintext goes here
     $Msg .= $Text . "\n\n";
     // html section
     $Msg .= "\n--" . $IB . "\n";
     $Msg .= "Content-Type: text/html;\n\tcharset=\"" . $encoding . "\"\n";
     $Msg .= "Content-Transfer-Encoding: base64\n\n";
     // html goes here
     $Msg .= chunk_split(base64_encode($Html), 76, "\n") . "\n\n";
     // end of IB
     $Msg .= "\n--" . $IB . "--\n";
     // attachments
     if (is_array($AttmFiles) && $AttmFiles) {
         foreach ($AttmFiles as $AttmFile) {
             $patharray = explode("/", $AttmFile);
             $FileName = $patharray[count($patharray) - 1];
             $Msg .= "\n--" . $OB . "\n";
             $Msg .= "Content-Type: application/octet-stream;\n\tname=\"" . $FileName . "\"\n";
             $Msg .= "Content-Transfer-Encoding: base64\n";
             $Msg .= "Content-Disposition: attachment;\n\tfilename=\"" . $FileName . "\"\n\n";
             //file goes here
             $fd = fopen($AttmFile, "r");
             $FileContent = fread($fd, filesize($AttmFile));
             fclose($fd);
             $FileContent = chunk_split(base64_encode($FileContent), 76, "\n");
             $Msg .= $FileContent;
             $Msg .= "\n\n";
         }
     }
     if (LOG_SENDING_MAIL) {
         global $cms_user;
         $user = $cms_user ? $cms_user : CMS_profile_usersCatalog::getById(ROOT_PROFILEUSER_ID);
     }
     //message ends
     $Msg .= "\n--" . $OB . "--\n";
     foreach ($toUsers as $key => $to) {
         if (sensitiveIO::isValidEmail($to)) {
             $headers = "MIME-Version: 1.0\n";
             if ($FromName) {
                 $headers .= "From: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
                 $headers .= "Reply-To: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
                 $headers .= "Return-Path: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
                 $headers .= "X-Sender: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
             } else {
                 $headers .= "From: " . $From . "\n";
                 $headers .= "Reply-To: " . $From . "\n";
                 $headers .= "Return-Path: " . $From . "\n";
                 $headers .= "X-Sender: " . $From . "\n";
             }
             if (isset($toNames[$key]) && $toNames[$key]) {
                 $to = $this->EncodeHeader($toNames[$key]) . " <" . $to . ">";
             }
             if ($Error) {
                 $headers .= "Errors-To: " . $Error . "\n";
             }
             if ($cc) {
                 $headers .= "Cc: " . implode(',', $cc) . "\n";
             }
             if ($bcc) {
                 $headers .= "Bcc: " . implode(',', $bcc) . "\n";
             }
             /*$headers.="User-Agent: Automne (TM)\n";*/
             //Cause email to be reported as spam
             $headers .= "X-Mailer: Automne (TM)\n";
             $headers .= "X-Priority: 3\n";
             $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"" . $OB . "\"\n";
             //Check drop emails list (Automne default emails)
             if (!in_array($to, $this->_drop) && !in_array($From, $this->_drop)) {
                 //log in the cms_error_log the complete email
                 if (LOG_APPLICATION_MAIL) {
                     $this->log($to . "\n" . $this->EncodeHeader($Subject) . "\n\n" . $Msg);
                 }
                 //if mail deactivated always return true
                 if (NO_APPLICATION_MAIL) {
                     return $emailSent;
                 } else {
                     //send emails
                     $sent = @mail($to, $this->EncodeHeader($Subject), $Msg, $headers);
                 }
                 $emailSent = $emailSent && $sent;
                 if (LOG_SENDING_MAIL) {
                     $log = new CMS_log();
                     $log->logMiscAction(CMS_log::LOG_ACTION_SEND_EMAIL, $user, 'Email To ' . $to . ', From : ' . $From . ', Subject : ' . $Subject . ', Sent : ' . ($sent ? 'Yes' : 'Error'));
                 }
             } else {
                 if (LOG_SENDING_MAIL) {
                     $log = new CMS_log();
                     $log->logMiscAction(CMS_log::LOG_ACTION_SEND_EMAIL, $user, 'Email To ' . $to . ', From : ' . $From . ', Subject : ' . $Subject . ', Sent : No, Dropped because sender or receiver address is under Automne drop address list');
                 } else {
                     $this->raiseError('Email to ' . $to . ', from : ' . $From . ' (subject : ' . $Subject . '), Dropped because sender or receiver address is under Automne drop address list');
                 }
             }
         } else {
             if (LOG_SENDING_MAIL) {
                 $log = new CMS_log();
                 $log->logMiscAction(CMS_log::LOG_ACTION_SEND_EMAIL, $user, 'Email To ' . $to . ', From : ' . $From . ', Subject : ' . $Subject . ', Sent : No, Dropped because receiver address is not valid');
             } else {
                 $this->raiseError('Email to ' . $to . ', from : ' . $From . ' (subject : ' . $Subject . '), Dropped because receiver address is not valid');
             }
         }
     }
     if (!$emailSent) {
         $this->raiseError('Email was not sent, please check your sendmail configuration or SMTP connection in php.ini');
     }
     return $emailSent;
 }
Example #8
0
                         $content .= '<li class="atm-pic-ok">' . $line['text'] . '</li>';
                         break;
                     case 1:
                         $content .= '<li class="atm-pic-cancel">' . $line['text'] . '</li>';
                         break;
                 }
                 break;
         }
     }
     $content .= '</ul>';
     break;
 case 'browser-cache-reset':
     //update SUBVERSION file
     $file = new CMS_file(PATH_MAIN_FS . "/SUBVERSION");
     if ($file->exists()) {
         $date = (int) $file->getContent();
         $date++;
         $file->setContent((string) $date);
         if ($file->writeToPersistence()) {
             $cms_message = $cms_language->getMessage(MESSAGE_OPERATION_DONE);
         } else {
             $cms_message = $cms_language->getMessage(MESSAGE_UPDATE_ERROR);
         }
     } else {
         if (@file_put_contents(PATH_MAIN_FS . "/SUBVERSION", time()) !== false) {
             CMS_file::chmodFile(FILES_CHMOD, PATH_MAIN_FS . "/SUBVERSION");
             $cms_message = $cms_language->getMessage(MESSAGE_OPERATION_DONE);
         } else {
             $cms_message = $cms_language->getMessage(MESSAGE_CREATION_ERROR);
         }
     }