<?php
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Damien Tanner
// Purpose of file: Module administration / activating/deactivating, etc.
// ----------------------------------------------------------------------
if (!eregi("admin.php", $GLOBALS['PHP_SELF'])) die('Access Denied');
if (!authorised(0, 'Modules::', '::', ACCESS_ADMIN)) die('Access Denied');
modules_get_language();
function modules_menu($module)
{
menu_title('',_MODULESADMIN);
menu_graphic(false);
menu_add_option('admin.php?module='.$module.'&op=main', _LIST,'');
menu_add_option('admin.php?module='.$module.'&op=generate', _GENERATE,'');
}
function modules_get_image($module)
{
$file = 'modules/'.$module.'/images/admin.';
if (file_exists($file.'gif')) return $file.'gif';
elseif (file_exists($file.'jpg')) return $file.'jpg';
elseif (file_exists($file.'png')) return $file.'png';
else return 'modules/NS-Admin/images/default.gif';
}
function modules_img($file,$alternate='')
{
$img = @getimagesize($file);
return '<img src="'.$file.'" alt="'.$alternate.'" border="0" '.$img[3].'>';
}
function modules_admin_generate($var)
{
$handle = opendir('modules');
while ($dir=readdir($handle))
if (file_exists('modules/'.$dir.'/admin.php') and ($dir!='NS-Admin') and ($dir!='..'))
{
$name = ereg_replace('NS-','',$dir);
$text = '_'.strtoupper($name);
$image = modules_get_image($dir);
$item[$name] = array('module'=>$dir,'image'=>$image,'text'=>$text);
}
closedir($handle);
ksort($item);
$handle = @fopen('modules/'.$var['module'].'/data.php','w');
if (!$handle) die('change modules/NS-Modules/data.php autorization ; set it to write<br>Sorry, Pascal Riva');
fwrite($handle,'<?php'."\n");
foreach ($item as $name=>$data)
fwrite($handle,'$module_item[] = array("module"=>"'.$data['module'].'","image"=>"'.$data['image'].'","text"=>'.$data['text'].');'."\n");
fwrite($handle,'?>');
fclose($handle);
modules_menu($var['module']);
include 'header.php';
menu_draw();
OpenTable();
echo _MODULE_GENERATE_DO,"\n";
CloseTable();
include 'footer.php';
}
function modules_admin_main($var)
{
modules_menu($var['module']);
include 'header.php';
menu_draw();
OpenTable();
echo '<center>'."\n"
.'<font class="pn-title"><b>'._MODSINSTALLED.'</b></font>'."\n"
.'<br><br>'."\n"
.'<table border="0" width="100%" cellpadding="0" cellspacing="0">'."\n"
.'<tr><td align="center"><img src="images/admin/modules/find.gif" alt="">'._FINDMOD.'</td></tr>'."\n"
.'<tr>'."\n"
.'<td align="center">'."\n"
.'<form action="admin.php" method="get">'."\n"
.'<input type="text" name="q" size="25" value="Coming soon !">'."\n"
.'<input type="hidden" name="op" value="findmodule">'."\n"
.'</form>'."\n"
.'</td>'."\n"
.'</tr>'."\n"
.'</table>'."\n"
.'<br><br>'."\n";
$handle = opendir('modules');
while ($f = readdir($handle))
if ((!ereg('[.]', $f)) && $f != 'CVS')
{
$modversion = '';
$modversion['filename'] = $f;
$modversion['name'] = $f;
$modversion['version'] = '';
$modversion['description'] = '';
$modversion['credits'] = '';
$modversion['help'] = '';
$modversion['changelog'] = '';
$modversion['license'] = '';
$modversion['official'] = 0;
$modversion['author'] = '';
$modversion['contact'] = '';
$modversion['admin'] = 0;
if (file_exists($file='modules/'.$f.'/Version.php'))
include $file;
$moduleslist[] = $modversion;
}
closedir($handle);
usort($moduleslist, 'modules_admin_sorting');
// for use below
$oimg = modules_img('images/admin/modules/official.gif');
$gimg = modules_img('images/global/green_dot.gif',_DISABLE);
$rimg = modules_img('images/global/red_dot.gif',_ENABLE);
$cimg = modules_img('images/admin/modules/credits.gif');
$himg = modules_img('images/admin/modules/help.gif');
$limg = modules_img('images/admin/modules/license.gif');
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
foreach ($moduleslist as $v)
{
echo '<tr>'."\n"
.'<td width="70%">'."\n"
.'<font class="pn-normal">'."\n"
.'<b>'.$v['name'].'</b>'."\n";
if ($v['official']==1) echo $oimg."\n";
if ($v[admin] == 1) {
echo "";
} else {
echo '[<a href="modules.php?module='.$var['module'].'&op=modload&name='.$v['filename'].'&file=index">'._VIEWMODULE.'</a>]'."\n";
}
if ($v['author'])
if ($v['contact'])
if (ereg('@',$v['contact']))
echo '[<a href="mailto:'.$v['contact'].'">'.$v['author'].'</a>]'."\n";
else
echo '[<a href="'.$v['contact'].'">'.$v['author'].'</a>]'."\n";
else
echo '['.$v['author'].']'."\n";
echo '</font>'."\n"
.'</td>'."\n"
.'<td width="15%" rowspan="2"><font class="pn-normal">'._VERSION.' : '.$v['version'].'</font></td>'."\n"
.'<td width="15%" rowspan="2">'."\n";
if (!eregi('NS-',$v['filename']))
echo '<a href="admin.php?module='.$var['module'].'&op=status&mod='.$v[filename].'">'.$rimg.'</a>'."\n";
elseif ($v['admin']==0)
echo '<a href="admin.php?module='.$var['module'].'&op=status&mod='.$v[filename].'">'.$gimg.'</a>'."\n";
if ($v['credits'])
echo '<a href="admin.php?module='.$var['module'].'&op=info&type=credits&mod='.$v['filename'].'">'.$cimg.'</a>'."\n";
if ($v['help'])
echo '<a href="admin.php?module='.$var['module'].'&op=info&type=help&mod='.$v['filename'].'">'.$himg.'</a>'."\n";
if ($v[license])
echo '<a href="admin.php?module='.$var['module'].'&op=info&type=license&mod='.$v['filename'].'">'.$limg.'</a>'."\n";
echo '</td>'."\n"
.'</tr>'."\n"
.'<tr><td width="70%"><font class="pn-normal">'.$v['description'].'</font></td></tr>'."\n"
.'<tr><td> </td></tr>'."\n";
}
echo '</table>'."\n"
.'</center>';
CloseTable();
include 'footer.php';
}
function modules_admin_info($var)
{
modules_menu($var['module']);
include 'header.php';
menu_draw();
OpenTable();
echo '<center><font class="pn-title"><b>'._MODINFO.' '.ereg_replace('_', ' ', $var['mod']).'</b></font></center>'."\n"
.'<br><br>'."\n";
if (file_exists($file='modules/'.$var['mod'].'/Version.php'))
{
include $file;
echo '<hr>'."\n"
.'<font class="pn-normal">'."\n"
.implode('<br/>',file('modules/'.$var['mod'].'/'.$modversion[$var['type']]))
.'</font>'."\n"
.'<hr>'."\n";
}
else
echo _FILE_NOT_FOUND.' : '.$file;
CloseTable();
include 'footer.php';
}
function modules_admin_sorting($left, $right)
{
return strcasecmp($left['name'], $right['name']);
}
function modules_admin_status($var)
{
if (substr($var['mod'],0,3)=='NS-')
$newname = substr($var['mod'],3);
else
$newname = 'NS-'.$var['mod'];
rename('modules/'.$var['mod'],'modules/'.$newname);
modules_admin_main($var);
}
?>