/**
     * Get array of contacts data by Email
     *
     * @param string $data
     * @return array of CMS_profile_user
     * @access public
     */
    static function getByEmail($data)
    {
        if (!SensitiveIO::isValidEmail($data)) {
            CMS_grandFather::raiseError('$data must be a valid email : ' . $data);
            return array();
        }
        $aUsers = array();
        //create the request to look for the data
        $sql = 'select `id_cd` 
			from `contactDatas`
			where `email_cd` = "' . sensitiveIO::sanitizeSQLString($data) . '"';
        //launching the request
        $q = new CMS_query($sql);
        //checking if ok and looping on results
        if (!$q->hasError()) {
            while (($oTmpUserId = $q->getValue("id_cd")) !== false) {
                //creating the user and filling the data
                $oTmpUser = CMS_profile_usersCatalog::getByID($oTmpUserId);
                if (!$oTmpUser->hasError()) {
                    $oTmpUser->getContactData();
                    if (!$oTmpUser->hasError()) {
                        $aUsers[] = $oTmpUser;
                    }
                }
            }
            unset($oTmpUser, $oTmpUserId);
        }
        return $aUsers;
    }
 /**
  * Returns all the resource validations the user can do
  * Static function.
  *
  * @param CMS_user $user The user we want the validations of
  * @param string $module_codebame The module codename we want the validations of, if ommitted, validations for all the modules will be returned
  * @return array(string=>CMS_resourceValidation) The validations to do, indexed by module codename
  * @access public
  */
 static function getValidations(&$user, $module_codename = false)
 {
     if (!is_a($user, "CMS_user")) {
         parent::raiseError("User is not a valid CMS_user object");
         return;
     }
     if ($module_codename) {
         if (!($module = CMS_resourceModulesCatalog::getByCodename($codename))) {
             return;
         }
     }
     if ($module) {
         $modules = array($module);
     } else {
         $modules = CMS_modulesCatalog::getAll();
     }
     $validations = array();
     foreach ($modules as $aModule) {
         if (!$user->hasValidationClearance($aModule->getID())) {
             continue;
         }
         $validations_to_add = $aModule->getValidations($user);
         if ($validations_to_add) {
             $validations[$aModule->getCodename()] = $validations_to_add;
         }
     }
     return $validations;
 }
示例#3
0
 function __call($name, $arguments)
 {
     if (is_callable(array('CMS_session', $name))) {
         return call_user_func_array(array('CMS_session', $name), $arguments);
     } else {
         CMS_grandFather::raiseError('unkown method ' . $name . ' in CMS_context');
     }
 }
示例#4
0
 /**
  * Compute the tag
  *
  * @return string the PHP / HTML content computed
  * @access private
  */
 protected function _compute()
 {
     if (!isset($this->_computeParams['object']) || !$this->_computeParams['object'] instanceof CMS_page) {
         CMS_grandFather::raiseError('atm-js-add tag must be outside of <block> tags');
         return '';
     }
     if (!isset($this->_attributes['file'])) {
         CMS_grandFather::raiseError('atm-js-add tag must have file parameter');
         return '';
     }
     $files = CMS_module::moduleUsage($this->_computeParams['object']->getID(), "atm-js-tags-add");
     $files = is_array($files) ? $files : array();
     //append module js files
     $files = array_merge($files, array($this->_attributes['file']));
     //save files
     CMS_module::moduleUsage($this->_computeParams['object']->getID(), "atm-js-tags-add", $files, true);
 }
示例#5
0
 public static function DOMElementToString($domelement, $contentOnly = false)
 {
     if (!is_a($domelement, "DOMElement")) {
         CMS_grandFather::raiseError('Domelement is not a DOMElement instance');
         return false;
     }
     static $autoClosedTagsList;
     if (!$autoClosedTagsList) {
         $xml2Array = new CMS_xml2Array();
         $tagsList = $xml2Array->getAutoClosedTagsList();
         $autoClosedTagsList = implode($tagsList, '|');
     }
     $output = '';
     if ($contentOnly) {
         $output = '';
         foreach ($domelement->childNodes as $node) {
             $output .= $node->ownerDocument->saveXML($node, LIBXML_NOEMPTYTAG);
         }
     } else {
         $output = $domNode->ownerDocument->saveXML($domNode, LIBXML_NOEMPTYTAG);
     }
     //convert output encoding if needed
     if (io::isUTF8($output)) {
         if (io::strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8') {
             $output = utf8_decode($output);
         }
     } else {
         if (io::strtolower(APPLICATION_DEFAULT_ENCODING) == 'utf-8') {
             $output = utf8_encode($output);
         }
     }
     //to correct a bug in libXML < 2.6.27
     if (LIBXML_VERSION < 20627 && strpos($output, '&#x') !== false) {
         $output = preg_replace_callback('/(&#x[0-9A-Z]+;)/U', create_function('$matches', 'return io::decodeEntities($matches[0]);'), $output);
     }
     //replace tags like <br></br> by auto closed tags and strip cariage return arround entities
     $output = preg_replace(array('#\\n(&[a-z]+;)\\n#U', '#<(' . $autoClosedTagsList . ')([^>]*)></\\1>#U'), array('\\1', '<\\1\\2/>'), $output);
     return $output;
 }
 /**
  * Move the data of a resource from one data location to another.
  * May be used by every module, provided it respects the naming rules described in the modules HOWTO
  *
  * @param string $module, The module codename
  * @param integer $resourceID The DB ID of the resource whose data we want to move
  * @param string $locationFrom The starting location, among the available RESOURCE_DATA_LOCATION
  * @param string $locationTo The ending location, among  the available RESOURCE_DATA_LOCATION
  * @param boolean $copyOnly If set to true, the deletion from the originating tables and dirs won't occur
  * @return boolean true on success, false on failure
  * @access public
  * @static
  */
 function moveResourceData($module, $resourceID, $locationFrom, $locationTo, $copyOnly = false)
 {
     //get all datas locations
     $locations = CMS_resource::getAllDataLocations();
     if (!in_array($locationFrom, $locations)) {
         CMS_grandFather::raiseError("LocationFrom is not a valid location : " . $locationFrom);
         return false;
     }
     if (!in_array($locationTo, $locations)) {
         CMS_grandFather::raiseError("LocationTo is not a valid location : " . $locationTo);
         return false;
     }
     if (!sensitiveIO::IsPositiveInteger($resourceID)) {
         CMS_grandFather::raiseError("ResourceID must be a positive integer : " . $resourceID);
         return false;
     }
     //first move DB datas
     $tables_prefixes = array('mod_subobject_date_', 'mod_subobject_integer_', 'mod_subobject_string_', 'mod_subobject_text_');
     foreach ($tables_prefixes as $table_prefix) {
         //delete all in the destination table and insert new ones
         if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
             $sql = "\n\t\t\t\t\treplace into\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tobjectID='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
         if (!$copyOnly) {
             //delete from the starting table
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
     }
     //second, move the files
     $locationFromDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
     //cut here if the locationFromDir doesn't exists. That means the module doesn't have files
     if (!$locationFromDir->exists()) {
         return true;
     }
     if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
         $locationToDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
         //cut here if the locationToDir doesn't exists.
         if (!$locationToDir->exists()) {
             CMS_grandFather::raiseError("LocationToDir does not exists : " . PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo);
             return false;
         }
         //delete all files of the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     $this->raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
         //then copy or move them to the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 $to = str_replace('/' . $locationFrom . '/', '/' . $locationTo . '/', $file);
                 if ($copyOnly) {
                     if (!CMS_file::copyTo($file, $to)) {
                         $this->raiseError("Can't copy file " . $file . " to " . $to);
                         return false;
                     }
                 } else {
                     if (!CMS_file::moveTo($file, $to)) {
                         $this->raiseError("Can't move file " . $file . " to " . $to);
                         return false;
                     }
                 }
                 //then chmod new file
                 CMS_file::chmodFile(FILES_CHMOD, $to);
             }
         }
     } else {
         //then get all files of the locationFromDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     $this->raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
     }
     return true;
 }
