$content = array('success' => true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_UPDATE_FILE, array($node)); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UPDATE_FILE) . ' ' . $node; } } break; case 'create': if (is_dir($file) && $filelabel) { if (!is_file($file . '/' . $filelabel)) { $extension = io::strtolower(pathinfo($file . '/' . $filelabel, PATHINFO_EXTENSION)); if (isset($allowedFiles[$extension])) { $file = new CMS_file($file . '/' . $filelabel); if ($file->setContent($definition) && $file->writeToPersistence()) { $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT_FILE, $cms_user, "File : " . $node . '/' . $filelabel); $content = array('success' => true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_CREATE_FILE, array($filelabel)); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UPDATE_FILE) . ' ' . $filelabel; } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_CREATE_FILE_EXTENSION, array($filelabel)); } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_CREATE_FILE_EXISTS, array($filelabel)); } } break; default: CMS_grandFather::raiseError('Unknown action to do ...');
$website->setRedirectAltDomain($_POST["altredir"]); $website->setMeta('description', $_POST['description']); $website->setMeta('keywords', $_POST['keywords']); $website->setMeta('category', $_POST['category']); $website->setMeta('robots', $_POST['robots']); $website->setMeta('author', $_POST['author']); $website->setMeta('replyto', $_POST['replyto']); $website->setMeta('copyright', $_POST['copyright']); $website->setMeta('language', $_POST['language']); $website->setMeta('favicon', $_POST['favicon']); $website->setMeta('metas', $_POST['metas']); if (!$cms_message && !$website->hasError()) { $website->writeToPersistence(); CMS_tree::regenerateAllPages(true); $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_WEBSITE_EDIT, $cms_user, "Website : " . $website->getLabel()); $dialog->reloadAll(); header("Location: websites.php?cms_message_id=" . MESSAGE_ACTION_OPERATION_DONE . "&" . session_name() . "=" . session_id()); exit; } } break; } $dialog->setBackLink("websites.php"); $title = $cms_language->getMessage(MESSAGE_PAGE_TITLE); $dialog->setTitle($title); if ($cms_message) { $dialog->setActionMessage($cms_message); } $grand_root = CMS_tree::getRoot(); $tree_href = PATH_ADMIN_SPECIAL_TREE_WR;
if ($page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { $pagesIds[] = $page->getID(); } } if ($pagesIds) { CMS_tree::submitToRegenerator($pagesIds, true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGEN, array(sizeof($pagesIds))); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_NO_PUBLIC_PAGE); } break; case 'copy': if (is_a($template, "CMS_pageTemplate") && !$template->hasError()) { //Dupplicate selected template with given label $label = $cms_language->getMessage(MESSAGE_PAGE_COPY_OF) . ' ' . $template->getLabel(); $template = CMS_pageTemplatesCatalog::getCloneFromID($templateId, $label); $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Template : " . $label . " (create template)"); $content = array('success' => array('templateId' => $template->getID())); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label)); $view->setContent($content); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_TEMPLATE); } break; } //set user message if any if ($cms_message) { $view->setActionMessage($cms_message); } $view->show();
case 'identity': //set return to false by default $content = array('success' => false); if (!isset($group) || !is_a($group, "CMS_profile_usersGroup")) { $group = new CMS_profile_usersGroup(); } //is it a new user creation ? $groupCreation = $group->getGroupId() ? false : true; $group->setLabel($label); $group->setDescription($description); // Check if any errors when updating group datas if (!$cms_message) { $group->writeToPersistence(); $log = new CMS_log(); if (!$groupCreation) { $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_GROUP_EDIT, $cms_user, "Group : " . $group->getLabel() . "(Edit group identity)"); } else { $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_GROUP_EDIT, $cms_user, "Group : " . $group->getLabel() . "(Creation)"); } if ($groupCreation) { $content = array('success' => array('groupId' => $group->getGroupId())); $cms_message = $cms_language->getJsMessage(MESSAGE_PAGE_GROUP_CREATED); } else { $content = array('success' => true); $cms_message = $cms_language->getMessage(MESSAGE_PAGE_DATA_SAVED_GROUP); } } $view->setContent($content); break; } //set user message if any
/** * Delete object and values. * If object is a primary resource, this deletion is submitted to validation and an email is sent to validators. * * @param boolean $hardDelete : completely destroy object and associated resource if any. After this, this object will no longer exists at all. Default : false. * /!\ if object is a primary resource, no validation will be queried to validators, object will be directly destroyed from all locations. /!\ * @return boolean true on success, false on failure * @access public */ function delete($hardDelete = false) { global $cms_user; //get Object definition $objectDef = $this->getObjectDefinition(); //get module codename $polyModuleCodename = $objectDef->getValue('module'); //if object is not a primary resource if ($this->_objectResourceStatus != 1 || $hardDelete) { $forceSecondaryRessourcePublication = false; if ($this->_objectResourceStatus == 2 && !$hardDelete) { //if this object is a secondary resource, primary items which uses this object must be updated //get all primary resource associated $primaryItems = CMS_poly_object_catalog::getPrimaryItemsWhichUsesSecondaryItem($this->_ID, true, false); if ($primaryItems) { foreach ($primaryItems as $primaryItem) { $primaryItem->writeToPersistence(); } } else { $forceSecondaryRessourcePublication = true; } } //if object is not a secondary resource, delete public datas, else preserve it : it will be deleted on primary resource validation if ($this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication || $hardDelete) { //delete datas from public locations CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_PUBLIC, RESOURCE_DATA_LOCATION_DEVNULL); if (!$hardDelete) { //mark item as deleted CMS_modulePolymodValidation::markDeletedItem($this->getID()); } else { //destroy poly_object reference $sql = "delete from mod_object_polyobjects where id_moo = '" . $this->getID() . "'"; new CMS_query($sql); } } if ($this->_objectResourceStatus != 1 && $this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication) { $modulesCodes = new CMS_modulesCodes(); //add a call to all modules for before validation specific treatment $modulesCodes->getModulesCodes(MODULE_TREATMENT_BEFORE_VALIDATION_TREATMENT, '', $this, array('result' => VALIDATION_OPTION_ACCEPT, 'lastvalidation' => true, 'module' => $polyModuleCodename, 'action' => 'delete')); } if (!$hardDelete) { //move resource datas from edited to deleted location CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_DELETED); } else { //delete datas from edited locations CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_DEVNULL); } if ($this->_objectResourceStatus != 1 && $this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication) { //add a call to all modules for after validation specific treatment $modulesCodes->getModulesCodes(MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT, '', $this, array('result' => VALIDATION_OPTION_ACCEPT, 'lastvalidation' => true, 'module' => $polyModuleCodename, 'action' => 'delete')); } if ($this->_objectResourceStatus == 1 && $hardDelete) { //delete associated resource parent::destroy(); } //Log action $log = new CMS_log(); $language = $cms_user->getLanguage(); $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_DELETE, $cms_user, 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $polyModuleCodename); if ($hardDelete) { unset($this); } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $polyModuleCodename)); CMS_cache::clearTypeCache('polymod'); return true; } else { //change the article proposed location and send emails to all the validators if ($this->setProposedLocation(RESOURCE_LOCATION_DELETED, $cms_user)) { parent::writeToPersistence(); if (APPLICATION_ENFORCES_WORKFLOW) { if (!NO_APPLICATION_MAIL) { //get editors $editors = $this->getEditors(); $editorsIds = array(); foreach ($editors as $editor) { $editorsIds[] = $editor->getUserId(); } $validators = CMS_profile_usersCatalog::getValidators($polyModuleCodename); foreach ($validators as $validator) { //add script to send email for validator if needed CMS_scriptsManager::addScript($polyModuleCodename, array('task' => 'emailNotification', 'object' => $this->getID(), 'validator' => $validator->getUserId(), 'type' => 'delete', 'editors' => $editorsIds)); } //then launch scripts execution CMS_scriptsManager::startScript(); } } else { $validation = new CMS_resourceValidation($polyModuleCodename, RESOURCE_EDITION_LOCATION, $this); $mod = CMS_modulesCatalog::getByCodename($polyModuleCodename); $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT); } //Log action $log = new CMS_log(); $language = $cms_user->getLanguage(); $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_DELETE, $cms_user, $polyModuleCodename, $this->getStatus(), 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $this); //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $polyModuleCodename)); CMS_cache::clearTypeCache('polymod'); return true; } else { return false; } } }
break; case 'regenerate': //submit all public pages using this row to the regenerator $pagesIds = CMS_rowsCatalog::getPagesByRow($rowId, false, true); if ($pagesIds) { CMS_tree::submitToRegenerator($pagesIds, true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGEN, array(sizeof($pagesIds))); } else { $cms_message = $cms_language->getMessage(MESSAGE_ACTION_NO_PAGES); } break; case 'copy': if (is_a($row, "CMS_row") && !$row->hasError()) { //Dupplicate selected row with given label $label = $cms_language->getMessage(MESSAGE_PAGE_COPY_OF) . ' ' . $row->getLabel(); $row = CMS_rowsCatalog::getCloneFromID($rowId, $label); $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Row : " . $label . " (create row)"); $content = array('success' => array('rowId' => $row->getID())); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label)); $view->setContent($content); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_ROW); } break; } //set user message if any if ($cms_message) { $view->setActionMessage($cms_message); } $view->show();
/** * Authenticate user * This method can * - authenticate user throught authentification process * - load already authenticated user in current session (or SSO) * - disconnect user * * @param array $params : indexed array of authentification parameters (default : nothing) * Accepted array keys are : * - authenticate : boolean : default true if disconnect is not set * - disconnect : boolean : default false * - login : string : user login to authenticate * - password : string : user password to authenticate * - remember : boolean : default false * - tokenName : string * - token : string * - type : string : type of authentification (admin|frontend) : default APPLICATION_USER_TYPE contant * - ... and any parameter needed by authentifications processes handled by modules * @return void * @access public * @static */ public static function authenticate($params = array()) { //first clean old sessions datas from database CMS_session::_cleanSessions(); // Get Zend Auth instance $auth = Zend_Auth::getInstance(); // Use CMS_auth as session storage space $auth->setStorage(new Zend_Auth_Storage_Session('atm-auth')); //set authentification type if (!isset($params['type'])) { $params['type'] = APPLICATION_USER_TYPE; } //set permanent auth status if (isset($params['remember']) && $params['remember']) { self::$_permanent = true; } else { $params['remember'] = false; } //clear auth storage if disconnection is queried and set default authenticate value if (isset($params['disconnect']) && $params['disconnect']) { //log disconection if user exists $storageValue = $auth->getStorage()->read(); if (io::isPositiveInteger($storageValue)) { //load user $user = CMS_profile_usersCatalog::getByID($storageValue); if ($user) { //log new session $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_DISCONNECT, $user, 'IP: ' . @$_SERVER['REMOTE_ADDR'] . ', UA: ' . @$_SERVER['HTTP_USER_AGENT']); } } //clear session content CMS_session::deleteSession(true); if (!isset($params['authenticate'])) { $params['authenticate'] = false; } } else { $params['disconnect'] = false; if (!isset($params['authenticate'])) { $params['authenticate'] = true; } } //init authenticated boolean $authenticated = false; //keep old storage value, because storage will be reseted by each module authentification $storageValue = $auth->getStorage()->read(); //loop on each authentification types suupported foreach (array('credentials', 'session', 'cookie', 'sso') as $authType) { //load modules $modules = CMS_modulesCatalog::getAll('id'); //get last module $module = array_pop($modules); //set authentification type as param $params['authType'] = $authType; //then try it for each modules do { //if module has auth method, try it if (method_exists($module, 'getAuthAdapter')) { //overwrite auth storage value with old value $auth->getStorage()->write($storageValue); //get module auth adapter $authAdapter = $module->getAuthAdapter($params); //authenticate user self::$_result = $auth->authenticate($authAdapter); //To debug Auth process easily, discomment this line //CMS_grandFather::log($_SERVER['SCRIPT_NAME'].' - '.$module->getCodename().' - Auth type : '.$authType.'/'.$params['type'].' - Auth result : '.self::$_result->getCode().($auth->hasIdentity() ? ' - Identity : '.$auth->getIdentity() : '').' - Message : '.(sizeof(self::$_result->getMessages()) == 1 ? array_pop(self::$_result->getMessages()) : print_r(self::$_result->getMessages(), true))); switch (self::$_result->getCode()) { case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: //user crendentials does not exists (ex: no login/pass provided) //nothing for now break; case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: //invalid login/pass //nothing for now break; case Zend_Auth_Result::SUCCESS: if ($auth->hasIdentity()) { // get user from identity found $user = $authAdapter->getUser($auth->getIdentity()); //check if user is valid if (isset($user) && $user && !$user->hasError() && !$user->isDeleted() && $user->isActive()) { $authenticated = true; //overwrite auth identity with valid user Id $auth->getStorage()->write($user->getUserId()); } else { unset($user); } } break; case Zend_Auth_Result::FAILURE: //user found but has error during loading (user inactive or deleted) //nothing for now break; default: //other unidentified cases : thrown an error CMS_grandFather::raiseError('Authentification return code ' . self::$_result->getCode() . ' for module ' . $module->getCodename() . ' with parameters ' . print_r($params, true)); break; } } //get next last module $module = array_pop($modules); } while (!$authenticated && $module); //if user is authenticated, break authentification foreach if ($authenticated) { break; } } //if authenticated : set or refresh session datas in table, regenerate session Id if ($authenticated && $user) { $q = new CMS_query("\n\t\t\tselect \n\t\t\t\tid_ses, cookie_expire_ses\n\t\t\tfrom \n\t\t\t\tsessions \n\t\t\twhere \n\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString(Zend_Session::getId()) . "' \n\t\t\t\tand user_ses='" . sensitiveIO::sanitizeSQLString($user->getUserId()) . "'"); //get old session Id $oldSessionId = Zend_Session::getId(); if ($q->getNumRows() > 0) { //if session already exists : update it //regenerate session Id randomly (arround 1/100 times) //removed : cause session instability /*if (!rand(0, 100)) { //session id should not be regenerated each times because in case of a lot of concurrent calls, session can be destroyed Zend_Session::regenerateId(); }*/ $r = $q->getArray(); $id = $r['id_ses']; //Cookie if (self::$_permanent || $r['cookie_expire_ses'] != '0000-00-00 00:00:00') { self::$_permanent = true; // Cookie expire in APPLICATION_COOKIE_EXPIRATION days $expires = time() + 60 * 60 * 24 * APPLICATION_COOKIE_EXPIRATION; CMS_session::setCookie(CMS_session::getAutoLoginCookieName(), base64_encode($id . '|' . Zend_Session::getId()), $expires); } //DB session $sql = "\n\t\t\t\t\tupdate \n\t\t\t\t\t\tsessions \n\t\t\t\t\tset\n\t\t\t\t\t\tlastTouch_ses=NOW(),\n\t\t\t\t\t\tuser_ses='" . sensitiveIO::sanitizeSQLString($user->getUserId()) . "',\n\t\t\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString(Zend_Session::getId()) . "',\n\t\t\t\t\t\tremote_addr_ses='" . sensitiveIO::sanitizeSQLString(@$_SERVER['REMOTE_ADDR']) . "'"; if (self::$_permanent) { $sql .= ",\n\t\t\t\t\t\tcookie_expire_ses = DATE_ADD(NOW(), INTERVAL " . APPLICATION_COOKIE_EXPIRATION . " DAY)"; } $sql .= "\n\t\t\t\t\twhere\n\t\t\t\t\t \tid_ses='" . sensitiveIO::sanitizeSQLString($id) . "'"; $q = new CMS_query($sql); //if autologin : log it if (in_array(CMS_auth::AUTH_AUTOLOGIN_VALID, self::$_result->getMessages())) { //log autologin session $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_AUTO_LOGIN, $user, 'IP: ' . @$_SERVER['REMOTE_ADDR'] . ', UA: ' . @$_SERVER['HTTP_USER_AGENT']); } } else { //otherwhise, create user session //regenerate session Id Zend_Session::regenerateId(); //delete old session record if any $q = new CMS_query("\n\t\t\t\t\tdelete\n\t\t\t\t\tfrom \n\t\t\t\t\t\tsessions \n\t\t\t\t\twhere \n\t\t\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString($oldSessionId) . "'"); //insert new session record $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tsessions\n\t\t\t\t\tset\n\t\t\t\t\t\tlastTouch_ses=NOW(),\n\t\t\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString(Zend_Session::getId()) . "',\n\t\t\t\t\t\tuser_ses='" . sensitiveIO::sanitizeSQLString($user->getUserId()) . "',\n\t\t\t\t\t\tremote_addr_ses='" . sensitiveIO::sanitizeSQLString(@$_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\t"; if (self::$_permanent) { $sql .= ",\n\t\t\t\t\tcookie_expire_ses = DATE_ADD(NOW(), INTERVAL " . APPLICATION_COOKIE_EXPIRATION . " DAY)"; } $q = new CMS_query($sql); if (!$q->hasError() && self::$_permanent) { // Cookie expire in APPLICATION_COOKIE_EXPIRATION days $expires = time() + 60 * 60 * 24 * APPLICATION_COOKIE_EXPIRATION; CMS_session::setCookie(CMS_session::getAutoLoginCookieName(), base64_encode($q->getLastInsertedID() . '|' . Zend_Session::getId()), $expires); } //log new session $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_LOGIN, $user, 'Permanent cookie: ' . (self::$_permanent ? 'Yes' : 'No') . ', IP: ' . @$_SERVER['REMOTE_ADDR'] . ', UA: ' . @$_SERVER['HTTP_USER_AGENT']); } //set user as currently logged user self::$_userID = $user->getUserId(); } else { if (APPLICATION_USER_TYPE == "frontend" && APPLICATION_ENFORCES_ACCESS_CONTROL) { //set public user as currently logged user self::$_userID = ANONYMOUS_PROFILEUSER_ID; } } //for backward compatibility $_SESSION["cms_context"] = new CMS_context(); }
$content = array('success' => true, 'id' => $item->getID()); } } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_ALIAS_PROTECTED, false, 'cms_aliases'); $item->raiseError('Error during modification of alias ' . $item->getID() . '. Alias is protected.'); } break; case 'delete': $item = CMS_module_cms_aliases::getByID($aliasId); if (!$item->isProtected()) { $path = $item->getPath(); if ($item->destroy()) { //Log action $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_DELETE, $cms_user, 'Delete Alias ' . $path, 'cms_aliases'); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); $content = array('success' => true); } else { $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETE_ERROR); } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_ALIAS_PROTECTED, false, 'cms_aliases'); $category->raiseError('Error during modification of alias ' . $item->getID() . '. Alias is protected.'); } break; default: CMS_grandFather::raiseError('Unknown action to do ...'); $view->show(); break; }
/** * 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; }
} } if (!$skipSearch) { $rows = CMS_rowsCatalog::getAll($viewinactive, $keyword, $groups, $rowIds, $cms_user, $currentTpl, $currentCS, $start, $limit); $rowsDatas['total'] = sizeof(CMS_rowsCatalog::getAll($viewinactive, $keyword, $groups, $rowIds, $cms_user, $currentTpl, $currentCS, 0, 0, false)); } else { $rows = array(); $rowsDatas['total'] = 0; } foreach ($rows as $row) { if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_TEMPLATES)) { //rows if ($delete) { if (is_a($row, "CMS_row") && !$row->hasClientSpaces()) { $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_DELETE, $cms_user, "Row : " . $row->getLabel()); $row->destroy(); unset($row); $rowsDatas['total']--; continue; } } if ($activate) { $row->setUsability(1); $row->writeToPersistence(); } if ($desactivate) { $row->setUsability(0); $row->writeToPersistence(); } }
} } else { $pageTplIds = $items; } $templatesDatas = array(); $templatesDatas['results'] = array(); //get array of available templates $templates = CMS_pageTemplatesCatalog::getAll($viewinactive, $keyword, $groups, $website, $pageTplIds, $cms_user, $start, $limit); $templatesDatas['total'] = sizeof(CMS_pageTemplatesCatalog::getAll($viewinactive, $keyword, $groups, $website, $pageTplIds, $cms_user, 0, 0, false)); foreach ($templates as $template) { if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) { //templates if ($delete) { if (is_a($template, "CMS_pageTemplate") && !$template->hasPages()) { $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_DELETE, $cms_user, "Template : " . $template->getLabel()); if ($template->isPrivate()) { $template->destroy(); } else { //destroy with definition file $template->destroy(true); } unset($template); $templatesDatas['total']--; continue; } } if ($activate) { $template->setUsability(1); $template->writeToPersistence(); }
} $view->setContent($content); break; case 'useralerts': //set return to false by default $content = array('success' => false); if (is_a($user, "CMS_profile_user")) { //set all alerts levels $user->resetAlertLevel(); foreach ($alerts as $codename => $levels) { $level = array_sum($levels); $user->setAlertLevel($level, $codename); } $user->writeToPersistence(); $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_USER_EDIT, $cms_user, "User : "******" (edit alerts levels)"); //if this not a personal profile update, send email alert if (!$personalProfile) { $group_email = new CMS_emailsCatalog(); $languages = CMS_languagesCatalog::getAllLanguages(); $subjects = array(); $bodies = array(); foreach ($languages as $language) { $subjects[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_USER_EDIT_SUBJECT); $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_USER_EDIT_BODY, array($user->getLogin())) . "\n" . $language->getMessage(MESSAGE_EMAIL_USER_EDIT_ALERTLEVEL); } $group_email->setUserMessages(array($user), $bodies, $subjects, ALERT_LEVEL_PROFILE, MOD_STANDARD_CODENAME); $group_email->sendMessages(); } $content = array('success' => true); $cms_message = $cms_language->getMessage(MESSAGE_PAGE_USER_DATA_REGISTERED);