if(($page_place===false)||((substr($page_place[0],0,7)=='COMCODE')&&($type!==null/*looking deeper than a normal Comcode page*/))){
// This code branch is finding absolute monikers (easy case), or monikers pointing to a Comcode page (special case)...
// Reassemble source URL moniker from incorrectly-derived URL components
$url_moniker='';
$url_moniker.=get_param_string('page','',true);/* Has to be unadulterated, $page has /s/-/_ */
@@ -733,35 +735,39 @@ function process_url_monikers($page, $redirect_if_non_canonical = true)
}
// ... and query it
$sql='SELECT m_resource_page,m_resource_type,m_resource_id FROM '.get_table_prefix().'url_id_monikers WHERE ';
$sql.=db_string_equal_to('m_moniker','/'.$url_moniker).' OR ';
$sql.=db_string_equal_to('m_moniker',$url_moniker).' AND '.db_string_equal_to('m_resource_type','').' AND '.db_string_equal_to('m_resource_id',$zone).' OR ';
$sql.=db_string_equal_to('m_moniker','/'.str_replace('-','_',$url_moniker)).' OR ';
$sql.=db_string_equal_to('m_moniker',str_replace('-','_',$url_moniker)).' AND '.db_string_equal_to('m_resource_type','').' AND '.db_string_equal_to('m_resource_id',$zone);
$test=$GLOBALS['SITE_DB']->query($sql,1);
if(array_key_exists(0,$test)){
if(_request_page($test[0]['m_resource_page'],$zone)!==false){// ... if operable within the zone we're in
$sql='SELECT * FROM '.get_table_prefix().'url_id_monikers WHERE ';
$sql.=db_string_equal_to('m_moniker','/'.$url_moniker).' OR ';// Absolute
$sql.=db_string_equal_to('m_moniker',$url_moniker).' AND '.db_string_equal_to('m_resource_type','').' AND '.db_string_equal_to('m_resource_id',$zone).' OR ';// Comcode page
// (dash replacement...)
$sql.=db_string_equal_to('m_moniker','/'.str_replace('-','_',$url_moniker)).' OR ';// Absolute
$sql.=db_string_equal_to('m_moniker',str_replace('-','_',$url_moniker)).' AND '.db_string_equal_to('m_resource_type','').' AND '.db_string_equal_to('m_resource_id',$zone);// Comcode page
$monikers=$GLOBALS['SITE_DB']->query($sql,1);
if(array_key_exists(0,$monikers)){
if(_request_page($monikers[0]['m_resource_page'],$zone)!==false){// ... if operable within the zone we're in
if($url_id!==null&&$redirect_if_non_canonical){// NB: Comcode page monikers would have been handled in the code above
// Does this URL arrangement support monikers? We find out by interrogating hooks to see if the moniker can sit under the module's zone+page+type stub.
if($url_id!==null){// NB: Comcode page monikers would have been handled in the code above
if(($correct_moniker!==null)&&($correct_moniker!=$url_id)&&(get_param_integer('keep_failover',null)!==0)&&(cms_srv('REQUEST_METHOD')!='POST')){// test is very unlikely to fail. Will only fail if the title of the resource was numeric - in which case the moniker was chosen to be the ID (NOT the number in the title, as that would have created ambiguity).
set_http_status_code('301');
@@ -789,38 +795,65 @@ function process_url_monikers($page, $redirect_if_non_canonical = true)