示例#7
0
 $value = sensitiveIO::request('value', 'is_array');
 $codename = sensitiveIO::request('module', CMS_modulesCatalog::getAllCodenames());
 $cms_page = CMS_tree::getPageByID($currentPage);
 //RIGHTS CHECK
 if (!is_object($cms_page) || $cms_page->hasError() || !$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT) || !$cms_user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_EDIT)) {
     CMS_grandFather::raiseError('Insufficient rights on page ' . $cms_page->getID());
     break;
 }
 //CHECKS user has module clearance
 if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
     CMS_grandFather::raiseError('Error, user has no rights on module : ' . $codename);
     break;
 }
 //ARGUMENTS CHECK
 if (!$cs || !$rowTag || !$rowId || !$blockId) {
     CMS_grandFather::raiseError('Data missing ...');
     break;
 }
 //instanciate block
 $cms_block = new CMS_block_polymod();
 $cms_block->initializeFromID($blockId, $rowId);
 //instanciate block module
 $cms_module = CMS_modulesCatalog::getByCodename($codename);
 //get block datas if any
 $data = $cms_block->getRawData($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false);
 //get block parameters requirements
 $blockParamsDefinition = $cms_block->getBlockParametersRequirement($data["value"], $cms_page, true);
 //instanciate row
 $row = new CMS_row($rowId);
 //checks and assignments
 $formok = true;
示例#8
0
 /**
  * Analyse a form xhtml code check if it has some copy-pasted code inside
  *
  * @access public
  * @return true if none error found
  */
 function checkFormCode($formCode)
 {
     //get form ID in xhtml code
     $status = preg_match('#<form[^>]* id="cms_forms_(\\d*)"#iU', $formCode, $formId);
     $formId = array_map("trim", $formId);
     if ($status) {
         $formIdXHTML = $formId[1];
     }
     if (isset($formIdXHTML) && $this->getID() && $formIdXHTML != $this->getID()) {
         CMS_grandFather::raiseError("Can't use another form code pasted into XHTML source code");
         return false;
     }
     return true;
 }
