ocPortal Developer's Guide: Caches and Comcode pages
» Return to Contents
sources/caches.php
Global_functions_caches.php
Function summary
|
void
|
init__caches ()
|
|
?mixed
|
persistant_cache_get (mixed key, ?TIME min_cache_date)
|
|
void
|
persistant_cache_set (mixed key, mixed data, boolean server_wide, ?integer expire_secs)
|
|
void
|
persistant_cache_delete (mixed key)
|
|
void
|
persistant_cache_empty ()
|
|
void
|
decache (ID_TEXT cached_for, ?array identifier)
|
|
?array
|
find_cache_on (ID_TEXT codename)
|
|
?mixed
|
get_cache_entry (ID_TEXT codename, LONG_TEXT cache_identifier, integer ttl, boolean tempcode, boolean caching_via_cron, ?array map)
|
|
void
|
request_via_cron (ID_TEXT codename, ?array map, boolean tempcode)
|
void init__caches()
Standard code module initialisation function.
Parameters…
(No return value)
function init__caches()
{
global $CACHE_ON;
$CACHE_ON=NULL;
global $MEM_CACHE,$SITE_INFO;
$MEM_CACHE=NULL;
$use_memcache=((array_key_exists('use_mem_cache',$SITE_INFO)) && ($SITE_INFO['use_mem_cache']=='1'));// Default to off because badly configured caches can result in lots of very slow misses and lots of lost sessions || ((!array_key_exists('use_mem_cache',$SITE_INFO)) && ((function_exists('xcache_get')) || (function_exists('wincache_ucache_get')) || (function_exists('apc_fetch')) || (function_exists('eaccelerator_get')) || (function_exists('mmcache_get'))));
if ((($use_memcache)/* || ($GLOBALS['DEBUG_MODE'])*/) && ($GLOBALS['IN_MINIKERNEL_VERSION']!=1)) // There's some randomness so people in dev mode SOMETIMES use memcache. This'll stop it being allowed to rot.
{
if (class_exists('Memcache'))
{
$MEM_CACHE=new Memcache();
$MEM_CACHE->connect('localhost',11211) OR $MEM_CACHE=NULL;
}
elseif (function_exists('apc_fetch'))
{
require_code('caches_apc');
$MEM_CACHE=new apccache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS=apc_fetch(get_file_base().'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS===false) $ECACHE_OBJECTS=array();
}
elseif ((function_exists('eaccelerator_put')) || (function_exists('mmcache_put')))
{
require_code('caches_eaccelerator');
$MEM_CACHE=new eacceleratorcache();
global $ECACHE_OBJECTS;
if (function_exists('eaccelerator_get'))
$ECACHE_OBJECTS=eaccelerator_get(get_file_base().'ECACHE_OBJECTS');
if (function_exists('mmcache_get'))
$ECACHE_OBJECTS=mmcache_get(get_file_base().'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS===NULL) $ECACHE_OBJECTS=array();
}
elseif (function_exists('xcache_get'))
{
require_code('caches_xcache');
$MEM_CACHE=new xcache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS=xcache_get(get_file_base().'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS===false) $ECACHE_OBJECTS=array();
}
elseif (function_exists('wincache_ucache_get'))
{
require_code('caches_wincache');
$MEM_CACHE=new wincache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS=wincache_ucache_get(get_file_base().'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS===false) $ECACHE_OBJECTS=array();
}
elseif (file_exists(get_custom_file_base().'/persistant_cache/'))
{
require_code('caches_filesystem');
require_code('files');
$MEM_CACHE=new filecache();
}
}
}
?mixed persistant_cache_get(mixed key, ?TIME min_cache_date)
Get data from the persistant cache.
Parameters…
| Name |
key |
| Description |
Key |
| Type |
mixed |
| Name |
min_cache_date |
| Description |
Minimum timestamp that entries from the cache may hold (NULL: don't care) |
| Default value |
|
| Type |
?TIME |
Returns…
| Description |
The data (NULL: not found / NULL entry) |
| Type |
?mixed |
function persistant_cache_get($key,$min_cache_date=NULL)
{
global $MEM_CACHE;
if (($GLOBALS['DEBUG_MODE']) && (mt_rand(0,3)==1)) return NULL;
if ($MEM_CACHE===NULL) return NULL;
$test=$MEM_CACHE->get(get_file_base().serialize($key),$min_cache_date); // First we'll try specifically for site
if ($test!==NULL) return $test;
return $MEM_CACHE->get(('ocp'.float_to_raw_string(ocp_version_number())).serialize($key),$min_cache_date); // And last we'll try server-wide
}
void persistant_cache_set(mixed key, mixed data, boolean server_wide, ?integer expire_secs)
Put data into the persistant cache.
Parameters…
| Name |
key |
| Description |
Key |
| Type |
mixed |
| Name |
data |
| Description |
The data |
| Type |
mixed |
| Name |
server_wide |
| Description |
Whether it is server-wide data |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
expire_secs |
| Description |
The expiration time in seconds. (NULL: Default expiry in 60 minutes, or never if it is server-wide). |
| Default value |
|
| Type |
?integer |
(No return value)
function persistant_cache_set($key,$data,$server_wide=false,$expire_secs=NULL)
{
global $MEM_CACHE;
if ($MEM_CACHE===NULL) return NULL;
if ($expire_secs===NULL) $expire_secs=$server_wide?0:(60*60);
$MEM_CACHE->set(($server_wide?('ocp'.float_to_raw_string(ocp_version_number())):get_file_base()).serialize($key),$data,0,$expire_secs);
}
void persistant_cache_delete(mixed key)
Delete data from the persistant cache.
Parameters…
| Name |
key |
| Description |
Key name |
| Type |
mixed |
(No return value)
function persistant_cache_delete($key)
{
global $MEM_CACHE;
if ($MEM_CACHE===NULL) return NULL;
$MEM_CACHE->delete(get_file_base().serialize($key));
$MEM_CACHE->delete('ocp'.float_to_raw_string(ocp_version_number()).serialize($key));
}
void persistant_cache_empty()
Remove all data from the persistant cache.
Parameters…
(No return value)
function persistant_cache_empty()
{
global $MEM_CACHE;
if ($MEM_CACHE===NULL) return NULL;
$MEM_CACHE->flush();
}
void decache(ID_TEXT cached_for, ?array identifier)
Remove an item from the general cache (most commonly used for blocks).
Parameters…
| Name |
cached_for |
| Description |
The type of what we are cacheing (e.g. block name) |
| Type |
ID_TEXT |
| Name |
identifier |
| Description |
A map of identifiying characteristics (NULL: no identifying characteristics, decache all) |
| Default value |
|
| Type |
?array |
(No return value)
function decache($cached_for,$identifier=NULL)
{
if (running_script('stress_test_loader')) return;
if (get_page_name()=='admin_import') return;
// NB: If we use persistant cache we still need to decache from DB, in case we're switching between for whatever reason. Or maybe some users use persistant cache and others don't. Or maybe some nodes do and others don't.
if ($GLOBALS['MEM_CACHE']!==NULL)
{
persistant_cache_delete(array('CACHE',$cached_for));
}
$where=array('cached_for'=>$cached_for);
if ($identifier!==NULL) $where['identifier']=md5(serialize($identifier));
$GLOBALS['SITE_DB']->query_delete('cache',$where);
if ($identifier!==NULL)
{
global $TEMPCODE_SETGET;
$identifier[]=array_key_exists('in_panel',$TEMPCODE_SETGET)?$TEMPCODE_SETGET['in_panel']:'0';
$where['identifier']=md5(serialize($identifier));
$GLOBALS['SITE_DB']->query_delete('cache',$where);
}
}
?array find_cache_on(ID_TEXT codename)
Find the cache-on parameters for 'codename's cacheing style (prevents us needing to load up extra code to find it).
Parameters…
| Name |
codename |
| Description |
The codename of what will be checked for cacheing |
| Type |
ID_TEXT |
Returns…
| Description |
The cached result (NULL: no cached result) |
| Type |
?array |
function find_cache_on($codename)
{
if (defined('HIPHOP_PHP')) return;
// See if we have it cached
global $CACHE_ON;
if ($CACHE_ON===NULL)
{
$CACHE_ON=persistant_cache_get('CACHE_ON');
if ($CACHE_ON===NULL)
{
$CACHE_ON=$GLOBALS['SITE_DB']->query_select('cache_on',array('*'));
persistant_cache_set('CACHE_ON',$CACHE_ON);
}
}
foreach ($CACHE_ON as $row)
{
if ($row['cached_for']==$codename)
{
return $row;
}
}
return NULL;
}
?mixed get_cache_entry(ID_TEXT codename, LONG_TEXT cache_identifier, integer ttl, boolean tempcode, boolean caching_via_cron, ?array map)
Find the cached result of what is named by codename and the further constraints.
Parameters…
| Name |
codename |
| Description |
The codename to check for cacheing |
| Type |
ID_TEXT |
| Name |
cache_identifier |
| Description |
The further restraints (a serialized map) |
| Type |
LONG_TEXT |
| Name |
ttl |
| Description |
The TTL for the cache entry |
| Default value |
10000 |
| Type |
integer |
| Name |
tempcode |
| Description |
Whether we are cacheing Tempcode (needs special care) |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
caching_via_cron |
| Description |
Whether to defer caching to CRON. Note that this option only works if the block's defined cache signature depends only on $map (timezone, bot-type, in-panel and interlock are automatically considered) |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
map |
| Description |
Parameters to call up block with if we have to defer caching (NULL: none) |
| Default value |
|
| Type |
?array |
Returns…
| Description |
The cached result (NULL: no cached result) |
| Type |
?mixed |
function get_cache_entry($codename,$cache_identifier,$ttl=10000,$tempcode=false,$caching_via_cron=false,$map=NULL) // Default to a very big ttl
{
if ($GLOBALS['MEM_CACHE']!==NULL)
{
$pcache=persistant_cache_get(array('CACHE',$codename));
if ($pcache===NULL) return NULL;
$theme=$GLOBALS['FORUM_DRIVER']->get_theme();
$lang=user_lang();
$pcache=isset($pcache[$cache_identifier][$lang][$theme])?$pcache[$cache_identifier][$lang][$theme]:NULL;
if ($pcache===NULL)
{
if ($caching_via_cron)
{
request_via_cron($codename,$map,$tempcode);
return paragraph(do_lang_tempcode('CACHE_NOT_READY_YET'),'','nothing_here');
}
return NULL;
}
$cache_rows=array($pcache);
} else
{
$cache_rows=$GLOBALS['SITE_DB']->query_select('cache',array('*'),array('lang'=>user_lang(),'cached_for'=>$codename,'the_theme'=>$GLOBALS['FORUM_DRIVER']->get_theme(),'identifier'=>md5($cache_identifier)),'',1);
if (!isset($cache_rows[0])) // No
{
if ($caching_via_cron)
{
request_via_cron($codename,$map,$tempcode);
return paragraph(do_lang_tempcode('CACHE_NOT_READY_YET'),'','nothing_here');
}
return NULL;
}
if ($tempcode)
{
$ob=new ocp_tempcode();
if (!$ob->from_assembly($cache_rows[0]['the_value'],true)) return NULL;
$cache_rows[0]['the_value']=$ob;
} else
{
$cache_rows[0]['the_value']=unserialize($cache_rows[0]['the_value']);
}
}
$stale=(($ttl!=-1) && (time()>($cache_rows[0]['date_and_time']+$ttl*60)));
if ((!$caching_via_cron) && ($stale)) // Out of date
{
return NULL;
} else // We can use directly
{
if ($stale)
request_via_cron($codename,$map,$tempcode);
$cache=$cache_rows[0]['the_value'];
if ($cache_rows[0]['langs_required']!='')
{
$bits=explode('!',$cache_rows[0]['langs_required']);
$langs_required=explode(':',$bits[0]); // Sometimes lang has got intertwinded with non cacheable stuff (and thus was itself not cached), so we need the lang files
foreach ($langs_required as $lang)
if ($lang!='') require_lang($lang,NULL,NULL,true);
if (isset($bits[1]))
{
$javascripts_required=explode(':',$bits[1]);
foreach ($javascripts_required as $javascript)
if ($javascript!='') require_javascript($javascript);
}
if (isset($bits[2]))
{
$csss_required=explode(':',$bits[2]);
foreach ($csss_required as $css)
if ($css!='') require_css($css);
}
}
return $cache;
}
}
void request_via_cron(ID_TEXT codename, ?array map, boolean tempcode)
Request that CRON loads up a block's caching in the background.
Parameters…
| Name |
codename |
| Description |
The codename of the block |
| Type |
ID_TEXT |
| Name |
map |
| Description |
Parameters to call up block with if we have to defer caching (NULL: none) |
| Type |
?array |
| Name |
tempcode |
| Description |
Whether we are cacheing Tempcode (needs special care) |
| Type |
boolean |
(No return value)
function request_via_cron($codename,$map,$tempcode)
{
global $TEMPCODE_SETGET;
$map=array(
'c_theme'=>$GLOBALS['FORUM_DRIVER']->get_theme(),
'c_lang'=>user_lang(),
'c_codename'=>$codename,
'c_map'=>serialize($map),
'c_timezone'=>get_users_timezone(get_member()),
'c_is_bot'=>is_null(get_bot_type())?0:1,
'c_in_panel'=>((array_key_exists('in_panel',$TEMPCODE_SETGET)?$TEMPCODE_SETGET['in_panel']:'_false')=='_true')?1:0,
'c_interlock'=>((array_key_exists('interlock',$TEMPCODE_SETGET)?$TEMPCODE_SETGET['interlock']:'_false')=='_true')?1:0,
'c_store_as_tempcode'=>$tempcode?1:0,
);
if (is_null($GLOBALS['SITE_DB']->query_value_null_ok('cron_caching_requests','id',$map)))
$GLOBALS['SITE_DB']->query_insert('cron_caching_requests',$map);
}
sources/view_modes.php
Global_functions_view_modes.php
Function summary
|
void
|
init__view_modes ()
|
|
void
|
initialise_special_page_types (ID_TEXT special_page_type)
|
|
void
|
special_page_types (ID_TEXT special_page_type, tempcode out, string out_evaluated)
|
|
?PATH
|
find_template_path (ID_TEXT name)
|
|
string
|
find_template_tree_nice (ID_TEXT codename, array children, boolean fresh, boolean cache_started)
|
|
tempcode
|
ocportal_cleanup (?array caches)
|
|
void
|
erase_tempcode_cache ()
|
|
void
|
erase_comcode_cache ()
|
|
void
|
erase_cached_language ()
|
|
void
|
erase_cached_templates (boolean preserve_some)
|
|
string
|
do_xhtml_validation (string out, boolean display_regardless, integer preview_mode, boolean ret)
|
|
string
|
display_validation_results (string out, array error, boolean preview_mode, boolean ret)
|
void init__view_modes()
Standard code module initialisation function.
Parameters…
(No return value)
function init__view_modes()
{
global $ERASED_TEMPLATES_ONCE;
$ERASED_TEMPLATES_ONCE=false;
}
void initialise_special_page_types(ID_TEXT special_page_type)
Initialise state variables for the special page type being requested.
Parameters…
| Name |
special_page_type |
| Description |
The special page type. |
| Type |
ID_TEXT |
| Values restricted to |
query templates tree lang |
(No return value)
function initialise_special_page_types($special_page_type)
{
if ($special_page_type=='templates')
{
global $RECORD_TEMPLATES_USED;
$RECORD_TEMPLATES_USED=true;
}
elseif ($special_page_type=='tree')
{
global $RECORD_TEMPLATES_TREE;
$RECORD_TEMPLATES_TREE=true;
}
elseif (substr($special_page_type,0,12)=='lang_content')
{
global $RECORD_LANG_STRINGS_CONTENT;
$RECORD_LANG_STRINGS_CONTENT=true;
}
elseif (substr($special_page_type,0,4)=='lang')
{
global $RECORD_LANG_STRINGS;
$RECORD_LANG_STRINGS=true;
}
elseif ($special_page_type=='theme_images')
{
global $RECORD_IMG_CODES;
$RECORD_IMG_CODES=true;
}
elseif ($special_page_type=='ide_linkage')
{
global $RECORD_TEMPLATES_USED;
$RECORD_TEMPLATES_USED=true;
}
}
void special_page_types(ID_TEXT special_page_type, tempcode out, string out_evaluated)
Handle special page type output.
Parameters…
| Name |
special_page_type |
| Description |
The special page type. |
| Type |
ID_TEXT |
| Values restricted to |
query templates tree lang |
| Name |
out |
| Description |
The normal script tempcode output |
| Type |
tempcode |
| Name |
out_evaluated |
| Description |
The normal script evaluated output |
| Type |
string |
(No return value)
function special_page_types($special_page_type,&$out,/*&*/$out_evaluated)
{
global $RECORDED_TEMPLATES_USED;
if (function_exists('set_time_limit')) @set_time_limit(280);
$echo=do_header();
//$echo->evaluate_echo();
$echo2=new ocp_tempcode();
if (is_null($out_evaluated))
{
ob_start();
$out->evaluate_echo(); // False evaluation
ob_end_clean();
}
// HACKHACK: Yuck. we have to after-the-fact make it wide, and empty lots of internal caching to reset the state.
$_GET['wide_high']='1';
$_GET['wide']='1';
$GLOBALS['LOADED_PANELS']=array();
$GLOBALS['IS_WIDE_HIGH']=1;
$GLOBALS['IS_WIDE']=1;
$GLOBALS['TEMPCODE_SETGET']=array();
$GLOBALS['LOADED_TPL_CACHE']=array();
$GLOBALS['HELPER_PANEL_PIC']=NULL;
$GLOBALS['HELPER_PANEL_TEXT']=NULL;
$GLOBALS['HELPER_PANEL_TUTORIAL']=NULL;
$GLOBALS['HELPER_PANEL_HTML']=NULL;
// CSS
if (substr($special_page_type,-4)=='.css')
{
$url=build_url(array('page'=>'admin_themes','type'=>'edit_css','theme'=>$GLOBALS['FORUM_DRIVER']->get_theme(),'file'=>$special_page_type,'keep_wide_high'=>1),get_module_zone('admin_themes'));
header('Location: '.$url->evaluate());
exit();
}
// Site Tree Editor
if ($special_page_type=='site_tree')
{
$url=build_url(array('page'=>'admin_sitetree','type'=>'site_tree','id'=>get_zone_name().':'.get_page_name()),get_module_zone('admin_sitetree'));
header('Location: '.$url->evaluate());
exit();
}
// IDE linkage
if ($special_page_type=='ide_linkage')
{
$title=get_page_title('IDE_LINKAGE');
$file_links=new ocp_tempcode();
global $JAVASCRIPTS,$CSSS,$_REQUIRED_CODE,$LANGS_REQUESTED;
/*foreach (array_keys($JAVASCRIPTS) as $name) Already in list of templates
{
$txtmte_url='txmt://open?url=file://'.$name;
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('URL'=>$txtmte_url,'NAME'=>$name)));
}*/
foreach (array_keys($CSSS) as $name)
{
$search=find_template_place($name,get_site_default_lang(),$GLOBALS['FORUM_DRIVER']->get_theme(),'.css','css');
if (!is_null($search))
{
list($theme,$type)=$search;
$txtmte_url='txmt://open?url=file://'.get_file_base().'/themes/'.$theme.'/'.$type.'/'.$name.'.css';
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('DISPLAY_STRING'=>'(CSS)','URL'=>$txtmte_url,'NAME'=>$name.'.css')));
}
}
foreach (array_keys($_REQUIRED_CODE) as $name)
{
$path_a=get_file_base().'/'.((strpos($name,'.php')===false)?('/sources_custom/'.$name.'.php'):$name);
$path_b=get_file_base().'/'.((strpos($name,'.php')===false)?('/sources/'.$name.'.php'):str_replace('_custom','',$name));
if (file_exists($path_a))
{
$txtmte_url='txmt://open?url=file://'.$path_a;
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('DISPLAY_STRING'=>'(PHP)','URL'=>$txtmte_url,'NAME'=>$name.(((strpos($name,'.php')===false)?'.php':'')))));
}
if (file_exists($path_b))
{
$txtmte_url='txmt://open?url=file://'.$path_b;
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('DISPLAY_STRING'=>'(PHP)','URL'=>$txtmte_url,'NAME'=>$name.(((strpos($name,'.php')===false)?'.php':'')))));
}
}
foreach (array_keys($LANGS_REQUESTED) as $name)
{
if (file_exists(get_file_base().'/lang_custom/'.fallback_lang().'/'.$name.'.ini'))
{
$txtmte_url='txmt://open?url=file://'.get_file_base().'/lang_custom/'.fallback_lang().'/'.$name.'.ini';
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('DISPLAY_STRING'=>'(Language)','URL'=>$txtmte_url,'NAME'=>$name.'.ini')));
}
if (file_exists(get_file_base().'/lang/'.fallback_lang().'/'.$name.'.ini'))
{
$txtmte_url='txmt://open?url=file://'.get_file_base().'/lang/'.fallback_lang().'/'.$name.'.ini';
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('DISPLAY_STRING'=>'(Language)','URL'=>$txtmte_url,'NAME'=>$name.'.ini')));
}
}
foreach (array_unique($RECORDED_TEMPLATES_USED) as $name)
{
$search=find_template_place($name,get_site_default_lang(),$GLOBALS['FORUM_DRIVER']->get_theme(),'.tpl','templates');
if (!is_null($search))
{
list($theme,$type)=$search;
$txtmte_url='txmt://open?url=file://'.get_file_base().'/themes/'.$theme.'/'.$type.'/'.$name.'.tpl';
$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('DISPLAY_STRING'=>'(Templates)','URL'=>$txtmte_url,'NAME'=>$name.'.tpl')));
}
}
$echo2=do_template('INDEX_SCREEN',array('TITLE'=>$title,'CONTENT'=>$file_links,'PRE'=>do_lang_tempcode('TXMT_PROTOCOL_EXPLAIN'),'POST'=>''));
}
// Theme images mode
if ($special_page_type=='theme_images')
{
$title=get_page_title('THEME_IMAGE_EDITING');
$theme_images=new ocp_tempcode();
global $RECORDED_IMG_CODES;
foreach (array_keys($RECORDED_IMG_CODES) as $theme_image_details)
{
list($id,$theme,$lang)=unserialize($theme_image_details);
$url=build_url(array('page'=>'admin_themes','type'=>'edit_image','theme'=>is_null($theme)?$GLOBALS['FORUM_DRIVER']->get_theme():$theme,'lang'=>$lang,'id'=>$id),'adminzone');
$image=find_theme_image($id,false,false,$theme,$lang);
if ($image=='') continue;
$theme_images->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY',array('IMG'=>$image,'DESCRIPTION'=>'','URL'=>$url,'NAME'=>$id)));
}
$echo2=do_template('INDEX_SCREEN_FANCIER_SCREEN',array('TITLE'=>$title,'CONTENT'=>$theme_images,'PRE'=>do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'),'POST'=>''));
}
// Profile mode?
if ($special_page_type=='profile')
{
if (function_exists('xdebug_dump_function_profile'))
{
$type=XDEBUG_PROFILER_FS_SUM;
xdebug_dump_function_profile($type);
} else
{
$echo2=make_string_tempcode('Check out the dump using KCacheGrind.');
}
}
// Content translation mode
elseif (substr($special_page_type,0,12)=='lang_content')
{
$map_a=get_file_base().'/lang/langs.ini';
$map_b=get_custom_file_base().'/lang_custom/langs.ini';
if (!file_exists($map_b)) $map_b=$map_a;
$map=better_parse_ini_file($map_b);
$lang_name=user_lang();
if (array_key_exists($lang_name,$map)) $lang_name=$map[$lang_name];
global $RECORDED_LANG_STRINGS_CONTENT;
require_lang('lang');
require_code('form_templates');
$fields=new ocp_tempcode();
require_code('lang2');
$names=find_lang_content_names(array_keys($RECORDED_LANG_STRINGS_CONTENT));
foreach ($RECORDED_LANG_STRINGS_CONTENT as $key=>$forum_db)
{
$value_found=get_translated_text($key,$forum_db?$GLOBALS['FORUM_DB']:$GLOBALS['SITE_DB']);
if ($value_found!='')
{
$description=make_string_tempcode(escape_html($value_found));
if ((get_value('google_translate_api_key')===NULL) || (user_lang()==get_site_default_lang()))
{
$actions=new ocp_tempcode();
} else
{
require_javascript('javascript_translate');
$actions=do_template('TRANSLATE_ACTION',array('LANG_FROM'=>get_site_default_lang(),'LANG_TO'=>user_lang(),'NAME'=>'trans_'.strval($key),'OLD'=>$value_found));
}
$description->attach($actions);
$fields->attach(form_input_text(is_null($names[$key])?('#'.strval($key)):$names[$key],$description,'trans_'.strval($key),$value_found,false));
}
}
if ($fields->is_empty()) inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE'));
$title=get_page_title('__TRANSLATE_CONTENT',true,array($lang_name));
$post_url=build_url(array('page'=>'admin_lang','type'=>'_content','contextual'=>1),'adminzone');
$hidden=form_input_hidden('redirect',get_self_url(true,true));
$hidden=form_input_hidden('lang',user_lang());
$echo2=do_template('FORM_SCREEN',array('_GUID'=>'0d4dd16b023d0a7960f3eac85f54ddc4','SKIP_VALIDATION'=>true,'TITLE'=>$title,'HIDDEN'=>$hidden,'FIELDS'=>$fields,'URL'=>$post_url,'TEXT'=>do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'),'SUBMIT_NAME'=>do_lang_tempcode('SAVE')));
}
// Language mode
elseif (substr($special_page_type,0,4)=='lang')
{
$map_a=get_file_base().'/lang/langs.ini';
$map_b=get_custom_file_base().'/lang_custom/langs.ini';
if (!file_exists($map_b)) $map_b=$map_a;
$map=better_parse_ini_file($map_b);
$lang_name=user_lang();
if (array_key_exists($lang_name,$map)) $lang_name=$map[$lang_name];
global $RECORDED_LANG_STRINGS;
require_lang('lang');
require_code('form_templates');
require_code('lang2');
$fields=new ocp_tempcode();
$descriptions=get_lang_file_descriptions(fallback_lang());
foreach (array_keys($RECORDED_LANG_STRINGS) as $key)
{
$value_found=do_lang($key,NULL,NULL,NULL,NULL,false);
$description=array_key_exists($key,$descriptions)?make_string_tempcode($descriptions[$key]):new ocp_tempcode();
if (!is_null($value_found))
{
if ((get_value('google_translate_api_key')===NULL) || (user_lang()==get_site_default_lang()))
{
$actions=new ocp_tempcode();
} else
{
require_javascript('javascript_translate');
$actions=do_template('TRANSLATE_ACTION',array('LANG_FROM'=>get_site_default_lang(),'LANG_TO'=>user_lang(),'NAME'=>'l_'.$key,'OLD'=>str_replace('\n',chr(10),$value_found)));
}
$description->attach($actions);
$fields->attach(form_input_text($key,$description,'l_'.$key,str_replace('\n',chr(10),$value_found),false));
}
}
$title=get_page_title('__TRANSLATE_CODE',true,array($lang_name));
$post_url=build_url(array('page'=>'admin_lang','type'=>'_code2'),'adminzone');
$hidden=form_input_hidden('redirect',get_self_url(true,true));
$hidden=form_input_hidden('lang',user_lang());
$echo2=do_template('FORM_SCREEN',array('_GUID'=>'0d4dd16b023d0a7960f3eac85f54ddc4','SKIP_VALIDATION'=>true,'TITLE'=>$title,'HIDDEN'=>$hidden,'FIELDS'=>$fields,'URL'=>$post_url,'TEXT'=>do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'),'SUBMIT_NAME'=>do_lang_tempcode('SAVE')));
}
// Template mode?
if (($special_page_type=='templates') || ($special_page_type=='tree'))
{
require_lang('themes');
global $RECORD_TEMPLATES_USED;
$RECORD_TEMPLATES_USED=false;
$templates=new ocp_tempcode();
if ($special_page_type=='templates')
{
$title=get_page_title('TEMPLATES');
$_RECORDED_TEMPLATES_USED=array_count_values($RECORDED_TEMPLATES_USED);
ksort($_RECORDED_TEMPLATES_USED);
foreach ($_RECORDED_TEMPLATES_USED as $name=>$count)
{
//$restore_from=find_template_path($name);
$file=$name.'.tpl';
$edit_url=build_url(array('page'=>'admin_themes','type'=>'_edit_templates','theme'=>$GLOBALS['FORUM_DRIVER']->get_theme(),/*'restore_from'=>$restore_from,*/'f0file'=>$file),'adminzone',NULL,false,true);
$templates->attach(do_template('TEMPLATE_LIST_ENTRY',array('COUNT'=>integer_format($count),'NAME'=>$name,'EDIT_URL'=>$edit_url)));
}
} else
{
$title=get_page_title('TEMPLATE_TREE');
$hidden=new ocp_tempcode();
global $CSSS,$JAVASCRIPTS;
foreach (array_keys($CSSS) as $c)
{
$hidden->attach(form_input_hidden('f'.strval(mt_rand(0,100000)).'file',$c.'.css'));
}
foreach (array_keys($JAVASCRIPTS) as $c)
{
$hidden->attach(form_input_hidden('f'.strval(mt_rand(0,100000)).'file',strtoupper($c).'.tpl'));
}
$edit_url=build_url(array('page'=>'admin_themes','type'=>'_edit_templates','preview_url'=>get_self_url(true,false,array('special_page_type'=>NULL)),'theme'=>$GLOBALS['FORUM_DRIVER']->get_theme()),'adminzone',NULL,false,true);
$tree=find_template_tree_nice($out->codename,$out->children,$out->fresh);
$templates=do_template('TEMPLATE_TREE',array('_GUID'=>'ff2a2233b8b4045ba4d8777595ef64c7','HIDDEN'=>$hidden,'EDIT_URL'=>$edit_url,'TREE'=>$tree));
}
$echo2=do_template('TEMPLATE_LIST_SCREEN',array('_GUID'=>'ab859f67dcb635fcb4d1747d3c6a2c17','TITLE'=>$title,'TEMPLATES'=>$templates));
}
// Query mode?
if ($special_page_type=='query')
{
require_lang("profiling");
global $QUERY_LIST;
$queries=new ocp_tempcode();
$total_time=0.0;
global $M_SORT_KEY;
$M_SORT_KEY='time';
usort($QUERY_LIST,'multi_sort');
$QUERY_LIST=array_reverse($QUERY_LIST);
foreach ($QUERY_LIST as $query)
{
$queries->attach(do_template('QUERY_LOG',array('_GUID'=>'ab88e1e92609136229ad920c30647647','TIME'=>float_format($query['time'],3),'TEXT'=>$query['text'])));
$total_time+=$query['time'];
}
$title=get_page_title("VIEW_PAGE_QUERIES");
$total=count($QUERY_LIST);
$echo2=do_template('QUERY_SCREEN',array('_GUID'=>'5f679c8f657b4e4ae94ae2d0ed4843fa','TITLE'=>$title,'TOTAL'=>integer_format($total),'TOTAL_TIME'=>float_format($total_time,3),'QUERIES'=>$queries));
}
$echo->attach(globalise($echo2));
$echo->attach(do_footer());
$echo->handle_symbol_preprocessing();
$echo->evaluate_echo();
exit();
}
?PATH find_template_path(ID_TEXT name)
Finds the path of the given template codename.
Parameters…
| Name |
name |
| Description |
The template codename |
| Type |
ID_TEXT |
Returns…
| Description |
A path (NULL: no such template) |
| Type |
?PATH |
function find_template_path($name)
{
$theme=$GLOBALS['FORUM_DRIVER']->get_theme();
$restore_from=NULL;
$_codename=$name;
$tries=array( get_custom_file_base().'/themes/'.$theme.'/templates_custom/'.$_codename,
get_custom_file_base().'/themes/'.$theme.'/templates/'.$_codename,
get_file_base().'/themes/'.'default'.'/templates_custom/'.$_codename,
get_file_base().'/themes/'.'default'.'/templates/'.$_codename,
get_custom_file_base().'/themes/'.$theme.'/templates_custom/'.$name,
get_custom_file_base().'/themes/'.$theme.'/templates/'.$name,
get_file_base().'/themes/'.'default'.'/templates_custom/'.$name,
get_file_base().'/themes/'.'default'.'/templates/'.$name);
foreach ($tries as $try)
{
$restore_from=$try.'.tpl';
if (is_file($try.'.tpl')) break;
}
return $restore_from;
}
string find_template_tree_nice(ID_TEXT codename, array children, boolean fresh, boolean cache_started)
Convert a template tree structure into a HTML representation.
Parameters…
| Name |
codename |
| Description |
The codename of the current template item in the recursion |
| Type |
ID_TEXT |
| Name |
children |
| Description |
The template tree structure for children |
| Type |
array |
| Name |
fresh |
| Description |
Whether the template tree came from a cache (if so, we can take some liberties with it's presentation) |
| Type |
boolean |
| Name |
cache_started |
| Description |
As $fresh, except something underneath at any unknown point did come from the cache, so this must have by extension |
| Default value |
boolean-false |
| Type |
boolean |
Returns…
| Description |
HTML representation |
| Type |
string |
function find_template_tree_nice($codename,$children,$fresh,$cache_started=false)
{
if ($codename=='')
{
$source=make_string_tempcode('?');
}
elseif ($codename[0]==':')
{
$source=make_string_tempcode(substr($codename,1));
}
elseif ($codename=='(mixed)')
{
$source=make_string_tempcode($codename);
} else
{
//$restore_from=find_template_path($codename);
$file=$codename.'.tpl';
$guid=mixed();
foreach ($children as $child)
{
if ($child[0]==':guid') $guid=substr($child[1][0][0],1);
}
$edit_url=build_url(array('page'=>'admin_themes','type'=>'_edit_templates','preview_url'=>get_self_url(true,false,array('special_page_type'=>NULL)),'f0guid'=>$guid,'theme'=>$GLOBALS['FORUM_DRIVER']->get_theme()/*,'restore_from'=>$restore_from*/,'f0file'=>$file),'adminzone');
$source=do_template('TEMPLATE_TREE_ITEM',array('_GUID'=>'be8eb00699631677d459b0f7c5ba60c8','FILE'=>$file,'EDIT_URL'=>$edit_url,'CODENAME'=>$codename,'GUID'=>$guid,'ID'=>strval(mt_rand(0,100000))));
}
$out=$source->evaluate()/*.((!$fresh)?' (db-cached)':'')*/;
$middle='';
do
{
$_children=array();
foreach ($children as $child)
{
if ((count($child[1])!=0) || ((strlen($child[0])!=0) && ($child[0][0]!=':')))
{
$_children[]=$child;
}
}
$children=$_children;
if ((count($children)==1) && ($children[0][0]==':container'))
$children=$children[0][1];
}
while ((count($children)==1) && ($children[0][0]==':container'));
foreach ($children as $child)
{
$middle2=find_template_tree_nice($child[0],$child[1],$child[2],$cache_started || !$fresh);
if ($middle2!='')
{
$_middle=do_template('TEMPLATE_TREE_ITEM_WRAP',array('_GUID'=>'59f003e298db3b621132649d2e315f9d','CONTENT'=>$middle2));
$middle.=$_middle->evaluate();
}
/*if ((!(strlen($codename)>0)) && (count($children)==1) && ($cache_started || ($fresh)))
return $middle2; // Collapse pointless nestings*/
}
if (($middle=='') && ((strlen($codename)==0) || ($codename[0]==':'))) return '';
if ($middle!='')
{
$_out=do_template('TEMPLATE_TREE_NODE',array('_GUID'=>'ff937cbe28f1988af9fc7861ef01ffee','ITEMS'=>$middle));
$out.=$_out->evaluate();
}
return $out;
}
tempcode ocportal_cleanup(?array caches)
Rebuild the specified caches.
Parameters…
| Name |
caches |
| Description |
The caches to rebuild (NULL: all) |
| Default value |
|
| Type |
?array |
Returns…
| Description |
Any messages returned |
| Type |
tempcode |
function ocportal_cleanup($caches=NULL)
{
require_lang('cleanup');
$max_time=intval(round(floatval(ini_get('max_execution_time'))/1.5));
if ($max_time<60*4)
{
if (function_exists('set_time_limit')) @set_time_limit(0);
}
$messages=new ocp_tempcode();
$hooks=find_all_hooks('modules','admin_cleanup');
if ((array_key_exists('ocf',$hooks)) && (array_key_exists('ocf_topics',$hooks)))
{
// A little re-ordering
$temp=$hooks['ocf'];
unset($hooks['ocf']);
$hooks['ocf']=$temp;
}
if (!is_null($caches))
{
foreach ($caches as $cache)
{
if (array_key_exists($cache,$hooks))
{
require_code('hooks/modules/admin_cleanup/'.filter_naughty_harsh($cache));
$object=object_factory('Hook_'.filter_naughty_harsh($cache),true);
if (is_null($object)) continue;
$messages->attach($object->run());
} else
{
$messages->attach(paragraph(do_lang_tempcode('_MISSING_RESOURCE',escape_html($cache))));
}
}
}
else
{
foreach (array_keys($hooks) as $hook)
{
require_code('hooks/modules/admin_cleanup/'.filter_naughty_harsh($hook));
$object=object_factory('Hook_'.filter_naughty_harsh($hook),true);
if (is_null($object)) continue;
$info=$object->info();
if ($info['type']=='cache')
$messages->attach($object->run());
}
}
log_it('CLEANUP_TOOLS');
return $messages;
}
void erase_tempcode_cache()
Erase the tempcode cache.
Parameters…
(No return value)
function erase_tempcode_cache()
{
$GLOBALS['SITE_DB']->query_delete('cache_on',NULL,'',NULL,NULL,true);
$GLOBALS['SITE_DB']->query_delete('cache');
if (function_exists('persistant_cache_empty')) persistant_cache_empty();
}
void erase_comcode_cache()
Erase the Comcode cache. Warning: This can take a long time on large sites, so is best to avoid.
Parameters…
(No return value)
function erase_comcode_cache()
{
if ((substr(get_db_type(),0,5)=='mysql') && (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('db_meta_indices','i_fields',array('i_table'=>'translate','i_name'=>'decache')))))
{
$GLOBALS['SITE_DB']->query('UPDATE '.get_table_prefix().'translate FORCE INDEX (decache) SET text_parsed=\'\' WHERE text_parsed>\'\''/*this where is so indexing helps*/);
} else
{
$GLOBALS['SITE_DB']->query('UPDATE '.get_table_prefix().'translate SET text_parsed=\'\' WHERE '.db_string_not_equal_to('text_parsed','')/*this where is so indexing helps*/);
}
}
void erase_cached_language()
Erase the language cache.
Parameters…
(No return value)
function erase_cached_language()
{
$langs=find_all_langs(true);
foreach (array_keys($langs) as $lang)
{
$path=get_custom_file_base().'/lang_cached/'.$lang;
$_dir=@opendir($path);
if ($_dir===false)
{
if (!file_exists(dirname($path)))
@mkdir(dirname($path),0777) OR intelligent_write_error($path);
@mkdir($path,0777) OR intelligent_write_error($path);
fix_permissions($path,0777);
} else
{
while (false!==($file=readdir($_dir)))
{
if (substr($file,-4)=='.lcd')
{
if (running_script('index'))
{
$key='page__'.get_zone_name().'__'.get_page_name();
} else
{
$key='script__'.md5(serialize(ocp_srv('PHP_SELF')).serialize($_GET));
}
if ($key.'.lcd'==$file) continue; // Will be open/locked
$i=0;
while ((@unlink($path.'/'.$file)===false) && ($i<5))
{
if (!file_exists($path.'/'.$file)) break; // Race condition, gone already
sleep(1); // May be race condition, lock
$i++;
}
if ($i>=5)
{
if ((file_exists($path.'/'.$file)) && (substr($file,0,5)!='page_') && (substr($file,0,7)!='script_'))
{
@unlink($path.'/'.$file) OR intelligent_write_error($path.'/'.$file);
}
}
}
}
closedir($_dir);
}
}
init__lang();
require_all_lang();
}
void erase_cached_templates(boolean preserve_some)
Erase all template caches (caches in all themes).
Parameters…
| Name |
preserve_some |
| Description |
Whether to preserve CSS and JS files that might be linked to between requests |
| Default value |
boolean-false |
| Type |
boolean |
(No return value)
function erase_cached_templates($preserve_some=false)
{
global $ERASED_TEMPLATES_ONCE;
$ERASED_TEMPLATES_ONCE=true;
require_code('themes2');
$themes=find_all_themes();
$langs=find_all_langs(true);
foreach (array_keys($themes) as $theme)
{
foreach (array_keys($langs) as $lang)
{
$path=get_custom_file_base().'/themes/'.$theme.'/templates_cached/'.$lang.'/';
$_dir=@opendir($path);
if ($_dir===false)
{
@mkdir($path,0777);// OR warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY_REPAIR',escape_html($path)));
fix_permissions($path,0777);
} else
{
while (false!==($file=readdir($_dir)))
{
if ((substr($file,-4)=='.tcd') || (substr($file,-4)=='.tcp') || ((!$preserve_some) && ((substr($file,-3)=='.js') || (substr($file,-4)=='.css'))))
{
$i=0;
while ((@unlink($path.$file)===false) && ($i<5))
{
if (!file_exists($path.$file)) break; // Race condition, gone already
sleep(1); // May be race condition, lock
$i++;
}
if ($i>=5)
if (file_exists($path.$file)) @unlink($path.$file) OR intelligent_write_error($path.$file);
}
}
closedir($_dir);
}
}
}
// Often the back button will be used to return to a form, so we need to ensure we have not broken the Javascript
if (function_exists('get_member'))
{
javascript_enforce('javascript_validation');
javascript_enforce('javascript_editing');
}
}
string do_xhtml_validation(string out, boolean display_regardless, integer preview_mode, boolean ret)
Takes the output from the scripts, and check the XHTML for validity, then echoes the page, plus the validation results.
Parameters…
| Name |
out |
| Description |
The XHTML to validate |
| Type |
string |
| Name |
display_regardless |
| Description |
Display XHTML output regardless of whether there was an error or not |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
preview_mode |
| Description |
Whether we are opening up an XHTML-fragment in a preview box (0 means no, 1 means yes, 2 means we are asking for additional manual check information) |
| Default value |
0 |
| Type |
integer |
| Values restricted to |
0 1 2 |
| Name |
ret |
| Description |
Whether to return Tempcode |
| Default value |
boolean-false |
| Type |
boolean |
Returns…
| Description |
Returned result (won't return it $ret is false) |
| Type |
string |
function do_xhtml_validation($out,$display_regardless=false,$preview_mode=0,$ret=false)
{
if ((!$display_regardless) && ($preview_mode==0))
{
$hash=md5($out);
$test=$GLOBALS['SITE_DB']->query_value_null_ok('validated_once','hash',array('hash'=>$hash));
if (!is_null($test)) return '';
}
require_lang('validation');
require_css('adminzone');
require_code('obfuscate');
require_code('validation');
global $EXTRA_CHECK;
$show=false;
do
{
$error=check_xhtml($out,get_option('validation_xhtml')!='1',$preview_mode!=0,get_option('validation_javascript')=='1',get_option('validation_css')=='1',get_option('validation_wcag')=='1',get_option('validation_compat')=='1',get_option('validation_ext_files')=='1',$display_regardless || ($preview_mode==2));
$show=(count($error['errors'])!=0) || ($display_regardless);
if ((!$show) && (get_option('validation_ext_files')=='1'))
{
$out=array_pop($EXTRA_CHECK);
}
}
while ((!$show) && (!is_null($out)) && (get_option('validation_ext_files')=='1'));
if ($show)
{
return display_validation_results($out,$error,$preview_mode!=0,$ret);
} elseif ($preview_mode==0)
{
$GLOBALS['SITE_DB']->query_insert('validated_once',array('hash'=>$hash),false,true);
}
return '';
}
string display_validation_results(string out, array error, boolean preview_mode, boolean ret)
Show results of running a validation function.
Parameters…
| Name |
out |
| Description |
The data validated |
| Type |
string |
| Name |
error |
| Description |
Error information |
| Type |
array |
| Name |
preview_mode |
| Description |
Whether we are opening up an XHTML-fragment in a preview box |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
ret |
| Description |
Whether to return Tempcode |
| Default value |
boolean-false |
| Type |
boolean |
Returns…
| Description |
Returned result (won't return it $ret is false) |
| Type |
string |
function display_validation_results($out,$error,$preview_mode=false,$ret=false)
{
global $KEEP_MARKERS,$SHOW_EDIT_LINKS;
$KEEP_MARKERS=false;
$SHOW_EDIT_LINKS=false;
global $XHTML_SPIT_OUT;
$XHTML_SPIT_OUT=1;
if (function_exists('set_time_limit')) @set_time_limit(280);
require_css('adminzone');
if (!$ret)
{
$echo=do_header($preview_mode);
$echo->evaluate_echo();
} else
{
ob_start();
}
$title=get_page_title('VALIDATION_ERROR');
// Escape and colourfy
$i=0;
// Output header
if (count($_POST)==0)
{
$messy_url=(get_param_integer('keep_markers',0)==1)?new ocp_tempcode():build_url(array('page'=>'_SELF','special_page_type'=>'code','keep_markers'=>1),'_SELF',NULL,true);
$ignore_url=build_url(array('page'=>'_SELF','keep_novalidate'=>1),'_SELF',NULL,true);
$ignore_url_2=build_url(array('page'=>'_SELF','novalidate'=>1),'_SELF',NULL,true);
} else
{
$messy_url=new ocp_tempcode();
$ignore_url=new ocp_tempcode();
$ignore_url_2=new ocp_tempcode();
}
$error_lines=array();
$return_url=new ocp_tempcode();
if (count($error['errors'])!=0)
{
$errorst=new ocp_tempcode();
foreach ($error['errors'] as $j=>$_error)
{
$errorst->attach(do_template('VALIDATE_ERROR',array('_GUID'=>'2239470f4b9bd38fcb570689cecaedd2','I'=>strval($j),'LINE'=>integer_format($_error['line']),'POS'=>integer_format($_error['pos']),'ERROR'=>$_error['error'])));
$error_lines[$_error['line']]=1;
}
$errors=$errorst->evaluate();
$echo=do_template('VALIDATE_ERROR_SCREEN',array('_GUID'=>'db6c362632471e7c856380d32da91054','MSG'=>do_lang_tempcode('_NEXT_ITEM_BACK'),'RETURN_URL'=>$return_url,'TITLE'=>$title,'IGNORE_URL_2'=>$ignore_url_2,'IGNORE_URL'=>$ignore_url,'MESSY_URL'=>$messy_url,'ERRORS'=>$errorst,'RET'=>$ret));
unset($errorst);
$echo->evaluate_echo();
} else
{
$echo=do_template('VALIDATE_SCREEN',array('_GUID'=>'d8de848803287e4c592418d57450b7db','MSG'=>do_lang_tempcode('_NEXT_ITEM_BACK'),'RETURN_URL'=>$return_url,'TITLE'=>get_page_title('VIEWING_SOURCE'),'MESSY_URL'=>$messy_url,'RET'=>$ret));
$echo->evaluate_echo();
}
$level_ranges=$error['level_ranges'];
$tag_ranges=$error['tag_ranges'];
$value_ranges=$error['value_ranges'];
$current_range=0;
$current_tag=0;
$current_value=0;
$number=1;
$in_at=false;
for ($i=0;$i<strlen($out);++$i)
{
if (isset($level_ranges[$current_range]))
{
$level=$level_ranges[$current_range][0];
$start=$level_ranges[$current_range][1];
if ($start==0) $start=1; // Hack for when error starts before a line, messing up our output
if ($i==$start) // Add in a font tag
{
$x=8;
if ($level%$x==0) $colour='teal';
if ($level%$x==1) $colour='blue';
if ($level%$x==2) $colour='purple';
if ($level%$x==3) $colour='gray';
if ($level%$x==4) $colour='red';
if ($level%$x==5) $colour='maroon';
if ($level%$x==6) $colour='navy';
if ($level%$x==7) $colour='olive';
$previous=($i==0)?'':$out[$i-1];
$string=new ocp_tempcode();
if (($previous==' ') || ($previous==chr(10)) || ($previous==chr(13)))
$string->attach(str_pad('',$level*3*6,' '));
$string->attach(do_template('VALIDATE_TAG_START',array('_GUID'=>'3a4c99283d32006143fc688ce8f2cadc','COLOUR'=>$colour)));
$string->evaluate_echo();
}
}
if (isset($tag_ranges[$current_tag]))
{
$start=$tag_ranges[$current_tag][0];
if ($i==$start) // Add in a strong tag
{
$string=do_template('VALIDATE_TAG_NAME_START');
$string->evaluate_echo();
}
}
if (isset($value_ranges[$current_value]))
{
$start=$value_ranges[$current_value][0];
if ($i==$start) // Add in a em tag
{
$in_at=true;
$string=do_template('VALIDATE_ATTRIBUTE_START');
$string->evaluate_echo();
}
}
$char=$out[$i];
if (($char==chr(10)) || ($i==0))
{
if ($number>1)
{
$escaped_code=do_template('VALIDATE_LINE_END');
$escaped_code->evaluate_echo();
}
if (isset($error_lines[$number]))
{
$markers=new ocp_tempcode();
foreach ($error['errors'] as $j=>$_error)
{
if ($number==$_error['line'])
{
$markers->attach(do_template('VALIDATE_MARKER',array('_GUID'=>'4b1898d5f1e0f56d18a47561659da3bb','I'=>strval($j),'ERROR'=>$_error['error'])));
}
}
$escaped_code=do_template('VALIDATE_LINE_ERROR',array('_GUID'=>'2ffa5c26090d3d814206e3a9e46c7b4e','MARKERS'=>$markers,'NUMBER'=>integer_format($number)));
$escaped_code->evaluate_echo();
} else
{
$escaped_code=do_template('VALIDATE_LINE',array('_GUID'=>'4994f4748c3cd0cbf4e9278ca0e9b1fc','NUMBER'=>integer_format($number)));
$escaped_code->evaluate_echo();
}
++$number;
}
// Marker
$end_markers=new ocp_tempcode();
if (isset($error_lines[$number]))
{
foreach ($error['errors'] as $_error)
{
if ($i==$_error['global_pos'])
{
$_text=do_template('VALIDATE_MARKER_START');
$_text->evaluate_echo();
if ($char==chr(13) || ($char==chr(10)))
{
$__text='!'.do_lang('HERE').'!';
if (function_exists('ocp_mark_as_escaped')) ocp_mark_as_escaped($__text);
echo $__text;
}
$end_markers->attach(do_template('VALIDATE_MARKER_END'));
}
}
}
// Escaping
if ($char=='&') $char='&';
if ($char=='<') $char='<';
if ($char=='>') $char='>';
if ($char=='"') $char='"';
if ($char=='\'') $char=''';
if ((is_null($level_ranges)) && ($char==' ')) $char=' ';
if ((is_null($level_ranges)) && ($char=="\t")) $char=' ';
// if ($char==' ') $char=' ';
if (function_exists('ocp_mark_as_escaped')) ocp_mark_as_escaped($char);
echo $char;
// Marker
$end_markers->evaluate_echo();
if (isset($value_ranges[$current_value]))
{
$end=$value_ranges[$current_value][1];
if ($i==$end-1)
{
if ($in_at)
{
$text=do_template('VALIDATE_ATTRIBUTE_END');
$text->evaluate_echo();
}
$in_at=false;
++$current_value;
}
}
if (isset($level_ranges[$current_range]))
{
$end=$level_ranges[$current_range][2];
if ($i==$end-1)
{
$string=do_template('VALIDATE_TAG_END');
$string->evaluate_echo();
++$current_range;
while ((isset($level_ranges[$current_range])) && ($level_ranges[$current_range][1]<=$i))
{
++$current_range;
}
}
}
if (isset($tag_ranges[$current_tag]))
{
$end=$tag_ranges[$current_tag][1];
if ($i==$end-1)
{
$string=do_template('VALIDATE_TAG_NAME_END');
$string->evaluate_echo();
++$current_tag;
}
}
}
if ($number>1)
{
$escaped_code=do_template('VALIDATE_LINE_END');
$escaped_code->evaluate_echo();
}
$echo=do_template('VALIDATE_SCREEN_END',array('_GUID'=>'739514a06ae65252293fc62b1c7cec40','RET'=>$ret));
$echo->evaluate_echo();
if (!$ret)
{
$echo=do_footer();
$echo->evaluate_echo();
exit();
}
$out=ob_get_contents();
ob_end_clean();
return $out;
}
0 reviews: Unrated (average)
There have been no comments yet