예제 #1
0
 /**
  * Constructor
  * 
  * @access public
  * @param integer $id
  * @return void 
  */
 function __construct($id = 0)
 {
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_senders\n\t\t\t\twhere\n\t\t\t\t\tid_snd='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_senderID = $id;
             $this->_userID = $data["userID_snd"];
             $this->_clientIP = $data["clientIP_snd"];
             $this->_sessionID = $data["sessionID_snd"];
             $this->_languages = $data["languages_snd"];
             $this->_userAgent = $data["userAgent_snd"];
             if ($data["dateInserted_snd"] != '') {
                 $this->_dateInserted = new CMS_date(date("m-d-Y H:m:s", $data["dateInserted_snd"]));
             }
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     } else {
         $this->_dateInserted = new CMS_date();
         $this->_dateInserted->setNow();
     }
 }
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     $datas = array();
     if ($id && !$dbValues) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_plugin_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mowd='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $datas = $q->getArray();
         } else {
             $this->raiseError("Unknown ID :" . $id);
             return;
         }
     } elseif (is_array($dbValues) && $dbValues) {
         $datas = $dbValues;
     }
     if (is_array($datas) && $datas) {
         $this->_ID = (int) $datas['id_mowd'];
         $this->_objectValues["objectID"] = (int) $datas['object_id_mowd'];
         $this->_objectValues["labelID"] = (int) $datas['label_id_mowd'];
         $this->_objectValues["descriptionID"] = (int) $datas['description_id_mowd'];
         $this->_objectValues["query"] = $datas['query_mowd'] ? unserialize($datas['query_mowd']) : array();
         $this->_objectValues["definition"] = $datas['definition_mowd'];
         $this->_objectValues["compiledDefinition"] = $datas['compiled_definition_mowd'];
         $this->_objectValues["uuid"] = isset($datas['uuid_mowd']) ? $datas['uuid_mowd'] : '';
         //for compatibility with version < 0.97
         if ($this->_objectValues["definition"] && !$this->_objectValues["compiledDefinition"]) {
             $this->compileDefinition();
             $this->writeToPersistence();
         }
     }
 }
예제 #3
0
 /**
  * @param array(CMS_users) $users users to send message to
  * @param array(CMS_profile_user) $users
  * @param array($language=>$subject) $messages indexed by languages code
  * @param array($language=>$subject) $subjects indexed by languages code
  * @param integer $alertLevel
  * @return void
  * @access public
  */
 function setUserMessages($users, $messages, $subjects, $alertLevel = ALERT_LEVEL_VALIDATION, $module = MOD_STANDARD_CODENAME)
 {
     $mainURL = CMS_websitesCatalog::getMainURL();
     $template = is_file(PATH_MAIL_TEMPLATES_FS) ? PATH_MAIL_TEMPLATES_FS : '';
     foreach ($users as $user) {
         //if is integer create user object
         if (!is_a($user, "CMS_user_profile") && SensitiveIO::isPositiveInteger($user)) {
             $user = CMS_profile_usersCatalog::getByID($user);
         }
         //if user hasn't alert level for this module or user is not active anymore, skip it
         if (!$user->hasAlertLevel($alertLevel, $module) || $user->isDeleted() || !$user->isActive()) {
             //CMS_grandFather::raiseError('user '.$user->getFullName().' has no alerts for level '.$alertLevel.' for module '.$module);
             continue;
         }
         $userLang = $user->getLanguage();
         $email = new CMS_email();
         if ($user->getEmail()) {
             if ($email->setEmailTo($user->getEmail())) {
                 $email->setSubject($subjects[$userLang->getCode()], true);
                 $email->setBody($messages[$userLang->getCode()]);
                 $email->setFooter($userLang->getMessage(self::MESSAGE_EMAIL_BODY_URLS, array(APPLICATION_LABEL, $mainURL . "/", $mainURL . PATH_ADMIN_WR . "/")));
                 $email->setTemplate($template);
                 $this->_messages[] = $email;
             } else {
                 $this->raiseError("Email Catalog: email invalid (" . $user->getEmail() . ") for user : " . $user->getFullName());
             }
         }
     }
 }