示例#9
0
 /**
  * activates the script function.
  *
  * @return void
  * @access public
  */
 function activate()
 {
     parent::activate();
     if ($_SERVER['argv']['1'] == '-s' && SensitiveIO::isPositiveInteger($_SERVER['argv']['2'])) {
         // SUB-SCRIPT : Processes one script task
         @ini_set('max_execution_time', SUB_SCRIPT_TIME_OUT);
         //set max execution time for sub script
         @set_time_limit(SUB_SCRIPT_TIME_OUT);
         //set the PHP timeout for sub script
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tregenerator\n\t\t\t\twhere\n\t\t\t\t\tid_reg = '" . $_SERVER['argv']['2'] . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             //send script informations to process manager
             $this->_processManager->setParameters($data['module_reg'], $data['parameters_reg']);
             //instanciate script module
             $module = CMS_modulesCatalog::getByCodename($data['module_reg']);
             //then send script task to module (return task title by reference)
             $task = $module->scriptTask(unserialize($data['parameters_reg']));
             //delete the current script task
             $sql_delete = "\n\t\t\t\t\tdelete\n\t\t\t\t\tfrom\n\t\t\t\t\t\tregenerator\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_reg='" . $data['id_reg'] . "'";
             $q = new CMS_query($sql_delete);
             if ($this->_debug) {
                 $this->raiseError($this->_processManager->getPIDFilePath() . " : task " . $_SERVER['argv']['2'] . " seems " . (!$task ? 'NOT ' : '') . "done !");
                 $this->raiseError($this->_processManager->getPIDFilePath() . " : PID file exists ? " . @file_exists($this->_processManager->getPIDFilePath()));
             }
             $fpath = $this->_processManager->getPIDFilePath() . '.ok';
             if (@touch($fpath) && @chmod($fpath, octdec(FILES_CHMOD))) {
                 $f = @fopen($fpath, 'a');
                 if (!@fwrite($f, 'Script OK')) {
                     $this->raiseError($this->_processManager->getPIDFilePath() . " : Can't write into file: " . $fpath);
                 }
                 @fclose($f);
             } else {
                 $this->raiseError($this->_processManager->getPIDFilePath() . " : Can't create file: " . $fpath);
             }
         }
     } else {
         // MASTER SCRIPT : Processes all sub-scripts
         @ini_set('max_execution_time', MASTER_SCRIPT_TIME_OUT);
         //set max execution time for master script
         @set_time_limit(MASTER_SCRIPT_TIME_OUT);
         //set the PHP timeout  for master script
         //max simultaneous scripts
         $maxScripts = $_SERVER['argv']['2'];
         $scriptsArray = array();
         //send script informations to process manager
         $this->_processManager->setParameters(processManager::MASTER_SCRIPT_NAME, '');
         //the sql script which selects one script task at a time
         $sql_select = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tregenerator\n\t\t\t\tlimit\n\t\t\t\t\t" . $maxScripts . "\n\t\t\t";
         //and now, launch all sub-scripts until table is empty.
         while (true) {
             //get scripts
             $q = new CMS_query($sql_select);
             if ($q->getNumRows()) {
                 while (count($scriptsArray) < $maxScripts && ($data = $q->getArray())) {
                     // Launch sub-process
                     if (!APPLICATION_IS_WINDOWS) {
                         // On unix system
                         $sub_system = PATH_PACKAGES_FS . "/scripts/script.php -s " . $data["id_reg"] . " > /dev/null 2>&1 &";
                         if (!defined('PATH_PHP_CLI_UNIX') || !PATH_PHP_CLI_UNIX) {
                             CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; php " . $sub_system, $error);
                             if ($error) {
                                 CMS_grandFather::raiseError('Error during execution of sub script command (cd ' . PATH_REALROOT_FS . '; php ' . $sub_system . '), please check your configuration : ' . $error);
                                 return false;
                             }
                         } else {
                             CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; " . PATH_PHP_CLI_UNIX . " " . $sub_system, $error);
                             if ($error) {
                                 CMS_grandFather::raiseError('Error during execution of sub script command (cd ' . PATH_REALROOT_FS . '; ' . PATH_PHP_CLI_UNIX . ' ' . $sub_system . '), please check your configuration : ' . $error);
                                 return false;
                             }
                         }
                         $PIDfile = $this->_processManager->getTempPath() . "/" . SCRIPT_CODENAME . "_" . $data["id_reg"];
                         if ($this->_debug) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : Executes system(" . $sub_system . ")");
                         }
                         //sleep a little
                         @sleep(SLEEP_TIME);
                     } else {
                         // On windows system
                         //Create the BAT file
                         $command = '@echo off' . "\r\n" . '@start /B /BELOWNORMAL ' . realpath(PATH_PHP_CLI_WINDOWS) . ' ' . realpath(PATH_PACKAGES_FS . '\\scripts\\script.php') . ' -s ' . $data["id_reg"];
                         if (!@touch(realpath(PATH_WINDOWS_BIN_FS) . DIRECTORY_SEPARATOR . "sub_script.bat")) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : Create file error : sub_script.bat");
                         }
                         $replace = array('program files (x86)' => 'progra~2', 'program files' => 'progra~1', 'documents and settings' => 'docume~1');
                         $command = str_ireplace(array_keys($replace), $replace, $command);
                         $fh = fopen(realpath(PATH_WINDOWS_BIN_FS . DIRECTORY_SEPARATOR . "sub_script.bat"), "wb");
                         if (is_resource($fh)) {
                             if (!fwrite($fh, $command, io::strlen($command))) {
                                 CMS_grandFather::raiseError(processManager::MASTER_SCRIPT_NAME . " : Save file error : sub_script.bat");
                             }
                             fclose($fh);
                         }
                         $WshShell = new COM("WScript.Shell");
                         $oExec = $WshShell->Run(str_ireplace(array_keys($replace), $replace, realpath(PATH_WINDOWS_BIN_FS . '\\sub_script.bat')), 0, false);
                         $PIDfile = $this->_processManager->getTempPath() . DIRECTORY_SEPARATOR . SCRIPT_CODENAME . "_" . $data["id_reg"];
                         //sleep a little
                         @sleep(SLEEP_TIME);
                     }
                     if ($this->_debug) {
                         $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : script : " . $data["id_reg"] . " - sub_system : " . $sub_system);
                     }
                     $scriptsArray[] = array("PID" => $PIDfile, "startTime" => CMS_stats::getmicrotime(), "scriptID" => $data["id_reg"], "scriptDatas" => $data);
                 }
             } else {
                 // no more scripts to process
                 // > delete all temporary files
                 // > end script
                 if (APPLICATION_IS_WINDOWS) {
                     $files = glob(realpath($this->_processManager->getTempPath()) . DIRECTORY_SEPARATOR . SCRIPT_CODENAME . '*.ok', GLOB_NOSORT);
                     if (is_array($files)) {
                         foreach ($files as $file) {
                             if (!CMS_file::deleteFile($file)) {
                                 $this->raiseError("Can't delete file " . $file);
                                 return false;
                             }
                         }
                     }
                 } else {
                     $tmpDir = dir($this->_processManager->getTempPath());
                     while (false !== ($file = $tmpDir->read())) {
                         if (io::strpos($file, SCRIPT_CODENAME) !== false) {
                             @unlink($this->_processManager->getTempPath() . '/' . $file);
                         }
                     }
                 }
                 break;
             }
             while (true) {
                 @sleep(SLEEP_TIME);
                 //wait a little to check sub_scripts
                 $break = false;
                 $timeStop = CMS_stats::getmicrotime();
                 if ($this->_debug) {
                     $this->raiseError(processManager::MASTER_SCRIPT_NAME . " Scripts in progress : " . sizeof($scriptsArray));
                 }
                 foreach ($scriptsArray as $nb => $aScript) {
                     if ($this->_debug) {
                         $this->raiseError(processManager::MASTER_SCRIPT_NAME . " PID : " . $aScript["PID"] . " - time : " . ($timeStop - $aScript["startTime"]));
                     }
                     $ok = '';
                     $ok = is_file($aScript["PID"] . '.ok');
                     if ($ok) {
                         //$break = true;
                         if ($this->_debug) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " Script : " . $aScript["PID"] . " OK !");
                         }
                         unset($scriptsArray[$nb]);
                     } elseif ($timeStop - $aScript["startTime"] >= SUB_SCRIPT_TIME_OUT) {
                         if ($this->_debug) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : Script : " . $aScript["PID"] . " NOT OK !");
                         }
                         $this->raiseError(processManager::MASTER_SCRIPT_NAME . ' : Error on task : ' . $aScript["scriptID"] . ' ... skip it. Task parameters : ' . print_r($aScript['scriptDatas'], true));
                         //$break = true;
                         unset($scriptsArray[$nb]);
                         //delete the script in error from task list
                         $q_del = "\n\t\t\t\t\t\t\t\tdelete\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\tregenerator\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\tid_reg='" . $aScript["scriptID"] . "'";
                         $q_del = new CMS_query($q_del);
                     }
                 }
                 if (!$scriptsArray) {
                     break;
                 }
             }
         }
     }
 }
示例#10
0
 /**
  * Analyse an array of field id datas and return the CMS_forms_field DB id associated
  *
  * @access private
  * @param string $fieldIDDatas the encoded field id datas to analyse
  * @return integer the field id found
  */
 function extractEncodedID($fieldIDDatas)
 {
     $fieldIDDatas = CMS_forms_field::decodeFieldIdDatas($fieldIDDatas);
     $id = false;
     if (is_array($fieldIDDatas)) {
         foreach ($fieldIDDatas as $anIDData) {
             $id = sensitiveIO::isPositiveInteger($anIDData) ? $anIDData : $id;
         }
     }
     if (!$id) {
         if (is_object($this)) {
             $this->raiseError("No positive integer id found");
             return false;
         } else {
             CMS_grandFather::raiseError("No positive integer id found");
             return false;
         }
     }
     return $id;
 }
