2008-12-02 00:32:30 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* e107 website system
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-2008 e107 Inc (e107.org)
|
|
|
|
* Released under the terms and conditions of the
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
|
|
|
*
|
|
|
|
* URL Management
|
|
|
|
*
|
|
|
|
* $Source: /cvs_backup/e107_0.8/e107_admin/eurl.php,v $
|
2008-12-02 11:03:02 +00:00
|
|
|
* $Revision: 1.3 $
|
|
|
|
* $Date: 2008-12-02 11:03:02 $
|
2008-12-02 00:32:30 +00:00
|
|
|
* $Author: secretr $
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../class2.php');
|
2008-12-02 11:03:02 +00:00
|
|
|
if (!getperms('L'))
|
|
|
|
{
|
2008-12-02 00:32:30 +00:00
|
|
|
header('location:'.e_BASE.'index.php');
|
|
|
|
exit;
|
2008-12-02 00:40:28 +00:00
|
|
|
}
|
2008-12-02 00:32:30 +00:00
|
|
|
|
|
|
|
$e_sub_cat = 'eurl';
|
|
|
|
require_once(e_ADMIN.'auth.php');
|
|
|
|
|
|
|
|
$urlc = new admin_url_config();
|
|
|
|
|
|
|
|
if (isset($_POST['update']))
|
|
|
|
{
|
|
|
|
$res = $urlc->update();
|
|
|
|
$plug_message = $res ? LAN_UPDATED : ($res === 0 ? LAN_NO_CHANGE : LAN_UPDATED_FAILED);
|
|
|
|
$plug_message = "<div class='center clear'>".$plug_message."</div><br />";
|
|
|
|
}
|
|
|
|
|
|
|
|
//var_dump($pref['url_config'], $e107->url->getUrl('pm', 'main', array('f'=>'box', 'box'=>2)));
|
|
|
|
|
|
|
|
$urlc->renderPage();
|
|
|
|
require_once(e_ADMIN.'footer.php');
|
|
|
|
|
|
|
|
class admin_url_config {
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
var $_rs;
|
|
|
|
var $_plug;
|
|
|
|
var $_api;
|
2008-12-02 11:03:02 +00:00
|
|
|
|
|
|
|
function admin_url_config()
|
2008-12-02 00:32:30 +00:00
|
|
|
{
|
|
|
|
global $e107;
|
|
|
|
require_once(e_HANDLER.'plugin_class.php');
|
|
|
|
require_once(e_HANDLER.'file_class.php');
|
|
|
|
require_once(e_HANDLER.'form_handler.php');
|
|
|
|
$this->_rs = new form();
|
|
|
|
$this->_plug = new e107plugin();
|
|
|
|
$this->_fl = new e_file();
|
|
|
|
$this->_api = &$e107;
|
|
|
|
}
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
function renderPage()
|
2008-12-02 00:40:28 +00:00
|
|
|
{
|
2008-12-02 00:32:30 +00:00
|
|
|
global $plug_message;
|
|
|
|
$text = "<div class='center'>
|
|
|
|
{$plug_message}
|
|
|
|
<form action='".e_SELF."' method='post' id='urlconfig-form'>
|
|
|
|
<table style='".ADMIN_WIDTH."' class='fborder admin-config'>
|
|
|
|
";
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
$empty = "
|
|
|
|
<tr>
|
|
|
|
<td colspan='2' class='forumheader3 center'>".LAN_EURL_EMPTY."</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
$text .= "
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2008-12-02 11:03:02 +00:00
|
|
|
<td colspan='2' class='forumheader'>".LAN_EURL_CORECONFIG."</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
|
|
|
|
$tmp = $this->render_sections('core');
|
|
|
|
if($tmp) $text .= $tmp;
|
|
|
|
else $text .= $empty;
|
2008-12-02 00:32:30 +00:00
|
|
|
|
|
|
|
$text .= "
|
|
|
|
<tr>
|
2008-12-02 11:03:02 +00:00
|
|
|
<td colspan='2' class='forumheader'>".LAN_EURL_PLUGCONFIG."</td>
|
2008-12-02 00:32:30 +00:00
|
|
|
</tr>";
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
$tmp = $this->render_sections('plugin');
|
|
|
|
if($tmp) $text .= $tmp;
|
|
|
|
else $text .= $empty;
|
2008-12-02 00:32:30 +00:00
|
|
|
|
|
|
|
$text .= "
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
<tr>
|
|
|
|
<td colspan='2' class='forumheader tfoot center'>".$this->_rs->form_button('submit', 'update', LAN_UPDATE)."</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
</div>";
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
$this->_api->ns->tablerender(PAGE_NAME, $text);
|
2008-12-02 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
function render_sections($id)
|
2008-12-02 00:40:28 +00:00
|
|
|
{
|
2008-12-02 11:03:02 +00:00
|
|
|
|
|
|
|
if($id == 'core')
|
2008-12-02 00:40:28 +00:00
|
|
|
{
|
2008-12-02 00:32:30 +00:00
|
|
|
$sections = $this->get_core_sections();
|
2008-12-02 11:03:02 +00:00
|
|
|
} else
|
2008-12-02 00:40:28 +00:00
|
|
|
{
|
2008-12-02 00:32:30 +00:00
|
|
|
$sections = $this->_plug->getall(1);
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
$ret = '';
|
2008-12-02 11:03:02 +00:00
|
|
|
foreach ($sections as $section)
|
2008-12-02 00:40:28 +00:00
|
|
|
{
|
2008-12-02 00:32:30 +00:00
|
|
|
if($id == 'core' && !is_readable(e_FILE.'e_url/core/'.$section['core_path'])) continue;
|
|
|
|
elseif($id == 'plugin' && !is_readable(e_PLUGIN.$section['plugin_path'].'/e_url')) continue;
|
|
|
|
$ret .= $this->render_section($id, $section);
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
function render_section($id, $section)
|
2008-12-02 00:32:30 +00:00
|
|
|
{
|
2008-12-02 11:03:02 +00:00
|
|
|
$this->normalize($id, $section);
|
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
$text .= "
|
|
|
|
<tr>
|
|
|
|
<td class='forumheader3' style='width: 30%'>{$section['name']}</td>
|
2008-12-02 11:03:02 +00:00
|
|
|
<td class='forumheader3' style='width: 70%'>
|
2008-12-02 00:32:30 +00:00
|
|
|
".$this->render_section_radio($id, $section)."
|
|
|
|
";
|
|
|
|
$text .= "
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
return $text;
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
|
|
|
function render_section_radio($id, $section)
|
2008-12-02 00:32:30 +00:00
|
|
|
{
|
|
|
|
global $pref;
|
|
|
|
//DEFAULT
|
|
|
|
$checked_def = varset($pref['url_config'][$section['path']]) ? '' : ' checked="checked"';
|
|
|
|
$def = "
|
|
|
|
<input type='radio' id='{$section['path']}-default' name='cprofile[{$section['path']}]' value='0'{$checked_def} />
|
2008-12-02 11:03:02 +00:00
|
|
|
<label for='{$section['path']}-default'>".LAN_EURL_DEFAULT."</label>
|
2008-12-02 00:32:30 +00:00
|
|
|
";
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
//CUSTOM - CENTRAL REPOSITORY
|
|
|
|
$udefined_id = $id.'-custom:'.$section['path'];
|
|
|
|
$udefined_path = e_FILE."e_url/custom/{$id}/{$section['path']}/";
|
|
|
|
$need_save = false; $checked = false;
|
|
|
|
$custom = '';
|
|
|
|
if(is_readable($udefined_path))
|
|
|
|
{
|
|
|
|
//Search the central url config repository - one config to rull them all
|
|
|
|
if($pref['url_config'][$section['path']])
|
|
|
|
{
|
|
|
|
$pref['url_config'][$section['path']] = $udefined_id;
|
|
|
|
$need_save = true;
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
$checked = $pref['url_config'][$section['path']] == $udefined_id ? ' checked="checked"' : '';
|
|
|
|
$custom = "
|
|
|
|
<div class='clear'><!-- --></div>
|
|
|
|
<input type='radio' id='{$section['path']}-custom' name='cprofile[{$section['path']}]' value='{$udefined_id}'{$checked} />
|
2008-12-02 11:03:02 +00:00
|
|
|
<label for='{$section['path']}-custom'>".LAN_EURL_UDEFINED."</label>
|
|
|
|
<a href='#{$section['path']}-custom-info' class='e-expandit' title='".LAN_EURL_INFOALT."'><img src='".e_IMAGE_ABS."admin_images/docs_16.png' alt='' /></a>
|
2008-12-02 00:32:30 +00:00
|
|
|
<div class='e-hideme' id='{$section['path']}-custom-info'>
|
|
|
|
<div class='indent'>
|
2008-12-02 11:03:02 +00:00
|
|
|
".LAN_EURL_UDEFINED_INFO."<br />
|
|
|
|
<strong>".LAN_EURL_LOCATION."</strong> ".e_FILE_ABS."e_url/custom/{$id}/{$section['path']}/"."
|
2008-12-02 00:32:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
//CUSTOM PROFILES - PLUGINS ONLY
|
2008-12-02 11:03:02 +00:00
|
|
|
$config_profiles = ''; $profile_id = '';
|
2008-12-02 00:32:30 +00:00
|
|
|
if($id == 'plugin')
|
2008-12-02 11:03:02 +00:00
|
|
|
$profile_path = e_PLUGIN."{$section['path']}/e_url/";
|
|
|
|
else
|
|
|
|
$profile_path = e_FILE."e_url/core/{$section['path']}/";
|
2008-12-02 00:32:30 +00:00
|
|
|
|
|
|
|
$config_profiles_array = $this->get_plug_profiles($profile_path);
|
|
|
|
//Search for custom url config released with the plugin
|
|
|
|
if($config_profiles_array)
|
|
|
|
{
|
|
|
|
foreach ($config_profiles_array as $config_profile) {
|
2008-12-02 11:03:02 +00:00
|
|
|
$profile_id = $id.'-profile:'.$config_profile;
|
2008-12-02 00:32:30 +00:00
|
|
|
$checked_profile = $pref['url_config'][$section['path']] == $profile_id ? ' checked="checked"' : '';
|
2008-12-02 11:03:02 +00:00
|
|
|
if($custom) $checked_profile = ' disabled="disabled"';
|
2008-12-02 00:32:30 +00:00
|
|
|
$config_profiles .= "
|
|
|
|
<div class='clear'><!-- --></div>
|
|
|
|
<input type='radio' id='{$section['path']}-profile-{$config_profile}' name='cprofile[{$section['path']}]' value='{$profile_id}'{$checked_profile} />
|
|
|
|
<label for='{$section['path']}-profile-{$config_profile}'>
|
2008-12-02 11:03:02 +00:00
|
|
|
".LAN_EURL_PROFILE." [{$config_profile}]
|
2008-12-02 00:32:30 +00:00
|
|
|
</label>
|
2008-12-02 11:03:02 +00:00
|
|
|
<a href='#{$section['path']}-profile-{$config_profile}-info' class='e-expandit' title='".LAN_EURL_INFOALT."'><img src='".e_IMAGE_ABS."admin_images/docs_16.png' alt='' /></a>
|
2008-12-02 00:32:30 +00:00
|
|
|
<div class='e-hideme' id='{$section['path']}-profile-{$config_profile}-info'>
|
|
|
|
<div class='indent'>
|
2008-12-02 11:03:02 +00:00
|
|
|
".LAN_EURL_PROFILE_INFO."<br />
|
|
|
|
<strong>".LAN_EURL_LOCATION."</strong> ".str_replace(array(e_PLUGIN, e_FILE), array(e_PLUGIN_ABS, e_FILE_ABS), $profile_path)."{$config_profile}/
|
2008-12-02 00:32:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
";
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->render_shutdown($need_save);
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
return $def.$config_profiles.$custom;
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
function get_plug_profiles($path)
|
|
|
|
{
|
|
|
|
$ret = $this->_fl->get_dirs($path, '', array('CVS', '.svn'));
|
|
|
|
return $ret;
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
function render_shutdown($now)
|
|
|
|
{
|
|
|
|
global $pref;
|
|
|
|
if($now && !isset($_POST['update']))
|
|
|
|
{
|
|
|
|
save_prefs();
|
|
|
|
}
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
|
|
|
function get_core_sections()
|
2008-12-02 00:32:30 +00:00
|
|
|
{
|
|
|
|
$core_def = array(
|
2008-12-02 11:03:02 +00:00
|
|
|
'news' => array("core_name" => LAN_EURL_CORE_NEWS, 'core_path' => 'news'),
|
|
|
|
'downloads' => array("core_name" => LAN_EURL_CORE_DOWNLOADS, 'core_path' => 'downloads')
|
2008-12-02 00:32:30 +00:00
|
|
|
);
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
return $core_def;
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
function normalize($id, &$section)
|
|
|
|
{
|
|
|
|
$tmp = $section;
|
2008-12-02 11:03:02 +00:00
|
|
|
foreach ($tmp as $k => $v)
|
2008-12-02 00:32:30 +00:00
|
|
|
{
|
2008-12-02 11:03:02 +00:00
|
|
|
$section[str_replace($id.'_', '', $k)] = $v;
|
2008-12-02 00:32:30 +00:00
|
|
|
unset($section[$k]);
|
|
|
|
}
|
|
|
|
}
|
2008-12-02 11:03:02 +00:00
|
|
|
|
|
|
|
function update()
|
2008-12-02 00:32:30 +00:00
|
|
|
{
|
|
|
|
global $pref;
|
|
|
|
$pref['url_config'] = $_POST['cprofile'];
|
|
|
|
return save_prefs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-02 11:03:02 +00:00
|
|
|
/*
|
2008-12-02 00:32:30 +00:00
|
|
|
function headerjs()
|
|
|
|
{
|
2008-12-02 11:03:02 +00:00
|
|
|
|
2008-12-02 00:32:30 +00:00
|
|
|
$js = "
|
|
|
|
<script type='text/javascript'>
|
|
|
|
|
|
|
|
</script>";
|
|
|
|
|
|
|
|
return $js;
|
2008-12-02 11:03:02 +00:00
|
|
|
|
|
|
|
}*/
|
2008-12-02 00:32:30 +00:00
|
|
|
?>
|