예제 #4
0
 /**
  * Constructor.
  * initializes the toolbar if the id is given.
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function __construct($id = 0, &$user)
 {
     if (!is_a($user, 'CMS_profile_user') || $user->hasError()) {
         $this->raiseError("User is not a valid CMS_profile_user");
         return;
     }
     $this->_user = $user;
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\ttoolbars\n\t\t\t\twhere\n\t\t\t\t\tid_tool='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_code = $data["code_tool"];
             $this->_label = $data["label_tool"];
             $this->_toolbarElements = explode('|', $data["elements_tool"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     } else {
         $this->_toolbarElements = array_keys($this->_elements);
     }
 }
예제 #5
0
 /**
  * Constructor.
  * initializes the linxDisplay.
  *
  * @param string $innerContent The tag content.
  * @return void
  * @access public
  */
 function __construct($type, $value, $relativeOffset, $crosswebsite = false, $website = '')
 {
     $authorized_types = array("node", "relative", "codename");
     $authorized_string_values = array("self", "brother", "father", "root");
     $this->_crosswebsite = $crosswebsite;
     if (!SensitiveIO::isInSet($type, $authorized_types)) {
         $this->raiseError("Type unknown : " . $type);
         return;
     }
     if ($type == 'node' && !SensitiveIO::isPositiveInteger($value)) {
         $this->raiseError("Bad value for 'node' type : " . $value);
         return;
     }
     if ($type == 'relative' && !SensitiveIO::isInSet($value, $authorized_string_values)) {
         $this->raiseError("Bad value for 'relative' type : " . $value);
         return;
     }
     if ($type == 'codename' && strtolower(io::sanitizeAsciiString($value)) != $value) {
         $this->raiseError("Bad value for 'codename' type : " . $value);
         return;
     }
     if ($type == 'codename' && strtolower(io::sanitizeAsciiString($website)) != $website) {
         $this->raiseError("Bad value for 'website' : " . $website);
         return;
     }
     $this->_type = $type;
     $this->_value = $value;
     $this->_website = $website;
     if ($this->_type == 'relative') {
         $this->_relativeOffset = $relativeOffset;
     }
 }
예제 #6
0
 /**
  * Get a contact data by Id
  *
  * @param integer or array $data
  * @return CMS_contactData or null
  * @access public
  */
 static function getById($data)
 {
     if (SensitiveIO::isPositiveInteger($data) || is_array($data)) {
         $obj = new CMS_contactData($data);
         if (!$obj->hasError()) {
             return $obj;
         }
     }
     return new CMS_contactData();
 }
예제 #7
0
 /**
  * Returns a queried CMS_website value
  * Static function.
  *
  * @param integer $id The DB ID of the wanted CMS_website
  * @param string $type The value type to get
  * @return CMS_website value or false on failure to find it
  * @access public
  */
 static function getWebsiteValue($id, $type)
 {
     static $websitesInfos;
     if (!SensitiveIO::isPositiveInteger($id)) {
         CMS_grandFather::raiseError("Website id must be positive integer : " . $id);
         return false;
     }
     if (!isset($websitesInfos[$id][$type])) {
         $website = CMS_websitesCatalog::getByID($id);
         if (!$website) {
             $return = false;
         } else {
             switch ($type) {
                 case 'codename':
                     $return = $website->getCodename();
                     break;
                 case 'root':
                     $return = $website->getRoot()->getID();
                     break;
                 case 'domain':
                     $return = $website->getURL();
                     break;
                 case 'keywords':
                 case 'description':
                 case 'category':
                 case 'author':
                 case 'replyto':
                 case 'copyright':
                 case 'language':
                 case 'robots':
                 case 'favicon':
                 case 'metas':
                     $return = $website->getMeta($type);
                     break;
                 case 'title':
                     $return = $website->getLabel();
                     break;
                 default:
                     CMS_grandFather::raiseError("Unknown type value to get : " . $type);
                     $return = false;
                     break;
             }
             $websitesInfos[$id][$type] = $return;
         }
     }
     return $websitesInfos[$id][$type];
 }
예제 #8
0
 /**
  * Constructor.
  * initializes the resource if the id is given
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function CMS_resource($id = 0)
 {
     if ($id) {
         if (SensitiveIO::isPositiveInteger($id)) {
             $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_res='{$id}'\n\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->getNumRows()) {
                 $data = $q->getArray();
                 $this->_id = $id;
                 $this->_status = new CMS_resourceStatus($data);
                 if ($this->_status->hasError()) {
                     $this->raiseError("Unfound status :" . $data["status_res"]);
                     return;
                 }
                 //build editors stack. If stack is malformed, it's a minor error, so proceed.
                 $this->_editors = new CMS_stack();
                 if (!$this->_editors->setTextDefinition($data["editorsStack_res"])) {
                     $this->raiseError("Editors stack malformed");
                     $this->_editors->emptyStack();
                 }
             } else {
                 $this->raiseError("Unknown ID :" . $id);
             }
         } elseif (is_array($id)) {
             $data = $id;
             $this->_id = $data["id_res"];
             $this->_status = new CMS_resourceStatus($data);
             if ($this->_status->hasError()) {
                 $this->raiseError("Unfound status :" . $data["status_res"]);
                 return;
             }
             //build editors stack. If stack is malformed, it's a minor error, so proceed.
             $this->_editors = new CMS_stack();
             if (!$this->_editors->setTextDefinition($data["editorsStack_res"])) {
                 $this->raiseError("Editors stack malformed");
                 $this->_editors->emptyStack();
             }
         } else {
             $this->raiseError("Id is not a positive integer nor array");
             return;
         }
     } else {
         $this->_status = new CMS_resourceStatus();
         $this->_editors = new CMS_stack();
     }
 }
예제 #9
0
 /**
  * Constructor
  * 
  * @access public
  * @param integer $id
  * @return void 
  */
 function __construct($id = 0)
 {
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_records\n\t\t\t\twhere\n\t\t\t\t\tid_rec='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_recordID = $id;
             $this->_fieldID = $data["field_rec"];
             $this->_senderID = $data["sending_rec"];
             $this->_value = $data["value_rec"];
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     }
 }
