Beispiel #1
0
 /**
  * Un-delete an object proposed for deletion (only for primary resource object type)
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function undelete()
 {
     if ($this->_objectResourceStatus != 1) {
         return false;
     }
     $this->removeProposedLocation();
     if (parent::writeToPersistence()) {
         global $cms_user;
         //get Object definition
         $objectDef = $this->getObjectDefinition();
         //get module codename
         $polyModuleCodename = $objectDef->getValue('module');
         //Log action
         $log = new CMS_log();
         $language = $cms_user->getLanguage();
         $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_UNDELETE, $cms_user, $polyModuleCodename, $this->getStatus(), 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $this);
         return true;
     } else {
         return false;
     }
 }
Beispiel #2
0
 /**
  * 
  * @param string $message - сообщение
  * @param string $fieldName - имя поля сгенерировшего сообщение
  */
 public function __construct($message, $fieldName)
 {
     parent::__construct($message, E_USER_ERROR);
     CMS_log::addMessage(__CLASS__, $fieldName);
     CMS_log::addMessage(__CLASS__, $message);
 }
Beispiel #3
0
 /**
  * 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();
 }
     }
     break;
 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;
Beispiel #5
0
} elseif (!$action && !$cms_page->getLock()) {
    $cms_page->lock($cms_user);
} elseif ($cms_page->getLock() && $cms_page->getLock() != $cms_user->getUserId()) {
    die("Page is locked");
}
if (!$cms_page->isDraft()) {
    //must copy data from edited to edition
    $tpl = $cms_page->getTemplate();
    CMS_moduleClientSpace_standard_catalog::moveClientSpaces($tpl->getID(), RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_EDITION, true);
    CMS_blocksCatalog::moveBlocks($cms_page, RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_EDITION, true);
    //log action
    $log = new CMS_log();
    $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_START_DRAFT, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getStatus(), "(Start new draft for page)", $cms_page);
} else {
    //log action
    $log = new CMS_log();
    $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_EDIT_DRAFT, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getStatus(), "(Continue existing page draft)", $cms_page);
}
//add ext and edit JS files
$cms_view->addJSFile('ext');
$cms_view->addJSFile('edit');
//unset vars to avoid interraction with page
unset($currentPage);
unset($action);
unset($tpl);
unset($log);
//get page content
$content = $cms_page->getContent($cms_language, PAGE_VISUALMODE_FORM);
echo $content;
/*only for stats*/
//if (STATS_DEBUG) view_stat();
Beispiel #6
0
                                foreach ($languages as $language) {
                                    $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_ARCHIVE_SUBJECT);
                                    $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_VALIDATION_AWAITS) . "\n" . $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_ARCHIVE_BODY, array($cms_page->getTitle() . ' (ID : ' . $cms_page->getID() . ')', $cms_user->getFullName()));
                                }
                                break;
                        }
                        break;
                }
                $potentialValidators = CMS_profile_usersCatalog::getValidators(MOD_STANDARD_CODENAME);
                $validators = array();
                foreach ($potentialValidators as $aPotentialValidator) {
                    if ($aPotentialValidator->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) {
                        $validators[] = $aPotentialValidator;
                    }
                }
                $group_email->setUserMessages($validators, $bodies, $subjects, ALERT_LEVEL_VALIDATION, MOD_STANDARD_CODENAME);
                $group_email->sendMessages();
            } else {
                $validation = new CMS_resourceValidation(MOD_STANDARD_CODENAME, $edited, $cms_page);
                $mod = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME);
                $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT);
            }
        }
    }
    //log event
    if ($logAction) {
        $log = new CMS_log();
        $log->logResourceAction($logAction, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getStatus(), "", $cms_page);
    }
}
$view->show();
Beispiel #7
0
                 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
                 $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;
             $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT_FILE, $cms_user, "File : " . $node);
             $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:
Beispiel #9
0
                CMS_tree::attachPageToTree($pg, $father);
                if ($pg->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED) {
                    CMS_tree::attachPageToTree($pg, $father, true);
                }
                if (!APPLICATION_ENFORCES_WORKFLOW) {
                    //submit the page to the regenerator
                    CMS_tree::submitToRegenerator($pg->getID(), true);
                    //validate the father
                    $pg->regenerate(true);
                    $validation = new CMS_resourceValidation(MOD_STANDARD_CODENAME, RESOURCE_EDITION_SIBLINGSORDER + RESOURCE_EDITION_CONTENT, $father);
                    $mod = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME);
                    $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT);
                }
                $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
                $archives = CMS_tree::getArchivedPagesData();
                $log = new CMS_log();
                $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_UNARCHIVE, $cms_user, MOD_STANDARD_CODENAME, $pg->getStatus(), "", $pg);
            }
        }
        break;
}
$dialog = new CMS_dialog();
$content = '';
$dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE), 'pic_archives.gif');
if ($cms_message) {
    $dialog->setActionMessage($cms_message);
    $dialog->reloadTree();
}
if (is_array($archives) && $archives) {
    $content .= '
		<table border="0" cellpadding="2" cellspacing="2">
Beispiel #10
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;
 }
