$b)?$a:$b);
}
if (!file_exists($FILE_BASE.'/sources/global.php'))
{
$a=strrpos($FILE_BASE,'/');
$b=strrpos($FILE_BASE,'\\');
$RELATIVE_PATH=substr($FILE_BASE,(($a>$b)?$a:$b)+1);
$FILE_BASE=substr($FILE_BASE,0,($a>$b)?$a:$b);
} else
{
$RELATIVE_PATH='';
}
@chdir($FILE_BASE);
global $NON_PAGE_SCRIPT;
$NON_PAGE_SCRIPT=0;
global $FORCE_INVISIBLE_GUEST;
$FORCE_INVISIBLE_GUEST=0;
if (!file_exists($FILE_BASE.'/sources/global.php')) exit('
Critical startup errorocPortal startup error
The second most basic ocPortal startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the ocPortal system, so please check all files are uploaded correctly.
Once all ocPortal files are in place, ocPortal must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.
ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the ocPortal website. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.
ocPortal is a website engine created by ocProducts.
'); require($FILE_BASE.'/sources/global.php');
// If we're still here, we're ok to go
do_site();
?>
$b)?$a:$b);
}
if (!file_exists($FILE_BASE.'/sources/global.php'))
{
$a=strrpos($FILE_BASE,'/');
$b=strrpos($FILE_BASE,'\\');
$RELATIVE_PATH=substr($FILE_BASE,(($a>$b)?$a:$b)+1);
$FILE_BASE=substr($FILE_BASE,0,($a>$b)?$a:$b);
} else
{
$RELATIVE_PATH='';
}
@chdir($FILE_BASE);
global $NON_PAGE_SCRIPT;
$NON_PAGE_SCRIPT=1;
global $FORCE_INVISIBLE_GUEST;
$FORCE_INVISIBLE_GUEST=0;
if (!file_exists($FILE_BASE.'/sources/global.php')) exit('Critical startup errorocPortal startup error
The second most basic ocPortal startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the ocPortal system, so please check all files are uploaded correctly.
Once all ocPortal files are in place, ocPortal must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.
ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the ocPortal website. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.
ocPortal is a website engine created by ocProducts.
'); require($FILE_BASE.'/sources/global.php');
require_code('themes2');
generate_logo(get_param('name'),get_param('title'),true,get_param('theme'));
?>
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
[title="1"]{!MULTI_SITE_NETWORKING}[/title]
[block="netlink"]main_notes[/block]
This is a guide to using Occle - your interactive ocPortal command-line.
To begin with...[title="1"]Edit quotes[/title]
Place each quote on its own line. These quotes will be shown in the main_quotes block (by default). Please note that this editing page is just a Comcode page set up to edit the 'quotes' file, and the use of 'quotes' with the quotes block is just a default - you may have multiple quote blocks using multiple quote files.
[block="quotes"]main_notes[/block]
[title]Admin Zone[/title]
[block]main_staff_checklist[/block]
[block]main_staff_new_version[/block]
Know someone who needs a website? [page=":recommend:misc:ocp=1"]Recommend ocPortal[/page] and they'll be sent a link to your own site too.
Want to chat about ocPortal or just generally chat to other website administrators?
If so, visit the [url="ocPortal forum"]http://ocportal.com/forum/[/url]. Also, you may want to check out the [url="ocPortal blog"]http://ocportal.com/site/pg/blog[/url].
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
order deny,allow
deny from all
language-code) (NULL: disabled).
*/
function get_entry_points()
{
return array('misc'=>'ADMIN_ZONE','structure'=>'STRUCTURE','usage'=>'USAGE','style'=>'STYLE','setup'=>'SETUP','tools'=>'TOOLS','security'=>'SECURITY_GROUP_SETUP');
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
require_code('templates_interfaces');
require_all_lang();
$type=get_param('type','misc');
switch ($type)
{
case 'misc':
return do_next_manager_hooked('ADMIN_ZONE','DOC_ADMIN_ZONE','');
case 'structure':
return do_next_manager_hooked('STRUCTURE','DOC_STRUCTURE','structure');
case 'usage':
return do_next_manager_hooked('USAGE','DOC_USAGE','usage');
case 'style':
return do_next_manager_hooked('STYLE','DOC_STYLE','style');
case 'setup':
return do_next_manager_hooked('SETUP','DOC_SETUP','setup');
case 'tools':
return do_next_manager_hooked('TOOLS','DOC_TOOLS','tools');
case 'security':
return do_next_manager_hooked('SECURITY','DOC_SECURITY','security');
}
return new ocp_tempcode();
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array('misc'=>'VIEW_ACTION_LOGS');
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
//removed-assert
require_all_lang();
$type=get_param('type','misc');
if ($type=='misc') return $this->choose_moderator();
if ($type=='list') return $this->choose_action();
if ($type=='view') return $this->view_action();
if ($type=='toggle_ip_ban') return $this->toggle_ip_ban();
if ($type=='toggle_submitter_ban') return $this->toggle_submitter_ban();
if ($type=='toggle_member_ban') return $this->toggle_member_ban();
return new ocp_tempcode();
}
/**
* The UI to choose the moderator to view moderation logs of.
*
* @return tempcode The UI
*/
function choose_moderator()
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/actionlog';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_trace';
// Fiddly sorting into our list
$list=array();
if (get_forum_type()=='ocf')
{
$moderators=collapse_1d_complexity('l_by',$GLOBALS['FORUM_DB']->query_select('f_moderator_logs',array('DISTINCT l_by')));
foreach ($moderators as $moderator)
{
$username=$GLOBALS['FORUM_DRIVER']->get_username($moderator);
if (is_null($username)) $username=strval($moderator);
$list[$moderator]=$username;
}
}
$_staff=collapse_1d_complexity('the_user',$GLOBALS['SITE_DB']->query_select('adminlogs',array('DISTINCT the_user')));
foreach ($_staff as $staff)
{
$username=$GLOBALS['FORUM_DRIVER']->get_username($staff);
if (is_null($username)) $username=strval($staff);
if (!array_key_exists($staff,$list)) $list[$staff]=$username;
}
$entries=form_input_list_entry('-1',true,do_lang('ALL'));
asort($list);
foreach ($list as $id=>$username)
{
$entries->attach(form_input_list_entry(strval($id),false,$username));
}
$title=get_page_title('VIEW_ACTION_LOGS');
$post_url=build_url(array('page'=>'_SELF','type'=>'list'),'_SELF');
require_code('form_templates');
$fields=form_input_list(do_lang_tempcode('USERNAME'),'','id',$entries);
$submit_name=do_lang('VIEW_ACTION_LOGS');
breadcrumb_set_self(do_lang('CHOOSE_MODERATOR'));
return do_template('FORM_PAGE',array('_GUID'=>'f2c6eda24e0e973aa7e253054f6683a5','HIDDEN'=>'','TITLE'=>$title,'TEXT'=>'','POST_URL'=>$post_url,'FIELDS'=>$fields,'SUBMIT_NAME'=>$submit_name));
}
/**
* The UI to show a results table of moderation actions for a moderator.
*
* @return tempcode The UI
*/
function choose_action()
{
//removed-assert
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('CHOOSE_MODERATOR'))));
$title=get_page_title('VIEW_ACTION_LOGS');
$test_tpl=internalise_own_page($title);
if (is_object($test_tpl)) return $test_tpl;
$id=either_param_integer('id',-1);
$start=get_param_integer('start',0);
$max=get_param_integer('max',50);
$sortables=array('date_and_time'=>do_lang('DATE_TIME'),'the_type'=>do_lang('ACTION'));
list($sortable,$sort_order)=explode(' ',either_param('sort','date_and_time DESC'));
if ((($sort_order!='ASC') && ($sort_order!='DESC')) || (!array_key_exists($sortable,$sortables)))
log_hack_attack_and_exit('ORDERBY_HACK');
require_code('templates_interfaces');
$fields_title=results_field_title(array(do_lang('USERNAME'),do_lang('DATE_TIME'),do_lang('ACTION'),do_lang('PARAMETER_A'),do_lang('PARAMETER_B'),do_lang('_BANNED')),$sortables);
// Pull up our rows
if (get_forum_type()=='ocf')
{
$where=($id==-1)?NULL:array('l_by'=>$id);
$rows1=$GLOBALS['FORUM_DB']->query_select('f_moderator_logs',array('l_reason','id','l_by AS the_user','l_date_and_time AS date_and_time','l_the_type AS the_type','l_param_a AS param_a','l_param_b AS param_b'),$where);
} else $rows1=array();
$where=($id==-1)?NULL:array('the_user'=>$id);
$rows2=$GLOBALS['SITE_DB']->query_select('adminlogs',array('id','the_user','date_and_time','the_type','param_a','param_b','ip'),$where);
$rows=array_merge($rows1,$rows2);
$fields=new ocp_tempcode();
$pos=0;
while ((count($rows)!=0) && (($pos-$start)<$max))
{
$best=0; // Initialise type to integer
$_best=0; // Initialise type to integer
$best=NULL;
$_best=NULL;
foreach ($rows as $x=>$row)
{
if ((is_null($best))
|| (($row['date_and_time']<$_best) && ($sortable=='date_and_time') && ($sort_order=='ASC'))
|| (($row['date_and_time']>$_best) && ($sortable=='date_and_time') && ($sort_order=='DESC'))
|| (($row['the_type']<$_best) && ($sortable=='the_type') && ($sort_order=='ASC'))
|| (($row['the_type']>$_best) && ($sortable=='the_type') && ($sort_order=='DESC'))
)
{
$best=$x;
if ($sortable=='date_and_time') $_best=$row['date_and_time'];
if ($sortable=='the_type') $_best=$row['the_type'];
}
}
if ($pos>=$start)
{
$_username=$GLOBALS['FORUM_DRIVER']->get_username($rows[$best]['the_user']);
if (is_null($_username))
{
$_username=do_lang('UNKNOWN');
$rows[$best]['the_user']=$GLOBALS['FORUM_DRIVER']->get_guest_id();
}
$username=hyperlink($GLOBALS['FORUM_DRIVER']->member_profile_link($rows[$best]['the_user']),$_username);
$mode=array_key_exists('l_reason',$rows[$best])?'ocf':'ocp';
$url=build_url(array('page'=>'_SELF','type'=>'view','id'=>$rows[$best]['id'],'mode'=>$mode),'_SELF');
$mode_nice=($mode=='ocp')?'ocPortal':'OCF';
$date=hyperlink($url,do_timezoned_date($rows[$best]['date_and_time']),false,false,$mode_nice.'/'.$row['the_type'].'/'.strval($rows[$best]['id']));
if (!is_null($rows[$best]['param_a'])) $a=$rows[$best]['param_a']; else $a='';
if (!is_null($rows[$best]['param_b'])) $b=$rows[$best]['param_b']; else $b='';
$type_str=do_lang($rows[$best]['the_type'],$a,$b,NULL,NULL,false);
if (is_null($type_str)) $type_str=$rows[$best]['the_type'];
$banned_test_1=array_key_exists('ip',$rows[$best])?$GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip','ip',array('ip'=>$rows[$best]['ip'])):NULL;
$banned_test_2=$GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member','the_member',array('the_member'=>$rows[$best]['the_user']));
$banned_test_3=$GLOBALS['FORUM_DRIVER']->is_banned($rows[$best]['the_user']);
$banned=((is_null($banned_test_1)) && (is_null($banned_test_2)) && (!$banned_test_3))?do_lang('NO'):do_lang('YES');
$fields->attach(results_entry(array($username,$date,$type_str,$a,$b,$banned),true));
}
unset($rows[$best]);
$pos++;
}
$table=results_table(do_lang('ACTIONS'),$start,'start',$max,'max',count($rows),$fields_title,$fields,$sortables,$sortable,$sort_order,'sort');
return do_template('ACTION_LOGS_PAGE',array('_GUID'=>'d75c813e372c3ca8d1204609e54c9d65','TABLE'=>$table,'TITLE'=>$title));
}
/**
* The UI to view details of a specific moderation action.
*
* @return tempcode The UI
*/
function view_action()
{
//removed-assert
breadcrumb_set_self(do_lang('ENTRY'));
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('CHOOSE_MODERATOR')),array('_SELF:list',do_lang('VIEW_ACTION_LOGS'))));
$mode=get_param('mode','ocf');
$id=get_param_integer('id');
if ($mode=='ocf')
{
$rows=$GLOBALS['FORUM_DB']->query_select('f_moderator_logs',array('l_reason AS reason','id','l_by AS the_user','l_date_and_time AS date_and_time','l_the_type AS the_type','l_param_a AS param_a','l_param_b AS param_b'),array('id'=>$id),'',1);
} else
{
$rows=$GLOBALS['SITE_DB']->query_select('adminlogs',array('id','the_user','date_and_time','the_type','param_a','param_b','ip'),array('id'=>$id),'',1);
}
if (!array_key_exists(0,$rows)) user_clean_exit(do_lang_tempcode('MISSING_RESOURCE'));
$row=$rows[0];
$title=get_page_title('VIEW_ACTION_LOGS');
$username=$GLOBALS['FORUM_DRIVER']->get_username($row['the_user']);
if (is_null($username)) $username=do_lang('UNKNOWN');
$type_str=do_lang($row['the_type'],$row['param_a'],$row['param_b'],NULL,NULL,false);
if (is_null($type_str)) $type_str=$row['the_type'];
$fields=array(
'USERNAME'=>hyperlink($GLOBALS['FORUM_DRIVER']->member_profile_link($row['the_user']),$username),
'DATE_TIME'=>do_timezoned_date($row['date_and_time']),
'TYPE'=>$type_str,
'PARAMETER_A'=>is_null($row['param_a'])?'':$row['param_a'],
'PARAMETER_B'=>is_null($row['param_b'])?'':$row['param_b']);
if (array_key_exists('ip',$row)) $fields['IP_ADDRESS']=escape_html($row['ip']);
if (array_key_exists('reason',$row)) $fields['REASON']=escape_html($row['reason']);
if (array_key_exists('ip',$row))
{
$banned_test_1=$GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip','ip',array('ip'=>$row['ip']));
$fields['IP_BANNED']=make_string_tempcode(is_null($banned_test_1)?do_lang('NO'):do_lang('YES'));
if ($row['ip']!=get_ip_address())
{
$fields['IP_BANNED']->attach(do_template('ACTION_LOGS_TOGGLE_LINK',array('URL'=>build_url(array('page'=>'_SELF','type'=>'toggle_ip_ban','id'=>$row['ip']),'_SELF'))));
}
}
$banned_test_2=$GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member','the_member',array('the_member'=>$row['the_user']));
$fields['SUBMITTER_BANNED']=make_string_tempcode(is_null($banned_test_2)?do_lang('NO'):do_lang('YES'));
if (($row['the_user']!=$GLOBALS['FORUM_DRIVER']->get_guest_id()) && ($row['the_user']!=get_member()))
{
$fields['SUBMITTER_BANNED']->attach(do_template('ACTION_LOGS_TOGGLE_LINK',array('URL'=>build_url(array('page'=>'_SELF','type'=>'toggle_submitter_ban','id'=>$row['the_user']),'_SELF'))));
}
$banned_test_3=$GLOBALS['FORUM_DRIVER']->is_banned($row['the_user']);
$fields['MEMBER_BANNED']=make_string_tempcode($banned_test_3?do_lang('YES'):do_lang('NO'));
if (((get_forum_type()=='ocf') && ($row['the_user']!=$GLOBALS['FORUM_DRIVER']->get_guest_id())) && ($row['the_user']!=get_member()))
{
$fields['MEMBER_BANNED']->attach(do_template('ACTION_LOGS_TOGGLE_LINK',array('URL'=>build_url(array('page'=>'_SELF','type'=>'toggle_member_ban','id'=>$row['the_user']),'_SELF'))));
}
$fields['INVESTIGATE_USER']=hyperlink(build_url(array('page'=>'admin_lookup','id'=>(array_key_exists('ip',$row))?$row['ip']:$row['the_user']),'_SELF'),do_lang('PROCEED'));
require_code('templates_interfaces');
return view_space($title,$fields);
}
/**
* The UI and actualiser to toggle a member ban. Only works with OCF.
*
* @return tempcode The UI
*/
function toggle_member_ban()
{
$id=get_param_integer('id');
$test=$GLOBALS['FORUM_DRIVER']->is_banned($id);
if (!$test)
{
$title=get_page_title('MEMBER_BANNED');
require_code('ocf_members_action');
ocf_ban_member($id,'');
} else
{
$title=get_page_title('MEMBER_UNBANNED');
require_code('ocf_members_action');
ocf_unban_member($id,'');
}
persistant_cache_delete('IP_BANS');
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'db5343411f1657a2c11337ea8082e5a0','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI and actualiser to toggle a submitter ban.
*
* @return tempcode The UI
*/
function toggle_submitter_ban()
{
$id=get_param_integer('id');
$test=$GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member','the_member',array('the_member'=>$id));
if (is_null($test))
{
$title=get_page_title('IP_BANNED');
$GLOBALS['SITE_DB']->query_insert('usersubmitban_member',array('the_member'=>$id));
log_it('SUBMITTER_BANNED',strval($id));
} else
{
$title=get_page_title('IP_UNBANNED');
$GLOBALS['SITE_DB']->query_delete('usersubmitban_member',array('the_member'=>$id),'',1);
log_it('SUBMITTER_UNBANNED',strval($id));
}
persistant_cache_delete('IP_BANS');
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'a8b34d577e0a1105b679d7b5678b2916','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI and actualiser to toggle an IP ban.
*
* @return tempcode The UI
*/
function toggle_ip_ban()
{
$ip=get_param('id');
$test=$GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip','ip',array('ip'=>$ip));
if (is_null($test))
{
$title=get_page_title('IP_BANNED');
add_ip_ban($ip);
log_it('IP_BANNED',$ip);
} else
{
$title=get_page_title('IP_UNBANNED');
remove_ip_ban($ip);
log_it('IP_UNBANNED',$ip);
}
persistant_cache_delete('IP_BANS');
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'0092b96e7393efe05f1990cee6d97172','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array('misc'=>'ADDONS','modules'=>'MODULE_MANAGEMENT','import'=>'IMPORT_ADDON','addon_install'=>'INSTALL_ADDON','addon_export'=>'EXPORT_ADDON');
}
/**
* Standard modular uninstall function.
*/
function uninstall()
{
//removed-assert
$GLOBALS['SITE_DB']->drop_if_exists('addons');
$GLOBALS['SITE_DB']->drop_if_exists('addons_files');
$GLOBALS['SITE_DB']->drop_if_exists('addons_dependencies');
deldir_contents(get_custom_file_base().'/exports/mods',true);
}
/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from=NULL,$upgrade_from_hack=NULL)
{
$GLOBALS['SITE_DB']->create_table('addons',array(
'addon_name'=>'*SHORT_TEXT',
'addon_author'=>'SHORT_TEXT',
'addon_organisation'=>'SHORT_TEXT',
'addon_version'=>'SHORT_TEXT',
'addon_description'=>'LONG_TEXT',
'addon_install_time'=>'TIME'
));
$GLOBALS['SITE_DB']->create_table('addons_files',array(
'id'=>'*AUTO', // Because two SHORT_TEXT's as keys exceeds the 500 mysql key limit
'addon_name'=>'SHORT_TEXT',
'filename'=>'SHORT_TEXT'
));
$GLOBALS['SITE_DB']->create_table('addons_dependencies',array(
'id'=>'*AUTO', // Because two SHORT_TEXT's as keys exceeds the 500 mysql key limit
'addon_name'=>'SHORT_TEXT',
'addon_name_dependant_upon'=>'SHORT_TEXT',
'addon_name_incompatibility'=>'BINARY' // 0=dependency,1=incompatibility
));
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
//removed-assert
if (get_file_base()!=get_custom_file_base()) user_clean_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
$GLOBALS['HELPER_PANEL_PIC']='pagepics/addons';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_framework';
require_lang('addons');
require_lang('authors');
// Decide what we're doing
$type=get_param('type','misc');
if ($type=='misc') return $this->gui();
if ($type=='addon_export') return $this->addon_export();
if ($type=='_addon_export') return $this->_addon_export();
if ($type=='__addon_export') return $this->__addon_export();
if ($type=='addon_import') return $this->addon_import();
if ($type=='_addon_import') return $this->_addon_import();
if ($type=='addon_install') return $this->addon_install();
if ($type=='_addon_install') return $this->_addon_install();
if ($type=='addon_uninstall') return $this->addon_uninstall();
if ($type=='_addon_uninstall') return $this->_addon_uninstall();
if ($type=='reinstall') return $this->reinstall_module();
if ($type=='uninstall') return $this->uninstall_module();
if ($type=='upgrade') return $this->upgrade_module();
if ($type=='modules') return $this->modules_interface();
if ($type=='view') return $this->modules_view();
return new ocp_tempcode();
}
/**
* The main UI.
*
* @return tempcode The UI
*/
function gui()
{
$title=get_page_title('ADDONS');
$tpl_addons=new ocp_tempcode();
require_code('templates_interfaces');
$dh=opendir(get_custom_file_base().'/imports/mods/');
$addons=array();
while (($file=readdir($dh))!==false)
{
if (substr($file,-4)=='.tar')
{
$full=get_custom_file_base().'/imports/mods/'.$file;
require_code('tar');
$tar=tar_open($full,'rb');
$info_file=tar_get_file($tar,'mod.inf');
if (!is_null($info_file))
{
$info=better_parse_ini_file(NULL,$info_file['data']);
tar_close($tar);
$addons[$file]=$info;
}
}
}
closedir($dh);
$_rows=$GLOBALS['SITE_DB']->query_select('addons',array('*'));
$rows=array();
foreach ($_rows as $row)
{
$rows[$row['addon_name']]=$row;
}
foreach ($addons as $filename=>$addon)
{
$actions=new ocp_tempcode();
$status='';
if (array_key_exists($addon['name'],$rows))
{
$actions->attach(do_template('TABLE_TABLE_ACTION_DELETE_ENTRY',array('_GUID'=>'5e1e6145e7a4139c73abe57445b6277d','URL'=>build_url(array('page'=>'_SELF','type'=>'addon_uninstall','name'=>$addon['name']),'_SELF'))));
$status=do_lang('STATUS_INSTALLED');
unset($rows[$addon['name']]);
} else
{
$actions->attach(do_template('TABLE_TABLE_ACTION_INSTALL_ENTRY',array('_GUID'=>'e6e2bdac62c0d3afcd5251b3d525a1c9','URL'=>build_url(array('page'=>'_SELF','type'=>'addon_install','file'=>$filename),'_SELF'))));
}
$tpl_addons->attach(do_template('ADDON_PAGE_ADDON',array('_GUID'=>'cb61bdb9ce0cef5cd520440c5f62008f','STATUS'=>$status,'NAME'=>$addon['name'],'FILENAME'=>$filename,'AUTHOR'=>$addon['author'],'ORGANISATION'=>$addon['organisation'],'VERSION'=>$addon['version'],'ACTIONS'=>$actions)));
}
foreach ($rows as $row)
{
$actions=do_template('TABLE_TABLE_ACTION_DELETE_ENTRY',array('URL'=>build_url(array('page'=>'_SELF','type'=>'addon_uninstall','name'=>$addon['name']),'_SELF')));
$status=do_lang('STATUS_INSTALLED');
$tpl_addons->attach(do_template('ADDON_PAGE_ADDON',array('_GUID'=>'9a06f5a9c9e3085c10ab7fb17c3efcd1','STATUS'=>$status,'NAME'=>$row['addon_name'],'FILENAME'=>do_lang('NA'),'AUTHOR'=>$addon['addon_author'],'ORGANISATION'=>$row['addon_organisation'],'VERSION'=>$row['addon_version'],'ACTIONS'=>$actions)));
}
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('MENU'))));
return do_template('ADDON_PAGE',array('_GUID'=>'ed6c80c29fcae333323ef03619954b6b','TITLE'=>$title,'ADDONS'=>$tpl_addons));
}
/**
* The UI to get an addon from some source.
*
* @return tempcode The UI
*/
function addon_import()
{
//removed-assert
$title=get_page_title('IMPORT_ADDON');
require_code('form_templates');
$required=/*false;//*/true;
$javascript=/*'';//*/'standardAlternateFields(\'file\',\'url\');';
$fields=new ocp_tempcode();
$fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'),do_lang_tempcode('DESCRIPTION_UPLOAD'),'file',$required));
$fields->attach(form_input_tree_list(do_lang_tempcode('DOWNLOAD'),do_lang_tempcode('DESCRIPTION_DOWNLOAD_OCPORTALCOM'),'url',NULL,'choose_ocportalcom_addon',array(),$required));
$submit_name=do_lang('IMPORT_ADDON');
$post_url=build_url(array('page'=>'_SELF','type'=>'_addon_import','uploading'=>1),'_SELF');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS'))));
return do_template('FORM_PAGE',array('_GUID'=>'7f50130c5a46e0f6e8a95e936ce7bf47','HIDDEN'=>'','TITLE'=>$title,'SUBMIT_NAME'=>$submit_name,'FIELDS'=>$fields,'TEXT'=>'','POST_URL'=>$post_url,'JAVASCRIPT'=>$javascript));
}
/**
* The UI to retrieve a specified addon.
*
* @return tempcode The UI
*/
function _addon_import()
{
$title=get_page_title('IMPORT_ADDON');
require_code('uploads');
$url=post_param('url','');
// if ($url=='')
// {
$urls=get_url('url','file','imports/mods',0,0,false,'','',true);
// }
// else
// {
// $urls=array($url);
// }
$full=get_custom_file_base().'/'.$urls[0];
if (strtolower(substr($full,-4))!='.tar')
{
return mistake_page(get_page_title('ERROR_OCCURED'),do_lang_tempcode('ADDON_NOT_TAR'));
}
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'b96ad898072ec89cb319157b502f7bbf','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI to confirm the install of an addon.
*
* @return tempcode The UI
*/
function addon_install()
{
//removed-assert
$title=get_page_title('INSTALL_ADDON');
$file=get_param('file');
$full=get_custom_file_base().'/imports/mods/'.$file;
// Look in the tar
require_code('tar');
$tar=tar_open($full,'rb');
$directory=tar_get_directory($tar);
$info_file=tar_get_file($tar,'mod.inf');
if (is_null($info_file)) user_clean_exit(do_lang_tempcode('NOT_ADDON'));
$info=better_parse_ini_file(NULL,$info_file['data']);
$addon=$info['name'];
tar_close($tar);
$php=false;
$overwrite='';
$dirs=array();
$files=new ocp_tempcode();
foreach ($directory as $entry)
{
if ($entry['path']=='mod.inf') continue;
if ($entry['path']=='mod.php') continue;
// .php?
if (strtolower(substr($entry['path'],-4,4))=='.php')
{
$php=true;
$this_php=true;
} $this_php=false;
// chmod?
$pos=strrpos($entry['path'],'/');
if ($pos!==false) $dirs[substr($entry['path'],0,$pos)]=1; else $dirs['']=1;
// overwrite?
if (file_exists(get_file_base().'/'.$entry['path']))
{
if ($overwrite!='') $overwrite.=', ';
$overwrite.=/*do_lang('ROOT').'/'.*/(($entry['path']{0}=='/')?substr($entry['path'],1):$entry['path']);
$this_overwrite=true;
} else $this_overwrite=false;
// Template
if ($this_overwrite)
{
$files->attach(do_template('ADDON_INSTALL_FILES_WARNING',array('_GUID'=>'c62168dee316d8f73d20a0d70d41b1a4','PATH'=>$entry['path'],'ABOUT'=>do_lang('ADDON_FILE_WILL_OVERWRITE'))));
}
elseif ($this_php)
{
$files->attach(do_template('ADDON_INSTALL_FILES_WARNING',array('_GUID'=>'c0cf99f96262296df4afe2387f4cd3e8','PATH'=>$entry['path'],'ABOUT'=>do_lang('ADDON_FILE_IS_PHP'))));
}
else $files->attach(do_template('ADDON_INSTALL_FILES',array('_GUID'=>'74edcf396387c842cab5cfd0ab74b8f6','PATH'=>$entry['path'],'ABOUT'=>do_lang('ADDON_FILE_NORMAL'))));
}
$chmod='';
$root_chmod=false;
foreach (array_keys($dirs) as $dir)
{
if ((is_writable(get_file_base().'/'.$dir)) && (file_exists(get_file_base().'/'.$dir)))
{
if ($dir=='')
{
$root_chmod=true;
continue;
}
if ($chmod!='') $chmod.=', ';
$chmod.=do_lang('ROOT').(($dir{0}!='/')?'/':'').$dir;
}
elseif ((substr_count($dir,'/')==1) && (!file_exists(get_file_base().'/'.$dir)))
{
$root_chmod=true;
}
}
if ($root_chmod)
{
if ($chmod!='') $chmod.=', ';
$chmod.=do_lang('ROOT');
}
$warnings=new ocp_tempcode();
$warnings->attach(do_template('ADDON_INSTALL_WARNING',array('_GUID'=>'dd66b2c540908de60753a1ced73b8ac0','WARNING'=>do_lang_tempcode('ADDON_WARNING_GENERAL'))));
$incompatibilities=collapse_1d_complexity('addon_name',$GLOBALS['SITE_DB']->query_select('addons_dependencies',array('addon_name'),array('addon_name_dependant_upon'=>$addon,'addon_name_incompatibility'=>1)));
if (count($incompatibilities)!=0) $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('WARNING'=>do_lang_tempcode('ADDON_WARNING_INCOMPATIBILITIES',escape_html(implode(', ',$incompatibilities))))));
$_dependencies=explode(',',array_key_exists('dependencies',$info)?$info['dependencies']:'');
$dependencies=array();
foreach ($_dependencies as $dependency)
{
if ($dependency=='') continue;
$test=$GLOBALS['SITE_DB']->query_value_null_ok('addons','addon_name',array('addon_name'=>$addon));
if (is_null($test)) $dependencies[]=$dependency;
}
if (count($dependencies)!=0) $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('WARNING'=>do_lang_tempcode('ADDON_WARNING_MISSING_DEPENDENCIES',escape_html(implode(', ',$dependencies))))));
if ($overwrite!='') $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('_GUID'=>'fe40ed8192a452a835be4c0fde64406b','WARNING'=>do_lang_tempcode('ADDON_WARNING_OVERWRITE',escape_html($overwrite)))));
if ($php) $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('_GUID'=>'8cf249a119d10b2e97fc94cb9981dcea','WARNING'=>do_lang_tempcode('ADDON_WARNING_PHP'))));
// if ($chmod!='') $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('_GUID'=>'78121e40b9a26c2f33d09f7eee7b74be','WARNING'=>do_lang_tempcode('ADDON_WARNING_CHMOD',escape_html($chmod))))); // Now uses AFM
$url=build_url(array('page'=>'_SELF','type'=>'_addon_install','file'=>$file),'_SELF');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS'))));
return do_template('ADDON_INSTALL_CONFIRM_PAGE',array('_GUID'=>'79b8c0e900a498cfb166392163295a07','TITLE'=>$title,'URL'=>$url,'FILES'=>$files,'WARNINGS'=>$warnings,'NAME'=>$info['name'],'AUTHOR'=>$info['author'],'ORGANISATION'=>$info['organisation'],'VERSION'=>$info['version'],'DESCRIPTION'=>str_replace('\n','
',escape_html($info['description']))));
}
/**
* The UI and actualiser to install an addon.
*
* @return tempcode The UI
*/
function _addon_install()
{
//removed-assert
$title=get_page_title('INSTALL_ADDON');
require_code('abstract_file_manager');
force_have_afm_details();
$file=filter_naughty(get_param('file'));
$full=get_custom_file_base().'/imports/mods/'.$file;
require_code('tar');
$tar=tar_open($full,'rb');
$info_file=tar_get_file($tar,'mod.inf');
if (is_null($info_file)) user_clean_exit(do_lang_tempcode('NOT_ADDON'));
$info=better_parse_ini_file(NULL,$info_file['data']);
$directory=tar_get_directory($tar);
tar_extract_to_folder($tar,'',true);
$addon=$info['name'];
$author=$info['author'];
$organisation=$info['organisation'];
$version=$info['version'];
$dependencies=explode(',',array_key_exists('dependencies',$info)?$info['dependencies']:'');
$incompatibilities=explode(',',array_key_exists('incompatibilities',$info)?$info['incompatibilities']:'');
$description=$info['description'];
$GLOBALS['SITE_DB']->query_delete('addons',array('addon_name'=>$addon),'',1);
$GLOBALS['SITE_DB']->query_insert('addons',array(
'addon_name'=>$addon,
'addon_author'=>$author,
'addon_organisation'=>$organisation,
'addon_version'=>$version,
'addon_description'=>$description,
'addon_install_time'=>time()
));
foreach ($dependencies as $dependency)
{
$GLOBALS['SITE_DB']->query_insert('addons_dependencies',array(
'addon_name'=>$addon,
'addon_name_dependant_upon'=>trim($dependency),
'addon_name_incompatibility'=>0
));
}
foreach ($incompatibilities as $dependency)
{
$GLOBALS['SITE_DB']->query_insert('addons_dependencies',array(
'addon_name'=>$addon,
'addon_name_dependant_upon'=>trim($dependency),
'addon_name_incompatibility'=>1
));
}
foreach ($directory as $dir)
{
$dir=$dir['path'];
$GLOBALS['SITE_DB']->query_insert('addons_files',array(
'addon_name'=>$addon,
'filename'=>$dir
));
}
/* // Install new img files
foreach ($directory as $dir)
{
$dir=$dir['path'];
if (preg_match('#themes/(\w*)/([images|images_custom])/(.*)\.[png|gif|jpg|jpeg]#',$dir,$matches)!=0)
{
$theme=$matches[1];
$type=$matches[2];
$code=$matches[3];
// Now we update all themes to point to this file if they don't already have one that doesn't point into 'default'
$themes=find_all_themes();
$url=get_base_url().'/themes/'.urlencode($theme).'/'.$type.'/'.urlencode($code);
foreach (array_keys($themes) as $t_theme)
{
$test=$GLOBALS['SITE_DB']->query_value('theme_images','path',array('id'=>$code,'theme'=>$t_theme));
if ((is_null($test)) || ((strpos($test.'themes/default/images')===true) && ($theme!='default')))
{
$GLOBALS['SITE_DB']->query_delete('theme_images',array('id'=>$code,'theme'=>$t_theme),NULL,1);
$GLOBALS['SITE_DB']->query_insert('theme_images',array('id'=>$code,'theme'=>$t_theme,'path'=>$url));
}
}
}
}*/
// Install new zones
$zones=array('');
foreach ($directory as $dir)
{
$dir=$dir['path'];
$matches=array();
if (preg_match('#(\w*)/index.php#',$dir,$matches)!=0)
{
$zone=$matches[1];
$test=$GLOBALS['SITE_DB']->query_value_null_ok('zones','zone_name',array('zone_name'=>$zone));
if (is_null($test))
{
$GLOBALS['SITE_DB']->query_insert('zones',array('zone_name'=>$zone,'zone_title'=>insert_lang($zone,1),'zone_default_page'=>'start','zone_header_text'=>insert_lang('ocPortal-?',2),'zone_theme'=>'default','zone_wide'=>0,'zone_require_session'=>0));
}
$zones[]=$zone;
}
}
// Install new modules
foreach ($zones as $zone)
{
$prefix=($zone=='')?'':($zone.'/');
foreach ($directory as $dir)
{
$dir=$dir['path'];
if (preg_match('#'.$prefix.'(\w*)/([modules|modules_custom])/(.*)\.php#',$dir,$matches)!=0)
{
reinstall_module($zone,$matches[1]);
}
}
}
// Install new languages
decache('side_language');
// Load mod.php if it exists
$_modphp_file=tar_get_file($tar,'mod.php');
if (!is_null($_modphp_file))
{
$modphp_file=trim($_modphp_file['data']);
if (substr($modphp_file,0,5)=='') $modphp_file=substr($modphp_file,0,strlen($modphp_file)-2);
eval($modphp_file);
}
tar_close($tar);
log_it('INSTALL_ADDON',$addon);
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'e06d42c2db5b3d41f55d6465b2cf0a67','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI to uninstall an addon.
*
* @return tempcode The UI
*/
function addon_uninstall()
{
$title=get_page_title('UNINSTALL_ADDON');
$name=get_param('name');
$rows=$GLOBALS['SITE_DB']->query_select('addons_files',array('*'),array('addon_name'=>$name));
$files=blank_tempcode();
foreach ($rows as $row)
{
$files->attach(do_template('ADDON_INSTALL_FILES',array('PATH'=>$row['filename'])));
}
$dependencies=collapse_1d_complexity('addon_name',$GLOBALS['SITE_DB']->query_select('addons_dependencies',array('addon_name'),array('addon_name_dependant_upon'=>$name,'addon_name_incompatibility'=>0)));
$warnings=blank_tempcode();
if (count($dependencies)!=0) $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('WARNING'=>do_lang('ADDON_WARNING_MISSING_DEPENDENCIES',implode(', ',$dependencies)))));
$url=build_url(array('page'=>'_SELF','type'=>'_addon_uninstall','name'=>$name),'_SELF');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS'))));
return do_template('ADDON_UNINSTALL_CONFIRM_PAGE',array('_GUID'=>'fe96098c1f09d091fc10785134803135','TITLE'=>$title,'URL'=>$url,'WARNINGS'=>$warnings,'FILES'=>$files));
}
/**
* The UI to uninstall an addon.
*
* @return tempcode The UI
*/
function _addon_uninstall()
{
$title=get_page_title('UNINSTALL_ADDON');
require_code('abstract_file_manager');
force_have_afm_details();
$name=get_param('name');
$rows=$GLOBALS['SITE_DB']->query_select('addons_files',array('*'),array('addon_name'=>$name));
foreach ($rows as $row)
{
$test=$GLOBALS['SITE_DB']->query_value('addons_files','COUNT(*)',array('filename'=>$row['filename']));
if ($test==1)
{
$matches=array();
if (preg_match('#([^/]*)/?pages/modules(_custom)?/(.*)\.php#',$row['filename'],$matches)!=0)
uninstall_module($matches[1],$matches[3]);
if (preg_match('#sources(_custom)?/blocks/(.*)\.php#',$row['filename'],$matches)!=0)
uninstall_block($matches[2]);
if (($row['filename']!='mod.inf') && ($row['filename']!='mod.php') && ($row['filename']!=''))
{
afm_delete_file($row['filename']);
}
}
}
$GLOBALS['SITE_DB']->query_delete('addons_files',array('addon_name'=>$name));
$GLOBALS['SITE_DB']->query_delete('addons',array('addon_name'=>$name),'',1);
log_it('UNINSTALL_ADDON',$name);
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'247f407875788f264f0da49751174eba','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI to export an addon (1).
*
* @return tempcode The UI
*/
function addon_export()
{
//removed-assert
$title=get_page_title('EXPORT_ADDON');
// Lang packs
$url=build_url(array('page'=>'_SELF','type'=>'_addon_export','exp'=>'lang'),'_SELF');
$all_langs=find_all_langs();
ksort($all_langs);
$i=0;
$tpl_languages=new ocp_tempcode();
foreach ($all_langs as $lang=>$dir)
{
if ($dir=='lang_custom')
{
$files=$this->do_dir($dir.'/'.$lang);
$frm_langs=new ocp_tempcode();
foreach (array_keys($files) as $file)
{
$frm_langs->attach(form_input_hidden('file_'.strval($i),$file));
$i++;
}
$tpl_languages->attach(do_template('ADDON_EXPORT_LINE',array('_GUID'=>'4e2f56799bdb3c4930396315236e2383','NAME'=>$lang,'URL'=>$url,'FILES'=>$frm_langs)));
}
}
if ($tpl_languages->is_blank()) $tpl_languages=make_string_tempcode(do_lang('NONE'));
// Theme packs
$url=build_url(array('page'=>'_SELF','type'=>'_addon_export','exp'=>'theme'),'_SELF');
$all_themes=find_all_themes();
ksort($all_themes);
$i=0;
$tpl_themes=new ocp_tempcode();
foreach ($all_themes as $theme=>$theme_title)
{
if ($theme!='default')
{
$files=$this->do_dir('themes/'.$theme);
$frm_themes=new ocp_tempcode();
foreach (array_keys($files) as $file)
{
$frm_themes->attach(form_input_hidden('file_'.strval($i),$file));
$i++;
}
$tpl_themes->attach(do_template('ADDON_EXPORT_LINE',array('_GUID'=>'9c1dab6d6e6c13b5e01c86c83c3acde1','NAME'=>$theme_title,'URL'=>$url,'FILES'=>$frm_themes)));
}
}
if ($tpl_themes->is_blank()) $tpl_themes=make_string_tempcode(do_lang('NONE'));
// Files for choice export
$url=build_url(array('page'=>'_SELF','type'=>'_addon_export','exp'=>'custom'),'_SELF');
$files=$this->do_dir('');
ksort($files);
$frm_files=new ocp_tempcode();
$i=0;
foreach (array_keys($files) as $file)
{
$frm_files->attach(do_template('ADDON_EXPORT_FILE_CHOICE',array('_GUID'=>'77a91b947259c5e0cc7b5240b24425ca','ID'=>strval($i),'PATH'=>$file)));
$i++;
}
$tpl_files=do_template('ADDON_EXPORT_LINE_CHOICE',array('_GUID'=>'525b161afe5d84268360e960da5e759f','URL'=>$url,'FILES'=>$frm_files));
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS'))));
return do_template('ADDON_EXPORT_PAGE',array('_GUID'=>'d89367c0bbc3d6b8bd19f736d9474dfa','TITLE'=>$title,'LANGUAGES'=>$tpl_languages,'FILES'=>$tpl_files,'THEMES'=>$tpl_themes));
}
/**
* (Recursively) find all files we can choose to export.
*
* @param PATH The directory to search
* @return array A map, path=>1 (inverted list)
*/
function do_dir($dir)
{
//removed-assert
$full=get_file_base().'/'.(($dir=='')?'':($dir.'/'));
$temp=array();
$_dir=@opendir($full);
if ($_dir!==false)
{
while (false!==($file=readdir($_dir)))
{
if (($file!='.') && ($dir.'/'.$file!='/themes/default/css') && ($dir.'/'.$file!='/data/areaedit') && ($file!='..') && ($file!='.svn') && (((substr($file,-4)!='.css') && (substr($file,-3)!='.js')) || (strpos($dir,'/templates_cached/')===false)) && ((($file!='index.html') && ($file!='.htaccess') && ($file!='templates_cached')) || (substr($dir,0,7)=='themes/')) && (substr($file,-9)!='.editfrom') && (substr($file,-4)!='.tcd') && ($file!='CVS') && (substr($file,0,5)!='_vti_') && ($file!='lang_cached') && ($file!='uploads') && (!(($file=='info.php') && ($dir==''))))
{
$temp[$file]=1;
}
}
closedir($_dir);
}
$out=array();
foreach (array_keys($temp) as $file)
{
if (is_dir($full.$file)) // If there is a custom equiv we don't do it: we only do custom, or indeterminate-custom
{
if ((!array_key_exists($file.'_custom',$temp)) || (substr($dir,0,7)=='themes/'))
{
$under=$this->do_dir($dir.'/'.$file);
if ((count($under)!=1) || (!array_key_exists((($dir=='')?'':($dir.'/')).$file.'/index.html',$under)) || (substr($dir,0,7)=='themes/'))
$out=array_merge($out,$under);
}
} else $out[$dir.'/'.$file]=1;
}
return $out;
}
/**
* The UI to export an addon (2).
*
* @return tempcode The UI
*/
function _addon_export()
{
//removed-assert
$hidden=build_keep_post_fields();
$theme=get_param('theme',NULL);
if (get_param('exp','custom')=='theme')
{
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_releasing_themes';
if (!is_null($theme))
{
$files=$this->do_dir('themes/'.$theme);
$i=0;
foreach (array_keys($files) as $file)
{
$hidden->attach(form_input_hidden('file_'.strval($i),$file));
$i++;
}
}
}
$title=get_page_title('EXPORT_ADDON');
$fields=new ocp_tempcode();
require_code('form_templates');
$fields->attach(form_input_line(do_lang_tempcode('NAME'),do_lang_tempcode('DESCRIPTION_NAME'),'name','',true));
$fields->attach(form_input_line(do_lang_tempcode('AUTHOR'),do_lang_tempcode('DESCRIPTION_AUTHOR'),'author',$GLOBALS['FORUM_DRIVER']->get_username(get_member()),true));
$fields->attach(form_input_line(do_lang_tempcode('ORGANISATION'),do_lang_tempcode('DESCRIPTION_ORGANISATION'),'organisation',get_site_name(),false));
$fields->attach(form_input_line(do_lang_tempcode('_VERSION'),do_lang_tempcode('DESCRIPTION_VERSION'),'version','1.0',true));
$fields->attach(form_input_text(do_lang_tempcode('DESCRIPTION'),do_lang_tempcode('DESCRIPTION_DESCRIPTION'),'description','',true));
$fields->attach(form_input_line(do_lang_tempcode('DEPENDENCIES'),do_lang_tempcode('DESCRIPTION_DEPENDENCIES'),'dependencies','',false));
$fields->attach(form_input_line(do_lang_tempcode('INCOMPATIBILITIES'),do_lang_tempcode('DESCRIPTION_INCOMPATIBILITIES'),'incompatibilities','',false));
$submit_name=do_lang('EXPORT_ADDON');
$map=array('page'=>'_SELF','type'=>'__addon_export');
if (!is_null($theme))
{
$redir_url=build_url(array('page'=>'admin_themes','type'=>'themes'),'adminzone');
if (is_object($redir_url)) $redir_url=$redir_url->evaluate();
$map['redir_url']=$redir_url;
}
$post_url=build_url($map,'_SELF');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS')),array('_SELF:_SELF:misc',do_lang('EXPORT_ADDON'))));
breadcrumb_set_self(do_lang('CONFIRM'));
return do_template('FORM_PAGE',array('_GUID'=>'dd8bea111b0dfc7df7ddc7e2246f0ef9','HIDDEN'=>$hidden,'TITLE'=>$title,'SUBMIT_NAME'=>$submit_name,'FIELDS'=>$fields,'TEXT'=>'','POST_URL'=>$post_url));
}
/**
* The UI and actualiser to export an addon.
*
* @return tempcode The UI
*/
function __addon_export()
{
//removed-assert
$title=get_page_title('EXPORT_ADDON');
require_code('tar');
$file='file_'.strval(time()).'.tar';
$_full=get_custom_file_base().'/exports/mods/'.$file;
$tar=tar_open($_full,'wb');
foreach ($_POST as $key=>$val)
{
if (!is_string($val)) continue;
if (get_magic_quotes_gpc()) $val=stripslashes($val);
if (substr($key,0,5)=='file_')
{
$full=get_file_base().'/'.filter_naughty($val);
$data=file_get_contents($full);
$mode=fileperms($full);
$mtime=filemtime($full);
tar_add_file($tar,$val,$data,$mode,$mtime);
// If it's a theme, make a mod.php for the theme to restore images_custom mappings
if ((substr($val,0,7)=='themes/') && (substr($val,-10)=='/theme.ini'))
{
$theme=substr($val,7,strpos($val,'/theme.ini'));
$images=$GLOBALS['SITE_DB']->query_select('theme_images',array('*'),array('theme'=>$theme));
$data='query_insert(\'theme_images\',array(\'id\'=>\''.db_escape_string($image['id']).'\',\'theme\'=>\''.db_escape_string($image['theme']).'\',\'path\'=>\''.db_escape_string($image['path']).'\',\'lang\'=>\''.db_escape_string($image['lang']).'\'),false,true);'."\n";
}
$data.="?>\n";
tar_add_file($tar,'mod.php',$data,0444,time());
}
$full=get_file_base().'/'.filter_naughty($val).'.editfrom';
if (file_exists($full))
{
$data=file_get_contents($full,FILE_TEXT);
$mode=fileperms($full);
$mtime=filemtime($full);
tar_add_file($tar,$val,$data,$mode,$mtime);
}
}
}
// Our special file
$name=str_replace('"','\'',post_param('name'));
$incompatibilities=str_replace('"','\'',post_param('incompatibilities'));
$dependencies=str_replace('"','\'',post_param('dependencies'));
$author=str_replace('"','\'',post_param('author'));
$organisation=str_replace('"','\'',post_param('organisation'));
$version=str_replace('"','\'',post_param('version'));
$description=str_replace(chr(13),'',str_replace(chr(10),'\n',str_replace('"','\'',post_param('description'))));
$mod_inf=<<'_SELF','type'=>'misc'),'_SELF');
if (is_object($url)) $url=$url->evaluate();
$url=get_param('redir_url',$url);
assign_refresh($url,1.0,true);
return do_template('REDIRECT_PAGE',array('_GUID'=>'b24761a85056bb4370201dcd78584d75','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang_tempcode('ADDON_CREATED',escape_html($download_url))));
}
/**
* The UI to choose a zone (or blocks) to manage.
*
* @return tempcode The UI
*/
function modules_interface()
{
//removed-assert
$title=get_page_title('MODULE_MANAGEMENT');
require_code('form_templates');
$list=nice_get_zones();
$list->attach(form_input_list_entry('_block',false,do_lang('BLOCKS')));
$post_url=build_url(array('page'=>'_SELF','type'=>'view'),'_SELF');
$fields=form_input_list(do_lang_tempcode('ZONE_OR_BLOCKS'),'','id',$list);
$submit_name=do_lang('PROCEED');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS'))));
breadcrumb_set_self(do_lang('CHOOSE'));
return do_template('FORM_PAGE',array('_GUID'=>'43cc3d9031a3094b62e78461eb99fb5d','HIDDEN'=>'','TITLE'=>$title,'TEXT'=>'','FIELDS'=>$fields,'POST_URL'=>$post_url,'SUBMIT_NAME'=>$submit_name));
}
/**
* The UI to manage the modules (or blocks).
*
* @return tempcode The UI
*/
function modules_view()
{
//removed-assert
$title=get_page_title('MODULE_MANAGEMENT');
$zone=either_param('id');
$tpl_modules=new ocp_tempcode();
require_code('templates_interfaces');
if ($zone=='_block') $modules=find_all_blocks(); else $modules=find_all_modules($zone);
ksort($modules);
foreach ($modules as $module=>$type)
{
if ($zone!='_block')
{
$module_path=($zone=='')?('pages/'.$type.'/'.filter_naughty_harsh($module).'.php'):($zone.'/pages/'.$type.'/'.filter_naughty_harsh($module).'.php');
$prefix='module';
$rows=$GLOBALS['SITE_DB']->query_select('modules',array('*'),array('module_the_name'=>$module),'',1);
} else
{
$module_path=$type.'/blocks/'.filter_naughty_harsh($module).'.php';
$prefix='block';
$rows=$GLOBALS['SITE_DB']->query_select('blocks',array('*'),array('block_name'=>$module),'',1);
}
$info=extract_module_info(get_file_base().'/'.$module_path);
if (is_null($info)) continue;
if (get_param_integer('keep_module_dangerous',0)==1) $info['locked']=false;
$author=$info['author'];
$organisation=$info['organisation'];
$version=$info['version'];
$hacked_by=$info['hacked_by'];
$hack_version=$info['hack_version'];
$actions=new ocp_tempcode();
$status='';
if (array_key_exists(0,$rows))
{
$row=$rows[0];
if (!$info['locked']) $actions->attach(do_template('TABLE_TABLE_ACTION_DELETE_ENTRY',array('_GUID'=>'331afd26f5e62a6a4cdc4e2c520a4114','URL'=>build_url(array('page'=>'_SELF','type'=>'uninstall','zone'=>$zone,'module'=>$module),'_SELF'))));
if ($row[$prefix.'_version']<$version)
{
$status=do_lang('STATUS_TO_UPGRADE');
$actions->attach(do_template('TABLE_TABLE_ACTION_UPGRADE_ENTRY',array('_GUID'=>'e5d012cb8c839e0e869f1edfa008dacd','URL'=>build_url(array('page'=>'_SELF','type'=>'upgrade','zone'=>$zone,'module'=>$module),'_SELF'))));
}
elseif ((!is_null($hack_version)) && ($row[$prefix.'_hack_version']<$hack_version))
{
$status=do_lang('STATUS_TO_HACK');
$actions->attach(do_template('TABLE_TABLE_ACTION_UPGRADE_ENTRY',array('_GUID'=>'42c4473bf31dfd329e921e443ccc2ec3','URL'=>build_url(array('page'=>'_SELF','type'=>'upgrade','zone'=>$zone,'module'=>$module),'_SELF'))));
} else
{
$status=do_lang('STATUS_CURRENT');
}
if (!$info['locked'])
{
$actions->attach(do_template('TABLE_TABLE_ACTION_REINSTALL_ENTRY',array('_GUID'=>'c2d820af4b9a2f8633f6f5a4e3de76bc','URL'=>build_url(array('page'=>'_SELF','type'=>'reinstall','zone'=>$zone,'module'=>$module),'_SELF'))));
}
}
else
{
$actions->attach(do_template('TABLE_TABLE_ACTION_INSTALL_ENTRY',array('_GUID'=>'6b438e07cfe154afc21439479fd76978','URL'=>build_url(array('page'=>'_SELF','type'=>'reinstall','zone'=>$zone,'module'=>$module),'_SELF'))));
}
if (is_null($hacked_by)) $hacked_by='N/A';
if (is_null($hack_version)) $hack_version='N/A';
$tpl_modules->attach(do_template('MODULE_PAGE_MODULE',array('_GUID'=>'cf19adfd129c44a7ef1d6789002c6535','STATUS'=>$status,'NAME'=>$module,'AUTHOR'=>$author,'ORGANISATION'=>$organisation,'VERSION'=>strval($version),'HACKED_BY'=>$hacked_by,'HACK_VERSION'=>strval($hack_version),'ACTIONS'=>$actions)));
}
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('ADDONS')),array('_SELF:_SELF:modules',do_lang('CHOOSE'))));
return do_template('MODULE_PAGE',array('_GUID'=>'132b23107b49a23e0b11db862de1dd56','TITLE'=>$title,'MODULES'=>$tpl_modules));
}
/**
* The UI and actualiser to upgrade a module.
*
* @return tempcode The UI
*/
function upgrade_module()
{
//removed-assert
$module=get_param('module');
$zone=get_param('zone');
if ($zone!='_block')
upgrade_module($zone,$module);
else upgrade_block($module);
$title=get_page_title('UPGRADE_MODULE');
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'view','id'=>$zone),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'3c3291fec1b7dc3636a43386ace824f7','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI and actualiser to uninstall a module.
*
* @return tempcode The UI
*/
function uninstall_module()
{
//removed-assert
$module=get_param('module');
$zone=get_param('zone');
if ($zone!='_block') uninstall_module($zone,$module); else uninstall_block($module);
$title=get_page_title('UNINSTALL_MODULE');
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'view','id'=>$zone),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'5e29770370a50b8741b55719f23666ed','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI and actualiser to reinstall a module.
*
* @return tempcode The UI
*/
function reinstall_module()
{
//removed-assert
$module=get_param('module');
$zone=get_param('zone');
if ($zone!='_block') reinstall_module($zone,$module); else reinstall_block($module);
$title=get_page_title('REINSTALL_MODULE');
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'view','id'=>$zone),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'30c0d5079037e0da833dbe28603b82fa','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
}
?>
drop_if_exists('award_archive');
$GLOBALS['SITE_DB']->drop_if_exists('award_types');
}
/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from=NULL,$upgrade_from_hack=NULL)
{
//removed-assert
if ((!is_null($upgrade_from)) && ($upgrade_from<3))
{
delete_specific_permission('choose_dotw');
delete_config_option('dotw_update_time');
$GLOBALS['SITE_DB']->rename_table('dotw','award_archive');
$GLOBALS['SITE_DB']->add_table_field('award_archive','a_type_id','AUTO_LINK',db_get_first_id());
$GLOBALS['SITE_DB']->alter_table_field('award_archive','id','ID_TEXT','content_id');
$GLOBALS['SITE_DB']->add_table_field('award_archive','member_id','USER',$GLOBALS['FORUM_DRIVER']->get_guest_id());
$GLOBALS['SITE_DB']->change_primary_key('award_archive',array('a_type_id','date_and_time'));
}
if (is_null($upgrade_from))
{
$GLOBALS['SITE_DB']->create_table('award_archive',array(
'a_type_id'=>'*AUTO_LINK',
'date_and_time'=>'*TIME',
'content_id'=>'ID_TEXT',
'member_id'=>'USER'
));
}
if (((!is_null($upgrade_from)) && ($upgrade_from<3)) || (is_null($upgrade_from)))
{
$GLOBALS['SITE_DB']->create_table('award_types',array(
'id'=>'*AUTO',
'a_title'=>'SHORT_TRANS',
'a_description'=>'LONG_TRANS',
'a_points'=>'INTEGER',
'a_content_type'=>'ID_TEXT', // uses same naming convention as ocp_merge importer
'a_hide_awardee'=>'BINARY',
'a_update_time_hours'=>'INTEGER',
));
require_lang('awards');
$GLOBALS['SITE_DB']->query_insert('award_types',array(
'a_title'=>lang_code_to_default_content('DOTW'),
'a_description'=>lang_code_to_default_content('DESCRIPTION_DOTW'),
'a_points'=>0,
'a_content_type'=>'download',
'a_hide_awardee'=>1,
'a_update_time_hours'=>168
));
}
}
/**
* Standard modular entry-point finder function.
*
* @return ?array A map of entry points (type-code=>language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array_merge(array('misc'=>'AWARDS'),parent::get_entry_points());
}
/**
* Standard aed_module run_start.
*
* @param ID_TEXT The type of module execution
* @return tempcode The output of the run
*/
function run_start($type)
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/awards';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_featured';
require_code('awards');
if ($type=='misc') return $this->misc();
return new ocp_tempcode();
}
/**
* The do-next manager for before content management.
*
* @return tempcode The UI
*/
function misc()
{
//removed-assert
require_code('templates_interfaces');
return do_next_manager(get_page_title('AWARDS'),comcode_to_tempcode(do_lang('DOC_AWARDS'),NULL,true),
array(
/* type page params zone */
array('add_one',array('_SELF',array('type'=>'ad'),'_SELF'),do_lang('ADD_AWARD_TYPE')),
array('edit_one',array('_SELF',array('type'=>'ed'),'_SELF'),do_lang('EDIT_AWARD_TYPE')),
),
do_lang('AWARDS')
);
}
/**
* Get tempcode for adding/editing form.
*
* @param ?AUTO_LINK The ID of the award (NULL: not added yet)
* @param SHORT_TEXT The title
* @param LONG_TEXT The description
* @param integer How many points are given to the awardee
* @param ID_TEXT The content type the award type is for
* @param BINARY Whether to not show the awardee when displaying this award
* @param integer The approximate time in hours between awards (e.g. 168 for a week)
* @return tempcode The input fields
*/
function get_form_fields($id=NULL,$title='',$description='',$points=0,$content_type='download',$hide_awardee=0,$update_time_hours=168)
{
//removed-assert
$fields=new ocp_tempcode();
$fields->attach(form_input_line(do_lang_tempcode('TITLE'),do_lang_tempcode('DESCRIPTION_TITLE'),'title',$title,true));
$fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'),do_lang_tempcode('DESCRIPTION_DESCRIPTION'),'description',$description,true));
$fields->attach(form_input_integer(do_lang_tempcode('POINTS'),do_lang_tempcode('DESCRIPTION_AWARD_POINTS'),'points',$points,true));
$list=new ocp_tempcode();
$hooks=find_all_hooks('systems','awards');
foreach (array_keys($hooks) as $hook)
{
require_code('hooks/systems/awards/'.$hook);
$hook_object=object_factory('Hook_awards_'.$hook);
$hook_info=$hook_object->info();
if (!is_null($hook_info))
$list->attach(form_input_list_entry($hook,$hook==$content_type,$hook_info['title']));
}
if ($list->is_blank()) user_clean_exit(do_lang('NO_CATEGORIES'));
$fields->attach(form_input_list(do_lang_tempcode('CONTENT_TYPE'),do_lang_tempcode('DESCRIPTION_CONTENT_TYPE'),'content_type',$list));
$fields->attach(form_input_tick(do_lang_tempcode('HIDE_AWARDEE'),do_lang_tempcode('DESCRIPTION_HIDE_AWARDEE'),'hide_awardee',$hide_awardee==1));
$fields->attach(form_input_integer(do_lang_tempcode('AWARD_UPDATE_TIME_HOURS'),do_lang_tempcode('DESCRIPTION_AWARD_UPDATE_TIME_HOURS'),'update_time_hours',$update_time_hours,true));
// Permissions
$fields->attach($this->get_permission_fields(is_null($id)?NULL:strval($id)));
return $fields;
}
/**
* Standard aed_module list function.
*
* @return tempcode The selection list
*/
function nice_get_entries()
{
//removed-assert
$_m=$GLOBALS['SITE_DB']->query_select('award_types',array('id','a_title'));
$entries=new ocp_tempcode();
foreach ($_m as $m)
{
$entries->attach(form_input_list_entry($m['id'],false,text_lookup_original($m['a_title'])));
}
return $entries;
}
/**
* Standard aed_module edit form filler.
*
* @param AUTO_LINK The entry being edited
* @return tempcode The edit forum
*/
function fill_in_edit_form($id)
{
//removed-assert
$m=$GLOBALS['SITE_DB']->query_select('award_types',array('*'),array('id'=>$id),'',1);
if (!array_key_exists(0,$m)) user_clean_exit(do_lang_tempcode('MISSING_RESOURCE'));
$r=$m[0];
$fields=$this->get_form_fields($id,text_lookup_original($r['a_title']),text_lookup_original($r['a_description']),$r['a_points'],$r['a_content_type'],$r['a_hide_awardee'],$r['a_update_time_hours']);
return $fields;
}
/**
* Standard aed_module add actualiser.
*
* @return ID_TEXT The entry added
*/
function add_actualisation()
{
//removed-assert
$id=add_award_type(post_param('title'),post_param('description'),post_param_integer('points',0),post_param('content_type'),post_param_integer('hide_awardee',0),post_param_integer('update_time_hours'));
$this->set_permissions($id);
return strval($id);
}
/**
* Standard aed_module edit actualiser.
*
* @param ID_TEXT The entry being edited
*/
function edit_actualisation($id)
{
//removed-assert
edit_award_type(intval($id),post_param('title'),post_param('description'),post_param_integer('points',0),post_param('content_type'),post_param_integer('hide_awardee',0),post_param_integer('update_time_hours'));
$this->set_permissions($id);
}
/**
* Standard aed_module delete actualiser.
*
* @param ID_TEXT The entry being deleted
*/
function delete_actualisation($id)
{
//removed-assert
delete_award_type(intval($id));
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array('misc'=>'BACKUP');
}
/**
* Standard modular uninstall function.
*/
function uninstall()
{
//removed-assert
delete_value('last_backup');
//deldir_contents(get_custom_file_base().'/exports/backups',true);
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/backups';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_backup';
if (get_file_base()!=get_custom_file_base()) user_clean_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
decache('main_staff_checklist');
require_code('backup');
require_lang('backups');
@ini_set('memory_limit','-1'); // Has to be done for all stages -- so we know early if it will kill us whilst we can still see what's happening (on some systems, setting mem-limit kills PHP)
$type=get_param('type','misc');
if ($type=='make_backup') return $this->make_backup();
if ($type=='confirm_delete') return $this->confirm_delete();
if ($type=='delete') return $this->delete();
if ($type=='misc') return $this->backup_interface();
return new ocp_tempcode();
}
/**
* The UI to do a backup.
*
* @return tempcode The UI
*/
function backup_interface()
{
//removed-assert
$title=get_page_title('BACKUP');
$last_backup=intval(get_value('last_backup'));
$text=($last_backup==0)?do_lang('NO_LAST_BACKUP'):do_lang('LAST_BACKUP',number_format(round((time()-$last_backup)/(60*60*24),0)));
$url=build_url(array('page'=>'_SELF','type'=>'make_backup'),'_SELF');
$max_size=intval(get_value('backup_max_size'));
if ($max_size==0) $max_size=100;
require_code('form_templates');
$content=form_input_radio_entry('b_type','full',true,do_lang('FULL_BACKUP'));
$content->attach(form_input_radio_entry('b_type','incremental',false,do_lang('INCREMENTAL_BACKUP')));
$fields=form_input_radio(do_lang_tempcode('TYPE'),do_lang('BACKUP_TYPE'),$content);
$fields->attach(form_input_integer(do_lang_tempcode('MAX_SIZE'),do_lang('MAX_FILE_SIZE'),'max_size',$max_size,false));
if (module_installed('calendar'))
{
$fields->attach(form_input_date(do_lang_tempcode('SCHEDULE_TIME'),do_lang_tempcode('DESCRIPTION_SCHEDULE_TIME'),'schedule',true,true,true));
$recurrance_days=intval(get_value('backup_recurrance_days'));
if ($recurrance_days==0) $recurrance_days=NULL;
$fields->attach(form_input_integer(do_lang_tempcode('RECURRANCE_DAYS'),do_lang_tempcode('DESCRIPTION_RECURRANCE_DAYS'),'recurrance_days',$recurrance_days,false));
}
$form=do_template('FORM',array('_GUID'=>'64ae569b2cce398e89d1b4167f116193','HIDDEN'=>'','FIELDS'=>$fields,'SUBMIT_NAME'=>do_lang('BACKUP'),'TEXT'=>$text,'POST_URL'=>$url));
$results=$this->get_results();
return do_template('BACKUP_LAUNCH_PAGE',array('_GUID'=>'26a82a0627632db79b35055598de5d23','TITLE'=>$title,'RESULTS'=>$results,'FORM'=>$form));
}
/**
* Helper function to find information about past backups.
*
* @return tempcode The UI
*/
function get_results()
{
//removed-assert
// Find all files in the incoming directory
$path=get_custom_file_base().'/exports/backups/';
$handle=opendir($path);
$entries=array();
while (false!==($file=readdir($handle)))
{
if ((!is_dir($path.$file)) && ((get_file_extension($file)=='tar') || (get_file_extension($file)=='txt') || (get_file_extension($file)=='gz')) && (is_file($path.$file)))
{
$entries[]=array('file'=>$file,'size'=>filesize($path.$file),'mtime'=>filemtime($path.$file));
}
}
closedir($handle);
if (count($entries)!=0)
{
require_code('templates_interfaces');
$header_row=table_table_header_row(array(do_lang('FILENAME'),do_lang('SIZE'),do_lang('DATE_TIME'),do_lang('ACTIONS')));
$rows=new ocp_tempcode();
foreach ($entries as $entry)
{
$delete_url=build_url(array('page'=>'_SELF','type'=>'confirm_delete','file'=>$entry['file']),'_SELF');
$link=get_custom_base_url().'/exports/backups/'.$entry['file'];
$actions=do_template('TABLE_TABLE_ACTION_DELETE_ENTRY',array('_GUID'=>'23a8b5d5d345d8fdecc74b01fe5a9042','URL'=>$delete_url));
$rows->attach(table_table_row(array(hyperlink($link,escape_html($entry['file'])),number_format($entry['size']),do_timezoned_date($entry['mtime']),$actions)));
}
$files=do_template('TABLE_TABLE',array('_GUID'=>'726070efa71843236e975d87d4a17dae','HEADER_ROW'=>$header_row,'ROWS'=>$rows));
} else $files=new ocp_tempcode();
return $files;
}
/**
* The UI to confirm deletion of a backup file.
*
* @return tempcode The UI
*/
function confirm_delete()
{
//removed-assert
$title=get_page_title('DELETE');
$file=get_param('file');
$preview=do_lang('CONFIRM_DELETE',$file);
$url=build_url(array('page'=>'_SELF','type'=>'delete'),'_SELF');
$fields=form_input_hidden('file',$file);
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('BACKUP'))));
breadcrumb_set_self(do_lang('DELETE'));
return do_template('CONFIRM_PAGE',array('_GUID'=>'fa69bb63385525921c75954c03a3aa43','TITLE'=>$title,'PREVIEW'=>$preview,'URL'=>$url,'FIELDS'=>$fields));
}
/**
* The UI and actualiser to delete a backup file.
*
* @return tempcode The UI
*/
function delete()
{
//removed-assert
$title=get_page_title('DELETE');
$file=post_param('file');
$path=get_custom_file_base().'/exports/backups/'.filter_naughty($file);
if (!@unlink($path))
{
user_clean_exit(do_lang_tempcode('WRITE_ERROR',$path));
}
sync_file('exports/backups/'.$file);
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF');
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'190d3bfb3ba425cade1f4a8b6af1d2da','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
/**
* The UI and actualiser to start a backup.
*
* @return tempcode The UI
*/
function make_backup()
{
//removed-assert
$title=get_page_title('BACKUP');
$b_type=post_param('b_type');
if ($b_type=='full') $file='restore_'.uniqid('');
elseif ($b_type=='incremental') $file='dif_'.uniqid('');
else exit();
$max_size=post_param_integer('max_size',0);
if (($max_size==0) || (!is_numeric($max_size))) $max_size=1000000000;
if (module_installed('calendar'))
{
$schedule=get_input_date('schedule');
if (!is_null($schedule))
{
set_value('backup_schedule_time',strval($schedule));
set_value('backup_recurrance_days',strval(post_param('recurrance_days',0)));
set_value('backup_max_size',strval($max_size));
set_value('backup_b_type',$b_type);
return message_page($title,do_lang('SUCCESS'));
}
}
$instant=get_param_integer('keep_backup_instant',0); // Toggle this to true when debugging
@set_time_limit(0) OR user_clean_exit(do_lang_tempcode('SAFE_MODE'));
if ($instant==1)
{
make_backup_2($file,$b_type,$max_size);
} else
{
global $MB2_FILE,$MB2_B_TYPE,$MB2_MAX_SIZE;
$MB2_FILE=$file;
$MB2_B_TYPE=$b_type;
$MB2_MAX_SIZE=$max_size;
register_shutdown_function('make_backup_2');
}
$text=do_lang('BACKUP_INFO_2');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('BACKUP'))));
breadcrumb_set_self(do_lang('START'));
return do_template('BACKUP_PAGE',array('_GUID'=>'3dd15110b5bfbed0d28a5cb3945c503e','FILE'=>$file,'TITLE'=>$title,'TEXT'=>$text));
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array('!'=>'BULK_UPLOAD');
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/bulkuploadassistant';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_comcode';
require_lang('bulkupload');
$title=get_page_title('BULK_UPLOAD');
$parameter=post_param('parameter','');
require_code('form_templates');
if ($parameter=='')
{
$post_url=build_url(array('page'=>'_SELF'),'_SELF');
$text=paragraph(do_lang_tempcode('BULK_UPLOAD_HELP'));
$submit_name=do_lang('BULK_UPLOAD');
$fields=form_input_line(do_lang_tempcode('DIRECTORY'),do_lang('DIRECTORY_BULK'),'parameter','uploads/attachments/'.do_timezoned_date(time(),false),true);
return do_template('FORM_PAGE',array('_GUID'=>'77a2ca460745145d8a1d18cf24971fea','HIDDEN'=>'','FIELDS'=>$fields,'POST_URL'=>$post_url,'TITLE'=>$title,'TEXT'=>$text,'SUBMIT_NAME'=>$submit_name));
} else
{
$out=$this->do_dir(get_custom_file_base().'/'.filter_naughty($parameter));
if ($out->is_blank()) user_clean_exit(do_lang_tempcode('NO_ENTRIES'));
return do_template('BULK_HELPER_RESULTS_PAGE',array('_GUID'=>'5d373553cf21a58f15006bd4e600a9ee','TITLE'=>$title,'RESULTS'=>$out));
}
}
/**
* Scan a directory for files, and put them into the tempcode as an entry in the visual list.
*
* @param PATH The directory path
* @return tempcode The visual list of files
*/
function do_dir($path)
{
//removed-assert
$out=new ocp_tempcode();
$handle=@opendir($path);
if ($handle!==false)
{
while (false!==($file=readdir($handle)))
{
if (!is_special_file($file))
{
if (is_file($path.'/'.$file))
{
$filefull=substr($path,strlen(get_file_base().'/')).'/'.$file;
$out->attach(do_template('BULK_HELPER_ENTRY',array('_GUID'=>'f57ec94c57b0ef0096c80a6c463f31d3','FILEFULL'=>$filefull)));
} else
{
$out->attach($this->do_dir($path.'/'.$file));
}
}
}
closedir($handle);
} else user_clean_exit(do_lang_tempcode('FILE_NOT_FOUND',$path));
return $out;
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array_merge(array('delete_all'=>'DELETE_ALL_ROOMS'),parent::get_entry_points());
}
/**
* Standard aed_module run_start.
*
* @param ID_TEXT The type of module execution
* @return tempcode The output of the run
*/
function run_start($type)
{
//removed-assert
$this->extra_donext_entries=array(array('delete',array('_SELF',array('type'=>'delete_all'),'_SELF'),do_lang('DELETE_ALL_ROOMS')));
$GLOBALS['HELPER_PANEL_PIC']='pagepics/chatrooms';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_chat';
require_lang('chat');
require_code('chat');
require_code('chat2');
require_css('chat');
if ($type=='misc') return $this->misc();
if ($type=='delete_all') return $this->delete_all();
if ($type=='_delete_all') return $this->_delete_all();
return new ocp_tempcode();
}
/**
* The do-next manager for before content management.
*
* @return tempcode The UI
*/
function misc()
{
//removed-assert
require_code('templates_interfaces');
return do_next_manager(get_page_title('SECTION_CHAT'),comcode_to_tempcode(do_lang('DOC_CHAT'),NULL,true),
array(
/* type page params zone */
array('add_one',array('_SELF',array('type'=>'ad'),'_SELF'),do_lang('ADD_CHATROOM')),
array('edit_one',array('_SELF',array('type'=>'ed'),'_SELF'),do_lang('EDIT_CHATROOM')),
array('delete',array('_SELF',array('type'=>'delete_all'),'_SELF'),do_lang('DELETE_ALL_ROOMS')),
),
do_lang('SECTION_CHAT')
);
}
/**
* Get tempcode for a adding/editing form.
*
* @return tempcode The input fields
*/
function get_form_fields()
{
//removed-assert
return get_chatroom_fields();
}
/**
* Standard aed_module list function.
*
* @return tempcode The selection list
*/
function nice_get_entries()
{
//removed-assert
$rows=$GLOBALS['SITE_DB']->query_select('chat_rooms',array('*'),array('is_im'=>0),'ORDER BY room_name DESC');
$fields=new ocp_tempcode();
foreach ($rows as $row)
{
if (!handle_chatroom_pruning($row))
{
$fields->attach(form_input_list_entry($row['id'],false,$row['room_name']));
}
}
return $fields;
}
/**
* Standard aed_module edit form filler.
*
* @param AUTO_LINK The entry being edited
* @return tempcode The edit forum
*/
function fill_in_edit_form($id)
{
//removed-assert
$rows=$GLOBALS['SITE_DB']->query_select('chat_rooms',array('*'),array('id'=>$id),'',1);
if (!array_key_exists(0,$rows))
{
user_clean_exit(do_lang_tempcode('MISSING_RESOURCE'));
}
$row=$rows[0];
$allow2=rev_parse_allow_list_input($row['allow_list']);
$allow2_groups=rev_parse_allow_list_input_groups($row['allow_list_groups']);
$disallow2=rev_parse_allow_list_input($row['disallow_list']);
$disallow2_groups=rev_parse_allow_list_input_groups($row['disallow_list_groups']);
$username=$GLOBALS['FORUM_DRIVER']->get_username($row['room_owner']);
if (is_null($username)) $username='';//do_lang('UNKNOWN');
return get_chatroom_fields(false,$row['room_name'],text_lookup_original($row['c_welcome']),$username,$allow2,$allow2_groups,$disallow2,$disallow2_groups);
}
/**
* Standard aed_module add actualiser.
*
* @return ID_TEXT The entry added
*/
function add_actualisation()
{
//removed-assert
$allow2=parse_allow_list_input(post_param('allow_list'));
$allow2_groups=parse_allow_list_input_groups(post_param('allow_list_groups'));
$disallow2=parse_allow_list_input(post_param('disallow_list'));
$disallow2_groups=parse_allow_list_input_groups(post_param('disallow_list_groups'));
$id=add_chatroom(post_param('c_welcome'),post_param('room_name'),$GLOBALS['FORUM_DRIVER']->get_member_from_username(post_param('room_owner')),$allow2,$allow2_groups,$disallow2,$disallow2_groups,post_param('room_lang'));
return strval($id);
}
/**
* Standard aed_module edit actualiser.
*
* @param ID_TEXT The entry being edited
*/
function edit_actualisation($id)
{
//removed-assert
$allow2=post_param('allow_list',STRING_MAGIC_NULL);
if ($allow2!=STRING_MAGIC_NULL) $allow2=parse_allow_list_input($allow2);
$allow2_groups=post_param('allow_list_groups',STRING_MAGIC_NULL);
if ($allow2_groups!=STRING_MAGIC_NULL) $allow2_groups=parse_allow_list_input_groups($allow2_groups);
$disallow2=post_param('disallow_list',STRING_MAGIC_NULL);
if ($disallow2!=STRING_MAGIC_NULL) $disallow2=parse_allow_list_input($disallow2);
$disallow2_groups=post_param('disallow_list_groups',STRING_MAGIC_NULL);
if ($disallow2_groups!=STRING_MAGIC_NULL) $disallow2_groups=parse_allow_list_input_groups($disallow2_groups);
$_room_owner=post_param('room_owner',STRING_MAGIC_NULL);
$room_owner=($_room_owner==STRING_MAGIC_NULL)?INTEGER_MAGIC_NULL:$GLOBALS['FORUM_DRIVER']->get_member_from_username($_room_owner);
edit_chatroom(intval($id),post_param('c_welcome',STRING_MAGIC_NULL),post_param('room_name'),$room_owner,$allow2,$allow2_groups,$disallow2,$disallow2_groups,post_param('room_lang',STRING_MAGIC_NULL));
}
/**
* Standard aed_module delete actualiser.
*
* @param ID_TEXT The entry being deleted
*/
function delete_actualisation($id)
{
//removed-assert
delete_chatroom(intval($id));
}
/**
* The UI to delete all chat rooms.
*
* @return tempcode The UI
*/
function delete_all()
{
//removed-assert
$title=get_page_title('DELETE_ALL_ROOMS');
$fields=new ocp_tempcode();
require_code('form_templates');
$fields->attach(form_input_tick(do_lang_tempcode('PROCEED'),do_lang('Q_SURE'),'continue_delete',false));
$posting_name=do_lang('PROCEED');
//$posting_url=build_url(array('page'=>'_SELF','mode'=>$mode,'type'=>'private_add'),'_SELF');
$posting_url=build_url(array('page'=>'_SELF','type'=>'_delete_all'),'_SELF');
$text=paragraph(do_lang_tempcode('CONFIRM_DELETE_ALL_ROOMS'));
return do_template('FORM_PAGE',array('_GUID'=>'fdf02f5b3a3b9ce6d1abaccf0970ed73','HIDDEN'=>'','TITLE'=>$title,'FIELDS'=>$fields,'SUBMIT_NAME'=>$posting_name,'POST_URL'=>$posting_url,'TEXT'=>$text));
}
/**
* The UI and actualiser to delete all chat rooms.
*
* @return tempcode The UI
*/
function _delete_all()
{
//removed-assert
$delete=post_param_integer('continue_delete',0);
if ($delete!=1)
{
return $this->chat_interface();
}
else
{
$title=get_page_title('DELETE_ALL_ROOMS');
delete_all_chatrooms();
return $this->do_next_manager($title,'',NULL);
}
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array('misc'=>'CLEANUP_TOOLS');
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/cleanup';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_cleanup';
require_lang('cleanup');
require_code('view_modes');
// Decide what we're doing
$type=get_param('type','misc');
if ($type=='misc') return $this->choose_cache_type();
if ($type=='rebuild') return $this->do_rebuild();
return new ocp_tempcode();
}
/**
* The UI for choosing caches to empty.
*
* @return tempcode The UI
*/
function choose_cache_type()
{
//removed-assert
$hooks=find_all_hooks('modules','admin_cleanup');
$title=get_page_title('CLEANUP_TOOLS');
$url=build_url(array('page'=>'_SELF','type'=>'rebuild'),'_SELF');
require_code('form_templates');
$fields=new ocp_tempcode();
foreach (array_keys($hooks) as $hook)
{
require_code('hooks/modules/admin_cleanup/'.filter_naughty_harsh($hook));
$object=object_factory('Hook_'.filter_naughty_harsh($hook));
$output=$object->info();
if (!is_null($output))
{
$fields->attach(form_input_tick($output['title'],$output['description'],$hook,false));
}
}
return do_template('FORM_PAGE',array('_GUID'=>'85bfdf171484604594a157aa8983f920','SKIP_REQUIRED_NOTICE'=>'_true','TEXT'=>do_lang_tempcode('CACHES_PAGE'),'SUBMIT_NAME'=>do_lang_tempcode('PROCEED'),'HIDDEN'=>'','TITLE'=>$title,'FIELDS'=>$fields,'POST_URL'=>$url));
}
/**
* The UI and actualiser for emptying caches.
*
* @return tempcode The UI
*/
function do_rebuild()
{
//removed-assert
$messages=ocportal_cleanup(array_keys($_POST));
$messages->attach(paragraph(do_lang_tempcode('SUCCESS')));
$title=get_page_title('CLEANUP_TOOLS');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('CLEANUP_TOOLS'))));
breadcrumb_set_self(do_lang('START'));
return do_template('CLEANUP_COMPLETED_PAGE',array('_GUID'=>'598510a9ad9f01f3c0806319b32b5033','TITLE'=>$title,'MESSAGES'=>$messages));
}
}
?>
evaluate());
}
delete_config_option('width_left');
delete_config_option('width_right');
set_option('welcome_message','[html]'.get_option('welcome_message').'[/html]');
set_option('closed','[html]'.get_option('closed').'[/html]');
delete_config_option('xhtml_validation');
}
if ((is_null($upgrade_from)) || ($upgrade_from<7))
{
add_config_option('LOW_DISK_SPACE_SUBJECT','low_space_check','integer','return \'20\';','SITE','GENERAL'); // 20MB - very very low even for lame web hosts
add_config_option('ALLOW_AUDIO_VIDEOS','allow_audio_videos','tick','return \'1\';','SITE','ADVANCED');
add_config_option('VALIDATION','validation','tick','return \'0\';','SITE','VALIDATION',1); /*(in_array(ocp_srv('HTTP_HOST'),array('localhost','test.ocportal.com'))?'1':'0')*/ // return (!function_exists(\'memory_get_usage()\') || (ini_get(\'memory_limit\')!=\'8M\'))?\'1\':\'0\';
add_config_option('VALIDATION_XHTML','validation_xhtml','tick','return \'1\';','SITE','VALIDATION',1);
add_config_option('VALIDATION_WCAG','validation_wcag','tick','return \'1\';','SITE','VALIDATION',1);
add_config_option('VALIDATION_CSS','validation_css','tick','return \'0\';','SITE','VALIDATION',1);
add_config_option('VALIDATION_JAVASCRIPT','validation_javascript','tick','return \'0\';','SITE','VALIDATION',1);
add_config_option('VALIDATION_COMPAT','validation_compat','tick','return \'0\';','SITE','VALIDATION',1);
add_config_option('VALIDATION_EXT_FILES','validation_ext_files','tick','return \'0\';','SITE','VALIDATION',1);
}
if (is_null($upgrade_from))
{
set_value('version',float_to_raw_string(ocp_version_number()));
set_value('ocf_version',float_to_raw_string(ocp_version_number()));
// Site Configuration
// General
add_config_option('SITE_NAME','site_name','line','return \'ocPortal-?\';','SITE','GENERAL');
add_config_option('SITE_SCOPE','site_scope','transline','return \'ocPortal-?\';','SITE','GENERAL');
add_config_option('DESCRIPTION','description','transline','return \'ocPortal-?\';','SITE','GENERAL');
add_config_option('COPYRIGHT','copyright','transline','return \'Copyright ©, \'.get_site_name().\', \'.date(\'Y\').\'\';','SITE','GENERAL');
add_config_option('WELCOME_MESSAGE','welcome_message','transtext','return \'\';','SITE','GENERAL');
// Advanced
add_config_option('KEYWORDS','keywords','line','return \'\';','SITE','ADVANCED');
add_config_option('LOGO_MAP','logo_map','text','$tpl=do_template(\'IMAGE_MAP\'); return $tpl->evaluate();','SITE','ADVANCED');
add_config_option('GZIP_OUTPUT','gzip_output','tick','return \'0\';','SITE','ADVANCED',1);
// Environment
add_config_option('FORUM_IN_PORTAL','forum_in_portal','tick','return \'0\';','SITE','ENVIRONMENT',1);
add_config_option('NETWORK_LINKS','network_links','line','return get_base_url().\'/netlink.php\';','SITE','ENVIRONMENT',1);
add_config_option('EMAIL','staff_address','line','return \'staff@\'.get_domain();','SITE','ENVIRONMENT');
add_config_option('GD','is_on_gd','tick','return function_exists(\'imagetypes\')?\'1\':\'0\';','SITE','ENVIRONMENT',1);
add_config_option('FOLDER_CREATE','is_on_folder_create','tick','return \'1\';','SITE','ENVIRONMENT',1);
// Closed Site
add_config_option('CLOSED_SITE','site_closed','tick','return \''.(in_array(ocp_srv('HTTP_HOST'),array('localhost','test.ocportal.com'))?'0':'1').'\';','SITE','CLOSED_SITE');
add_config_option('MESSAGE','closed','transtext','return do_lang(\'BEING_INSTALLED\');','SITE','CLOSED_SITE');
add_config_option('MAXIMUM_USERS','maximum_users','integer','return \'100\';','SITE','CLOSED_SITE',1);
// Logging
add_config_option('CC_ADDRESS','cc_address','line','return \'staff_cc@\'.get_domain();','SITE','LOGGING');
add_config_option('LOG_PHP_ERRORS','log_php_errors','tick','return \'1\';','SITE','LOGGING');
add_config_option('DISPLAY_PHP_ERRORS','display_php_errors','tick','return \'1\';','SITE','LOGGING');
// Security/Group Options
// Uploading
add_config_option('FILE_TYPES','valid_types','line','return \'sql,odt,ods,ps,pdf,doc,ppt,xls,docx,pptx,xlsx,pub,txt,psd,tga,tif,gif,png,bmp,jpg,jpeg,avi,mov,mpg,mpeg,asf,wmv,ram,ra,rm,qt,mov,zip,tar,rar,gz,wav,mp3,ogg,torrent,php\';','SECURITY','UPLOAD'); // swf,fla,html,htm,svg,xml kept out for security reasons
add_config_option('IMAGE_TYPES','valid_images','line','return \'jpg,jpeg,gif,png\';','SECURITY','UPLOAD');
// Feature Options
// User Interaction
add_config_option('RATING','is_on_rating','tick','return \'1\';','FEATURE','USER_INTERACTION');
add_config_option('COMMENTS','is_on_comments','tick','return \'1\';','FEATURE','USER_INTERACTION');
add_config_option('FORUM_NAME','comments_forum_name','line','return do_lang(\'COMMENT_FORUM_NAME\',\'\',\'\',\'\',get_lang());','FEATURE','USER_INTERACTION');
add_config_option('PAGE_TEXT','comment_text','transtext','return do_template(\'COMMENTS_DEFAULT_TEXT\');','FEATURE','USER_INTERACTION');
// Images
add_config_option('THUMB_WIDTH','thumb_width','integer','return \'200\';','FEATURE','IMAGES');
add_config_option('MAX_SIZE','max_image_size','integer','return \'700\';','FEATURE','IMAGES');
}
}
/**
* Standard modular entry-point finder function.
*
* @return ?array A map of entry points (type-code=>language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array('misc'=>'CONFIGURATION','base'=>'BASE_CONFIGURATION');
}
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
//removed-assert
require_all_lang();
require_code('config2');
$type=get_param('type','misc');
if ($type=='base') return $this->base();
if ($type=='set') return $this->config_set();
if ($type=='page') return $this->config_interface();
if ($type=='misc') return $this->config_choose();
return new ocp_tempcode();
}
/**
* Redirect to the config_editor script.
*/
function base()
{
header('Location: '.get_base_url().'/config_editor.php');
exit();
}
/**
* The UI to choose what configuration page to edit.
*
* @return tempcode The UI
*/
function config_choose()
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/config';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_configuration';
$title=get_page_title('CONFIGURATION');
$rows=$GLOBALS['SITE_DB']->query_select('config',array('DISTINCT the_page'),NULL,'ORDER BY the_page');
$content=new ocp_tempcode();
foreach ($rows as $myrow)
{
$url=build_url(array('page'=>'_SELF','type'=>'page','id'=>$myrow['the_page']),'_SELF');
$name=do_lang('CONFIG_PAGE_'.$myrow['the_page']);
$content->attach(do_template('INDEX_PAGE_FANCIER_ENTRY',array('_GUID'=>'6ba2b09432d06e7502c71e7aac2d3527','TITLE'=>do_lang('CONFIGURATION'),'URL'=>$url,'NAME'=>$name,'DESCRIPTION'=>do_lang('CONFIG_PAGE_DESCRIPTION__'.$myrow['the_page']))));
}
return do_template('INDEX_PAGE_FANCIER_PAGE',array('_GUID'=>'c8fdb2b481625d58b0b228c897fda72f','PRE'=>'','POST'=>'','TITLE'=>$title,'CONTENT'=>$content));
}
/**
* The UI to edit a configuration page.
*
* @return tempcode The UI
*/
function config_interface()
{
//removed-assert
require_javascript('javascript_validation');
$page=get_param('id');
$title=get_page_title(do_lang('CONFIG_PAGE_'.$page),false);
$post_url=build_url(array('page'=>'_SELF','type'=>'set','id'=>$page),'_SELF');
$rows=$GLOBALS['SITE_DB']->query_select('config',array('*'),array('the_page'=>$page));
// Addin special ones
if ($page=='SITE') $rows[]=array('the_name'=>'timezone','human_name'=>'CURRENT_TIME','config_value'=>'','the_type'=>'special','eval'=>'','the_page'=>'SITE','section'=>'GENERAL','explanation'=>'','shared_hosting_restricted'=>0);
global $M_SORT_KEY;
$M_SORT_KEY='section';
usort($rows,'multi_sort');
// Move advanced section ones to the end
$rows2=array();
foreach ($rows as $i=>$row)
{
if ($row['section']=='ADVANCED')
{
$rows2[]=$row;
unset($rows[$i]);
}
}
$rows=array_merge($rows,$rows2);
$sections=new ocp_tempcode();
require_code('form_templates');
$current_section='';
$out=new ocp_tempcode();
foreach ($rows as $myrow)
{
$_section=do_lang($myrow['section'],NULL,NULL,NULL,NULL,false);
$name=do_lang($myrow['human_name'],NULL,NULL,NULL,NULL,false);
if ($myrow['the_type']=='special')
{
$explanation='';
} else
{
$explanation=do_lang($myrow['explanation'],NULL,NULL,NULL,NULL,false);
}
if ((is_null($_section)) || (is_null($name)) || (is_null($explanation))) continue;
if (($myrow['shared_hosting_restricted']==1) && (!is_null($GLOBALS['CURRENT_SHARE_USER']))) continue;
if (($myrow['section']!=$current_section) && ($current_section!=''))
{
$_current_section=do_lang($current_section);
$sections->attach(do_template('CONFIG_SECTION',array('_GUID'=>'af4c31daa1bc39714ab83b11bd6d3e51','SECTION'=>$out,'CURRENT_SECTION'=>$_current_section)));
$out=new ocp_tempcode();
}
switch ($myrow['the_type'])
{
case 'special':
if ($myrow['the_name']=='timezone')
{
$list=new ocp_tempcode();
$timezone=intval(get_value('timezone'));
for ($i=-26;$i<=26;$i++) // I know this looks like a huge range, but for some really weird/complex situations (inverse DST, with two +/- maximum dif clocks [server, client] set to GMT), it can get close
{
$text=date('g:i a, l',time()+$i*60*60);
$list->attach(form_input_list_entry(strval($i),($i==$timezone),$text,($i==0)));
}
$out->attach(form_input_list(do_lang_tempcode('CURRENT_TIME'),do_lang_tempcode('DESCRIPTION_CURRENT_TIME'),'timezone',$list));
}
break;
case 'integer':
$out->attach(form_input_integer($name,$explanation,$myrow['the_name'],intval(get_option($myrow['the_name'])),false));
break;
case 'line':
if ($myrow['the_name']=='currency')
{
$list=new ocp_tempcode();
$currencies=array('USD','CAD','EUR','GBP','JPY','AUD');
foreach ($currencies as $currency)
{
$list->attach(form_input_list_entry($currency,$currency==get_option($myrow['the_name'])));
}
$out->attach(form_input_list($name,$explanation,$myrow['the_name'],$list));
} else
{
/*if (strpos($myrow['the_name'],'password')!==false) password fields can't take defaults
$out->attach(form_input_password($name,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
else
*/$out->attach(form_input_line($name,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
}
break;
case 'transline':
$out->attach(form_input_line($name,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
break;
case 'text':
$out->attach(form_input_text($name,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
break;
case 'transtext':
$out->attach(form_input_text($name,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
break;
case 'float':
$out->attach(form_input_float($name,$explanation,$myrow['the_name'],floatval(get_option($myrow['the_name'])),false));
break;
case 'tick':
$out->attach(form_input_tick($name,$explanation,$myrow['the_name'],get_option($myrow['the_name'])=='1'));
break;
}
$current_section=$myrow['section'];
}
$sections->attach(do_template('CONFIG_SECTION',array('_GUID'=>'84c0db86002a33a383a7c2e195dd3913','SECTION'=>$out,'CURRENT_SECTION'=>$_section)));
list($warning_details,$ping_url)=handle_conflict_resolution();
breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang('CONFIGURATION'))));
breadcrumb_set_self(do_lang('CONFIG_PAGE_'.$page));
return do_template('CONFIG_PAGE',array('_GUID'=>'d01b28b71c38bbb52b6aaf877c7f7b0e','PING_URL'=>$ping_url,'WARNING_DETAILS'=>$warning_details,'TITLE'=>$title,'POST_URL'=>$post_url,'SECTIONS'=>$sections,'SUBMIT_NAME'=>do_lang('PROCEED')));
}
/**
* The UI and actualiser to edit a configuration page.
*
* @return tempcode The UI
*/
function config_set()
{
//removed-assert
$page=get_param('id','MAIN');
$title=get_page_title(do_lang('CONFIG_PAGE_'.$page),false);
require_code('points');
// Make sure we haven't locked ourselves out due to clean URL support
if ((post_param_integer('mod_rewrite',0)==1) && (!file_exists(get_file_base().'/.htaccess')))
{
user_clean_exit(do_lang_tempcode('BEFORE_MOD_REWRITE'));
}
// Make sure we haven't just locked staff out
$new_site_name=post_param('site_name','');
if (($new_site_name!='') && (get_option('is_on_sync_staff')=='1'))
{
$admin_groups=array_merge($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(),$GLOBALS['FORUM_DRIVER']->get_moderator_groups());
$staff=$GLOBALS['FORUM_DRIVER']->member_group_query($admin_groups);
foreach ($staff as $row_staff)
{
$member=$GLOBALS['FORUM_DRIVER']->pname_id($row_staff);
if ($GLOBALS['FORUM_DRIVER']->is_staff($member))
{
$_sites=point_info($member);
$sites=$_sites['sites'];
$sites=str_replace(', '.get_site_name(),'',$sites);
$sites=str_replace(','.get_site_name(),'',$sites);
$sites=str_replace(get_site_name().', ','',$sites);
$sites=str_replace(get_site_name().',','',$sites);
$sites=str_replace(get_site_name(),'',$sites);
$sites.=', '.$new_site_name;
$GLOBALS['FORUM_DRIVER']->set_custom_field($member,'sites',$sites);
}
}
}
$rows=$GLOBALS['SITE_DB']->query_select('config',array('*'),array('the_page'=>$page));
if ($page=='SITE') $rows[]=array('the_name'=>'timezone','shared_hosting_restricted'=>0,'the_type'=>'special');
foreach ($rows as $myrow)
{
if ($myrow['the_type']!='special')
{
$_section=do_lang($myrow['section'],NULL,NULL,NULL,NULL,false);
$name=do_lang($myrow['human_name'],NULL,NULL,NULL,NULL,false);
$explanation=do_lang($myrow['explanation'],NULL,NULL,NULL,NULL,false);
if ((is_null($_section)) || (is_null($name)) || (is_null($explanation))) continue;
}
if (($myrow['shared_hosting_restricted']==1) && (!is_null($GLOBALS['CURRENT_SHARE_USER']))) continue;
$value=mixed();
if ($myrow['the_type']=='tick') $value=post_param_integer($myrow['the_name'],0); else $value=post_param($myrow['the_name']);
if ($myrow['the_type']=='special')
{
if ($myrow['the_name']=='timezone')
{
set_value('timezone',$value);
}
}
elseif (!is_null($myrow['config_value']))
{
if (($myrow['the_type']=='transline') || ($myrow['the_type']=='transtext'))
{
$old_value=text_lookup_original($myrow['config_value']);
} else $old_value=$myrow['config_value'];
// If the option was changed
if ($old_value!=strval($value))
{
set_option($myrow['the_name'],strval($value),$myrow['the_type'],$myrow['config_value']);
}
}
else
{
if (($myrow['the_type']=='transline') || ($myrow['the_type']=='transtext'))
{
$_value=insert_lang($value,1);
} else $_value=$value;
$GLOBALS['SITE_DB']->query_update('config',array('config_value'=>strval($_value)),array('the_name'=>$myrow['the_name']),'',1);
}
}
// Clear some cacheing
require_code('view_modes');
erase_cached_templates();
require_code('zones2');
erase_comcode_page_cache();
$GLOBALS['SITE_DB']->query_delete('cache');
persistant_cache_delete('OPTIONS');
persistant_cache_empty();
// Show it worked / Refresh
$url=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF'); // ,'type'=>'page','id'=>$page
assign_refresh($url);
return do_template('REDIRECT_PAGE',array('_GUID'=>'68573f01bf51b8e6bc7a503ffebd4593','URL'=>$url,'TITLE'=>$title,'TEXT'=>do_lang('SUCCESS')));
}
}
?>
language-code) (NULL: disabled).
*/
function get_entry_points()
{
//removed-assert
return array_merge(array('misc'=>'CUSTOM_COMCODE'),parent::get_entry_points());
}
/**
* Standard modular info function.
*
* @return ?array Map of module info (NULL: module is disabled).
*/
function info()
{
//removed-assert
$info=array();
$info['author']='Chris Graham';
$info['organisation']='ocProducts';
$info['hacked_by']=NULL;
$info['hack_version']=NULL;
$info['version']=2;
$info['locked']=true;
return $info;
}
/**
* Standard modular uninstall function.
*/
function uninstall()
{
//removed-assert
$GLOBALS['SITE_DB']->drop_if_exists('custom_comcode');
}
/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from=NULL,$upgrade_from_hack=NULL)
{
//removed-assert
$GLOBALS['SITE_DB']->create_table('custom_comcode',array(
'tag_tag'=>'*ID_TEXT',
'tag_title'=>'SHORT_TRANS',
'tag_description'=>'SHORT_TRANS',
'tag_replace'=>'LONG_TEXT',
'tag_example'=>'LONG_TEXT',
'tag_parameters'=>'SHORT_TEXT',
'tag_enabled'=>'BINARY',
'tag_dangerous_tag'=>'BINARY',
'tag_block_tag'=>'BINARY',
'tag_textual_tag'=>'BINARY'
));
}
/**
* Standard aed_module run_start.
*
* @param ID_TEXT The type of module execution
* @return tempcode The output of the run
*/
function run_start($type)
{
//removed-assert
$GLOBALS['HELPER_PANEL_PIC']='pagepics/customcomcode';
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_comcode';
if ($type=='misc') return $this->misc();
return new ocp_tempcode();
}
/**
* The do-next manager for before content management.
*
* @return tempcode The UI
*/
function misc()
{
//removed-assert
require_code('templates_interfaces');
return do_next_manager(get_page_title('CUSTOM_COMCODE'),comcode_to_tempcode(do_lang('DOC_CUSTOM_COMCODE'),NULL,true),
array(
/* type page params zone */
array('add_one',array('_SELF',array('type'=>'ad'),'_SELF'),do_lang('ADD_CUSTOM_COMCODE_TAG')),
array('edit_one',array('_SELF',array('type'=>'ed'),'_SELF'),do_lang('EDIT_CUSTOM_COMCODE_TAG')),
),
do_lang('CUSTOM_COMCODE')
);
}
/**
* Get tempcode for a custom comcode tag adding/editing form.
*
* @param SHORT_TEXT The title (name) of the custom comcode tag
* @param LONG_TEXT The description of the tag
* @param BINARY Whether the tag is enabled
* @param ID_TEXT The actual tag code
* @param LONG_TEXT What to replace the tag with
* @param LONG_TEXT Example usage
* @param SHORT_TEXT Comma separated list of accepted parameters
* @param BINARY Whether it is a dangerous tag
* @param BINARY Whether it is a block tag
* @param BINARY Whether it is a textual tag
* @return tempcode The input fields
*/
function get_form_fields($title='',$description='',$enabled=1,$tag='this',$replace='{content}',$example='[this]blah[/this]',$parameters='',$dangerous_tag=0,$block_tag=0,$textual_tag=1)
{
$fields=new ocp_tempcode();
$fields->attach(form_input_line(do_lang_tempcode('COMCODE_TAG'),do_lang_tempcode('DESCRIPTION_COMCODE_TAG'),'tag',$tag,true));
$fields->attach(form_input_line(do_lang_tempcode('TITLE'),do_lang_tempcode('DESCRIPTION_TITLE'),'title',$title,true));
$fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'),do_lang_tempcode('DESCRIPTION_DESCRIPTION'),'description',$description,true));
$fields->attach(form_input_text(do_lang_tempcode('COMCODE_REPLACE'),do_lang_tempcode('DESCRIPTION_COMCODE_REPLACE'),'replace',$replace,true));
$fields->attach(form_input_line(do_lang_tempcode('PARAMETERS'),do_lang_tempcode('DESCRIPTION_COMCODE_PARAMETERS'),'parameters',$parameters,false));
$fields->attach(form_input_tick(do_lang_tempcode('ENABLED'),'','enabled',$enabled==1));
$fields->attach(form_input_tick(do_lang_tempcode('DANGEROUS_TAG'),do_lang_tempcode('DESCRIPTION_DANGEROUS_TAG'),'dangerous_tag',$dangerous_tag==1));
$fields->attach(form_input_tick(do_lang_tempcode('BLOCK_TAG'),do_lang_tempcode('DESCRIPTION_BLOCK_TAG'),'block_tag',$block_tag==1));
$fields->attach(form_input_tick(do_lang_tempcode('TEXTUAL_TAG'),do_lang_tempcode('DESCRIPTION_TEXTUAL_TAG'),'textual_tag',$textual_tag==1));
$fields->attach(form_input_line(do_lang_tempcode('EXAMPLE'),do_lang_tempcode('DESCRIPTION_COMCODE_EXAMPLE'),'example',$example,true));
return $fields;
}
/**
* Standard aed_module edit form filler.
*
* @param ID_TEXT The entry being edited
* @return tempcode The edit forum
*/
function fill_in_edit_form($id)
{
//removed-assert
$m=$GLOBALS['SITE_DB']->query_select('custom_comcode',array('*'),array('tag_tag'=>$id),'',1);
if (!array_key_exists(0,$m)) user_clean_exit(do_lang_tempcode('MISSING_RESOURCE'));
$r=$m[0];
$fields=$this->get_form_fields(text_lookup_original($r['tag_title']),text_lookup_original($r['tag_description']),$r['tag_enabled'],$r['tag_tag'],$r['tag_replace'],$r['tag_example'],$r['tag_parameters'],$r['tag_dangerous_tag'],$r['tag_block_tag'],$r['tag_textual_tag']);
return $fields;
}
/**
* Standard aed_module add actualiser.
*
* @return ID_TEXT The entry added
*/
function add_actualisation()
{
//removed-assert
$tag=post_param('tag');
global $VALID_COMCODE_TAGS;
$test=$GLOBALS['SITE_DB']->query_value_null_ok('custom_comcode','tag_tag',array('tag_tag'=>$tag));
if ((array_key_exists($tag,$VALID_COMCODE_TAGS)) || (!is_null($test))) user_cle