예제 #10
0
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     static $i18nm;
     //load available languages
     $this->getAvailableLanguages();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         if (!isset($i18nm[$id])) {
             if ($id && !$dbValues) {
                 $sql = "\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\tmod_object_i18nm\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tid_i18nm ='" . $id . "'\n\t\t\t\t\t";
                 $q = new CMS_query($sql);
                 if ($q->getNumRows()) {
                     $this->_ID = $id;
                     while ($arr = $q->getArray()) {
                         $this->_values[$arr["code_i18nm"]] = $arr['value_i18nm'];
                         $this->_DBKnown[] = $arr["code_i18nm"];
                     }
                 } else {
                     $this->raiseError("Unknown ID :" . $id);
                     return;
                 }
             } elseif ($id && is_array($dbValues) && $dbValues) {
                 $this->_ID = $id;
                 foreach ($dbValues as $code => $value) {
                     $this->_values[$code] = $value;
                     $this->_DBKnown[] = $code;
                 }
             }
             $i18nm[$id] = $this;
         } else {
             //$this = $GLOBALS["polyModule"]["i18nm"][$id];
             $this->_ID = $id;
             $this->_values = $i18nm[$id]->_values;
             $this->_DBKnown = $i18nm[$id]->_DBKnown;
         }
     }
 }
예제 #11
0
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     $datas = array();
     if ($id && !$dbValues) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_field,\n\t\t\t\t\tmod_object_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mof='" . $id . "'\n\t\t\t\t\tand object_id_mof = id_mod\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $datas = $q->getArray();
         } else {
             $this->raiseError("Unknown ID :" . $id);
             return;
         }
     } elseif (is_array($dbValues) && $dbValues) {
         $datas = $dbValues;
     }
     if (is_array($datas) && $datas) {
         //set parent values
         parent::__construct($datas['object_id_mof'], $datas);
         //set field values
         $this->_fieldID = (int) $datas['id_mof'];
         $this->_objectFieldValues["objectID"] = (int) $datas['object_id_mof'];
         $this->_objectFieldValues["labelID"] = (int) $datas['label_id_mof'];
         $this->_objectFieldValues["descriptionID"] = (int) $datas['desc_id_mof'];
         $this->_objectFieldValues["type"] = $datas['type_mof'];
         $this->_objectFieldValues["order"] = (int) $datas['order_mof'];
         $this->_objectFieldValues["system"] = $datas['system_mof'] ? true : false;
         $this->_objectFieldValues["required"] = $datas['required_mof'] ? true : false;
         $this->_objectFieldValues["indexable"] = $datas['indexable_mof'] ? true : false;
         $this->_objectFieldValues["searchlist"] = $datas['searchlist_mof'] ? true : false;
         $this->_objectFieldValues["searchable"] = $datas['searchable_mof'] ? true : false;
         $this->_objectFieldValues["params"] = $datas['params_mof'] ? unserialize($datas['params_mof']) : array();
         $this->_objectFieldValues["uuid"] = isset($datas['uuid_mof']) ? $datas['uuid_mof'] : '';
     } else {
         parent::__construct(0, array());
     }
 }
 /**
  * Returns a resourceValidation object instance from a DB id or from GetValidationByID function if exists.
  * Static function.
  *
  * @param integer $id the id of the saved object
  * @return resourceValidation the instance unserialized, false if not found.
  * @access public
  */
 static function getValidationInstance($id, $user = false)
 {
     if (!SensitiveIO::isPositiveInteger($id) && base64_decode($id) && $user) {
         //load validation form encoded ID (new validations system)
         $decodedID = explode('||', base64_decode($id));
         $module = CMS_modulesCatalog::getByCodename($decodedID[0]);
         $editions = $decodedID[1];
         $resourceID = $decodedID[2];
         if (isset($module) && isset($editions) && isset($resourceID)) {
             return $module->getValidationByID($resourceID, $user, $editions);
         }
     }
     $sql = "\n\t\t\tselect\n\t\t\t\tserializedObject_rv as data\n\t\t\tfrom\n\t\t\t\tresourceValidations\n\t\t\twhere\n\t\t\t\tid_rv='" . $id . "'\n\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         $instance = unserialize(stripslashes($q->getValue("data")));
         $instance->setID($id);
         return $instance;
     } else {
         parent::raiseError("Unknown id : " . $id);
         return false;
     }
 }
