<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.4 www.bcoos.net 2006-08 GPL
//v1.3 www.exoops.info 2006/03 GPL
// $Id: modulesadmin.php,v 1.22 2003/08/11 16:38:46 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
if( $xoopsUser->isAdmin($xoopsModule->mid()) ) {
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_list() {
global $bcoosConfig, $xoopsUser, $db, $xoopsModule;
xoops_cp_header();
OpenTable();
echo "
<h4 style='text-align:left'>"._MD_AM_MODADMIN."</h4>
<form action='admin.php' method='post' name='moduleadmin' id='moduleadmin'>
<table border='0' cellpadding='0' cellspacing='0' valign='top' width='100%'><tr>
<td class='bg2'>
<table width='100%' border='0' cellpadding='4' cellspacing='1'><tr valign='middle' class='bg3' align='center'>
<td><b>"._MD_AM_MODULE."</b></td>
<td><b>"._MD_AM_ACTION."</b></td>
<td><b>"._MD_AM_ORDER."</b><br />"._MD_AM_ORDER0."</td>
<td><b>"._MD_AM_VERSION."</b></td>
<td><b>"._MD_AM_LASTUP."</b></td>
<td><b>"._INFO."</b></td></tr>";
$installed_mods =& XoopsModule::getInstalledModules();
$listed_mods    = array();
// List installed modules
foreach ( $installed_mods as $module ) {
	echo "<tr align='center' valign='middle' class='bg1'><td valign='bottom'>";
if ( $module->hasAdmin() && $module->isActivated() ) {
	echo "<a href='".XOOPS_URL."/modules/".$module->dirname()."/".$module->adminindex()."'>".htmlspecialchars($module->name())."</a>";
	} else {
		echo htmlspecialchars($module->name());
	}
echo "
<input type='hidden' name='name[]' value='" .htmlspecialchars($module->name())."' />
<input type='hidden' name='oldstatus[]' value='1' /></td>";
if ( $module->dirname() != "system" && $module->isActivated() ) {
	echo "
	<td><select class='select' name='newstatus[]'>
	<option value='nochange' selected='selected'>"._MD_AM_NOCHANGE."</option>
	<option value='update'>"._UPDATE."</option>
	<option value='deactivate'>"._DEACTIVATE."</option>
	<option value='uninstall'>"._UNINSTALL."</option>";
} elseif ( $module->dirname() != "system" ) {
	echo "
	<td><select class='select' name='newstatus[]'>
	<option value='nochange' selected='selected'>"._MD_AM_NOCHANGE."</option>
	<option value='activate'>"._ACTIVATE."</option>
	<option value='update'>"._UPDATE."</option>
	<option value='uninstall'>"._UNINSTALL."</option>";
} else {
	echo "
	<td><select class='select' name='newstatus[]'>
	<option value='nochange' selected='selected'>"._MD_AM_NOCHANGE."</option>
	<option value='update'>"._UPDATE."</option>";
}
echo "
</select></td><td>";
if ( $module->hasMain() ) {
	echo "
	<input type='hidden' name='oldweight[]' value='".$module->weight()."' />
	<input type='text' class='text' name='weight[]' size='3' maxlength='5' value='".$module->weight()."' />";
	} else {
		echo "
		<input type='hidden' name='oldweight[]' value='0' />
		<input type='hidden' name='weight[]' value='0' />";
	}
echo "
</td>";
echo "
<td align='center'>".$module->currentVersion()."</td>
<td align='center'>".formatTimestamp($module->last_update(),"m")."&nbsp;";
if ( $module->dirname() != "system" && $module->isActivated() ) { echo "<span style='color:#00CC00;'>"._ACTIVE."</span></td>";
} elseif ( $module->dirname() != "system" ){ echo _INACTIVE."</td>"; 
} else { echo "<span style='color:#00CC00;'>"._ACTIVE."</span></td>"; }
echo "
<td><a href='javascript:openWithSelfMain(\"".XOOPS_URL."/modules/system/admin.php?fct=version&amp;mid=".$module->mid()."\",\"Info\",300,230);'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."editor_info.gif' border='0' alt='"._INFO."' /></a><input type='hidden' name='module[]' value='".$module->dirname()."' /></td>
</tr>";
$listed_mods[] = trim($module->dirname());
}
echo "
</table></td>
</tr></table><br />
<table border='0' cellpadding='0' cellspacing='0' valign='top' width='100%'><tr>
<td class='bg2'>
<table width='100%' border='0' cellpadding='4' cellspacing='1'><tr valign='middle' class='bg3' align='center'>
<td><b>"._MD_AM_MODULE."</b></td>
<td><b>"._MD_AM_ACTION."</b></td>
<td><b>"._MD_AM_ORDER."</b><br />"._MD_AM_ORDER0."</td>
<td><b>"._MD_AM_VERSION."</b></td>
<td><b>"._MD_AM_LASTUP."</b></td>
<td><b>"._INFO."</b></td></tr>";
// List inactive modules
$modules_dir = XOOPS_ROOT_PATH."/modules";
$handle = opendir($modules_dir);
while (false !== ($file = readdir($handle))) {
	if ( @is_dir($modules_dir."/".$file) && @file_exists($modules_dir."/".$file."/include/bcoos_module.php") ) {
		if ( !in_array(trim($file), $listed_mods) ) {
			$module = new XoopsModule();
			$module->loadModInfo($file);
echo "
<tr align='center' valign='middle' class='bg1'>
<td align='center' valign='bottom'>
".htmlspecialchars($module->name())."
<input type='hidden' name='name[]' value='" .htmlspecialchars($module->name())."' />
</td>
<td>
<input type='hidden' name='oldstatus[]' value='0' />
<select class='select' name='newstatus[]'>
<option value='nochange' selected='selected'>"._MD_AM_NOCHANGE."</option>
<option value='install'>"._INSTALL."</option>
</select>
</td>
<td>";
if ( $module->hasMain() ) {
	echo "
	<input type='hidden' name='oldweight[]' value='0' />
	<input type='text' class='text' name='weight[]' size='3' maxlength='5' value='1'/>";
	} else {
		echo "
		<input type='hidden' name='oldweight[]' value='0' />
		<input type='hidden' name='weight[]' value='0' />";
	}
echo "
</td>
<td align='center'>".$module->currentVersion()."</td>
<td align='center'>"._MD_AM_NOTINSTALLED."</td>
<td>
<a href='javascript:openWithSelfMain(\"".XOOPS_URL."/modules/system/admin.php?fct=version&amp;mid=".$module->dirname()."\",\"Info\",300,230);'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."editor_info.gif' border='0' alt='"._INFO."' /></a>
<input type='hidden' name='module[]' value='".$module->dirname()."' />
</td></tr>";
unset($module);
} // END in_array()
} // END ereg
} // END while
echo "
</table></td></tr>
<tr align='center'><td><br />
<input type='hidden' name='fct' value='modulesadmin' />
<input type='hidden' name='op' value='confirm' />
<input type='submit' class='button' name='submit' value='"._SUBMIT."' />
</td></tr></table>
</form>";
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_install($module) {
global $bcoosConfig, $xoopsUser, $db;
if ( !XoopsModule::moduleExists($module) ) {
	$mymodule = new XoopsModule();
	$mymodule->loadModInfo($module);
	$newmid   = $mymodule->install();
	//update the main menu cache
	if (!$newmid) {
		$ret  = "<p>".sprintf(_MD_AM_FAILINS, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br />";
		$errs = $mymodule->errors();
		foreach ($errs as $err) {
			$ret .= " - ".$err."<br />";
		}
		$ret .= "</p>";
		return $ret;
		} else {
			$mymodule = new XoopsModule($newmid);
			$result   = $mymodule->update();
			$groups   = $xoopsUser->groups();
			// retrieve all block ids for this module
			$blocks =& XoopsBlock::getByModule($newmid, false);
			foreach ($groups as $mygroup) {
				if ( XoopsGroup::checkRight("module", 0, $mygroup, "A") ) {
					$sql = "INSERT INTO ".$db->prefix("groups_modules_link")." SET groupid=$mygroup, mid=$newmid, type='A'";
					$db->query($sql);
					$sql = "INSERT INTO ".$db->prefix("groups_modules_link")." SET groupid=$mygroup, mid=$newmid, type='R'";
					$db->query($sql);
					foreach ($blocks as $blc) {
						$sql = "INSERT INTO ".$db->prefix("groups_blocks_link")." SET groupid=$mygroup, block_id=$blc, type='R'";
						$db->query($sql);
					}
				}
			}
		return "<p>".sprintf(_MD_AM_OKINS, "<b>".$mymodule->name()."</b>")."</p>";
		}
}
return "<p>".sprintf(_MD_AM_FAILINS, "<b>".$module."</b>")."&nbsp;"._ERROR.":<br /> - ".sprintf(_MD_AM_ALEXISTS, $module)."</p>";
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_uninstall($module) {
global $bcoosConfig, $_GET;
$mymodule =& XoopsModule::getByDirname($module);
if ($mymodule->dirname() == "system") {
	$msg = "<p>".
	sprintf(_MD_AM_FAILUNINS, "<b>".$mymodule->name()."</b>").
	"&nbsp;"._ERROR.":<br /> - "._MD_AM_SYSNO."</p>";
	return $msg;
	} elseif ($mymodule->dirname() == $bcoosConfig['startpage']) {
		$msg =  "<p>".
		sprintf(_MD_AM_FAILUNINS, "<b>".$mymodule->name()."</b>").
		"&nbsp;"._ERROR.":<br /> - "._MD_AM_STRTNO."</p>";
		return $msg;
		} else {
			if ( !$mymodule->uninstall() ) {
				$ret = "<p>".sprintf(_MD_AM_FAILUNINS, "<b>".$mymodule->name()."</b>").
				"&nbsp;"._ERROR.":<br />";
				$errs = $mymodule->errors();
				foreach($errs as $err) {
					$ret .= " - ".$err."<br />";
				}
			return $ret."</p>";
			}
	return "<p>".sprintf(_MD_AM_OKUNINS, "<b>".$mymodule->name()."</b>")."</p>";
	}
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_update($module) {
	global $bcoosConfig;
	$mymodule =& XoopsModule::getByDirname($module);
	if ( !$mymodule->update() ) {
		$ret = "<p>".sprintf(_MD_AM_FAILUPD, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br />";
		$errs = $mymodule->errors();
		foreach ( $errs as $err ) {
			$ret .= " - ".$err."<br />";
		}
		return $ret."</p>";
	}
	return "<p>".sprintf(_MD_AM_OKUPD, "<b>".$mymodule->name()."</b>")."</p>";
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_activate($module){
	global $bcoosConfig;
	$mymodule =& XoopsModule::getByDirname($module);
	if ( !$mymodule->activate() ) {
		$ret = "<p>".sprintf(_MD_AM_FAILACT, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br />";
		$errs = $mymodule->errors();
		foreach ( $errs as $err ) {
			echo " - ".$err."<br />";
		}
		return $ret."</p>";
	}
	return "<p>".sprintf(_MD_AM_OKACT, "<b>".$mymodule->name()."</b>")."</p>";
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_deactivate($module) {
global $bcoosConfig;
$mymodule =& XoopsModule::getByDirname($module);
if ($mymodule->dirname() == "system") {
	return "<p>".sprintf(_MD_AM_FAILDEACT, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br /> - "._MD_AM_SYSNO."</p>";
	} elseif ($mymodule->dirname() == $bcoosConfig['startpage']) {
		return "<p>".sprintf(_MD_AM_FAILDEACT, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br /> - "._MD_AM_STRTNO."</p>";
		} else {
			if ( !$mymodule->deactivate() ) {
				$ret = "<p>".sprintf(_MD_AM_FAILDEACT, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br />";
				$errs = $mymodule->errors();
				foreach ( $errs as $err ) {
					$ret .= " - ".$err."<br />";
				}
			return $ret."</p>";
			}
		return "<p>".sprintf(_MD_AM_OKDEACT, "<b>".$mymodule->name()."</b>")."</p>";
		}
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function module_order($module, $order){
global $bcoosConfig;
$mymodule =& XoopsModule::getByDirname($module);
if ( !$mymodule->changeOrder($order) ) {
	$ret = "<p>".sprintf(_MD_AM_FAILORDER, "<b>".$mymodule->name()."</b>")."&nbsp;"._ERROR.":<br />";
	$errs = $mymodule->errors();
	foreach ( $errs as $err ) {
		$ret .= " - ".$err."<br />";
	}
return $ret."</p>";
}
return "<p>".sprintf(_MD_AM_OKORDER, "<b>".$mymodule->name()."</b>")."</p>";
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function get_module_admin_menu() {
	global $bcoosConfig;
	/************************************************************
	 * Based on:
	 * - PHP Layers Menu 1.0.7(c)2001,2002 Marco Pratesi <pratesi@telug.it>
	 * - TreeMenu 1.1 - Bjorge Dijkstra <bjorge@gmx.net>
	 ************************************************************/
	$abscissa_step   = 90;	// step for the left boundaries of layers
	$abscissa_offset = 15;	// to choose the horizontal coordinate start offset for the layers
	$rightarrow      = "";
	// the following is to support browsers not detecting the mouse position
	$ordinata_step = 15;	// estimated value of the number of pixels between links on a layer
	$ordinata[1]   = (150-$ordinata_step);// to choose the vertical coordinate start offset for the layers
	$moveLayers      = array();
	$shutdown        = array();
	$firstleveltable = array();
	/*********************************************/
	/* read file to $tree array                  */
	/* tree[x][0] -> tree level                  */
	/* tree[x][1] -> item text                   */
	/* tree[x][2] -> item link                   */
	/* tree[x][3] -> link target                 */
	/* tree[x][4] -> module id                   */
	/*********************************************/
	$js       = "";
	$maxlevel = 0;
	$cnt      = 1;
	$mids     =& XoopsModule::getHasAdminModulesList(false);
	foreach ($mids as $mid) {
		$mod       = new XoopsModule($mid);
		$adminmenu = $mod->getAdminMenu();
		if ( !empty($adminmenu) || $mod->adminindex() ) {
			$tree[$cnt][0] = 1;
			$tree[$cnt][5] = $mod->name();
			$tree[$cnt][1] .= $mod->name();
			$tree[$cnt][2] = "\".XOOPS_URL.\"/modules/".$mod->dirname()."/".$mod->adminindex();
			$tree[$cnt][3] = "";
			$tree[$cnt][4] = $mid;
			$tree[$cnt][6] = "<b>"._VERSION.":</b> ".$mod->currentVersion()."<br /><b>"._DESCRIPTION.":</b> ".$mod->description()."";
			$layer_label[$cnt] = "L" . $cnt;
			if ( $tree[$cnt][0] > $maxlevel ) {
				$maxlevel = $tree[$cnt][0];
			}
			$cnt++;
			if ( !empty($adminmenu) ) {
				foreach ( $adminmenu as $menuitem ) {
					$menuitem['link'] = trim($menuitem['link']);
					$menuitem['target'] = trim($menuitem['target']);
					$tree[$cnt][0] = 2;
					$tree[$cnt][1] = trim($menuitem['title']);
					$tree[$cnt][2] = (empty($menuitem['link'])) ? "#" : "\".XOOPS_URL.\"/modules/".$mod->dirname()."/".$menuitem['link'];
					$tree[$cnt][3] = (empty($menuitem['target'])) ? "" : $menuitem['target'];
					$tree[$cnt][4] = $mid;
					$layer_label[$cnt] = "L" . $cnt;
					if ($tree[$cnt][0] > $maxlevel) {
						$maxlevel = $tree[$cnt][0];
					}
					$cnt++;
				}
			}
		}
	}
	$tmpcount = count($tree);
	$tree[$tmpcount+1][0] = 0;
	for ( $i = 0; $i < $maxlevel; $i++) {
		$abscissa[$i] = $i * $abscissa_step + $abscissa_offset;
	}
	for ( $cnt = 1; $cnt <= $tmpcount; $cnt++) {	// this counter scans all nodes
		// assign the layers name to the current hierarchical level,
		// to keep trace of the route leading to the current node on the tree
		$layername[$tree[$cnt][0]] = $layer_label[$cnt];
		// assign the starting vertical coordinates for all sublevels
		for ( $i = $tree[$cnt][0] + 1; $i < $maxlevel; $i++) {
			$ordinata[$i] = $ordinata[$i-1] + 1.5*$ordinata_step;
		}
		// increment the starting vertical coordinate for the current sublevel
		if ($tree[$cnt][0] < $maxlevel) {
			$ordinata[$tree[$cnt][0]] += $ordinata_step;
		}
		if ($tree[$cnt+1][0]>$tree[$cnt][0] && $cnt<$tmpcount) {
			// the node is not a leaf, hence it has at least a child
			// initialize the corresponding layer content trought a void string
			$layer[$layer_label[$cnt]] = "";
			// prepare the popUp function related to the children
	$js .= "\nfunction popUp" . $layer_label[$cnt] . "() {\n" . "shutdown();\n";
	$js .= "setleft('" . $layer_label[$cnt] . "'," . $abscissa[$tree[$cnt][0]] . ");\n";
			for ($i=1; $i<=$tree[$cnt][0]; $i++) {
				$js .= "popUp(\\\"" . $layername[$i] . "\\\", true);\n";
			}
			$js .= "}";
			// geometrical parameters are assigned to the new layer, related to the above mentioned children
			// $moveLayers[$tree[$cnt][4]] .= "setleft('" . $layer_label[$cnt] . "'," . $abscissa[$tree[$cnt][0]] . ");\n";
			$moveLayers[$tree[$cnt][4]] .= "settop('" . $layer_label[$cnt] . "'," . $ordinata[$tree[$cnt][0]] . ");";
			//$moveLayers[$tree[$cnt][4]] .= "setwidth('" . $layer_label[$cnt] . "'," . $abscissa_step . ");\n";
			// the new layer is accounted for in the shutdown() function
			$shutdown[$tree[$cnt][4]] .= "popUp('" . $layer_label[$cnt] . "', false);";
		}
		if ($tree[$cnt+1][0]>$tree[$cnt][0] && $cnt<$tmpcount) {
			// not a leaf
			$currentarrow = $rightarrow;
		} else {
			// a leaf
			$currentarrow = "";
		}
		/* */
		$currentlink = $tree[$cnt][2];
		/* */
		/*
		if ( $tree[$cnt+1][0] > $tree[$cnt][0] && $cnt < $tmpcount) {
		// not a leaf
			$currentlink = "#";
		} else {
		// a leaf
			$currentlink = $tree[$cnt][2];
		}
		*/
		if ($tree[$cnt][3] != "") {
			$currenttarget = " target='" . $tree[$cnt][3] . "'";
		} else {
			$currenttarget = "";
		}
		if ($tree[$cnt][0] > 1) {
			// the hierarchical level is > 1, hence the current node is not a child of the root node
			// handle accordingly the corresponding link, distinguishing if the current node is a leaf or not
			if ( $tree[$cnt+1][0] > $tree[$cnt][0] && $cnt < $tmpcount ) {	// not a leaf
				$onmouseover = " onMouseover='moveLayerY(\\\"" . $layer_label[$cnt] . "\\\", currentY) ; popUp" . $layer_label[$cnt] . "();";
			} else {	// a leaf
				$onmouseover = " onMouseover='popUp" . $layername[$tree[$cnt][0]-1] . "();";
			}
			$layer[$layername[$tree[$cnt][0]-1]] .= "<img src='\".XOOPS_URL.\"/images/icons/".$bcoosConfig['iconset']."menu_pointer.gif' />&nbsp;<a href='" . $currentlink . "'" . $onmouseover . "'" . $currenttarget . ">" .$tree[$cnt][1]. "</a>" . $currentarrow . "<br />\n";
		} elseif ($tree[$cnt][0] == 1) {
			// the hierarchical level is = 1, hence the current node is a child of the root node
			// handle accordingly the corresponding link, distinguishing if the current node is a leaf or not
			if ($tree[$cnt+1][0]>$tree[$cnt][0] && $cnt<$tmpcount) {
				// not a leaf
				$onmouseover = " onMouseover='moveLayerY(\\\"" . $layer_label[$cnt] . "\\\", currentY) ; popUp" . $layer_label[$cnt] . "();";
			} else {
				// a leaf
				$onmouseover = " onMouseover='shutdown();";
			}
			$firstleveltable[$tree[$cnt][4]] .= "<a href='" . $currentlink . "'" . $onmouseover . "'" . $currenttarget . ">" . $tree[$cnt][5] . "</a>" . $currentarrow . "<br />";
		}
	}	// end of the "for" cycle scanning all nodes
	$cellpadding = 10;
	$width = $abscissa_step - $cellpadding;
	$menu_layers = "";
	for ( $cnt = 1; $cnt <= $tmpcount; $cnt++ ) {
		if (!($tree[$cnt+1][0]<=$tree[$cnt][0])) {
			$menu_layers .= "
				<div id='".$layer_label[$cnt]."' style='position: absolute; visibility: hidden; z-index:1000;'>
				<table border='0' cellpadding='0' cellspacing='0' valign='top' width='".$abscissa_step."'><tr>
				<td class='bg2'>
				<table width='100%' border='0' cellpadding='4' cellspacing='1'><tr>
				<td class='bg3' align='center' nowrap='nowrap'><b>".$tree[$cnt][1]."</b></td>
				</tr><tr>
				<td class='bg1' nowrap='nowrap'>".$layer[$layer_label[$cnt]]."<br /></td>
				</tr><tr>
				<td class='bg3'>".$tree[$cnt][5]."<br />".$tree[$cnt][6]."</td>
				</tr></table></td>
				</tr></table></div>\n";
		}
	}
	$menu_layers .= "<script type='text/javascript'>\n<!--\nmoveLayers();\nloaded = 1;\n// -->\n</script>\n";
	$content = "<"."?php\n";
	$content .= "\$xoops_admin_menu_js = \"".$js."\";\n";
	foreach ( $moveLayers as $k => $v ){
		$content .= "\$xoops_admin_menu_ml[$k] = \"".$v."\";\n";
	}
	foreach ( $shutdown as $k => $v ){
		$content .= "\$xoops_admin_menu_sd[$k] = \"".$v."\";\n";
	}
	foreach ( $firstleveltable as $k => $v ){
		$content .= "\$xoops_admin_menu_ft[$k] = \"".$v."\";\n";
	}
	$content .= "\$xoops_admin_menu_dv = \"".$menu_layers."\";\n";
	$content .= "\n?".">";
	return $content;
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function write_module_admin_menu($content) {
$filename = XOOPS_ROOT_PATH."/modules/system/cache/adminmenu.php";
if ( !$file = fopen($filename, "w") ) {
	echo "open fail fail";
	return false;
}
if ( fwrite($file, $content) == -1 ) {
	echo "write fail";
	return false;
}
fclose($file);
return true;
}
//---------------------------------------------------------------------------------------//
	} else {
		redirect_header(XOOPS_URL."/", 3, _NOPERM);
	}
?>