Beispiel #11
0
        $currentTpl = $tplId;
    }
}
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();
        }
         $keyword = '';
     }
 } 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();
                                }
                            }
                            break;
                    }
                    $group_email = new CMS_emailsCatalog();
                    $group_email->setUserMessages($users, $bodies, $subjects, ALERT_LEVEL_VALIDATION, $validation->getModuleCodename());
                    $group_email->sendMessages();
                    //check if resource still exists
                    $resUpdated = $validation->getResource();
                    $deleted = true;
                    if ($resUpdated && is_object($resUpdated)) {
                        $res = $resUpdated;
                        $deleted = false;
                    }
                    //log action
                    $log = new CMS_log();
                    $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_VALIDATE_EDITION, $cms_user, $validation->getModuleCodename(), $res->getStatus(), "", $res);
                    if (!$deleted && $res->getStatus()) {
                        //Replace all the status icons by the new one across the whole interface
                        $status = $res->getStatus()->getHTML(false, $cms_user, $validation->getModuleCodename(), $res->getID());
                        $tinyStatus = $res->getStatus()->getHTML(true, $cms_user, $validation->getModuleCodename(), $res->getID());
                        $statusId = $res->getStatus()->getStatusId($validation->getModuleCodename(), $res->getID());
                        $jscontent .= '
						Automne.utils.updateStatus(\'' . $statusId . '\', \'' . sensitiveIO::sanitizeJSString($status) . '\', \'' . sensitiveIO::sanitizeJSString($tinyStatus) . '\');';
                    } else {
                        $jscontent .= '
						Automne.utils.removeResource(\'' . $validation->getModuleCodename() . '\', \'' . $res->getID() . '\');';
                    }
                }
            }
        }
Beispiel #14
0
            $website->set403($_POST["page403"]);
            $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();
Beispiel #15
0
 /**
  * Get by resource
  *
  * @param CMS_
  * @return array(CMS_log)
  * @access public
  */
 static function getByResourceAction($moduleCodename, $resourceId, $action, $limit = false)
 {
     $sql = "\n\t\t\tselect\n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tlog\n\t\t\twhere\n\t\t\t\tmodule_log='" . sensitiveIO::sanitizeSQLString($moduleCodename) . "'\n\t\t\t\tand resource_log='" . sensitiveIO::sanitizeSQLString($resourceId) . "'";
     if (is_array($action)) {
         $sql .= " and action_log in (" . sensitiveIO::sanitizeSQLString(implode(',', $action)) . ")";
     } else {
         $sql .= " and action_log='" . sensitiveIO::sanitizeSQLString($action) . "'";
     }
     $sql .= "\n\t\t\torder by\n\t\t\t\tdatetime_log desc\n\t\t";
     if ($limit && sensitiveIO::isPositiveInteger($limit)) {
         $sql .= " limit 0, " . $limit;
     }
     $logs = array();
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         $users = array();
         while ($r = $q->getArray()) {
             if (!isset($users[$r["user_log"]])) {
                 $users[$r["user_log"]] = CMS_profile_usersCatalog::getByID($r["user_log"]);
             }
             $lg = new CMS_log($r, $users[$r["user_log"]]);
             if (!$lg->hasError()) {
                 $logs[] = $lg;
             }
         }
     }
     return $logs;
 }
            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();
Beispiel #17
0
        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();
Beispiel #18
0
         if (!$cms_message) {
             $content = array('success' => true, 'id' => $item->getID());
             $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
             if ($action == 'save') {
                 break;
             }
             //validate saving
             if ($object->isPrimaryResource()) {
                 $codename = CMS_poly_object_catalog::getModuleCodenameForObject($item->getID());
                 if ($cms_user->hasValidationClearance($codename)) {
                     //then validate this item content
                     $validation = new CMS_resourceValidation($codename, RESOURCE_EDITION_CONTENT, $item);
                     $mod = CMS_modulesCatalog::getByCodename($codename);
                     $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT);
                     //Log action
                     $log = new CMS_log();
                     $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_DIRECT_VALIDATION, $cms_user, $codename, $item->getStatus(), 'Item \'' . $item->getLabel() . '\' (' . $item->getObjectDefinition()->getLabel($cms_language) . ')', $item);
                 }
             }
         }
     }
     break;
 case 'pluginSelection':
     $view->setDisplayMode(CMS_view::SHOW_RAW);
     $selectedContent = sensitiveIO::request('content');
     $pluginId = sensitiveIO::request('plugin');
     $selectedPlugin = new CMS_poly_plugin_definitions($pluginId);
     //then create the code to paste for the current selected object if any
     if (sensitiveIO::isPositiveInteger($itemId) && !$selectedPlugin->needSelection()) {
         //$item = CMS_poly_object_catalog::getObjectByID($selectedItem);
         $definition = $selectedPlugin->getValue('definition');
Beispiel #19
0
         }
     }
     $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);