예제 #13
0
 /**
  * Constructor
  * 
  * @access public
  * @param integer $id 
  * @param boolean $public if only public data to retrieve
  * @param CMS_profile_user $cms_user 
  */
 function __construct($id, $cms_user = false)
 {
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_formulars\n\t\t\t\twhere\n\t\t\t\t\tid_frm='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_formID = $id;
             $this->_name = $data["name_frm"];
             $this->_source = $data["source_frm"];
             $this->_public = $data["closed_frm"] > 0 ? false : true;
             // Form creator
             $this->_ownerID = (int) $data["owner_frm"];
             $this->_language = new CMS_language($data["language_frm"]);
             $this->_responses = (int) $data["responses_frm"];
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     } else {
         $this->_public = true;
         if (is_a($cms_user, 'CMS_profile_user')) {
             $this->_ownerID = $cms_user->getID();
         }
         $this->_language = CMS_languagesCatalog::getDefaultLanguage();
     }
 }
예제 #14
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;
                 }
             }
         }
     }
 }
예제 #15
0
 /**
  * Constructor
  * 
  * @access public
  * @param integer $id
  * @return void 
  */
 function __construct($id = 0, $formID = false)
 {
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_fields\n\t\t\t\twhere\n\t\t\t\t\tid_fld='" . $id . "'\n\t\t\t";
         if (sensitiveIO::isPositiveInteger($formID)) {
             $sql .= " and form_fld='" . $formID . "' ";
         }
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_fieldID = $id;
             if (SensitiveIO::isPositiveInteger($formID)) {
                 $this->_formID = $formID;
             }
             if (SensitiveIO::isPositiveInteger($data["form_fld"])) {
                 $this->_formID = $data["form_fld"];
             }
             $this->_label = $data["label_fld"];
             $this->_type = $data["type_fld"];
             $this->_options = unserialize($data["options_fld"]);
             $this->_name = $data["name_fld"];
             $this->_required = $data["required_fld"] ? true : false;
             $this->_active = $data["active_fld"] ? true : false;
             $this->_value = $data["defaultValue_fld"];
             $this->_dataValidation = $data["dataValidation_fld"];
             $this->_order = $data["order_fld"];
             $this->_params = unserialize($data["params_fld"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
             /*
             				if (SensitiveIO::isPositiveInteger($formID)) {
             					$this->_formID = $formID;
             				}
             				if (SensitiveIO::isPositiveInteger($id)) {
             					$this->_fieldID = $id;
             				}*/
         }
     } else {
         if (SensitiveIO::isPositiveInteger($formID)) {
             $this->_formID = $formID;
         }
     }
 }