$codename = sensitiveIO::request('module');
$rootId = io::substr(sensitiveIO::request('node', 'checkCatId', 'cat0'), 3);
$maxDepth = sensitiveIO::request('maxDepth', 'sensitiveIO::isPositiveInteger', 2);
if (!$codename) {
    CMS_grandFather::raiseError('Unknown module ...');
    $view->show();
}
//load module
$module = CMS_modulesCatalog::getByCodename($codename);
if (!$module) {
    CMS_grandFather::raiseError('Unknown module or module for codename : ' . $codename);
    $view->show();
}
//CHECKS user has module clearance
if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
    CMS_grandFather::raiseError('User has no rights on module : ' . $codename);
    $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($cms_language))));
    $view->show();
}
//get queried module categories
$attrs = array("module" => $codename, "language" => $cms_language, "level" => $rootId, "root" => $rootId ? false : 0, "attrs" => false, "cms_user" => $cms_user);
$categories = CMS_module::getModuleCategories($attrs);
$nodes = array();
foreach ($categories as $category) {
    $parentRight = sensitiveIO::isPositiveInteger($category->getAttribute('parentID')) ? $cms_user->hasModuleCategoryClearance($category->getAttribute('parentID'), CLEARANCE_MODULE_MANAGE) : $cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT);
    $categoryRight = $cms_user->hasModuleCategoryClearance($category->getID(), CLEARANCE_MODULE_MANAGE);
    $hasSiblings = $category->hasSiblings();
    $qtip = $category->getIconPath(false, PATH_RELATIVETO_WEBROOT, true) ? '<img style="max-width:280px;" src="' . $category->getIconPath(true) . '" /><br />' : '';
    $qtip .= $category->getDescription() ? $category->getDescription() . '<br />' : '';
    if ($category->isProtected()) {
        $qtip .= '<strong>' . $cms_language->getMessage(MESSAGE_CATEGORY_PROTECTED) . ' : </strong>' . $cms_language->getMessage(MESSAGE_CATEGORY_PROTECTED_DESC) . '<br />';
示例#12
0
define("MESSAGE_PAGE_EDIT_SELECTED", 1694);
define("MESSAGE_PAGE_CREATE_NEW_LANGUAGE", 1695);
//check user rights
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    CMS_grandFather::raiseError('User has no rights on language management');
    $view->show();
}
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_RAW);
//This file is an admin file. Interface must be secure
$view->setSecure();
$winId = sensitiveIO::request('winId');
if (!$winId) {
    CMS_grandFather::raiseError('Unknown window Id ...');
    $view->show();
}
//usefull vars
$searchURL = PATH_ADMIN_WR . '/languages-datas.php';
$editURL = PATH_ADMIN_WR . '/language.php';
$itemsControlerURL = PATH_ADMIN_WR . '/languages-controler.php';
$jscontent = <<<END
\tvar moduleObjectWindow = Ext.getCmp('{$winId}');
\tmoduleObjectWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_LANGUAGE_MANAGEMENT)}');
\t
\t//define search function into window (to be accessible by parent window)
\tmoduleObjectWindow.search = function() {
\t\tif (!moduleObjectWindow.ok) {
\t\t\treturn;
\t\t}
示例#13
0
 /**
  * Get array of categories this module can use to archive its datas
  *
  * @access public
  * @param array $attrs, array of attributes to determine which level of categoryies wanted, etc.
  *        format : array(language => CMS_language, level => integer, root => integer, attrs => array())
  * @return array(CMS_moduleCategory)
  * @static
  */
 function getModuleCategories($attrs)
 {
     if ((!isset($attrs["module"]) || !$attrs["module"]) && $this->_codename) {
         $attrs["module"] = $this->_codename;
     }
     if (!$attrs["module"]) {
         CMS_grandFather::raiseError("No codename defined to get its categories");
         return false;
     }
     if (APPLICATION_ENFORCES_ACCESS_CONTROL != false && !$attrs["cms_user"] instanceof CMS_profile) {
         CMS_grandFather::raiseError("Not valid CMS_profile given as enforced access control is active");
         return false;
     }
     if (isset($attrs["cms_user"]) && $attrs["cms_user"] instanceof CMS_profile && $attrs["cms_user"]->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
         // If current user is an adminsitrator, let's show all categories anytime
         unset($attrs["cms_user"]);
     }
     if (is_array($attrs) && $attrs) {
         $items = CMS_moduleCategories_catalog::getAll($attrs);
     }
     return $items;
 }
示例#14
0
}
if (!is_file($file)) {
    //file creation
    $fileCreation = true;
    $extension = '';
    $fileId = md5(rand());
    $fileDefinition = '';
    $labelField = "{\n\t\txtype:\t\t\t'textfield',\n\t\tvalue:\t\t\t'',\n\t\tname:\t\t\t'filelabel',\n\t\tfieldLabel:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_LABEL)}',\n\t\tborder:\t\t\tfalse,\n\t\tbodyStyle: \t\t'padding-bottom:10px'\n\t},";
    $anchor = '-110';
    $action = 'create';
} else {
    //file edition
    $fileCreation = false;
    $extension = io::strtolower(pathinfo($file, PATHINFO_EXTENSION));
    if (!isset($allowedFiles[$extension])) {
        CMS_grandFather::raiseError('Action on this type of file is not allowed.');
        $view->show();
    }
    $fileId = md5($file);
    $file = new CMS_file($file);
    $fileDefinition = $file->readContent();
    $labelField = '';
    $anchor = '-60';
    $action = 'update';
}
if (strtolower(APPLICATION_DEFAULT_ENCODING) == 'utf-8') {
    if (!io::isUTF8($fileDefinition)) {
        $fileDefinition = utf8_encode($fileDefinition);
    }
} else {
    if (io::isUTF8($fileDefinition)) {
示例#15
0
 /**
  * Get a CMS_textEditor from given parameters
  * 
  * @param mixed array(), $attrs each key => value is an attribute
  * of this class or an attribute to fckeditor
  * @return CMS_textEditor or null if error
  */
 function getEditorFromParams($attrs)
 {
     if (!is_array($attrs)) {
         CMS_grandFather::raiseError("None array of attributes passed to factory");
         return null;
     }
     $text_editor = new CMS_textEditor($attrs['form'], $attrs['field'], $attrs['value'], $_SERVER["HTTP_USER_AGENT"], '', $attrs['language'], $attrs['width'], $attrs['rows']);
     $fck_attrs = array('ToolbarSet' => $attrs['toolbarset'], 'Width' => $attrs['width'], 'Height' => $attrs['height']);
     $text_editor->setEditorAttributes($fck_attrs);
     return $text_editor;
 }
                    $cms_message = $cms_language->getMessage(MESSAGE_ERROR_NO_PAGES_FOUND);
                }
            }
        }
        break;
    case 'restart-scripts':
        CMS_scriptsManager::startScript(true);
        $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
        break;
    case 'stop-scripts':
        CMS_scriptsManager::clearScripts();
        CMS_scriptsManager::startScript(true);
        $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
        break;
    case 'clear-scripts':
        CMS_scriptsManager::clearScripts();
        $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
        break;
    default:
        CMS_grandFather::raiseError('Unknown action to do ...');
        $view->show();
        break;
}
//set user message if any
if ($cms_message) {
    $view->setActionMessage($cms_message);
}
if ($content) {
    $view->setContent($content);
}
$view->show();
示例#17
0
// $Id: polymod-help.php,v 1.3 2010/03/08 16:42:07 sebastien Exp $
/**
 * PHP page : Load polymod help for object.
 * Used accross an Ajax request.
 *
 * @package Automne
 * @subpackage admin
 * @author Sébastien Pauchet <*****@*****.**>
 */
