<?php

/*
 *	W-AGORA 4.0
 *	-----------
 *	$Id: admin.php,v 1.37 2005/12/21 11:13:48 mdruilhe Exp $
 *	Usage:		Administration of w-agora - Main entry page => choose a site
 *	Author:		Marc Druilhe <mdruilhe@w-agora.com>
 */	

	include ('globals.inc');

# if site has been selected : redirect to admin_site
# --------------------------------------------------
	if (!empty($site) && ($site!="agora") ) {
		header ("Location: admin_site.$ext?site=$site");
		exit;
	}

	if (!empty($bn) ) {
		header ("Location: admin_forum.$ext?site=$site&bn=$bn");
		exit;
	}

# ¨No site defined => default to "agora" main site
# ------------------------------------------------
	$site="agora";
	define("no_auth_required", 1);
	include ("init_admin.inc");

# read site administration configuration
# --------------------------------------
	include ("$site_cfg_file");
	if (empty($bn_msgs) ) {
		include ("$bn_dir_default/site_msgs.$ext");
	} else {
		include "$bn_dir/$bn_msgs";
	}

	display_header (TITLE_SITE_MANAGEMENT);

# list all sites from the main database
# -------------------------------------
	$WA_SELF = "admin_site.$ext";
	$sites = $db->listForums ("agora");
	if (is_array($sites)) {
		$label_wa = LABEL_AGORA_WEBSITE;
		echo "<table border=0 width=\"100%\"><tr><td width=\"200\" valign=\"top\">";
		echo "<center><a href=\"http://www.w-agora.net\" target=\"_top\"><img src=\"images/logo1_admin.jpg\" border=\"0\" alt=\"$label_wa\"></a></center><br />";
		echo "<center><a href=\"index.$ext?about\">W-Agora infos</a></center><br />";

		$languages = array(
			"fr" => "W-Agora en français",
			"en" => "W-Agora in english",
			"de" => "W-Agora in deutsch",
			"ja" => "W-Agora in Japanese",
			"da" => "W-Agora p&aring; dansk",
			"it" => "W-Agora in italiano",
			"pl" => "W-Agora in polish",
			"nl" => "W-Agora in dutch",
			"sv" => "W-Agora in swedish",
			"ru" => "W-Agora in russian",
			"ca" => "W-Agora in catalan",
			"es" => "W-Agora en español",
			"he" => "W-Agora in hebrew",
			"hu" => "W-Agora in hungarian"
		);

		$i = 0;
		foreach($languages as $lg=>$text) {
			$i++;
			$flags .= anchor("admin.$ext?lang=$lg", "", "<img height=\"16\" width=\"30\" src=\"images/flag_$lg.png\" border=\"0\" alt=\"$text\">", "$text") . "&nbsp;";
			if (($i%6) == 0) {
				$flags .= "<br /><br />";
			}	 
		}

		echo "<table width=\"90%\"><tr>";
		echo "<td align=\"center\" valign=\"middle\">$flags</td>";
		echo "</tr></table><br />";

		left_menu_header("<img src=\"$icon_dir/add_folder.gif\" align=\"middle\" width=\"18\" height=\"18\" border=\"0\"> " . LABEL_CREATE_SITE);
		left_menu_item ("create_site.$ext", '_self', LABEL_CREATE_SITE, LABEL_CREATE_SITE);
		left_menu_footer();

		left_menu_header("<img src=\"$icon_dir/edit_folder.gif\" align=\"middle\" width=\"15\" height=\"15\" border=\"0\" alt=\"". TITLE_SITE_OUTLINE. '"> '.TITLE_SITE_OUTLINE);
		left_menu_item ("editconf.$ext?site=agora&editsite=1", '_self', LABEL_SITECONF, LABEL_SITECONF);
		left_menu_item ("editform.$ext?site=agora&file=header", '_self', LABEL_HEADER, LABEL_HEADER);
		left_menu_item ("editlist.$ext?site=agora", '_self', LABEL_SITES_OUTLINE, LABEL_SITES_OUTLINE);
		left_menu_item ("editform.$ext?site=agora&file=footer", '_self', LABEL_FOOTER, LABEL_FOOTER);
		left_menu_item ("editform.$ext?site=agora&file=style", '_self', LABEL_STYLESHEET, LABEL_STYLESHEET);
		left_menu_footer();
?>
<br />
<hr noshade="noshade">
<center>
<br /><A HREF="http://www.hotscripts.com/Detailed/2287.html?RID=10467"><img src="http://images.hotscripts.com/dynamic/rating.gif?2287"  width="120" height="90" border="0" alt="Please, rate w-agora at HotScripts.com"></a>
	<br /><br />
<a href="http://sourceforge.net/projects/w-agora"><img src="http://sourceforge.net/sflogo.php?group_id=3413&type=1" width="88" height="31" border="0" alt="Project hosted at SourceForge"></a><br />
</center>

<?php 

		echo "</td><td>";
		table_header(
			LABEL_SITES_AVAILABLE . "<div align=\"right\">&nbsp;&nbsp;&nbsp;<a href=\"create_site.$ext\"><img src=\"$icon_dir/add_folder.gif\" align=\"absmiddle\" width=\"18\" height=\"18\" border=\"0\"> " . LABEL_CREATE_SITE . "</a></div>");
		echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"0\">";
		echo "<tr><th align=\"left\">" . COLUMN_NAME . "</th><th align=\"left\">" . COLUMN_SITE_TITLE . "</th><th align=\"center\">" . COLUMN_DELETE . "</th><th align=\"center\">" . COLUMN_EDIT . "</th></tr>";

		reset($sites);
		while (list($name, $site) = each($sites)) {
			$title = $site["bn_title"];
			$descr = $site["descr"];
			$bn_name = $site["bn_name"];
			echo "<tr><td width=\"20%\">";
			displayUrl ("admin_site.${ext}?site=$bn_name&bn=", "", "<img src=\"images/folder.gif\" width=\"16\" height=\"16\" border=\"0\" valign=\"absmiddle\"> $name");
			echo "</td><td><dt>$title</dt><dd><font size=\"1\">$descr</font></dd></td><td align=\"center\" valign=\"middle\">";
			displayUrl ("delete_site.${ext}?site=$bn_name&bn=", "", "<img src=\"images/icons/delete_folder.gif\" align=\"absmiddle\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . sprintf (ALT_DELETE_SITE, $bn_name). "\">");
			echo "</td><td align=\"center\" valign=\"middle\">";
			displayUrl ("edit_site.$ext?site=$bn_name&bn=", "", "<img src=\"$icon_dir/edit_folder.gif\" width=\"15\" height=\"15\" border=\"0\" align=\"absmiddle\" alt=\"" . sprintf (ALT_EDIT_SITE, $bn_name). "\">");
			echo "</td></tr>\n";
		}
		echo "</table>";
		echo "</td></tr></table>";
		table_footer();
	} else {
		msgForm (ERROR_NO_SITE, "create_site.${ext}");
	}
?>