예제 #16
0
파일: log.php 프로젝트: davidmottet/automne
 /**
  * Set ResourceId
  *
  * @param integer
  * @return void
  * @access public
  */
 function setResource($resource)
 {
     // Check if CMS_module object
     if (is_a($resource, "CMS_resource")) {
         $this->_resource = $resource->getID();
     } elseif (SensitiveIO::isPositiveInteger($id)) {
         $this->_resource = $resource;
     } else {
         $this->raiseError("Resource object required: ");
     }
 }
             if ($regenok) {
                 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE) . ' : ' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATED, array($regenok));
             }
             if ($regenerror) {
                 $cms_message .= $cms_message ? '<br />' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror)) : $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror));
             }
         }
     }
     break;
 case 'regenerate-pages':
     if ($pages) {
         $tmpPages = preg_split('#[ ;,]#', $pages);
         $pages = array();
         foreach ($tmpPages as $p) {
             $p = trim($p);
             if (SensitiveIO::isPositiveInteger($p)) {
                 $pages[] = $p;
             } elseif (preg_match("#[0-9]+\\-[0-9]+#", $p)) {
                 $subPages = explode('-', $p);
                 sort($subPages);
                 for ($idp = $subPages[0]; $idp <= $subPages[1]; $idp++) {
                     $pages[] = $idp;
                 }
             }
         }
         $pages = array_unique($pages);
         sort($pages);
         if (sizeof($pages)) {
             $validPages = CMS_tree::pagesExistsInUserSpace($pages);
             if (sizeof($validPages)) {
                 if (sizeof($validPages) > 3) {
예제 #18
0
파일: row.php 프로젝트: davidmottet/automne
 /**
  * Constructor.
  *
  * @param integer $id the DB ID of the row
  * @param string $tagID the XML Tag ID of the row (if instansiated from the tag)
  * @return void
  * @access public
  */
 function __construct($id = 0, $tagID = false)
 {
     $this->_tagID = $tagID;
     $this->_modules = new CMS_stack();
     $this->_groups = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_standard_rows\n\t\t\t\twhere\n\t\t\t\t\tid_row='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_label = $data["label_row"];
             $this->_groups->setTextDefinition($data["groupsStack_row"]);
             $this->_definitionFile = $data["definitionFile_row"];
             $this->_modules->setTextDefinition($data["modulesStack_row"]);
             $this->_image = $data["image_row"] ? $data["image_row"] : $this->_image;
             $this->_useable = $data["useable_row"] ? true : false;
             $this->_description = $data["description_row"];
             $this->_tplfilter = trim($data["tplfilter_row"]) ? explode(';', $data["tplfilter_row"]) : array();
             $this->_uuid = $data["uuid_row"];
         } else {
             $this->raiseError("Unknown id :" . $id);
         }
     }
 }
예제 #19
0
 /**
  * Gets alias by its internal ID
  *
  * @param integer $id The DB ID of the alias to get
  * @return CMS_resource_cms_aliases or false if not found
  * @access public
  * @static
  */
 static function getByID($id, $reset = false)
 {
     if (!SensitiveIO::isPositiveInteger($id)) {
         CMS_grandFather::raiseError("Id must be positive integer : " . $id . ' - ' . io::getCallInfos());
         return false;
     }
     static $aliases;
     if (isset($aliases[$id]) && !$reset) {
         return $aliases[$id];
     }
     $aliases[$id] = new CMS_resource_cms_aliases($id);
     /*if ($aliases[$id]->hasError()) {
     			$aliases[$id] = false;
     		}*/
     return $aliases[$id];
 }
예제 #20
0
 /**
  * Duplicate this block
  * Used to duplicate a CMS_page.
  *
  * @param CMS_page $destinationPage, the page receiving a copy of this block
  * @param boolean $public The precision needed for USERSPACE location
  * @return CMS_block object
  */
 function duplicate(&$destinationPage, $public = false)
 {
     if (SensitiveIO::isPositiveInteger($this->_dbID) && $this->_file) {
         $table = $this->_getDataTableName(RESOURCE_LOCATION_USERSPACE, $public);
         //Copy linked file
         //In new file name, delete reference to old page and add refernce to new one
         $_newFilename = "p" . $destinationPage->getID() . io::substr($this->_file, io::strpos($this->_file, "_"), io::strlen($this->_file));
         if (@is_file(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file) && @copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename) && @chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename, octdec(FILES_CHMOD))) {
             //Public
             if ($public) {
                 if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename, octdec(FILES_CHMOD))) {
                     $this->raiseError("Duplicate, copy of new file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename);
                 }
             }
             $_newEnlargedFilename = '';
             //With enlarged file
             if ($this->_enlargedFile != '') {
                 $_newEnlargedFilename = "p" . $destinationPage->getID() . io::substr($this->_enlargedFile, io::strpos($this->_enlargedFile, "_"), io::strlen($this->_enlargedFile));
                 //Edited
                 if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_enlargedFile, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename, octdec(FILES_CHMOD))) {
                     $this->raiseError("Duplicate, copy of new enlarged file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename);
                 }
                 //Public
                 if ($public) {
                     if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_enlargedFile, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename, octdec(FILES_CHMOD))) {
                         $this->raiseError("Duplicate, copy of new enlarged file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename);
                     }
                 }
             }
             //Save new datas
             $str_set = "\n\t\t\t\t\t\tpage='" . $destinationPage->getID() . "',\n\t\t\t\t\t\tclientSpaceID='" . $this->_clientSpaceID . "',\n\t\t\t\t\t\trowID='" . $this->_rowID . "',\n\t\t\t\t\t\tblockID='" . $this->_tagID . "',\n\t\t\t\t\t\tlabel='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($this->_label)) . "',\n\t\t\t\t\t\tfile='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($_newFilename)) . "',\n\t\t\t\t\t\texternalLink='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($this->_externalLink)) . "',\n\t\t\t\t\t\tenlargedFile='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($_newEnlargedFilename)) . "'\n\t\t\t\t";
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $table . "\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t";
             $q = new CMS_query($sql);
             if (!$q->hasError()) {
                 //Table Edition
                 $sql = "\n\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\t" . $this->_getDataTableName(RESOURCE_LOCATION_EDITION, false) . "\n\t\t\t\t\t\tset\n\t\t\t\t\t\t\tid='" . $q->getLastInsertedID() . "',\n\t\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t\t";
                 $q = new CMS_query($sql);
                 return !$q->hasError();
             } else {
                 $this->raiseError("Duplicate, SQL insertion of new filename failed : " . $sql);
             }
         } else {
             $this->raiseError("Duplicate, copy of file failed :" . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file);
         }
     }
     return false;
 }
