本文整理汇总了PHP中sensitiveIO::sanitizeAsciiString方法的典型用法代码示例。如果您正苦于以下问题:PHP sensitiveIO::sanitizeAsciiString方法的具体用法?PHP sensitiveIO::sanitizeAsciiString怎么用?PHP sensitiveIO::sanitizeAsciiString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sensitiveIO
的用法示例。
在下文中一共展示了sensitiveIO::sanitizeAsciiString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByName
/**
* Get all the aliases for a given name
*
* @param string $name The name to get aliases of
* @param boolean $returnObject function return array of id or array of CMS_resource_cms_aliases (default)
* @return array
* @access public
* @static
*/
static function getByName($name, $returnObject = true)
{
if (!$name || $name != sensitiveIO::sanitizeAsciiString($name, '@')) {
return array();
}
$sql = "\n\t\t\tselect\n\t\t\t\tid_ma\n\t\t\tfrom\n\t\t\t\tmod_cms_aliases\n\t\t\twhere \n\t\t\t\talias_ma='" . io::sanitizeSQLString($name) . "'\n\t\t\torder by id_ma asc";
$q = new CMS_query($sql);
$result = array();
while ($arr = $q->getArray()) {
if ($returnObject) {
$alias = CMS_module_cms_aliases::getByID($arr["id_ma"]);
if ($alias && !$alias->hasError()) {
$result[$arr["id_ma"]] = $alias;
}
} else {
$result[$arr["id_ma"]] = $arr["id_ma"];
}
}
return $result;
}
示例2: checkTagValues
protected function checkTagValues(&$tag, $requirements)
{
if (!is_array($requirements)) {
$this->raiseError('Tag requirements must be an array');
return false;
}
foreach ($requirements as $name => $requirementType) {
//check parameter existence
if ($requirementType['mandatory'] && !isset($tag['attributes'][$name])) {
if ($this->_mode == self::CHECK_PARSING_MODE) {
$this->_parsingError .= "\n" . 'Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute';
return false;
} else {
$this->raiseError('Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute');
return false;
}
} elseif (isset($tag['attributes'][$name])) {
//if any, check value requirement
$message = false;
switch ($requirementType['value']) {
case 'alphanum':
if ($tag['attributes'][$name] != sensitiveIO::sanitizeAsciiString($tag['attributes'][$name], '', '_')) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be composed with alphanumeric caracters (0-9a-z_) : ' . $tag['attributes'][$name];
}
break;
case 'language':
if (isset($this->_parameters['module'])) {
$languages = CMS_languagesCatalog::getAllLanguages($this->_parameters['module']);
} else {
$languages = CMS_languagesCatalog::getAllLanguages();
}
if (!isset($languages[$tag['attributes'][$name]])) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be a valid language code : ' . $tag['attributes'][$name];
}
break;
case 'object':
if (!sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], 9, -3))) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object';
}
break;
case 'field':
if (strrpos($tag['attributes'][$name], 'fields') === false || !sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], strrpos($tag['attributes'][$name], 'fields') + 9, -2))) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object field';
}
break;
case 'page':
if (!io::isPositiveInteger($tag['attributes'][$name])) {
// Assuming the structure {websitecodename:pagecodename}
$page = trim($tag['attributes'][$name], "{}");
if (strpos($page, ":") !== false) {
list($websiteCodename, $pageCodename) = explode(':', $page);
$website = CMS_websitesCatalog::getByCodename($websiteCodename);
if (!$website) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow Website codename : ' . $websiteCodename . '';
} else {
$pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
if (!$pageID) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow page codename ' . $pageCodename . ' in website : ' . $websiteCodename . '';
}
}
} else {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must be an integer or use the format websitecodename:pagecodename';
}
} else {
if (!CMS_tree::getPageByID($tag['attributes'][$name])) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow pageID : ' . $tag['attributes'][$name];
}
}
break;
default:
//check
if (!preg_match('#^' . $requirementType['value'] . '$#i', $tag['attributes'][$name])) {
$message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must match expression \'' . $requirementType['value'] . '\' : ' . $tag['attributes'][$name];
}
break;
}
if ($message) {
if ($this->_mode == self::CHECK_PARSING_MODE) {
$this->_parsingError .= "\n<br />" . $message;
return false;
} else {
$this->raiseError($message);
return false;
}
}
}
}
return true;
}
示例3: _natecasecomp
function _natecasecomp($str1, $str2)
{
return strnatcasecmp(sensitiveIO::sanitizeAsciiString($str1), sensitiveIO::sanitizeAsciiString($str2));
}
示例4: implode
//then create CVS file
//CSV header
$csv = implode(';', $header) . "\n";
//CSV content
if (sizeof($formDatas)) {
foreach ($formDatas as $formData) {
$count = 0;
foreach ($header as $fieldID => $head) {
$csv .= $count ? ';' : '';
if (!$fileFields[$fieldID]) {
$csv .= '"' . cleanvalue($formData[$fieldID]) . '"';
} else {
if ($formData[$fieldID]) {
$csv .= '"' . $filesPath . cleanvalue($formData[$fieldID]) . '"';
} else {
$csv .= '""';
}
}
$count++;
}
$csv .= "\n";
}
}
//Then send CSV file
header("Cache-Control: public");
//This is needed to avoid bug with IE in HTTPS
header("Pragma:");
//This is needed to avoid bug with IE in HTTPS
header('Content-type: text/csv; charset=' . APPLICATION_DEFAULT_ENCODING);
header("Content-Disposition: attachment; filename=export_" . sensitiveIO::sanitizeAsciiString($form->getAttribute('name')) . "_" . date('Ymd') . ".csv");
echo $csv;
示例5: checkTagRequirements
/**
* Check tags attributes requirements
*
* @param array $requirements : tag attributes requirements at the following format :
array(string attributeName => mixed attributeType)
With attributeType in :
- boolean true : check only presence of an attribute value
- alphanum : attribute value must be a simple alphanumeric value without special chars
- language : attribute value must be a valid language code
- orderType : attribute value must be a valid order type
- valid PERL regular expression : attribute value must be mattch the regular expression
* @return string indented php code
* @access public
*/
function checkTagRequirements($requirements)
{
if (!is_array($requirements)) {
$this->raiseError('Tag requirements must be an array');
return false;
}
foreach ($requirements as $name => $requirementType) {
//check parameter existence
if (!isset($this->_attributes[$name])) {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : missing \'' . $name . '\' attribute';
return false;
} elseif ($requirementType !== true) {
//if any, check value requirement
switch ($requirementType) {
case 'alphanum':
if ($this->_attributes[$name] != sensitiveIO::sanitizeAsciiString($this->_attributes[$name], '', '_')) {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute must only be composed with alphanumeric caracters (0-9a-z_) : ' . $this->_attributes[$name];
return false;
}
break;
case 'language':
if (isset($this->_parameters['module'])) {
$languages = CMS_languagesCatalog::getAllLanguages($this->_parameters['module']);
} else {
$languages = CMS_languagesCatalog::getAllLanguages();
}
if (!isset($languages[$this->_attributes[$name]])) {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute must only be a valid language code : ' . $this->_attributes[$name];
return false;
}
break;
case 'object':
if (!sensitiveIO::isPositiveInteger(io::substr($this->_attributes[$name], 9, -3))) {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute does not represent a valid object';
return false;
}
break;
case 'field':
if (strrpos($this->_attributes[$name], 'fields') === false || !sensitiveIO::isPositiveInteger(io::substr($this->_attributes[$name], strrpos($this->_attributes[$name], 'fields') + 9, -2))) {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute does not represent a valid object field';
return false;
}
break;
case 'paramType':
if (!in_array($this->_attributes[$name], CMS_object_search::getStaticSearchConditionTypes()) && !sensitiveIO::isPositiveInteger($this->_attributes[$name]) && io::substr($this->_attributes[$name], -12) != "['fieldID']}") {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute, must be one of these values : ' . implode(', ', CMS_object_search::getStaticSearchConditionTypes());
return false;
}
break;
case 'orderType':
if (!in_array($this->_attributes[$name], CMS_object_search::getStaticOrderConditionTypes()) && !sensitiveIO::isPositiveInteger($this->_attributes[$name]) && io::substr($this->_attributes[$name], -12) != "['fieldID']}") {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute, must be one of these values : ' . implode(', ', CMS_object_search::getStaticOrderConditionTypes());
return false;
}
break;
default:
//check
if (!preg_match('#^' . $requirementType . '$#i', $this->_attributes[$name])) {
$this->_tagError .= "\n" . 'Malformed ' . $this->_name . ' tag : \'' . $name . '\' attribute must match expression \'' . $requirementType . '\' : ' . $this->_attributes[$name];
return false;
}
break;
}
}
}
return true;
}
示例6: _natecasecomp
static function _natecasecomp($str1, $str2)
{
$str1 = sensitiveIO::sanitizeAsciiString($str1);
$str2 = sensitiveIO::sanitizeAsciiString($str2);
return strnatcasecmp($str1, $str2);
}
示例7: setCode
/**
* Sets the toolbar code
*
* @param string $code the toolbar code to set
* @return boolean true on success, false on failure.
* @access public
*/
function setCode($code)
{
$this->_code = io::substr(sensitiveIO::sanitizeAsciiString($code), 0, 20);
return true;
}
示例8: dirname
* Used accross a fileupload request to process one uploaded file
*
* @package Automne
* @subpackage admin
* @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>
*/
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_JSON);
//This file is an admin file. Interface must be secure
$view->setSecure();
$file = sensitiveIO::sanitizeAsciiString(sensitiveIO::request('file'));
$module = sensitiveIO::sanitizeAsciiString(sensitiveIO::request('module'));
$visualisation = sensitiveIO::sanitizeAsciiString(sensitiveIO::request('visualisation'));
$fileDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'module' => $module, 'visualisation' => $visualisation);
if (!$file || !$module) {
$view->setContent($fileDatas);
$view->show();
}
//check for the given file for queried module
if (!file_exists(PATH_MODULES_FILES_FS . '/' . $module . '/' . $visualisation . '/' . $file)) {
$view->setContent($fileDatas);
$view->show();
}
$file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $module . '/' . $visualisation . '/' . $file);
//return file datas
$fileDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension(), 'module' => $module, 'visualisation' => $visualisation);
$view->setContent($fileDatas);
$view->show();
示例9: _showBody
//.........这里部分代码省略.........
break;
case 'arbo':
echo '
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="frame">
' . $this->_getTitleDesign($this->_title, "admin_frame", "picto_pages.gif") . '
' . $this->_showMessage() . '
' . $this->_parseContent($this->_content) . '
</body>
';
break;
case 'modules':
echo '
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="frame">
' . $this->_getTitleDesign($this->_title, "admin_frame", "picto_modules.gif") . '
' . $this->_showMessage() . '
' . $this->_parseContent($this->_content) . '
</body>
';
break;
default:
$user = $this->_context->getUser();
$language = $user->getLanguage();
echo '<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="admin" onLoad="initJavascript();">';
//content is out of frames, so add Automne content header and do not display menu
if ($this->_displayMode == 'out') {
echo '
<table width="100%" height="72" border="0" cellpadding="0" cellspacing="0" style="background:url(' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond.gif) repeat-x bottom left;">
<tr>
<td width="562" height="72" valign="top" class="admin">
<table width="562" height="30" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="472" height="30" class="admin_date">
<!-- <span class="admin_site_label">' . APPLICATION_LABEL . '</span> - <b>' . date($language->getDateFormat(), time()) . '</b>--></td>
<td width="90" height="30" class="admin"><a href="http://www.automne-cms.org" target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/powered.gif" border="0" /></a></td>
</tr>
</table>
<table width="562" height="42" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="562" height="42" background="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond.gif" valign="center"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="562" height="1" border="0" /><br />
' . $this->_getSubMenu() . '
</td>
</tr>
</table>
</td>
<td width="138" height="72"><a href="' . CMS_websitesCatalog::getMainURL() . '" target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/logo.png" class="png" width="138" height="72" border="0" /></a></td>
<td width="100%" height="72" valign="top" class="admin">
<table width="100%" height="72" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" height="30"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="1" height="1" border="0" /></td>
</tr>
<tr>
<td width="100%" height="42" background="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond.gif"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="1" height="1" border="0" /></td>
</tr>
</table>
</td>
</tr>
</table>';
} else {
echo $this->_getSubMenu();
}
//display content
echo '
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="15"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" border="0" width="15" height="1" /></td>
<td class="admin">';
if ($this->_title) {
echo $this->_getTitleDesign($this->_title, "admin_h1", $this->_picto);
}
echo '<br />' . $this->_showMessage();
$replace = array(PATH_ADMIN_WR => '', 'modules/' => '', '/' => '_', '.php' => '');
if (io::strpos($_SERVER["SCRIPT_NAME"], '/polymod/') !== false && isset($_REQUEST['polymod'])) {
$replace['polymod'] = $_REQUEST['polymod'];
}
$filename = sensitiveIO::sanitizeAsciiString(str_replace(array_keys($replace), $replace, $_SERVER["SCRIPT_NAME"]));
if (file_exists(PATH_ADMIN_FS . '/inc/' . $filename . "_" . $language->getCode() . ".inc.php")) {
include_once PATH_ADMIN_FS . '/inc/' . $filename . "_" . $language->getCode() . ".inc.php";
}
echo '
' . $this->_parseContent($this->_content) . '
<br />
</td>
</tr>
</table>
' . $this->_beforeBody;
if ($this->_displayMode != "loading") {
echo '</body>';
} else {
//add loading class
require_once "loadingDialog.php";
//start loading mode
CMS_LoadingDialog::startLoadingMode();
}
break;
}
}
示例10: _createRecursiveDetailledStructure
protected function _createRecursiveDetailledStructure($objectsStructure, &$objectInfos, &$language, &$translationtable, $path, $translatedpath)
{
$structure = array();
foreach ($objectsStructure as $fieldID => $field) {
if (!is_array($field)) {
//Field
if (class_exists($field)) {
$object = new $field(array(), $objectInfos[$fieldID]);
//get object structure infos
$structure[io::substr($fieldID, 5)] = $object->getStructure();
//create path and translated path
$structure[io::substr($fieldID, 5)]['path'] = $path . '[' . io::substr($fieldID, 5) . ']';
$structure[io::substr($fieldID, 5)]['fieldID'] = io::substr($fieldID, 5);
if ($language && is_a($language, 'CMS_language')) {
$structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$fieldID]->getLabel($language));
$count = 1;
while (isset($translationtable[$structure[io::substr($fieldID, 5)]['translatedpath']])) {
$count++;
$structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$fieldID]->getLabel($language)) . $count;
}
CMS_poly_module_structure::_updateTranslationTable($translationtable, $structure[io::substr($fieldID, 5)]);
}
}
} else {
$object = array_shift(array_keys($field));
if (io::strpos($object, 'object') === 0) {
//poly_object
//get object structure infos
$structure[io::substr($fieldID, 5)] = $objectInfos[$object]->getStructure();
//create path and translated path
$structure[io::substr($fieldID, 5)]['path'] = $path . '[' . io::substr($fieldID, 5) . ']';
$structure[io::substr($fieldID, 5)]['fieldID'] = io::substr($fieldID, 5);
if ($language && is_a($language, 'CMS_language')) {
$structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$object]->getLabel($language));
$count = 1;
while (isset($translationtable[$structure[io::substr($fieldID, 5)]['translatedpath']])) {
$count++;
$structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$object]->getLabel($language)) . $count;
}
CMS_poly_module_structure::_updateTranslationTable($translationtable, $structure[io::substr($fieldID, 5)]);
}
//recurse on fields
$structure[io::substr($fieldID, 5)]['fields'] = CMS_poly_module_structure::_createRecursiveDetailledStructure($field[$object], $objectInfos, $language, $translationtable, $structure[io::substr($fieldID, 5)]['path'] . "['fields']", $structure[io::substr($fieldID, 5)]['translatedpath']);
} elseif (io::strpos($object, 'multiobject') === 0) {
//multi poly_object
$objectDef = new CMS_multi_poly_object(io::substr($object, 11), $datas = array(), $objectInfos[$fieldID]);
//get object structure infos
$structure[io::substr($fieldID, 5)] = $objectDef->getStructure();
//create path and translated path
$structure[io::substr($fieldID, 5)]['path'] = $path . '[' . io::substr($fieldID, 5) . ']';
$structure[io::substr($fieldID, 5)]['fieldID'] = io::substr($fieldID, 5);
if ($language && is_a($language, 'CMS_language')) {
$structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectDef->getFieldLabel($language));
$count = 1;
while (isset($translationtable[$structure[io::substr($fieldID, 5)]['translatedpath']])) {
$count++;
$structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectDef->getFieldLabel($language)) . $count;
}
CMS_poly_module_structure::_updateTranslationTable($translationtable, $structure[io::substr($fieldID, 5)]);
}
//recurse on fields
$subobjectsDef = array('fieldn' => array('object' . io::substr($object, 11) => $field[$object]));
$structure[io::substr($fieldID, 5)]['fields'] = CMS_poly_module_structure::_createRecursiveDetailledStructure($subobjectsDef, $objectInfos, $language, $translationtable, $structure[io::substr($fieldID, 5)]['path'] . "['fields']", $structure[io::substr($fieldID, 5)]['translatedpath']);
}
}
}
return $structure;
}
示例11: elseif
if (isset($_POST['hasprotect']) && $_POST['protect'] == 1) {
$module->setFilesProtection(true);
} elseif (isset($_POST['hasprotect'])) {
$module->setFilesProtection(false);
}
//set htaccess in deleted directory
if (is_dir(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/deleted')) {
CMS_file::copyTo(PATH_HTACCESS_FS . '/htaccess_no', PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/deleted/.htaccess');
CMS_file::chmodFile(FILES_CHMOD, PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/deleted/.htaccess');
}
header("Location: modules_admin.php?moduleCodename=" . $moduleCodename . "&cms_message_id=" . MESSAGE_ACTION_OPERATION_DONE . "&" . session_name() . "=" . session_id());
exit;
}
} else {
//checks
if (!$_POST["codename"] || $_POST["codename"] != sensitiveIO::sanitizeAsciiString($_POST["codename"])) {
$cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_CODENAME)));
} else {
//check for codename not already used
$modules = CMS_modulesCatalog::getAll("label", false);
foreach ($modules as $aModule) {
if ($aModule->getCodename() == $_POST["codename"]) {
$cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_CODENAME_USED);
}
}
}
$languages = CMS_languagesCatalog::getAllLanguages();
foreach ($languages as $aLanguage) {
if (!$_POST['label' . $aLanguage->getCode()]) {
$cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($aLanguage->getLabel()));
}
示例12: setAlias
/**
* Sets the title of the alias
*
* @param string $alias The title to set
* @return boolean true on success, false on failure
* @access public
*/
function setAlias($alias)
{
//clean alias characters
$alias = sensitiveIO::sanitizeAsciiString($alias, '@');
//check if alias directory already exists
if (@is_dir($this->getPath(false, PATH_RELATIVETO_FILESYSTEM) . $alias)) {
//check if directory is used by another alias
$aliases = CMS_module_cms_aliases::getByName($alias);
$otherAlias = false;
$otherAliasesUsesWebsites = array();
foreach ($aliases as $anAlias) {
if ($this->getID() != $anAlias->getID() && $this->getPath(false) . $alias . '/' == $anAlias->getPath(true)) {
//check websites of other aliases. It must not use same domain as current one
if (!$anAlias->getWebsites()) {
//this other alias use all domains, so current alias can never be used
return false;
} else {
$otherAliasesUsesWebsites = array_merge($anAlias->getWebsites(), $otherAliasesUsesWebsites);
}
$otherAlias = true;
}
}
if (!$otherAlias && $this->getPath(false) . $alias . '/' != $this->getPath(true)) {
//no other alias use this directory, so it is used by something else
return false;
} elseif ($otherAliasesUsesWebsites) {
//check if this alias can be used by a website
$otherAliasesUsesWebsites = array_unique($otherAliasesUsesWebsites);
if ($this->getWebsites()) {
$websites = $this->getWebsites();
} else {
$websites = array_keys(CMS_websitesCatalog::getAll());
}
$freeWebsite = array();
foreach ($websites as $codename) {
if (!in_array($codename, $otherAliasesUsesWebsites)) {
$freeWebsite[] = $codename;
}
}
if (!$freeWebsite) {
//no free website for this alias
return false;
}
//limit alias to free websites
$this->setWebsites($freeWebsite);
}
}
//alias already exists, check if alias name change. If so, delete old files
if ($this->getID() && $this->_alias != $alias) {
$this->_deleteFiles();
}
$this->_alias = $alias;
return true;
}
示例13: define
define("MESSAGE_PAGE_FIELD_ADD", 260);
define("MESSAGE_PAGE_FIELD_DELETE", 854);
define("MESSAGE_FORM_ERROR_CODENAME_USED", 1308);
define("MESSAGE_PAGE_FIELD_TOOLBAR", 1404);
//checks
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES)) {
header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id());
exit;
}
$cms_message = '';
switch ($_POST["cms_action"]) {
case "validate":
$toolbar = new CMS_wysiwyg_toolbar($_POST['toolbar'], $cms_user);
if (!$_POST['label'] || !$_POST['code']) {
}
if (!$toolbar->getID() && (!$_POST["code"] || $_POST["code"] != substr(sensitiveIO::sanitizeAsciiString($_POST["code"]), 0, 20))) {
$cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_CODENAME)));
} elseif ($_POST['code'] && !$toolbar->getID()) {
foreach ($toolbars as $aToolbar) {
if ($aToolbar->getCode() == $_POST["code"]) {
$cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_CODENAME_USED);
}
}
if (!$cms_message) {
$toolbar->setCode($_POST["code"]);
}
}
$toolbar->setLabel($_POST["label"]);
$toolbar->setElements(explode(';', $_POST["elements"]));
if (!$cms_message) {
$toolbar->writeToPersistence();