define("ENABLE_HTML_COMPRESSION", false);
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
define('MESSAGE_PAGE_NO_LOGS', 1608);
define("MESSAGE_PAGE_NO_SERVER_RIGHTS", 748);
//CHECKS user has admin clearance
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    CMS_grandFather::raiseError('User has no administration rights');
    echo $cms_language->getMessage(MESSAGE_PAGE_NO_SERVER_RIGHTS);
    exit;
}
$date = sensitiveIO::request('date');
$errorFile = '';
$gzip = false;
$now = new CMS_date();
$now->setNow(true);
$requestedDate = new CMS_date();
$requestedDate->setFormat($cms_language->getDateFormat());
$requestedDate->setLocalizedDate($date);
if (!$requestedDate->hasError()) {
    if (CMS_date::compare($requestedDate, $now, '==')) {
        $errorFile = PATH_MAIN_FS . '/' . CMS_grandFather::ERROR_LOG;
    } else {
示例#18
0
 /**
  * Start the scripts process queue.
  * Remove the lock file then relaunch the script if force is true
  *
  * @param boolean $force Set to true if you wish to remove the lock file before launch
  * @return void
  * @access public
  * @static
  */
 static function startScript($force = false)
 {
     if (USE_BACKGROUND_REGENERATOR) {
         $forceRestart = '';
         if ($force) {
             $forceRestart = ' -F';
         } elseif (processManager::hasRunningScript()) {
             return false;
         }
         //test if we're on windows or linux, for the output redirection
         if (APPLICATION_IS_WINDOWS) {
             if (realpath(PATH_PHP_CLI_WINDOWS) === false) {
                 CMS_grandFather::raiseError("Unknown CLI location : " . PATH_PHP_CLI_WINDOWS . ", please check your configuration.");
                 return false;
             }
             // Create the BAT file
             $command = '@echo off' . "\r\n" . 'start /B /LOW ' . realpath(PATH_PHP_CLI_WINDOWS) . ' ' . realpath(PATH_PACKAGES_FS . '\\scripts\\script.php') . ' -m ' . REGENERATION_THREADS . $forceRestart;
             $replace = array('program files (x86)' => 'progra~2', 'program files' => 'progra~1', 'documents and settings' => 'docume~1');
             $command = str_ireplace(array_keys($replace), $replace, $command);
             if (!@touch(PATH_WINDOWS_BIN_FS . "/script.bat")) {
                 CMS_grandFather::_raiseError("CMS_scriptsManager : startScript : Create file error : " . PATH_WINDOWS_BIN_FS . "/script.bat");
                 return false;
             }
             $fh = @fopen(PATH_WINDOWS_BIN_FS . "/script.bat", "wb");
             if (is_resource($fh)) {
                 if (!@fwrite($fh, $command, io::strlen($command))) {
                     CMS_grandFather::raiseError("Save file error : script.bat");
                 }
                 @fclose($fh);
             }
             $WshShell = new COM("WScript.Shell");
             $oExec = $WshShell->Run(str_ireplace(array_keys($replace), $replace, realpath(PATH_WINDOWS_BIN_FS . '\\script.bat')), 0, false);
         } else {
             $error = '';
             if (!defined('PATH_PHP_CLI_UNIX') || !PATH_PHP_CLI_UNIX) {
                 $return = CMS_patch::executeCommand('which php 2>&1', $error);
                 if ($error) {
                     CMS_grandFather::raiseError('Error when finding php CLI with command "which php", please check your configuration : ' . $error);
                     return false;
                 }
                 if (io::substr($return, 0, 1) != '/') {
                     CMS_grandFather::raiseError('Can\'t find php CLI with command "which php", please check your configuration.');
                     return false;
                 }
                 $return = CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; php " . PATH_PACKAGES_FS . "/scripts/script.php -m " . REGENERATION_THREADS . $forceRestart . " > /dev/null 2>&1 &", $error);
                 if ($error) {
                     CMS_grandFather::raiseError('Error during execution of script command (cd ' . PATH_REALROOT_FS . '; php ' . PATH_PACKAGES_FS . '/scripts/script.php -m ' . REGENERATION_THREADS . $forceRestart . '), please check your configuration : ' . $error);
                     return false;
                 }
             } else {
                 $return = CMS_patch::executeCommand(PATH_PHP_CLI_UNIX . ' -v 2>&1', $error);
                 if ($error) {
                     CMS_grandFather::raiseError('Error when testing php CLI with command "' . PATH_PHP_CLI_UNIX . ' -v", please check your configuration : ' . $error);
                     return false;
                 }
                 if (io::strpos(io::strtolower($return), '(cli)') === false) {
                     CMS_grandFather::raiseError(PATH_PHP_CLI_UNIX . ' is not the CLI version');
                     return false;
                 }
                 $return = CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; " . PATH_PHP_CLI_UNIX . " " . PATH_PACKAGES_FS . "/scripts/script.php -m " . REGENERATION_THREADS . $forceRestart . " > /dev/null 2>&1 &", $error);
                 if ($error) {
                     CMS_grandFather::raiseError('Error during execution of script command (cd ' . PATH_REALROOT_FS . '; ' . PATH_PHP_CLI_UNIX . ' ' . PATH_PACKAGES_FS . '/scripts/script.php -m ' . REGENERATION_THREADS . $forceRestart . '), please check your configuration : ' . $error);
                     return false;
                 }
             }
             //CMS_grandFather::log($return);
             //CMS_grandFather::log("cd ".PATH_REALROOT_FS."; php ".PATH_PACKAGES_FS."/scripts/script.php -m ".REGENERATION_THREADS.$forceRestart." > /dev/null 2>&1 &");
             //@system("cd ".PATH_REALROOT_FS."; php ".PATH_PACKAGES_FS."/scripts/script.php -m ".REGENERATION_THREADS.$forceRestart." > /dev/null 2>&1 &");
         }
     } else {
         CMS_session::setSessionVar('start_script', true);
     }
 }
if ($cms_page->hasError()) {
    CMS_grandFather::raiseError('Selected page (' . $currentPage . ') has error ...');
    $view->show();
}
//check user rights
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) {
    CMS_grandFather::raiseError('Error, user has no rights on page : ' . $cms_page->getID());
    $view->show();
}
//get block datas
if (class_exists($blockClass)) {
    $cms_block = new $blockClass();
    $cms_block->initializeFromBasicAttributes($blockId);
    $rawDatas = $cms_block->getRawData($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false);
} else {
    CMS_grandFather::raiseError('Error, can\'t get block class : ' . $blockClass);
    $view->show();
}
$maxFileSize = CMS_file::getMaxUploadFileSize('K');
if ($rawDatas['file'] && file_exists(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file'])) {
    $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file']);
    $fileDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension());
} else {
    $fileDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
}
$filePath = $fileDatas['filepath'];
$fileDatas = sensitiveIO::jsonEncode($fileDatas);
$flashvars = sensitiveIO::sanitizeJSString($rawDatas["flashvars"]);
$params = sensitiveIO::sanitizeJSString($rawDatas["params"]);
$attributes = sensitiveIO::sanitizeJSString($rawDatas["attributes"]);
$jscontent = <<<END
示例#20
0
 /**
  * Create the redirection of an alias
  *
  * @return boolean true on success, false on failure
  * @access public
  * @static
  */
 function redirect()
 {
     //get aliases for current folder
     $dirname = array_pop(explode(DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_NAME'])));
     $aliases = CMS_module_cms_aliases::getByName($dirname);
     if (!$aliases) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']));
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //check each aliases returned to get the one which respond to current alias
     $matchAlias = false;
     $domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']);
     $websites = array();
     if ($domain) {
         $websites = CMS_websitesCatalog::getWebsitesFromDomain($domain);
     }
     foreach ($aliases as $alias) {
         if (!$matchAlias && dirname($_SERVER['SCRIPT_NAME']) == substr($alias->getPath(), 0, -1)) {
             if ($websites) {
                 foreach ($websites as $website) {
                     //alias match path, check for website
                     if (!$alias->getWebsites() || !$website || in_array($website->getId(), $alias->getWebsites())) {
                         //alias match website, use it
                         $matchAlias = $alias;
                     }
                 }
             } else {
                 //alias match path, check for website
                 if (!$alias->getWebsites()) {
                     //alias match website, use it
                     $matchAlias = $alias;
                 }
             }
         }
     }
     if (!$matchAlias) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']) . ' and domain ' . $domain);
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //if alias is used as a page url, return page
     if ($matchAlias->urlReplaced()) {
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             $page = CMS_tree::getPageById($matchAlias->getPageID());
         } else {
             //no valid page set, go to 404
             $matchAlias->raiseError('No page set for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         if (!$page || $page->hasError()) {
             //no valid page found, go to 404
             $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         //return page path
         $pPath = $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
         if ($pPath) {
             if (file_exists($pPath)) {
                 return $pPath;
             } elseif ($page->regenerate(true)) {
                 clearstatcache();
                 if (file_exists($pPath)) {
                     return $pPath;
                 }
             }
         }
         //no valid url page found, go to 404
         $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     } else {
         //this is a redirection
         $params = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
         if (isset($_SERVER['HTTP_REFERER'])) {
             header("Referer: " . $_SERVER['HTTP_REFERER']);
         }
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             //it's a redirection to an Automne Page
             $page = CMS_tree::getPageById($matchAlias->getPageID());
             if ($page && !$page->hasError()) {
                 $pageURL = CMS_tree::getPageValue($matchAlias->getPageID(), 'url');
                 if ($pageURL) {
                     CMS_view::redirect($pageURL . $params, true, $matchAlias->isPermanent() ? 301 : 302);
                 } else {
                     //no valid url page found, go to 404
                     $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                     CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
                 }
             } else {
                 //no valid page found, go to 404
                 $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                 CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
             }
         } elseif ($matchAlias->getURL()) {
             //it's a redirection to an URL
             CMS_view::redirect($matchAlias->getURL(), true, $matchAlias->isPermanent() ? 301 : 302);
         } else {
             //no valid redirection found, go to 404
             $matchAlias->raiseError('Invalid redirection for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
     }
 }
示例#21
0
        if ($lock = $item->getLock()) {
            $lockUser = CMS_profile_usersCatalog::getById($lock);
            $lockDate = $item->getLockDate();
            $date = $lockDate ? $lockDate->getLocalizedDate($cms_language->getDateFormat() . ' @ H:i:s') : '';
            $name = sensitiveIO::sanitizeJSString($lockUser->getFullName());
            CMS_grandFather::raiseError('Error, item ' . $itemId . ' is locked by ' . $lockUser->getFullName());
            $jscontent = "\n\t\t\tvar window = Ext.getCmp('{$winId}');\n\t\t\tif (window) {\n\t\t\t\twindow.close();\n\t\t\t}\n\t\t\tAutomne.message.popup({\n\t\t\t\tmsg: \t\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_ELEMENT_LOCKED, array($itemLabel, $name, $date), MOD_POLYMOD_CODENAME)}',\n\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\ticon: \t\t\t\tExt.MessageBox.ERROR\n\t\t\t});";
            $view->addJavascript($jscontent);
            $view->show();
        } else {
            $item->lock($cms_user);
        }
    }
    //check user rights on item
    if (!$item->userHasClearance($cms_user, CLEARANCE_MODULE_EDIT)) {
        CMS_grandFather::raiseError('Error, user has no rights item ' . $itemId);
        $jscontent = "\n\t\tvar window = Ext.getCmp('{$winId}');\n\t\tif (window) {\n\t\t\twindow.close();\n\t\t}\n\t\tAutomne.message.popup({\n\t\t\tmsg: \t\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_ELEMENT_EDIT_RIGHTS_ERROR, array($itemLabel), MOD_POLYMOD_CODENAME)}',\n\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\tclosable: \t\t\tfalse,\n\t\t\ticon: \t\t\t\tExt.MessageBox.ERROR\n\t\t});";
        $view->addJavascript($jscontent);
        $view->show();
    }
} else {
    //instanciate clean object (creation)
    $item = new CMS_poly_object($object->getID(), '');
}
$winLabel = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_TITLE_MODULE, array($cms_module->getLabel($cms_language))) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE, array($object->getLabel($cms_language)), MOD_POLYMOD_CODENAME));
$fieldsObjects = $item->getFieldsObjects();
$itemFields = '';
foreach ($fieldsObjects as $fieldID => $aFieldObject) {
    $fieldAdmin = $item->getHTMLAdmin($fieldID, $cms_language, '');
    if (is_array($fieldAdmin)) {
        $itemFields .= sensitiveIO::jsonEncode($fieldAdmin) . ',';
示例#22
0
 public function __construct($message, $code = 0)
 {
     CMS_grandFather::raiseError($message);
 }
 /**
  * Replace vars like {object:field:type} or {var|session|request|page:name:type}. Called during definition compilation
  *
  * @param string $text : the text which need to be replaced
  * @param boolean reverse : reverse single and double quotes useage (default is false : double quotes)
  * @param array $optionalReplacement : optionnal replacement to do
  * @param boolean $cleanNotMatches : remove vars without matches
  * @param mixed $matchCallback : function name or array(object classname, object method) which represent a valid callback function to execute on matches
  * @return text : the text replaced
  * @access public
  */
 function preReplaceVars($text, $reverse = false, $cleanNotMatches = false, $matchCallback = array('CMS_polymod_definition_parsing', 'encloseString'), $returnMatchedVarsArray = false)
 {
     static $replacements;
     //if no text => return
     if (!$text || !trim($text)) {
         return $text;
     }
     //substitute simple replacement values
     $preReplaceCount = 0;
     $text = preg_replace("#{([a-zA-Z]+)}#", '@@@\\1@@@', $text, -1, $preReplaceCount);
     $count = 1;
     //loop on text for vars to replace if any
     while (preg_match_all("#{[^{}\n]+}#", $text, $matches) && $count) {
         $matches = array_unique($matches[0]);
         //get all tags handled by modules
         if (!$replacements) {
             //create replacement array
             $replacements = array();
             $modules = CMS_modulesCatalog::getAll("id");
             foreach ($modules as $codename => $aModule) {
                 $moduleReplacements = $aModule->getModuleReplacements();
                 if (is_array($moduleReplacements) && $moduleReplacements) {
                     foreach ($moduleReplacements as $pattern => $replacement) {
                         $replacements[$pattern] = $replacement;
                     }
                 }
             }
         }
         $replace = $replacements;
         //pr($matches);
         if ($reverse) {
             $reversedReplace = array();
             foreach ($replace as $key => $value) {
                 $reversedReplace[str_replace("'", "\\\\'", $key)] = $value;
             }
             $replace = $reversedReplace;
         }
         $count = 0;
         $matchesValues = preg_replace(array_keys($replace), $replace, $matches, -1, $count);
         //create vars conversion table
         $replace = array();
         if ($matchesValues) {
             if (isset($this->_parameters['module'])) {
                 $externalReferences = CMS_poly_object_catalog::getFieldsReferencesUsage($this->_parameters['module']);
             } else {
                 $externalReferences = CMS_poly_object_catalog::getFieldsReferencesUsage();
             }
             foreach ($matches as $key => $match) {
                 //record external references for cache reference
                 if ($externalReferences) {
                     foreach ($externalReferences as $id => $type) {
                         if (strpos($match, '[\'fields\'][' . $id . ']') !== false || strpos($match, '[\\\'fields\\\'][' . $id . ']') !== false) {
                             //CMS_grandFather::log(print_r($this->_elements, true));
                             $this->_elements = array_merge_recursive($type, (array) $this->_elements);
                             //CMS_grandFather::log(print_r($this->_elements, true));
                         }
                     }
                 }
                 //record used pages for cache reference
                 if (strpos($match, '{page:') !== false) {
                     $this->_elements['module'][] = MOD_STANDARD_CODENAME;
                 }
                 //record used users for cache reference
                 if (strpos($match, '{user:'******'resource'][] = 'users';
                 }
                 if ($match != $matchesValues[$key]) {
                     $matchValue = $matchesValues[$key];
                 } else {
                     $matchValue = null;
                 }
                 //apply callback if any to value
                 if (isset($matchValue)) {
                     if ($matchCallback !== false) {
                         if (is_callable($matchCallback)) {
                             $replace[$match] = call_user_func($matchCallback, $matchValue, $reverse);
                         } else {
                             CMS_grandFather::raiseError("Unknown callback function : " . $matchCallback);
                             return false;
                         }
                     } else {
                         $replace[$match] = $matchValue;
                     }
                 } elseif ($cleanNotMatches) {
                     $replace[$match] = '';
                 }
             }
         }
         //return matched vars if needed
         if ($returnMatchedVarsArray) {
             //substitute simple replacement values
             if ($preReplaceCount) {
                 $replace = preg_replace("#\\@\\@\\@([a-zA-Z]+)\\@\\@\\@#", '{\\1}', $replace);
             }
             return $replace;
         } else {
             //then replace variables in text and return it
             $text = str_replace(array_keys($replace), $replace, $text);
         }
     }
     //substitute simple replacement values
     if ($preReplaceCount) {
         $text = preg_replace("#\\@\\@\\@([a-zA-Z]+)\\@\\@\\@#", '{\\1}', $text);
     }
     return $text;
 }
示例#24
0
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_RAW);
//This file is an admin file. Interface must be secure
$view->setSecure();
$winId = sensitiveIO::request('winId', '', 'copyPageWindow');
$currentPage = sensitiveIO::request('currentPage', 'sensitiveIO::isPositiveInteger');
//try to instanciate the requested page
$cms_page = CMS_tree::getPageByID($currentPage);
//instanciate page and check if user has view rights on it
if (isset($cms_page) && $cms_page->hasError() || !is_object($cms_page)) {
    CMS_grandFather::raiseError('Error on page : ' . $cms_page->getID());
    $view->show();
}
//check for view rights for user
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_VIEW)) {
    CMS_grandFather::raiseError('Error, user has no rights on page : ' . $cms_page->getID());
    $view->show();
}
$pageId = $cms_page->getID();
$pageTitle = sensitiveIO::sanitizeJSString($cms_page->getTitle(true));
$onClick = base64_encode("\n\tthis.node.select();\n");
//Page templates replacement
$pageTemplate = $cms_page->getTemplate();
//hack if page has no valid template attached
if (!is_a($pageTemplate, "CMS_pageTemplate")) {
    $pageTemplate = new CMS_pageTemplate();
}
$pageTplId = CMS_pageTemplatesCatalog::getTemplateIDForCloneID($pageTemplate->getID());
$pageTplLabel = sensitiveIO::sanitizeJSString($pageTemplate->getLabel());
$jscontent = <<<END
\tvar copyPageWindow = Ext.getCmp('{$winId}');
示例#25
0
$module = CMS_modulesCatalog::getByCodename($codename);
if (!$module || !$module->isPolymod()) {
    CMS_grandFather::raiseError('Unknown module or module is not polymod for codename : ' . $codename);
    $view->setContent($itemsDatas);
    $view->show();
}
//CHECKS user has module clearance
if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
    CMS_grandFather::raiseError('User has no rights on module : ' . $codename);
    $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($cms_language))));
    $view->setContent($itemsDatas);
    $view->show();
}
//CHECKS objectId
if (!$objectId) {
    CMS_grandFather::raiseError('Missing objectId to search in module ' . $codename);
    $view->setContent($itemsDatas);
    $view->show();
}
//load current object definition
$object = CMS_poly_object_catalog::getObjectDefinition($objectId);
// Check if need to use a specific display for search results
$resultsDefinition = $object->getValue('resultsDefinition');
//load fields objects for object
$objectFields = CMS_poly_object_catalog::getFieldsDefinition($object->getID());
//Add all subobjects to search if any
$fields = array();
$possibleTargets = array();
foreach ($objectFields as $fieldID => $field) {
    if (isset($_REQUEST['items_' . $object->getID() . '_' . $fieldID])) {
        $fields[$fieldID] = sensitiveIO::request('items_' . $object->getID() . '_' . $fieldID, '', '');
示例#26
0
$view->setDisplayMode(CMS_view::SHOW_JSON);
//This file is an admin file. Interface must be secure
$view->setSecure();
//get search vars
$search = sensitiveIO::request('search');
$letter = sensitiveIO::request('letter');
$sort = sensitiveIO::request('sort');
$dir = sensitiveIO::request('dir');
$start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0);
$limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', CMS_session::getRecordsPerPage());
$userId = sensitiveIO::request('userId', 'sensitiveIO::isPositiveInteger');
$filter = sensitiveIO::request('filter') ? true : false;
$groupsDatas = array();
$groupsDatas['groups'] = array();
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITUSERS)) {
    CMS_grandFather::raiseError('User has no users management rights ...');
    $view->setContent($groupsDatas);
    $view->show();
}
//load user's groups if any
if ($userId) {
    $userGroups = CMS_profile_usersGroupsCatalog::getGroupsOfUser($userId, true);
} else {
    $userGroups = array();
}
if ($userId && $filter) {
    //search users
    $groups = CMS_profile_usersGroupsCatalog::search($search, $letter, $userId, array(), $sort, $dir, $start, $limit);
} else {
    //search users
    $groups = CMS_profile_usersGroupsCatalog::search($search, $letter, false, array(), $sort, $dir, $start, $limit);
                $modulesTreatment->setDefinition($datas);
                $datas = $modulesTreatment->treatContent(true);
                //set datas as returned content
                $view->setContent($datas);
                $edited = true;
            } else {
                CMS_grandFather::raiseError('Can\'t get row type ' . $rowId . ' from clientspace ' . $cs . ' of page ' . $cms_page->getID() . ' with row id ' . $rowTag);
                $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT));
            }
        } else {
            CMS_grandFather::raiseError('Can\'t get block class type ' . $blockClass . ' to update content');
            $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT));
        }
        break;
    default:
        CMS_grandFather::raiseError('Unknown action ' . $action . ' to do for page ' . $currentPage);
        $view->show();
        break;
}
//set user message if any
if (isset($cms_message) && $cms_message) {
    $view->setActionMessage($cms_message);
}
//Eval PHP content if any
$content = $view->getContent();
if (io::strpos($content, '<?php') !== false) {
    ob_start();
    $content = sensitiveIO::evalPHPCode($content);
    $return = ob_get_clean();
    $content = $return . $content;
    //set datas as returned content
示例#28
0
 function toXML(&$definition, $part = false, $replaceVars = false)
 {
     //return back xml
     $result = "";
     if (!$definition && is_object($this)) {
         $definition = $this->_arrOutput;
     }
     if (!$definition) {
         parent::raiseError("No definition found");
         return '';
     }
     $c = 0;
     while (isset($definition[$c])) {
         //assign node value
         if (isset($definition[$c]["textnode"])) {
             //replacements on text nodes
             if ($replaceVars) {
                 $dummyTag = new CMS_XMLTag('html', array(), array(), array('context' => CMS_XMLTag::HTML_CONTEXT));
                 $result .= $dummyTag->replaceVars((string) $definition[$c]["textnode"]);
             } else {
                 $result .= (string) $definition[$c]["textnode"];
             }
         } elseif (isset($definition[$c]["phpnode"])) {
             //replacements on text nodes
             if ($replaceVars) {
                 $dummyTag = new CMS_XMLTag('html', array(), array(), array('context' => CMS_XMLTag::HTML_TAG_CONTEXT));
                 $result .= '<?php ' . $dummyTag->replaceVars($definition[$c]["phpnode"]) . ' ?>';
             } else {
                 $result .= '<?php ' . $definition[$c]["phpnode"] . ' ?>';
             }
         } else {
             $autoclosed = in_array($definition[$c]["nodename"], CMS_xml2Array::$autoClosedTagsList) || substr($definition[$c]["nodename"], 0, 3) == 'atm' && !isset($definition[$c]["childrens"]);
             if (!$part || $part == self::ARRAY2XML_START_TAG) {
                 $tagOpening = '<' . $definition[$c]["nodename"];
                 if (is_array($definition[$c]["attributes"])) {
                     while (list($key, $value) = each($definition[$c]["attributes"])) {
                         $tagOpening .= ' ' . $key . '="' . $value . '"';
                     }
                 }
                 $tagOpening .= $autoclosed ? ' />' : '>';
                 $tagOpenReplaced = false;
                 if ($replaceVars) {
                     $dummyTag = new CMS_XMLTag('html', array(), array(), array('context' => CMS_XMLTag::HTML_TAG_CONTEXT));
                     $prepared = addcslashes($tagOpening, '"');
                     $replaced = $dummyTag->replaceVars($prepared);
                     if ($replaced != $prepared) {
                         $tagOpening = '<?php echo "' . $replaced . '"; ?>';
                         $tagOpenReplaced = true;
                     }
                 }
                 $result .= $tagOpening;
             }
             if (!$part) {
                 if (isset($definition[$c]["childrens"])) {
                     $result .= $this->toXML($definition[$c]["childrens"], $part);
                 }
             }
             if ((!$part || $part == self::ARRAY2XML_END_TAG) && !$autoclosed) {
                 $tagClose = '</' . $definition[$c]["nodename"] . '>';
                 if (isset($tagOpenReplaced) && $tagOpenReplaced) {
                     $tagClose = '<?php echo "' . $tagClose . '"; ?>';
                 }
                 $result .= $tagClose;
             }
         }
         $c++;
     }
     return $result;
 }
示例#29
0
function getMainURL()
{
    CMS_grandFather::raiseError('This function is no longer available in this version of Automne');
    return false;
}
示例#30
0
 /**
  * Create a CMS_linxCondition instance from a given DOMElement
  *
  * @param DOMElement $tag The DOMElement to convert
  * @return CMS_linxNodespec The CMS_linxCondition instance
  * @access public
  * @static
  */
 static function createCondition($tag)
 {
     if (!is_a($tag, "DOMElement")) {
         CMS_grandFather::raiseError('Tag is not a DOMElement instance');
         return false;
     }
     if (!$tag->hasAttribute("property") || !$tag->hasAttribute("operator")) {
         $this->raiseError('Condition property is not well formed');
         return false;
     }
     return new CMS_linxCondition($tag);
 }