예제 #21
0
 /**
  * Builds where statement with a key and its value
  * The key can be known, this class will create statements in consequence
  * or not known so key is understood as a field name and this
  * method will append a statement such $key='$value'
  *
  * @access public
  * @param string $key name of statement to set
  * @param string $value , the value to give
  */
 function addWhereCondition($type, $value)
 {
     switch ($type) {
         case "language":
             array_push($this->_where, "language_frm='" . SensitiveIO::sanitizeSQLString($value->getCode()) . "'");
             break;
         case "profile":
             if (APPLICATION_ENFORCES_ACCESS_CONTROL != false) {
                 $a_where = CMS_moduleCategories_catalog::getViewvableCategoriesForProfile($value, MOD_CMS_FORMS_CODENAME, true);
                 array_push($this->_tables, "modulesCategories");
                 array_push($this->_where, "id_mca=category_fca");
                 array_push($this->_tables, "mod_cms_forms_categories");
                 array_push($this->_where, "id_frm=form_fca");
                 if (sizeof($a_where)) {
                     $a_where = array_keys($a_where);
                     array_push($this->_where, 'category_fca in (' . @implode(',', $a_where) . ')');
                 } else {
                     $a_where = array_keys($a_where);
                     array_push($this->_where, 'category_fca = NULL');
                 }
             }
             break;
         case "category":
             $value = $this->_sanitizeSQLString($value);
             if (SensitiveIO::isPositiveInteger($value) && ($s_lineage = CMS_moduleCategories_catalog::getLineageOfCategoryAsString($value))) {
                 array_push($this->_tables, "modulesCategories");
                 array_push($this->_tables, "mod_cms_forms_categories");
                 array_push($this->_where, "id_mca=category_fca");
                 array_push($this->_where, "id_frm=form_fca");
                 array_push($this->_where, "(lineage_mca = '" . SensitiveIO::sanitizeSQLString($s_lineage) . "' or lineage_mca like '" . SensitiveIO::sanitizeSQLString($s_lineage) . ";%')");
             }
             break;
         case "keywords":
             $value = $this->_sanitizeSQLString($value);
             $kwrds = @explode(" ", $value);
             $kwrds = SensitiveIO::sanitizeSQLString(@implode("%", $kwrds));
             if (trim($kwrds) != '%') {
                 array_push($this->_where, "name_frm like '%" . $kwrds . "%'");
             }
             break;
         default:
             $value = $this->_sanitizeSQLString($value);
             array_push($this->_where, $type . "='" . SensitiveIO::sanitizeSQLString($value) . "'");
             break;
     }
     $this->_tables = @array_unique($this->_tables);
     $this->_where = @array_unique($this->_where);
 }
예제 #22
0
 /**
  * Duplicate current page into another one
  * All contents and external datas are duplicated too
  *
  * @param CMS_user user, the user processing to creation
  * @param integer templateID, a new template to duplicate the page with
  * @param boolean $dontDuplicateContent If true, the content of the page is not duplicated
  * @return CMS_page newly created, or null on error
  */
 function duplicate(&$user, $templateID = 0, $dontDuplicateContent = false)
 {
     $pg = null;
     if ($user->hasPageClearance($this->getID(), CLEARANCE_PAGE_VIEW) && $user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_EDIT)) {
         $pg = new CMS_page();
         $pg->lock($user);
         $pg->addEdition(RESOURCE_EDITION_CONTENT, $user);
         //Which template to use?
         if (!$templateID) {
             $newTpl = CMS_pageTemplatesCatalog::getCloneFromID($this->_templateID, false, true, false, $this->_templateID);
         } else {
             $newTpl = CMS_pageTemplatesCatalog::getCloneFromID($templateID, false, true, false, $this->_templateID);
         }
         if (!is_a($newTpl, 'CMS_pageTemplate') || $newTpl->hasError()) {
             $this->raiseError("Error during template clone creation.");
         } else {
             $pg->setTemplate($newTpl->getID());
         }
         //Duplicate page base datas
         $pg->setTitle($this->getTitle(), $user);
         $pg->setLinkTitle($this->getLinkTitle(), $user);
         $pg->setDescription($this->getDescription(false, false), $user);
         $pg->setKeywords($this->getKeywords(false, false), $user);
         $pg->setPublicationDates($this->getPublicationDateStart(false), $this->getPublicationDateEnd(false));
         $pg->setReminderOn($this->getReminderOn(false, false), $user);
         $pg->setReminderOnMessage($this->getReminderOnMessage(false, false), $user);
         $pg->setCategory($this->getCategory(false, false), $user);
         $pg->setAuthor($this->getAuthor(false, false), $user);
         $pg->setReplyto($this->getReplyto(false, false), $user);
         $pg->setCopyright($this->getCopyright(false, false), $user);
         $pg->setLanguage($this->getLanguage(false, false), $user);
         $pg->setRobots($this->getRobots(false, false), $user);
         $pg->setPragma($this->getPragma(false, false), $user);
         $pg->setRefresh($this->getRefresh(false, false), $user);
         $pg->setRedirectLink($this->getRedirectLink(), $user);
         $pg->setMetas($this->getMetas(false, false), $user);
         $pg->setCodename($this->getCodename(), $user, false);
         if (SensitiveIO::isPositiveInteger($this->getReminderPeriodicity())) {
             $pg->setReminderPeriodicity($this->getReminderPeriodicity(), $user);
         }
         $pg->writeToPersistence();
         $pg->unlock();
         //Duplicate contents, get all blocks and duplicate them
         if (!$dontDuplicateContent) {
             $this->duplicateContent($user, $pg);
         }
     } else {
         $this->raiseError("User doesn't have rights to do this creation");
     }
     return $pg;
 }
예제 #23
0
 /**
  * Writes the clientSpace into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     if ($this->_templateID && $this->_tagID) {
         $table = "mod_standard_clientSpaces";
         $table .= $this->_editionMode ? "_edition" : "_edited";
         //delete from table
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\ttemplate_cs='" . $this->_templateID . "'\n\t\t\t\t\tand tagID_cs='" . SensitiveIO::sanitizeSQLString($this->_tagID) . "'\n\t\t\t";
         $q = new CMS_query($sql);
         //insert new rows datas if any
         if (is_array($this->_rows) && $this->_rows) {
             $sql = "insert into\n\t\t\t\t\t\t\t" . $table . "\n\t\t\t\t\t\t\t(`template_cs`, `tagID_cs`, `rowsDefinition_cs`, `type_cs`, `order_cs`) \n\t\t\t\t\t\tVALUES ";
             $count = 0;
             foreach ($this->_rows as $order => $row) {
                 if (SensitiveIO::isPositiveInteger($row->getID())) {
                     $sql .= $count ? ',' : '';
                     $sql .= "('" . $this->_templateID . "', '" . SensitiveIO::sanitizeSQLString($this->_tagID) . "', '" . SensitiveIO::sanitizeSQLString($row->getTagID()) . "', '" . $row->getID() . "', '" . $order . "')";
                     $count++;
                 }
             }
             $q = new CMS_query($sql);
             if ($q->hasError()) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Returns boolean depending on wheather label exists or not
  * Static function.
  * 
  * @param string $label
  * @param integer $groupId
  * @access public
  */
 static function labelExists($label, $groupId = 0)
 {
     if ((SensitiveIO::isPositiveInteger($groupId) || $groupId == 0) && $label) {
         $sqlWhere = '';
         if ($groupId) {
             $sqlWhere = "\n\t\t\t\t\tid_prg  != '" . $groupId . "' \n\t\t\t\t and ";
         }
         $sql = "\n\t\t\t\tselect distinct\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tprofilesUsersGroups\n\t\t\t\twhere\n\t\t\t\t\t" . $sqlWhere . "\n\t\t\t\t\tlabel_prg='" . trim(sensitiveIO::sanitizeSQLString($label)) . "'\n\t\t\t";
         $q = new CMS_query($sql);
         return $q->getNumRows();
     }
     // As label may exist
     return true;
 }
예제 #25
0
 /**
  * Constructor.
  * initializes the template if the id is given.
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function __construct($id = 0)
 {
     $this->_groups = new CMS_stack();
     $this->_modules = new CMS_stack();
     $this->_websitesdenied = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tpageTemplates\n\t\t\t\twhere\n\t\t\t\t\tid_pt='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_label = $data["label_pt"];
             $this->_image = $data["image_pt"];
             $this->_definitionFile = $data["definitionFile_pt"];
             $this->_groups->setTextDefinition($data["groupsStack_pt"]);
             $this->_modules->setTextDefinition($data["modulesStack_pt"]);
             $this->_useable = $data["inUse_pt"];
             $this->_private = $data["private_pt"];
             $this->_printingClientSpaces = trim($data["printingCSOrder_pt"]) ? explode(";", $data["printingCSOrder_pt"]) : array();
             $this->_description = $data["description_pt"];
             $this->_websitesdenied->setTextDefinition($data["websitesdenied_pt"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     }
 }
 /**
  * Delete one category clearance
  * 
  * @param integer $categoryID, ID of category to delete from stack
  * @return boolean true on success
  * @access public 
  */
 function del($categoryID)
 {
     if (SensitiveIO::isPositiveInteger($categoryID)) {
         $this->_categoriesClearances->del($categoryID);
         return true;
     } else {
         $this->raiseError("Category ID required : " . var_dump($categoryID));
         return false;
     }
 }
예제 #27
0
 /**
  * Sets the internal link
  * Reset the target to "_top"
  *
  * @param integer $pageID The DB ID of the page linked
  * @return boolean true on success, false on failure
  * @access public
  */
 function setInternalLink($pageID)
 {
     $this->_internalLink = $pageID;
     if (SensitiveIO::isPositiveInteger($pageID)) {
         $this->_target = '_top';
     }
     return true;
 }
예제 #28
0
 /**
  * Duplicate this block
  * Used to duplicate a CMS_page.
  *
  * @param CMS_page $destinationPage, the page receiving a copy of this block
  * @param boolean $public The precision needed for USERSPACE location
  * @return CMS_block object
  */
 function duplicate(&$destinationPage, $public = false)
 {
     if (SensitiveIO::isPositiveInteger($this->_dbID)) {
         $table = $this->_getDataTableName(RESOURCE_LOCATION_USERSPACE, $public);
         $str_set = "\n\t\t\t\t\tpage='" . $destinationPage->getID() . "',\n\t\t\t\t\tclientSpaceID='" . $this->_clientSpaceID . "',\n\t\t\t\t\trowID='" . $this->_rowID . "',\n\t\t\t\t\tblockID='" . $this->_tagID . "',\n\t\t\t\t\ttype='CMS_block_cms_forms',\n\t\t\t\t\tvalue='" . SensitiveIO::sanitizeSQLString(serialize($this->_value)) . "'\n\t\t\t";
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\t" . $table . "\n\t\t\t\tset\n\t\t\t\t\t" . $str_set . "\n\t\t\t";
         $q = new CMS_query($sql);
         if (!$q->hasError()) {
             //Table Edition
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $this->_getDataTableName(RESOURCE_LOCATION_EDITION, false) . "\n\t\t\t\t\tset\n\t\t\t\t\t\tid='" . $id . "',\n\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t";
             $q = new CMS_query($sql);
             return !$q->hasError();
         } else {
             $this->raiseError("Duplicate, insertion failed: " . $sql);
         }
     } else {
         $this->raiseError("Duplicate, object does not have a DB ID, not initialized");
     }
     return false;
 }
예제 #29
0
//
// $Id: page-previsualization.php,v 1.5 2010/03/08 16:41:19 sebastien Exp $
/**
 * PHP page : page previsualization
 * Used to view the page edited data.
 *
 * @package Automne
 * @subpackage admin
 * @author Antoine Pouch <*****@*****.**> &
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
$currentPage = sensitiveIO::request('currentPage', 'sensitiveIO::isPositiveInteger', CMS_session::getPageID());
$draft = sensitiveIO::request('draft') ? true : false;
//unset request to avoid it to have interaction with page code
sensitiveIO::unsetRequest(array('draft', 'currentPage'));
//CHECKS
if (!SensitiveIO::isPositiveInteger($currentPage)) {
    die("Invalid page");
}
//view edited or edition mode ?
$cms_visual_mode = $draft ? PAGE_VISUALMODE_HTML_EDITION : PAGE_VISUALMODE_HTML_EDITED;
$cms_page = CMS_tree::getPageByID($currentPage);
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) {
    die('No rigths on page ...');
    exit;
}
//unset vars to avoid interraction with page
unset($currentPage);
unset($draft);
echo $cms_page->getContent($cms_language, $cms_visual_mode);
예제 #30
0
 /**
  * Gets resource by its internal ID (not the resource table DB ID)
  *
  * @param integer $resourceID The DB ID of the resource in the module table(s)
  * @return CMS_resource The CMS_resource subclassed object
  * @access public
  */
 function getResourceByID($resourceID)
 {
     if (!SensitiveIO::isPositiveInteger($resourceID)) {
         $this->raiseError("Resource ID is not a positive integer");
         return false;
     }
 }