<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.2 www.exoops.info 2006/03 
// $Id: index.php,v 1.10 2003/03/02 23:52:57 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: James Knickelbein
// Author Website : http://www.journeymilwaukee.com
// Licence Type   : GPL
// ------------------------------------------------------------------------- //
include_once("admin_header.php");
$eh     = new ErrorHandler(0);
$mytree = new XoopsTree($db->prefix("adresses_cat"), "cid", "pid");
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function adresses() {
global $db;
xoops_cp_header();
OpenTable();
// Temporarily 'homeless' adresses (to be revised in index.php breakup) Disabled for adresses
//$result = $db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_broken")."");
//list($totalbrokenadresses) = $db->fetch_row($result);
//if ($totalbrokenadresses > 0) {
//	$totalbrokenadresses = "<span style='font-weight: bold'>$totalbrokenadresses</span>";
//}
$result2 = $db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_mod")."");
list($totalmodrequests) = $db->fetchRow($result2);
if ($totalmodrequests > 0) {
	$totalmodrequests = "<span style='font-weight: bold'>$totalmodrequests</span>";
}
$result3 = $db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_adresses")." WHERE status=0");
list($totalnewadresses) = $db->fetchRow($result3);
if ($totalnewadresses > 0) {
	$totalnewadresses = "<span style='font-weight: bold'>$totalnewadresses</span>";
}
?>
- <a href="index.php?op=adressesConfigAdmin"><?php echo _GENERALSETTINGS;?></a>
<br /><br />
- <a href="index.php?op=adressesConfigMenu"><?php echo _ADDMODIFYDELETECATEGORIESFILES;?></a>
<br /><br />
- <a href="index.php?op=listNewadresses"><?php echo _MD_ADRESSWAITING;?> (<?php echo $totalnewadresses;?>)</a>
<br /><br />
<!--DISABLED - <a href="index.php?op=listBrokenadresses"><?php echo _BROKENFILEREPORTS;?> (<?php echo $totalbrokenadresses;?>)</a>
<br /><br /> -->
- <a href="index.php?op=listModReq"><?php echo _MODIFICATIONREQUESTS;?> (<?php echo $totalmodrequests;?>)</a>
<?php
$result = $db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_adresses")." WHERE status>0");
list($numrows) = $db->fetchRow($result);
echo "<br /><br /><div align='center'>";
printf(_MD_THEREARE, $numrows);
echo "</div>";
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function listNewadresses() {
global $db, $myts, $eh, $mytree;
// List adresses waiting for validation
$result  = $db->query("SELECT lid, cid, title, description, url, homepage, adres, zip, city, country, phone, mobile, fax, email, opentime, banner, logourl, submitter FROM ".$db->prefix("adresses_adresses")." WHERE status=0 ORDER BY date DESC");
$numrows = $db->getRowsNum($result);
xoops_cp_header();
OpenTable();
echo "<h4>"._MD_ADRESSWAITING." ($numrows)</h4><br />";
if ($numrows > 0) {
	while (list($lid, $cid, $title, $description, $url, $homepage, $adres, $zip, $city, $country, $phone, $mobile, $fax, $email, $opentime, $banner, $logourl, $uid) = $db->fetchRow($result)) {
		$title       = $myts->makeTboxData4Edit($title);
		$url         = $myts->makeTboxData4Edit($url);
		$homepage    = $myts->makeTboxData4Edit($homepage);
		$adres       = $myts->makeTboxData4Edit($adres);
        $zip         = $myts->makeTboxData4Edit($zip);
        $city        = $myts->makeTboxData4Edit($city);
        $country     = $myts->makeTboxData4Edit($country);
        $phone       = $myts->makeTboxData4Edit($phone);
        $mobile      = $myts->makeTboxData4Edit($mobile);
        $fax         = $myts->makeTboxData4Edit($fax);
        $email       = $myts->makeTboxData4Edit($email);
        $opentime    = $myts->makeTboxData4Edit($opentime);
        $banner      = $myts->makeTboxData4Edit($banner);
		$logourl     = $myts->makeTboxData4Edit($logourl);
		$description = $myts->makeTboxData4Edit($description);
		if ($uid != 0) {
			$submitter = XoopsUser::getUnameFromId($uid);
			$submitter = $myts->makeTboxData4Show($submitter);
		}
?>
<form action="index.php" method="post">
<table width="100%">
<tr><td nowrap><b><?php echo _SUBMITTER;?>:</b></td>
<td><a href="<?php echo XOOPS_URL;?>/userinfo.php?uid=<?php echo $uid;?>"><?php echo $submitter;?></a></td>
</tr><tr>
<td nowrap><b><?php echo _MD_ADRESSTITLE;?>:</b></td>
<td><input type="text" class="text" name="title" size="50" maxlength="100" value="<?php echo $title;?>"></td>
</tr><!-- DISABLED <tr>
<td nowrap><?php echo _DOWNLOADURL;?></td>
<td><input type="text" class="text" name="url" size="50" maxlength="255" value="<?php echo $url;?>"> [ <a href="<?php echo formatURL(XOOPS_URL."/modules/adresses/cache/files/", $url);?>"><?php echo _DOWNLOAD;?></a> ]</td>
</tr> --><tr>
<td nowrap><b><?php echo _CATEGORY.': ';?>:</b></td>
<td><?php $mytree->makeMySelBox("title", "title", $cid);?></td>
</tr><tr>
<td><?php echo _MD_ADRESC;?></td>
<td><input type="text" class="text" name="adres" size="60" maxlength="100" value="<?php echo $adres;?>"></td>
</tr><tr>
<td><?php echo _MD_ZIPC;?></td>
<td><input type="text" class="text" name="zip" size="15" maxlength="15" value="<?php echo $zip;?>"></td>
</tr><tr>
<td><?php echo _MD_CITYC;?></td>
<td><input type="text" class="text" name="city" size="60" maxlength="80" value="<?php echo $city;?>"></td>
</tr><tr>
<td><?php echo _MD_COUNTRYC;?></td>
<td><input type="text" class="text" name="country" size="60" maxlength="80" value="<?php echo $country;?>"></td>
</tr><tr>
<td><?php echo _MD_PHONEC;?></td>
<td><input type="text" class="text" name="phone" size="40" maxlength="50" value="<?php echo $phone;?>"></td>
</tr><tr>
<td><?php echo _MD_MOBILEC;?></td>
<td><input type="text" class="text" name="mobile" size="40" maxlength="50" value="<?php echo $mobile;?>"></td>
</tr><tr>
<td><?php echo _MD_FAXC;?></td>
<td><input type="text" class="text" name="fax" size="40" maxlength="50" value="<?php echo $fax;?>"></td>
</tr><tr>
<td><?php echo _EMAIL.':';?></td>
<td><input type="text" class="text" name="email" size="60" maxlength="80" value="<?php echo $email;?>"></td>
</tr><tr>
<td nowrap><b><?php echo _SITEURL;?>:</b></td>
<td><input type="text" class="text" name="homepage" size="50" maxlength="255" value="<?php echo $homepage;?>"> [ <a href="<?php echo $homepage;?>"><?php echo _VISIT;?></a> ]</td>
</tr><tr>
<td colspan="2">&nbsp;</td>
</tr><tr>
<td nowrap><b><?php echo _MD_OPENTIMEC;?></b></td>
<td><textarea cols="40" rows="4" class="text" name="opentime" value="<?php echo $opentime;?>"></textarea></td>
</tr><tr>
<td valign="top" nowrap><b><?php echo _DESCRIPTION.':';?>:</b></td>
<td>
<?php
$desc = new XoopsFormDhtmlTextArea('', 'filedesc', $description, 10, 50);
echo $desc->render();
?>
</td>
</tr><tr>
<td><?php echo _MD_SHOTIMAGEC;?></td>
<td><input type="text" class="text" name="logourl" size="50" maxlength="255" value="<?php echo $logourl;?>"> [ <a href="<?php echo $logourl;?>"><?php echo _VISIT;?></a> ]</td>
</tr><!-- DISABLED<tr>
<td><?php echo _MD_BANNERC;?></td>
<td><input type="text" class="text" name="banner" size="50" maxlength="255" value="<?php echo $banner;?>"> [ <a href="<?php echo $banner;?>"><?php echo _VISIT;?></a> ]</td>
</tr> --><tr>
<td align="right">
<input type="hidden" name="op" value="approve">
<input type="hidden" name="lid" value="<?php echo $lid;?>">
<input type="submit" class="button" value="<?php echo _APPROVE;?>">
</form></td>
<td align="left"><?php echo myTextForm("index.php?op=delNewAdress&lid=$lid", _DELETE);?></td>
</tr></table>
<?php
	}
	} else {
		echo _NONEWSUBMITTED;
	}
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function adressesConfigMenu() {
global $db, $myts, $eh, $mytree;
xoops_cp_header();
$result=$db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_cat")."");
list($numrows) = $db->fetchRow($result);
if ($numrows > 0) {
	OpenTable();
	// If there is a category, add a New Adres
?>
<form method="post" action="index.php" enctype="multipart/form-data">
<h4><?php echo _ADDCONTENT;?></h4><br />
<table width="100%"><tr>
<td align="right" ><b><?php echo _MD_ADRESSTITLE;?></b></td>
<td><input type="text" class="text" name="title" size="50" maxlength="100" /></td>
</tr><!-- DISABLED <tr>
<td valign="top" nowrap><?php echo _DOWNLOADURL;?></td>
<td>
<input type="text" class="text" name="url" size="50" maxlength="255" />
<?php
echo "<br />";
?>
</td>
</tr><tr>
<td>&nbsp;</td>
<td><?php printf(_MD_FILE, "modules/adresses/cache/files/");?></td>
</tr> --><tr>
<td align="right" ><b><?php echo _CATEGORY.': ';?></b></td>
<td><?php $mytree->makeMySelBox("title", "title");?></td>
</tr><tr>
<td align="right" nowrap><b>*<?php echo _MD_ADRESC;?></b></td>
<td><input type="text" class="text" name="adres" size="60" maxlength="100"></td>
</tr><tr>
<td align="right" nowrap><b>*<?php echo _MD_ZIPC;?></b></td>
<td><input type="text" class="text" name="zip" size="15" maxlength="15"></td>
</tr><tr>
<td align="right" nowrap><b>*<?php echo _MD_CITYC;?></b></td>
<td><input type="text" class="text" name="city" size="60" maxlength="80"></td>
</tr><tr>
<td align="right" nowrap><b>*<?php echo _MD_COUNTRYC;?></b></td>
<td><input type="text" class="text" name="country" size="60" maxlength="80"></td>
</tr><tr>
<td align="right" nowrap><b><?php echo _MD_PHONEC;?></b></td>
<td><input type="text" class="text" name="phone" size="40" maxlength="50"></td>
</tr><tr>
<td align="right" nowrap><b><?php echo _MD_MOBILEC;?></b></td>
<td><input type="text" class="text" name="mobile" size="40" maxlength="50"></td>
</tr><tr>
<td align="right" nowrap><b><?php echo _MD_FAXC;?></b></td>
<td><input type="text" class="text" name="fax" size="40" maxlength="50"></td>
</tr><tr>
<td align="right" nowrap><b><?php echo _EMAIL.':';?></b></td>
<td><input type="text" class="text" name="email" size="60" maxlength="80"></td>
</tr><tr>
<td align="right" ><b><?php echo _SITEURL;?></b></td>
<td><input type="text" class="text" name="homepage" size="50" maxlength="255" value="http://"></td>
</tr><tr>
<td colspan="2">&nbsp;</td>
</tr><tr>
<td align="right" Valign="top" nowrap><b><?php echo _MD_OPENTIMEC;?></b></td>
<td><textarea cols="40" rows="4" class="text" name="opentime"></textarea></td>
</tr><tr>
<td align="right" valign="top" nowrap><b><?php echo _DESCRIPTION.':';?></b></td>
<td>
<?php
$desc = new XoopsFormDhtmlTextArea('', 'filedesc', '', 10, 50);
echo $desc->render();
?>
</td>
</tr><tr>
<td align="right" valign="top" nowrap><b><?php echo _SHOTIMAGE;?></b></td>
<td>
<input type="text" class="text" name="logourl" size="50" maxlength="255">
<?php
echo "<br />";
$upload = new Upload();
$upload->printFormField("image");
?>
</td>
</tr><tr>
<td>&nbsp;</td>
<td><?php printf(_SHOTDESCRIPTION, "modules/adresses/cache/images/shots/");?></td>
</tr><!-- DISABLED<tr>
<td align="right" nowrap><b><?php echo _MD_BANNERC;?></b></td>
<td><input type="text" class="text" name="banner" size="50" maxlength="255" value="http://"></td>
</tr> --></table>
<br />
<input type="hidden" name="op" value="addAdress" />
<input type="submit" class="button" value="<?php echo _ADD;?>" />
</form>
<?php
CloseTable();
echo "<br />";
OpenTable();
// Modify Adres
?>
<form method="post" action="index.php">
<h4><?php echo _MODIFYCONTENTINFO;?></h4>
<?php echo _FILEID;?>
<input type="text" class="text" name="lid" size="12" maxlength="11">
<input type="hidden" name="fct" value="adresses">
<input type="hidden" name="op" value="modAdresses">
<input type="submit" class="button" value="<?php echo_MODIFY;?>">
</form>
<?php
CloseTable();
echo "<br />";
OpenTable();
// Modify Category
?>
<form method="post" action="index.php">
<h4><?php echo _MODIFYCATEGORY;?></h4>
<?php echo _CATEGORY.': ';?>
<?php $mytree->makeMySelBox("title", "title");?>
<input type="hidden" name="op" value="modCat">
<input type="submit" class="button" value="<?php echo _MODIFY;?>">
</form>
<?php
CloseTable();
echo "<br />";
OpenTable();
// Add a New Sub-Category
?>
<form method="post" action="index.php">
<h4><?php echo _ADDSUBCATEGORY;?></h4>
<?php echo _TITLE.':';?>
<input type="text" class="text" name="title" size="30" maxlength="50">
<?php echo _IN;?>
<?php $mytree->makeMySelBox("title", "title");?>
<input type="hidden" name="op" value="addCat">
<input type="submit" class="button" value="<?php echo _ADD;?>">
</form>
<?php
CloseTable();
echo "<br />";
}
// Add a New Main Category
OpenTable();
?>
<form method="post" action="index.php">
<h4><?php echo _MD_ADDMAIN;?></h4>
<?php echo _TITLE.':';?>
<input type="text" class="text" name="title" size="30" maxlength="50">
<input type="hidden" name="op" value="addCat">
<input type="submit" class="button" value="<?php echo _ADD;?>">
</form>
<?php
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function delVote() {
global $db, $_GET, $eh;
$rid = intval($_GET['rid']);
$lid = intval($_GET['lid']);
$query = "DELETE FROM ".$db->prefix("adresses_votedata")." WHERE ratingid=$rid";
$db->query($query) or $eh->show("0013");
updaterating($lid);
redirect_header("index.php", 1, _MD_VOTEDELETED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description Broken Adres. You have to delete this part for adresses
*
* @param type $var description
* @return type description
*/
function listBrokenadresses() {
global $db, $myts, $eh;
$result = $db->query("SELECT reportid, lid, sender, ip FROM ".$db->prefix("adresses_broken")." ORDER BY reportid");
$totalbrokenadresses = $db->getRowsNum($result);
xoops_cp_header();
OpenTable();
echo "<h4>"._BROKENFILEREPORTS." ($totalbrokenadresses)</h4><br />";
if ($totalbrokenadresses == 0) {
	echo _NOBROKENREPORTS;
	} else {
		$colorswitch = "bg1";
		?>
		<center><?php echo _ONLYDELETEREPORT;?><br /><?php echo _DELETEDATAANDREPORT;?></center>
		<br /><br /><br />
		<table align="center" width="90%"><tr>
		<td><b><?php echo _TITLE.': ';?></b></td>
		<td><b><?php echo _REPORTER;?></b></td>
		<td><b><?php echo _SUBMITTER;?></b></td>
		<td><b><?php echo _IGNORE;?></b></td>
		<td><b><?php echo _EDIT;?></b></td>
		<td><b><?php echo _DELETE;?></b></td>
		</tr>
		<?php
while (list($reportid, $lid, $senderid, $ip) = $db->fetchRow($result)) {
	$result2 = $db->query("SELECT title, url, submitter FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid");
	list($title, $url, $ownerid) = $db->fetchRow($result2);
	$title = $myts->makeTboxData4Show($title);
	if ($senderid != 0) {
		$sender = XoopsUser::getUnameFromId($senderid);
		$sender = $myts->makeTboxData4Show($sender);
	}
	if ($ownerid != 0) {
		$owner = XoopsUser::getUnameFromId($ownerid);
		$owner = $myts->makeTboxData4Show($owner);
	}
	echo "
	<tr>
	<td class='$colorswitch'><a href='".formatURL(XOOPS_URL."/modules/adresses/cache/files/", $url)."'>$title</a></td>
	<td class='$colorswitch'><a href='".XOOPS_URL."/userinfo.php?uid=$senderid'>$sender</a> ($ip)</td>
	<td class='$colorswitch'><a href='".XOOPS_URL."/userinfo.php?uid=$ownerid'>$owner</a></td>
	<td class='$colorswitch' align='center'>";
	echo myTextForm("index.php?op=ignoreBrokenadresses&lid=$lid" , "X");
	echo "</td><td class='$colorswitch' align='center'>";
	echo myTextForm("index.php?op=modAdresses&lid=$lid" , "X");
	echo "</td><td class='$colorswitch' align='center'>";
	echo myTextForm("index.php?op=delBrokenadresses&lid=$lid" , "X");
	echo "</td></tr>";
	if ($colorswitch == "bg1") {
		$colorswitch = "bg3";
		} else {
			$colorswitch="bg1";
		}
	}
	echo "</table>";
}
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description Broken Adres. You have to delete this part for adresses
*
* @param type $var description
* @return type description
*/
function delBrokenadresses() {
global $db, $_GET, $eh;
$lid = intval($_GET['lid']);
$query = "DELETE FROM ".$db->prefix("adresses_broken")." WHERE lid=$lid";
$db->query($query) or $eh->show("0013");
$query  = "SELECT url, logourl FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid";
$result = $db->query($query);
list($url, $logourl) = $db->fetchRow($result);
@unlink("../cache/files/" . basename($url));
@unlink("../cache/shots/" . basename($logourl));
$query = "DELETE FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid";
$db->query($query) or $eh->show("0013");
build_rss();
redirect_header("./index.php?op=listBrokenadresses", 1, _MD_FILEDELETED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description Broken Adres. You have to delete this part for adresses
*
* @param type $var description
* @return type description
*/
function ignoreBrokenadresses() {
global $db, $_GET, $eh;
$lid   = intval($_GET['lid']);
$query = "DELETE FROM ".$db->prefix("adresses_broken")." WHERE lid=$lid";
$db->query($query) or $eh->show("0013");
redirect_header("./index.php?op=listBrokenadresses", 1, _BROKENFILEREPORTDELETED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function listModReq() {
global $db, $myts, $eh, $mytree, $adressesConfig;
xoops_cp_header();
OpenTable();
$sql_mod = $db->query("SELECT requestid, lid, cid, title, description, url, homepage, adres, zip, city, country, phone, mobile, fax, email, opentime, banner, modifysubmitter FROM ".$db->prefix("adresses_mod")." ORDER BY requestid");
$totalmodrequests = $db->getRowsNum($sql_mod);
echo "<h4>"._USERMODIFICATIONREQUEST." ($totalmodrequests)</h4><br />";
if ($totalmodrequests > 0) {
	while (list($requestid, $lid, $cid, $title, $description, $url, $homepage, $adres, $zip, $city, $country, $phone, $mobile, $fax, $email, $opentime, $banner, $logourl, $modifysubmitter) = $db->fetchRow($sql_mod)) {
		$cidtitle      = $mytree->getNicePathFromId($cid, "title", XOOPS_URL."/modules/adresses/viewcat.php?");
		$cidtitle      = substr($cidtitle, 0, -2);
		$title         = $myts->makeTboxData4Show($title);
		$url           = formatURL(XOOPS_URL."/modules/adresses/cache/files/", $myts->makeTboxData4Show($url));
		$homepage      = $myts->makeTboxData4Show($homepage);
		$adres       = $myts->makeTboxData4Show($adres);
        $zip         = $myts->makeTboxData4Show($zip);
        $city        = $myts->makeTboxData4Show($city);
        $country     = $myts->makeTboxData4Show($country);
        $phone       = $myts->makeTboxData4Show($phone);
        $mobile      = $myts->makeTboxData4Show($mobile);
        $fax         = $myts->makeTboxData4Show($fax);
        $email       = $myts->makeTboxData4Show($email);
        $opentime    = $myts->makeTboxData4Show($opentime);
        $banner      = $myts->makeTboxData4Show($banner);
        $logourl     = $myts->makeTboxData4Show($logourl);
		$description   = $myts->makeTareaData4Show($description);
		if ($modifysubmitter != 0) {
			$submittername = XoopsUser::getUnameFromId($modifysubmitter);
			$submittername = $myts->makeTareaData4Show($submittername);
		}
		$sql_original = $db->query("SELECT cid, title, description, url, homepage, adres, zip, city, country, phone, mobile, fax, email, opentime, banner, logourl, submitter FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid");
		list($origcid, $origtitle, $origdescription, $origurl, $orighomepage, $origadres, $origzip, $origcity, $origcountry, $origphone, $origmobile, $origfax, $origemail, $origopentime, $origbanner, $origlogourl, $owner) = $db->fetch_row($sql_original);
		$origcidtitle    = $mytree->getNicePathFromId($origcid, "title", XOOPS_URL."/modules/adresses/viewcat.php?");
		$origcidtitle    = substr($origcidtitle, 0, -2);
		$origtitle       = $myts->makeTboxData4Show($origtitle);
		$origurl         = formatURL(XOOPS_URL."/modules/adresses/cache/files/", $myts->makeTboxData4Show($origurl));
		$orighomepage    = $myts->makeTboxData4Show($orighomepage);
		$origadres       = $myts->makeTboxData4Show($origadres);
        $origzip         = $myts->makeTboxData4Show($origzip);
        $origcity        = $myts->makeTboxData4Show($origcity);
        $origcountry     = $myts->makeTboxData4Show($origcountry);
        $origphone       = $myts->makeTboxData4Show($origphone);
        $origmobile      = $myts->makeTboxData4Show($origmobile);
        $origfax         = $myts->makeTboxData4Show($origfax);
        $origemail       = $myts->makeTboxData4Show($origemail);
        $origopentime    = $myts->makeTboxData4Show($origopentime);
        $origbanner      = $myts->makeTboxData4Show($origbanner);
		$origlogourl      = $myts->makeTboxData4Show($origlogourl);
		$origdescription = $myts->makeTareaData4Show($origdescription);
		if ($owner != 0) {
			$ownername       = XoopsUser::getUnameFromId($owner);
			$ownername       = $myts->makeTareaData4Show($ownername);
		}
?>
<hr align="center" size="1" noshade="noshade" />
<table width="100%" cellspacing="0" cellpadding="0"><tr>
<td valign="top"><b><?php echo _PROPOSED;?></b></td>
<td width="20%" valign="top">&nbsp;</td>
</tr><tr>
<td valign="top"><b><?php echo _MD_ADRESSTITLE;?></b> <?php echo $title;?></td>
</tr><!-- DISABLED <tr>
<td valign="top"><b><?php echo _DOWNLOADURL;?>:</b> <a href="<?php echo $url;?>" ><?php echo $url;?></a></td>
</tr> --><tr>
<td valign="top"><b><?php echo _CATEGORY.': ';?></b> <?php echo $cidtitle;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_ADRESC;?></b> <?php echo $adres;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_ZIPC;?></b> <?php echo $zip;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_CITYC;?></b> <?php echo $city;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_COUNTRYC;?></b> <?php echo $country;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_PHONEC;?></b> <?php echo $phone;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_MOBILEC;?></b> <?php echo $mobile;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_FAXC;?></b> <?php echo $fax;?></td>
</tr><tr>
<td valign="top"><b><?php echo _EMAIL.':';?></b> <?php echo $email;?></td>
</tr><tr>
<td valign="top"><b><?php echo _SITEURL;?> <a href="<?php echo $homepage;?>"><?php echo $homepage;?></a>:</b></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_OPENTIMEC;?></b> <?php echo $opentime;?></td>
</tr><tr>
<td valign="top"><b><?php echo _DESCRIPTION.':';?></b> <?php echo $description;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_SHOTIMAGEC;?></b> <a href="<?php echo $origlogourl;?>"><?php echo $origlogourl;?></a></b></td>
</tr><!-- DISABLED <tr>
<td valign="top"><b><?php echo _MD_BANNERC;?>:</b> <?php echo $banner;?></td>
</tr> --><tr>
<td colspan="2">&nbsp;</td>
</tr><tr>
<td valign="top"><b><?php echo _ORIGINAL;?></b></td>
<td width="20%" valign="top">&nbsp;</td>
</tr><tr>
<td valign="top"><b><?php echo _MD_ADRESSTITLE;?></b> <?php echo $origtitle;?></td>
</tr><!-- DISABLED <tr>
<td valign="top"><small><?php echo _DOWNLOADURL;?> <a href="<?php echo $origurl;?>"><?php echo $origurl;?></a></td>
</tr> --><tr>
<td valign="top"><b><?php echo _CATEGORY.': ';?></b> <?php echo $origcidtitle;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_ADRESC;?></b> <?php echo $origadres;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_ZIPC;?></b> <?php echo $origzip;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_CITYC;?></b> <?php echo $origcity;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_COUNTRYC;?></b> <?php echo $origcountry;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_PHONEC;?></b> <?php echo $origphone;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_MOBILEC;?></b> <?php echo $origmobile;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_FAXC;?></b> <?php echo $origfax;?></td>
</tr><tr>
<td valign="top"><b><?php echo _EMAIL.':';?></b> <?php echo $origemail;?></td>
</tr><tr>
<td valign="top"><b><?php echo _SITEURL;?></b> <a href="<?php echo $orighomepage;?>"><?php echo $orighomepage;?></a></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_OPENTIMEC;?></b> <?php echo $origopentime;?></td>
</tr><tr>
<td valign="top"><b><?php echo _DESCRIPTION.':';?></b> <?php echo $origdescription;?></td>
</tr><tr>
<td valign="top"><b><?php echo _MD_SHOTIMAGEC;?></b> <a href="<?php echo $origlogourl;?>"><?php echo $origlogourl;?></a></td>
</tr><!-- DISABLED <tr>
<td valign="top"><b><?php echo _MD_BANNERC;?>:</b> <?php echo $origbanner;?></td>
</tr> --><tr align="center">
<td colspan="2">
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
<td valign="top" width="35%"><small><?php echo _SUBMITTER;?> <a href="<?php echo XOOPS_URL;?>/userinfo.php?uid=<?php echo $modifysubmitter;?>"><?php echo $submittername;?></a></small></td>
<td valign="top" width="35%"><small><?php echo _OWNER;?> <a href="<?php echo XOOPS_URL;?>/userinfo.php?uid=<?php echo $owner;?>"><?php echo $ownername;?></a></small></td>
<td valign="top" width="5%"><?php echo myTextForm("index.php?op=changeModReq&requestid=$requestid" , _APPROVE);?></td>
<td valign="top" width="5%"><?php echo myTextForm("index.php?op=modAdresses&lid=$lid" , _EDIT);?></td>
<td valign="top" width="5%"><?php echo myTextForm("index.php?op=ignoreModReq&requestid=$requestid", _IGNORE);?></td>
</tr></table>
</td>
</tr></table>
<?php
	}
	} else {
		echo _NOMODIFICATIONREQUEST;
	}
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function changeModReq() {
global $db, $_GET, $eh, $myts;
$requestid = intval($_GET['requestid']);
$sql = "SELECT
	lid,
	cid,
	title,
	url,
	homepage,
	adres,
	zip,
	city,
	country,
	phone,
	mobile,
	fax,
	email,
	opentime,
	banner,
	logourl,
	description
	FROM ".$db->prefix("adresses_mod")."
	WHERE requestid=$requestid";
$result = $db->query($sql);
list($lid, $cid, $title, $url, $homepage, $adres, $zip, $city, $country, $phone, $mobile, $fax, $email, $opentime, $banner, $logourl, $description) = $db->fetch_row($result);
$title       = $myts->oopsAddSlashesRT($title);
$url         = $myts->oopsAddSlashesRT($url);
$homepage    = $myts->oopsAddSlashesRT($homepage);
$description = $myts->oopsAddSlashesRT($description);
$adres       = $myts->oopsAddSlashesRT($adres);
$zip         = $myts->oopsAddSlashesRT($zip);
$city        = $myts->oopsAddSlashesRT($city);
$country     = $myts->oopsAddSlashesRT($country);
$phone       = $myts->oopsAddSlashesRT($phone);
$mobile      = $myts->oopsAddSlashesRT($mobile);
$fax         = $myts->oopsAddSlashesRT($fax);
$email       = $myts->oopsAddSlashesRT($email);
$opentime    = $myts->oopsAddSlashesRT($opentime);
$banner      = $myts->oopsAddSlashesRT($banner);
$logourl     = $myts->oopsAddSlashesRT($logourl);
$sql = "UPDATE ".$db->prefix("adresses_adresses")." SET
	cid=$cid,
	title='$title',
	description='$description',
	url='$url',
	homepage='$homepage',
	adres='$adres',
	zip='$zip',
	city='$city',
	country='$country',
	phone='$phone',
	mobile='$mobile',
	fax='$fax',
	email='$email',
	opentime='$opentime',
	banner='$banner',
	logourl='$logourl',
	status=2,
	date=".time()."
	WHERE lid=$lid";
$db->query($sql) or $eh->show("0013");
$db->query("DELETE FROM ".$db->prefix("adresses_mod")." WHERE requestid=$requestid") or $eh->show("0013");
redirect_header("index.php", 1, _UPDATED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function ignoreModReq() {
global $db, $_GET, $eh;
$requestid = intval($_GET['requestid']);
$query     = "DELETE FROM ".$db->prefix("adresses_mod")." WHERE requestid=$requestid";
$db->query($query) or $eh->show("0013");
redirect_header("./index.php?op=listModReq", 1, _MD_MODREQDELETED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function delAdress() {
global $db, $_GET, $eh;
$lid = intval($_GET['lid']);
$query  = "SELECT url, logourl FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid";
$result = $db->query($query);
list($url, $logourl) = $db->fetchRow($result);
@unlink("../cache/files/" . basename($url));
@unlink("../cache/shots/" . basename($logourl));
$query = "DELETE FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid";
$db->query($query) or $eh->show("0013");
$query = "DELETE FROM ".$db->prefix("adresses_votedata")." WHERE lid=$lid";
$db->query($query) or $eh->show("0013");
build_rss();
redirect_header("index.php", 1, _MD_FILEDELETED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function modCat() {
global $db, $xoopsModule, $_POST, $_GET, $myts, $eh, $mytree;
$cid = !empty($_POST["cid"]) ? intval($_POST["cid"]) : intval($_GET["cid"]);
xoops_cp_header();
OpenTable();
echo "<h4>"._MODIFYCATEGORY."</h4><br />";
$result = $db->query("SELECT pid, title, imgurl, description FROM ".$db->prefix("adresses_cat")." WHERE cid=$cid");
global $desc;
list($pid, $title, $imgurl, $description) = $db->fetchRow($result);
$title  = $myts->makeTboxData4Edit($title);
$imgurl = $myts->makeTboxData4Edit($imgurl);
$desc   = $myts->makeTboxData4Edit($description);
?>
<form action="./index.php" method="post" enctype="multipart/form-data">
<?php echo _TITLE.':';?><br />
<input type="text" class="text" name="title" value="<?php echo $title;?>" size="51" maxlength="50">
<br /><br />
<input type="text" class="text" name="imgurl" value="<?php echo $imgurl;?>" size="51" maxlength="255"><br />
<?php
$upload = new Upload();
$upload->printFormField("image");
echo "<br />".sprintf(_AM_IMGLOCATION, "modules/".$xoopsModule->dirname()."/cache/logos/");
?>
<br /><br />
<?php echo _DESCRIPTION;?>:<br />
<?php
$desc = new XoopsFormDhtmlTextArea('', 'desc', $desc, 10, 50);
echo $desc->render();
?>
<br /><br />
<?php echo _PARENT;?><br />
<?php $mytree->makeMySelBox("title", "title", $pid, 1, "pid");?>
<br /><br />
<input type="hidden" name="cid" value="<?php echo $cid;?>" />
<input type="hidden" name="op" value="modCatS" /><br />
<input type="submit" class="button" value="<?php echo _SAVE;?>" />
<input type="button" class="button" value="<?php echo _DELETE;?>" onclick="location='index.php?pid=<?php echo $pid;?>&cid=<?php echo $cid;?>&op=delCat';" />
<input type="button" class="button" value="<?php echo _CANCEL;?>" onclick="location='index.php';" />
</form>
<?php
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function modCatS() {
global $db, $myts, $_POST, $_FILES;
$cid         = intval($_POST['cid']);
$pid         = intval($_POST['pid']);
$imgurl      = $myts->makeTboxData4Save($_POST['imgurl']);
$title       = $myts->makeTboxData4Save($_POST['title']);
$description = $myts->makeTboxData4Save($_POST['desc']);
if ( !empty($_FILES['image']['name']) ) {
	$upload = new Upload();
	$upload->setUploadPath(XOOPS_ROOT_PATH."/modules/adresses/cache/logos");
	$upload->setAllowedMimeTypes(".gif|.jpg|.png");
	$upload->setFileName($cid);
	$upload->setDestinationFileName("image");
	$result = $upload->doUpload();
	if ($result) {
		$imgurl = $upload->FileName.".".$upload->getFileExtension();
	} else {
		$errors = $upload->getUploadErrors();
		$errorstring = "";
		$errorstring .= "<strong>::Errors occured::</strong><br />\n";
		while(list($filename,$values) = each($errors)) {
			$errorstring .= "File: " . $filename . "<br />";
			$count = count($values);
			for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "<br />"; }
		}
		redirect_header("index.php?op=modCat&cid=$cid", 3, $errorstring);
		exit();
	}
}
$db->query("UPDATE ".$db->prefix("adresses_cat")." SET title='$title', imgurl='$imgurl', pid='$pid', description='$description' WHERE cid=$cid");
build_rss();
redirect_header("index.php?op=modCat&cid=$cid", 1, _UPDATED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function addCat() {
global $db, $_POST, $myts, $eh;
$pid   = intval($_POST['cid']);
$title = $myts->makeTboxData4Save($_POST["title"]);
$newid = $db->genId($db->prefix("adresses_cat")."_cid_seq");
$query = $db->query("INSERT INTO ".$db->prefix("adresses_cat")." SET cid='$newid', pid='$pid', title='$title'") or $eh->show("0013");
if ($newid == 0) {
	$newid = $db->getInsertId($query);
}
redirect_header("index.php?op=modCat&cid=$newid", 1, _NEWCATEGORYADDED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function delCat() {
global $db, $_GET, $mytree;
$cid = intval($_GET['cid']);
if ($_GET['ok'] == 1) {
	//get all subcategories under the specified category
	$arr  = $mytree->getAllChildId($cid);
	$size = count($arr);
	for ($i=0; $i<$size; $i++) {
		//get all adresses in each subcategory
		$result = $db->query("SELECT lid, url, logourl FROM ".$db->prefix("adresses_adresses")." WHERE cid=".$arr[$i]."");
		//now for each adress, delete the text data and vote data associated with the adress
		while (list($lid, $url, $logourl) = $db->fetchRow($result)) {
			@unlink("../cache/files/" . basename($url));
			@unlink("../cache/shots/" . basename($logourl));
			$db->query("DELETE FROM ".$db->prefix("adresses_votedata")." WHERE lid=$lid");
			$db->query("DELETE FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid");
		}
		//all adresses for each subcategory is deleted, now delete the subcategory data
		$result = $db->query("SELECT imgurl FROM ".$db->prefix("adresses_cat")." WHERE cid=".$arr[$i]."");
		list($imgurl) = $db->fetchRow($result);
		@unlink("../cache/logos/" . basename($imgurl));
		$db->query("DELETE FROM ".$db->prefix("adresses_cat")." WHERE cid=".$arr[$i]."");
	}
	//all subcategory and associated data are deleted, now delete category data and its associated data
	$result = $db->query("SELECT lid, url, logourl FROM ".$db->prefix("adresses_adresses")." WHERE cid=$cid");
	while (list($lid, $url, $logourl) = $db->fetchRow($result)) {
		@unlink("../cache/files/" . basename($url));
		@unlink("../cache/shots/" . basename($logourl));
		$db->query("DELETE FROM ".$db->prefix("adresses_votedata")." WHERE lid=$lid");
		$db->query("DELETE FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid");
	}
	$result = $db->query("SELECT imgurl FROM ".$db->prefix("adresses_cat")." WHERE cid=$cid");
	list($imgurl) = $db->fetchRow($result);
	@unlink("../cache/logos/" . basename($imgurl));
	$db->query("DELETE FROM ".$db->prefix("adresses_cat")." WHERE cid=$cid");
	build_rss();
	redirect_header("index.php", 1, _CATEGORYDELETED);
	exit();
	} else {
		xoops_cp_header();
		OpenTable();
		echo "<h4>"._DELETECATEGORYANDCONTENT."</h4><br /><table><tr><td>";
		echo myTextForm("index.php?op=delCat&cid=$cid&ok=1", _YES);
		echo "</td><td>";
		echo myTextForm("index.php", _NO);
		echo "</td></tr></table>";
		CloseTable();
		xoops_cp_footer();
	}
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function addAdress() {
global $db, $myts, $xoopsUser, $eh, $_FILES, $_POST; //addAdres
$homepage    = formatURL($myts->makeTboxData4Save($_POST["homepage"]));
$url         = $myts->makeTboxData4Save($_POST["url"]);
$logourl     = $myts->makeTboxData4Save($_POST["logourl"]);
$title       = $myts->makeTboxData4Save($_POST["title"]);
$adres       = $myts->makeTboxData4Save($_POST["adres"]);
$zip         = $myts->makeTboxData4Save($_POST["zip"]);
$city        = $myts->makeTboxData4Save($_POST["city"]);
$country     = $myts->makeTboxData4Save($_POST["country"]);
$phone       = $myts->makeTboxData4Save($_POST["phone"]);
$mobile      = $myts->makeTboxData4Save($_POST["mobile"]);
$fax         = $myts->makeTboxData4Save($_POST["fax"]);
$email       = $myts->makeTboxData4Save($_POST["email"]);
$opentime    = $myts->makeTboxData4Save($_POST["opentime"]);
$banner      = $myts->makeTboxData4Save($_POST["banner"]);
$description = $myts->makeTboxData4Save($_POST["filedesc"]);
$submitter   = $xoopsUser->uid();
$result        = $db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_adresses")." WHERE url='$url'");
list($numrows) = $db->fetchRow($result);
// Check if Adress exist
//if ($numrows > 0) {
//	redirect_header("index.php?op=adressesConfigMenu", 3, _MD_ERROREXIST);
//	exit();
//}
// Check if Title is empty
if ( empty($title) ) {
	redirect_header("index.php?op=adressesConfigMenu", 3, _ERRORTITLE);
	exit();
}
// Check if Description is empty Disabled for Admin
//if ( empty($description) ) {
//	redirect_header("index.php?op=adressesConfigMenu", 3, _EMPTYDESCRIPTION);
//	exit();
//}
//if ( empty($size) || !is_numeric($size) ) {
//	$size = 0;
//}
if ( !empty($_POST['cid']) ) {
	$cid = intval($_POST['cid']);
	} else {
		$cid = 0;
	}
if ( !empty($_FILES['download']['name']) ) {
	$upload = new Upload();
	$upload->setUploadPath(XOOPS_ROOT_PATH."/modules/adresses/cache/files");
	$upload->setDestinationFileName("download");
	$result = $upload->doUpload();
	
	if ($result) {
                $url  = $upload->HTTP_POST_FILES[$upload->uploadFieldName]['name'];
                $size = $upload->HTTP_POST_FILES[$upload->uploadFieldName]['size'];
	} else {
		$errors = $upload->getUploadErrors();
		$errorstring = "";
		$errorstring .= "<strong>::Errors occured::</strong><br />\n";
		while(list($filename,$values) = each($errors)) {
			$errorstring .= "File: " . $filename . "<br />";
			$count = count($values);
			for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "<br />"; }
		}
		redirect_header("index.php?op=adressesConfigMenu", 3, $errorstring);
		exit();
	}
}
if ( !empty($_FILES['image']['name']) ) {
	$upload = new Upload();
	$upload->setAllowedMimeTypes(".gif|.jpg|.jpeg|.png");
	$upload->setUploadPath(XOOPS_ROOT_PATH."/modules/adresses/cache/shots");
	$upload->setDestinationFileName("image");
	$upload->setFileName($cid);
	$result = $upload->doUpload();
	
	if ($result) {
		$logourl = $upload->FileName.".".$upload->getFileExtension();
	} else {
		$errors = $upload->getUploadErrors();
		$errorstring = "";
		$errorstring .= "<strong>::Errors occured::</strong><br />\n";
		while(list($filename,$values) = each($errors)) {
			$errorstring .= "File: " . $filename . "<br />";
			$count = count($values);
			for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "<br />"; }
		}
		redirect_header("index.php?op=adressesConfigMenu", 3, $errorstring);
		exit();
	}
}
// Check if URL is empty Disabled
//if ( empty($url) ) {
//	redirect_header("index.php?op=adressesConfigMenu", 3, _EMPTYURL);
//	exit();
//}
$newid = $db->genId($db->prefix("adresses_adresses")."_lid_seq");
$sql   = "
	INSERT INTO ".$db->prefix("adresses_adresses")." SET
	lid=$newid,
	cid=$cid,
	title='$title',
	description='$description',
	url='$url',
	homepage='$homepage',
	adres='$adres',
	zip='$zip',
	city='$city',
	country='$country',
	phone='$phone',
	mobile='$mobile',
	fax='$fax',
	email='$email',
	opentime='$opentime',
	banner='$banner',
	logourl='$logourl',
	submitter=$submitter,
	status=1,
	date=".time().",
	hits=0,
	rating=0,
	votes=0,
	comments=0";
$db->query($sql) or $eh->show("0013");
build_rss();
redirect_header("index.php", 1, _CONTENTADDED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function delNewAdress() {
global $db, $_GET;
$lid   = intval($_GET['lid']);
$query  = "SELECT url, logourl FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid";
$result = $db->query($query);
list($url, $logourl) = $db->fetchRow($result);
@unlink("../cache/files/" . basename($url));
@unlink("../cache/shots/" . basename($logourl));
$query = "DELETE FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid";
$db->query($query);
redirect_header("./index.php?op=listNewadresses", 1, _MD_FILEDELETED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function modAdresses() {
global $db, $_GET, $_POST, $myts, $eh, $mytree;
$lid= !empty($_POST['lid']) ? intval($_POST['lid']) : intval($_GET['lid']);
$result = $db->query("SELECT cid, title, description, url, homepage, adres, zip, city, country, phone, mobile, fax, email, opentime, banner, logourl FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid") or $eh->show("0013");
list($cid, $title, $description, $url, $homepage, $adres, $zip, $city, $country, $phone, $mobile, $fax, $email, $opentime, $banner, $logourl) = $db->fetchRow($result);
$homepage    = $myts->makeTboxData4Edit($homepage);
$title       = $myts->makeTboxData4Edit($title);
$description = $myts->makeTboxData4Edit($description);
$url         = $myts->makeTboxData4Edit($url);
$adres       = $myts->makeTboxData4Edit($adres);
$zip         = $myts->makeTboxData4Edit($zip);
$city        = $myts->makeTboxData4Edit($city);
$country     = $myts->makeTboxData4Edit($country);
$phone       = $myts->makeTboxData4Edit($phone);
$mobile      = $myts->makeTboxData4Edit($mobile);
$fax         = $myts->makeTboxData4Edit($fax);
$email       = $myts->makeTboxData4Edit($email);
$opentime    = $myts->makeTboxData4Edit($opentime);
$banner      = $myts->makeTboxData4Edit($banner);
$logourl     = $myts->makeTboxData4Edit($logourl);
xoops_cp_header();
OpenTable();
?>
<form method="post" action="index.php" enctype="multipart/form-data">
<h4><?php echo _MODIFYCONTENTINFO;?></h4><br />
<table width="100%"><tr>
<td><?php echo _FILEID;?></td>
<td><b><?php echo $lid;?></b></td>
</tr><tr>
<td><?php echo _MD_ADRESSTITLE;?></td>
<td><input type="text" class="text" name="title" value="<?php echo $title;?>" size="60" maxlength="100" /></td>
</tr><!-- DISABLED<tr>
<td valign="top"><?php echo _DOWNLOADURL;?></td>
<td>
<input type="text" class="text" name="url" value="<?php echo $url;?>" size="50" maxlength="255" /> [ <a href="<?php echo formatURL(XOOPS_URL."/modules/adresses/cache/files/", $url);?>"><?php echo _DOWNLOAD;?></a> ]
<br /><input type="file" class="file" name="download">
</td>
</tr><tr>
<td>&nbsp;</td>
<td><?php printf(_MD_FILE, "modules/adresses/cache/files/");?></td>
</tr> --><tr>
<td><?php echo _CATEGORY.': ';?></td>
<td><?php $mytree->makeMySelBox("title", "title", $cid);?></td>
</tr><tr>
<td><?php echo _MD_ADRESSC;?></td>
<td><input type="text" class="text" name="adres" value="<?php echo $adres;?>" size="60" maxlength="100" /></td>
</tr><tr>
<td><?php echo _MD_ZIPC;?></td>
<td><input type="text" class="text" name="zip" value="<?php echo $zip;?>" size="15" maxlength="15" /></td>
</tr><tr>
<td><?php echo _MD_CITYC;?></td>
<td><input type="text" class="text" name="city" value="<?php echo $city;?>" size="60" maxlength="80" /></td>
</tr><tr>
<td><?php echo _MD_COUNTRYC;?></td>
<td><input type="text" class="text" name="country" value="<?php echo $country;?>" size="60" maxlength="80" /></td>
</tr><tr>
<td><?php echo _MD_PHONEC;?></td>
<td><input type="text" class="text" name="phone" value="<?php echo $phone;?>" size="40" maxlength="50" /></td>
</tr><tr>
<td><?php echo _MD_MOBILEC;?></td>
<td><input type="text" class="text" name="mobile" value="<?php echo $mobile;?>" size="40" maxlength="50" /></td>
</tr><tr>
<td><?php echo _MD_FAXC;?></td>
<td><input type="text" class="text" name="fax" value="<?php echo $fax;?>" size="40" maxlength="50" /></td>
</tr><tr>
<td><?php echo _EMAIL.':';?></td>
<td><input type="text" class="text" name="email" value="<?php echo $email;?>" size="60" maxlength="80" /></td>
</tr><tr>
<td><?php echo _SITEURL;?></td>
<td><input type="text" class="text" name="homepage" value="<?php echo $homepage;?>" size="50" maxlength="255" /></td>
</tr><tr>
<td><?php echo _MD_OPENTIMEC;?></td>
<td><textarea cols="40" rows="4" class="text" name="opentime" value="<?php echo $opentime;?>"><?php echo $opentime;?></textarea></td>
</tr><!-- DISABLED <tr>
<td><?php echo _MD_BANNERC;?></td>
<td><input type="text" class="text" name="size" value="<?php echo $banner;?>" size="10" maxlength="100" /></td>
</tr> --><tr>
<td valign="top"><?php echo _DESCRIPTION.':';?></td>
<td>
<?php
$desc = new XoopsFormDhtmlTextArea('', 'filedesc', $description, 10, 50);
echo $desc->render();
?>
</td>
</tr><tr>
<td valign="top"><?php echo _SHOTIMAGE;?></td>
<td>
<input type="text" class="text" name="logourl" value="<?php echo $logourl;?>" size="60" maxlength="255" />
<br />
<?php
$upload = new Upload();
$upload->printFormField("image");
?>
</td>
</tr><tr>
<td>&nbsp;</td>
<td><?php printf(_SHOTDESCRIPTION, "modules/adresses/cache/images/shots/");?></td>
</tr><tr>
<td>
<input type="hidden" name="lid" value="<?php echo $lid;?>" />
<input type="hidden" name="op" value="modadress" />
<input type="submit" class="button" value="<?php echo _SUBMIT;?>" />
</form>
</td>
<td>
<table><tr>
<td><?php echo myTextForm("index.php?op=delAdress&lid=$lid" , _DELETE);?></td>
<td><?php echo myTextForm("index.php?op=adressesConfigMenu", _CANCEL);?></td>
</tr></table>
</td>
</tr></table><hr />
<?php
$result5 = $db->query("SELECT COUNT(*) FROM ".$db->prefix("adresses_votedata")."");
list($totalvotes) = $db->getRowsNum($result5);
echo "<table valign='top' width='100%'><tr><td colspan='7'><b>";
printf(_MD_DLRATINGS, $totalvotes);
echo "</b><br /><br /></td></tr>";
// Show Registered Users Votes
$result5 = $db->query("SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ".$db->prefix("adresses_votedata")." WHERE lid = $lid AND ratinguser != 0 ORDER BY ratingtimestamp DESC");
$votes   = $db->getRowsNum($result5);
echo "<tr><td colspan='7'><br /><br /><b>";
printf(_REGISTEREDUSERSTOTALVOTES, $votes);
echo "
</b><br /><br /></td>
</tr><tr>
<td><b>"._USER."</b></td>
<td><b>"._IPADDRESS."</b></td>
<td><b>"._RATING."</b></td>
<td><b>"._MD_USERAVG."</b></td>
<td><b>"._MD_TOTALRATE."</b></td>
<td><b>"._DATE."</b></td>
<td align='center'><b>"._DELETE."</b></td>
</tr>";
if ($votes == 0) {
	echo "<tr><td align='center' colspan='7'>"._NOREGISTEREDUSERVOTES."<br /></td></tr>";
}
$x=0;
$colorswitch = "bg1";
while (list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp)=$db->fetchRow($result5)) {
	$formatted_date = formatTimestamp($ratingtimestamp, "s");
	$result2        = $db->query("SELECT rating FROM ".$db->prefix("adresses_votedata")." WHERE ratinguser=$ratinguser");
	$uservotes      = $db->getRowsNum($result2);
	$useravgrating  = 0;
	while (list($rating2) = $db->fetchRow($result2)) {
		$useravgrating = ($useravgrating + $rating2);
	}
	$useravgrating = ($useravgrating / $uservotes);
	$useravgrating = number_format($useravgrating, 1);
	$ratinguname   = XoopsUser::getUnameFromId($ratinguser);
	echo "
	<tr>
	<td class='$colorswitch'>$ratinguname</td>
	<td class='$colorswitch'>$ratinghostname</td>
	<td class='$colorswitch'>$rating</td>
	<td class='$colorswitch'>$useravgrating</td>
	<td class='$colorswitch'>$uservotes</td>
	<td class='$colorswitch'>$formatted_date</td>
	<td class='$colorswitch' align='center'>";
	echo myTextForm("index.php?op=delVote&lid=$lid&rid=$ratingid", "X");
	echo "</td></tr>";
	$x++;
	if ($colorswitch == "bg1") {
		$colorswitch = "bg3";
		} else {
			$colorswitch = "bg1";
		}
}
// Show Unregistered Users Votes
$result5 = $db->query("SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM ".$db->prefix("adresses_votedata")." WHERE lid = $lid AND ratinguser = 0 ORDER BY ratingtimestamp DESC");
$votes   = $db->getRowsNum($result5);
echo "<tr><td colspan='7'><br /><br /><b>";
printf(_ANONYMOUSUSERTOTALVOTES, $votes);
echo "
</b><br /><br /></td>
</tr><tr>
<td colspan='2'><b>"._IPADDRESS."</b></td>
<td colspan='3'><b>"._RATING."</b></td>
<td><b>"._DATE."</b></b></td>
<td align='center'><b>"._DELETE."</b></td>
</tr>";
if ($votes == 0) {
	echo "<tr><td colspan='7' align='center'>"._MD_NOUNREGVOTES."</td></tr>";
}
$x=0;
$colorswitch = "bg1";
while (list($ratingid, $rating, $ratinghostname, $ratingtimestamp) = $db->fetchRow($result5)) {
	$formatted_date = formatTimestamp($ratingtimestamp, "s");
	echo "
	<td colspan='2' class='$colorswitch'>$ratinghostname</td>
	<td colspan='3' class='$colorswitch'>$rating</td>
	<td class='$colorswitch'>$formatted_date</td>
	<td class='$colorswitch' align='center'>";
	echo myTextForm("index.php?op=delVote&lid=$lid&rid=$ratingid", "X");
	echo "</td></tr>";
	$x++;
	if ($colorswitch == "bg1") {
		$colorswitch = "bg3";
		} else {
			$colorswitch="bg1";
		}
}
echo "<tr><td colspan='6'>&nbsp;</td></tr></table>";
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function modadress() {
global $db, $myts, $eh, $_POST, $_FILES;
$cid         = intval($_POST['cid']);
$lid         = intval($_POST['lid']);
$homepage    = formatURL($myts->makeTboxData4Save($_POST["homepage"]));
$url         = $myts->makeTboxData4Save($_POST["url"]);
$logourl     = $myts->makeTboxData4Save($_POST["logourl"]);
$title       = $myts->makeTboxData4Save($_POST["title"]);
$adres       = $myts->makeTboxData4Save($_POST['adres']);
$zip         = $myts->makeTboxData4Save($_POST['zip']);
$city        = $myts->makeTboxData4Save($_POST['city']);
$country     = $myts->makeTboxData4Save($_POST['country']);
$phone       = $myts->makeTboxData4Save($_POST['phone']);
$mobile      = $myts->makeTboxData4Save($_POST['mobile']);
$fax         = $myts->makeTboxData4Save($_POST['fax']);
$email       = $myts->makeTboxData4Save($_POST['email']);
$opentime    = $myts->makeTboxData4Save($_POST['opentime']);
$description = $myts->makeTboxData4Save($_POST["filedesc"]);
$banner      = $myts->makeTboxData4Save($_POST["banner"]);
// Check if Title is empty
if ( empty($title) ) {
	redirect_header("index.php?op=modAdresses&lid=$lid", 3, _EMPTYTITLE);
	exit();
}
// Check if Description is empty Disabled for admin
//if ( empty($description) ) {
//	redirect_header("index.php?op=modAdresses&lid=$lid", 3, _EMPTYDESCRIPTION);
//	exit();
//}
//if ( empty($size) || !is_numeric($size) ) {
//	$size = 0;
//}
if ( !empty($_FILES['download']['name']) || !empty($_FILES['image']['name']) ) {
	
	$upload = new Upload();
	$upload->setUploadPath(XOOPS_ROOT_PATH.'/modules/adresses/cache/files');
	$upload->setAllowedMimeTypes($adressesConfig['accepted_files']);
	$upload->setDestinationFileName('download');
	$result = $upload->doUpload();
	
	if ($result) {
                $url  = $upload->HTTP_POST_FILES[$upload->uploadFieldName]['name'];
                $size = $upload->HTTP_POST_FILES[$upload->uploadFieldName]['size'];
	} else {
		$errors = $upload->getUploadErrors();
		$errorstring = "";
		$errorstring .= "<strong>::Errors occured::</strong><br />\n";
		while(list($filename,$values) = each($errors)) {
			$errorstring .= "File: " . $filename . "<br />";
			$count = count($values);
			for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "<br />"; }
		}
		redirect_header("index.php?op=modAdresses&lid=$lid", 3, $errorstring);
		exit();
	}
	
	$upload = new Upload();
	$upload->setUploadPath(XOOPS_ROOT_PATH.'/modules/adresses/cache/shots');
	$upload->setAllowedMimeTypes(".gif|.jpeg|.jpg|.png");
	$upload->setDestinationFileName('image');
	$upload->setFileName($lid);
	$result = $upload->doUpload();
	
	if ( $result) {
		$logourl = $upload->HTTP_POST_FILES[$upload->uploadFieldName]['name'];
	} else {
		$errors = $upload->getUploadErrors();
		$errorstring = "";
		$errorstring .= "<strong>::Errors occured::</strong><br />\n";
		while(list($filename,$values) = each($errors)) {
			$errorstring .= "File: " . $filename . "<br />";
			$count = count($values);
			for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "<br />"; }
		}
		redirect_header("index.php?op=modAdresses&lid=$lid", 3, $errorstring);
		exit();
	}
}
// Check if URL is empty Disabled
//if ( empty($url) ) {
//	redirect_header("index.php?op=modAdresses&lid=$lid", 3, _EMPTYURL);
//	exit();
//}
$sql = "
	UPDATE ".$db->prefix("adresses_adresses")." SET
	cid=$cid,
	title='$title',
	description='$description',
	url='$url',
	homepage='$homepage',
	adres='$adres',
	zip='$zip',
	city='$city',
	country='$country',
	phone='$phone',
	mobile='$mobile',
	fax='$fax',
	email='$email',
	opentime='$opentime',
	banner='$banner',
	logourl='$logourl',
	status=2,
	date=".time()."
	WHERE lid=$lid";
$db->query($sql) or $eh->show("0013");
build_rss();
redirect_header("index.php", 1, _UPDATED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function approve() {
global $bcoosConfig, $db, $_POST, $myts, $eh;
$lid = intval($_POST['lid']);
$cid = intval($_POST['cid']);
if ( empty($cid) ) {
	$cid = 0;
}
$homepage    = formatURL($myts->makeTboxData4Save($_POST["homepage"]));
$url         = $myts->makeTboxData4Save($_POST["url"]);
$logourl     = $myts->makeTboxData4Save($_POST["logourl"]);
$title       = $myts->makeTboxData4Save($_POST["title"]);
$adres       = $myts->makeTboxData4Save($_POST['adres']);
$zip         = $myts->makeTboxData4Save($_POST['zip']);
$city        = $myts->makeTboxData4Save($_POST['city']);
$country     = $myts->makeTboxData4Save($_POST['country']);
$phone       = $myts->makeTboxData4Save($_POST['phone']);
$mobile      = $myts->makeTboxData4Save($_POST['mobile']);
$fax         = $myts->makeTboxData4Save($_POST['fax']);
$email       = $myts->makeTboxData4Save($_POST['email']);
$opentime    = $myts->makeTboxData4Save($_POST['opentime']);
$description = $myts->makeTboxData4Save($_POST["filedesc"]);
$banner      = $myts->makeTboxData4Save($_POST['banner']);
$query = "
	UPDATE
	".$db->prefix("adresses_adresses")."
	SET
	cid=$cid,
	title='$title',
	description='$description',
	url='$url',
	homepage='$homepage',
	adres='$adres',
	zip='$zip',
	city='$city',
	country='$country',
	phone='$phone',
	mobile='$mobile',
	fax='$fax',
	email='$email',
	opentime='$opentime',
	banner='$banner',
	logourl='$logourl',
	status=1,
	date=".time()."
	WHERE
	lid=$lid";
$db->query($query) or $eh->show("0013");
$result = $db->query("SELECT submitter FROM ".$db->prefix("adresses_adresses")." WHERE lid=$lid");
list($submitter) = $db->fetchRow($result);
$submitter = new XoopsUser($submitter);
$subject   = sprintf(_YOURCONTENTSUBMITEDAT, $bcoosConfig['title']);
$message   = sprintf(_MD_HELLO, $submitter->uname());
$message  .= "\n\n"._APPROVENOTIFY."\n\n";
$siteurl   = XOOPS_URL."/modules/adresses/";
$message  .= sprintf(_VISITUSAT, $siteurl);
$message  .= "\n\n"._THANKSSUBMIT."\n\n".$bcoosConfig['title']."\n".XOOPS_URL."\n".$bcoosConfig['adminmail']."";
$xoopsMailer =& getMailer();
$xoopsMailer->useMail();
$xoopsMailer->setToEmails($submitter->getVar("email"));
$xoopsMailer->setFromEmail($bcoosConfig['adminmail']);
$xoopsMailer->setFromName($bcoosConfig['title']);
$xoopsMailer->setSubject($subject);
$xoopsMailer->setBody($message);
//$xoopsMailer->send(); // Temporarly disabled !!
build_rss();
redirect_header("./index.php?op=listNewadresses", 1, _CONTENTADDED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function adressesConfigAdmin() {
global $myts, $adressesConfig;
xoops_cp_header();
OpenTable();
?>
<h4><?php echo _GENERALSETTINGS;?></h4><br />
<form action="index.php" method="post">
<table width="100%" border="0"><tr>
<td nowrap><?php echo _ITEMSPERPAGE;?></td>
<td width="100%">
<select class="select" name="perpage">
<option value="<?php echo $adressesConfig['perpage'];?>" selected="selected"><?php echo $adressesConfig['perpage'];?></option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="50">50</option>
</select>
</td>
</tr><tr>
<td nowrap><?php echo _HITSTOBEPOPULAR;?></td>
<td width="100%">
<select class="select" name="popular">
<option value="<?php echo $adressesConfig['popular'];?>" selected="selected"><?php echo $adressesConfig['popular'];?></option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="500">500</option>
<option value="1000">1000</option>
</select>
</td>
</tr><tr>
<td nowrap><?php echo _MD_DLSNEW;?></td>
<td width="100%">
<select class="select" name="newadresses">
<option value="<?php echo $adressesConfig['newadresses'];?>" selected="selected"><?php echo $adressesConfig['newadresses'];?></option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="50">50</option>
</select>
</td>
</tr><tr>
<?php
$chk1 = ''; $chk0 = '';
($adressesConfig['useshots'] == 1) ? $chk1 = " checked='checked'" : $chk0 = " checked='checked'";
?>
<td nowrap><?php echo _MD_USESHOTS;?></td>
<td width="100%">
<input type="radio" class="radio" name="useshots" value="1"<?php echo $chk1;?> /> <?php echo _YES;?>
<input type="radio" class="radio" name="useshots" value="0"<?php echo $chk0;?> /> <?php echo _NO;?>
</td>
</tr><tr>
<td nowrap><?php echo _SHOTIMAGEWIDTH;?></td>
<td width="100%">
<input type="text" class="text" size="10" name="shotwidth" value="<?php echo $adressesConfig['shotwidth'];?>" />
</td>
</tr><tr>
<?php
$chk1 = ''; $chk0 = '';
($adressesConfig['anon_add'] == 1) ? $chk1 = " checked='checked'" : $chk0 = " checked='checked'";
?>
<td nowrap><?php echo _AM_ANON_ADD;?></td>
<td width="100%">
<input type="radio" class="radio" name="anon_add" value="1"<?php echo $chk1;?> /> <?php echo _YES;?>
<input type="radio" class="radio" name="anon_add" value="0"<?php echo $chk0;?> /> <?php echo _NO;?>
</td>
</tr><tr>
<?php
$chk1 = ''; $chk0 = '';
($adressesConfig['check_external'] == 1) ? $chk1 = " checked='checked'" : $chk0 = " checked='checked'";
?>
<td nowrap><?php echo _DENYEXTERNALINKAGE;?></td>
<td width="100%">
<input type="radio" class="radio" name="check_external" value="1"<?php echo $chk1;?> /> <?php echo _YES;?>
<input type="radio" class="radio" name="check_external" value="0"<?php echo $chk0;?> /> <?php echo _NO;?>
</td>
</tr><tr>
<td colspan="2"><hr /></td>
</tr><tr>
<?php
$chk1 = ''; $chk0 = '';
($adressesConfig['rss_enable'] == 1) ? $chk1 = " checked='checked'" : $chk0 = " checked='checked'";
?>
<td nowrap><?php echo _ENABLEFEEDS;?></td>
<td width="100%">
<input type="radio" class="radio" name="rss_enable" value="1"<?php echo $chk1;?> /> <?php echo _YES;?>
<input type="radio" class="radio" name="rss_enable" value="0"<?php echo $chk0;?> /> <?php echo _NO;?>
</td>
</tr><tr>
<td nowrap><?php echo _FEEDMAXITEMS;?></td>
<td width="100%">
<select class="select" name="rss_maxitems">
<option value="<?php echo $adressesConfig['rss_maxitems'];?>" selected="selected"><?php echo $adressesConfig['rss_maxitems'];?></option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
</select>
</td>
</tr><tr>
<td nowrap><?php echo _FEEDMAXDESCRIPTION;?></td>
<td width="100%">
<select class="select" name="rss_maxdescription">
<option value="<?php echo $adressesConfig['rss_maxdescription'];?>" selected="selected"><?php echo $adressesConfig['rss_maxdescription'];?></option>
<option value="50">50</option>
<option value="100">100</option>
<option value="150">150</option>
<option value="200">200</option>
<option value="250">250</option>
<option value="300">300</option>
</select>
</td>
</tr><tr>
<td colspan="2"><hr /></td>
</tr><tr>
<?php
$chk1 = ''; $chk0 = '';
($adressesConfig['allow_upload'] == 1) ? $chk1 = " checked='checked'" : $chk0 = " checked='checked'";
?>
<td nowrap><?php echo _UPLOADENABLE;?><br /></td>
<td width="100%">
<input type="radio" class="radio" name="allow_upload" value="1"<?php echo $chk1;?> /> <?php echo _YES;?>
<input type="radio" class="radio" name="allow_upload" value="0"<?php echo $chk0;?> /> <?php echo _NO;?><br /><?php echo _MD_NOTACTIVE;?>
</td>
</tr><!-- DISABLED <tr>
<td nowrap><?php echo _UPLOADACCEPTED;?></td>
<td width="100%">
<input type="text" class="text" size="30" name="accepted_files" value="<?php echo $adressesConfig['accepted_files'];?>" />
</td>
</tr><tr>
<td nowrap><?php echo _UPLOADLIMIT;?></td>
<td width="100%">
<input type="text" class="text" size="10" name="upload_limit" value="<?php echo $adressesConfig['upload_limit'];?>" /> <?php echo _BYTES;?>
</td>
</tr> --><tr>
<td colspan="2"><hr /></td>
</tr><tr>
<td valign="top" nowrap><?php echo _AM_DISCLAIMER;?></td>
<td width="100%">
<?php
$disclaimer = join('', file("../cache/disclaimer.txt"));
$disclaimer = $myts->makeTboxData4PreviewInForm($disclaimer);
$desc       = new XoopsFormDhtmlTextArea('', 'disclaimer', $disclaimer, 10, 50);
echo $desc->render();
?>
</td>
</tr><tr>
<td colspan="2"><hr /></td>
</tr><tr>
<td colspan="2">
<input type="hidden" name="op" value="adressesConfigChange">
<input type="submit" class="button" value="<?php echo _SAVE;?>">
<input type="button" class="button" value="<?php echo _CANCEL;?>" onclick="javascript:history.go(-1)">
</td>
</tr></table>
</form>
<?php
CloseTable();
xoops_cp_footer();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function adressesConfigChange() {
global $_POST, $myts;
$content  = "<?php\n";
$content .= "\$adressesConfig['popular']            = ".intval($_POST['popular']).";\n";
$content .= "\$adressesConfig['newadresses']        = ".intval($_POST['newadresses']).";\n";
$content .= "\$adressesConfig['perpage']            = ".intval($_POST['perpage']).";\n";
$content .= "\$adressesConfig['useshots']           = ".intval($_POST['useshots']).";\n";
$content .= "\$adressesConfig['shotwidth']          = ".intval($_POST['shotwidth']).";\n";
$content .= "\$adressesConfig['anon_add']           = ".intval($_POST['anon_add']).";\n";
$content .= "\$adressesConfig['check_external']     = ".intval($_POST['check_external']).";\n";
$content .= "\$adressesConfig['rss_enable']         = ".intval($_POST['rss_enable']).";\n";
$content .= "\$adressesConfig['rss_maxitems']       = ".intval($_POST['rss_maxitems']).";\n";
$content .= "\$adressesConfig['rss_maxdescription'] = ".intval($_POST['rss_maxdescription']).";\n";
$content .= "\$adressesConfig['allow_upload']       = ".intval($_POST['allow_upload']).";\n";
$content .= "\$adressesConfig['accepted_files']     = '".$_POST['accepted_files']."';\n";
$content .= "\$adressesConfig['upload_limit']       = ".intval($_POST['upload_limit']).";\n";
$content .= "?>";
$filename = "../cache/config.php";
if ( $file = fopen($filename, "w") ) {
	fwrite($file, $content);
	fclose($file);
	} else {
		redirect_header("index.php", 1, _NOTUPDATED);
		exit();
	}
$filename = "../cache/disclaimer.txt";
if ( $file = fopen($filename, "wb") ) {
	$disclaimer = $myts->oopsStripSlashesGPC($_POST['disclaimer']);
	fwrite($file, $disclaimer);
	fclose($file);
	} else {
		redirect_header("index.php", 1, _NOTUPDATED);
		exit();
	}
redirect_header("index.php", 1, _UPDATED);
exit();
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function build_rss() {
global $db, $adressesConfig,$bcoosConfig;
if ($adressesConfig['rss_enable'] == 1) {
	$SQL= "SELECT title, lid, version, description FROM ".$db->prefix("mydownloads_downloads")." WHERE status !=0 ORDER BY date DESC";
	$query = $db->query($SQL, $mydownloadsConfig['rss_maxitems']);
	if ($query) {
		$rss = new UniversalFeedCreator();
		$rss->title = $xoopsConifg['title']." :: " ._MI_MYADRESSES_NAME;
		$rss->link = XOOPS_URL."/modules/adresses/";
		$rss->description = $bcoosConfig['description'];
		
		$image = new FeedImage();
		$image->title = $bcoosConfig['title']." :: " ._MI_MYADRESSES_NAME;
		$image->url = XOOPS_URL."/images/button.png"; 
		$image->link = XOOPS_URL."/modules/adresses/";
		$image->description = $bcoosConfig['description'];
		
		$rss->image = $image; 
		while ( list($title, $link, $version, $description) = $db->fetchRow($query) ) {
		
			$item = new FeedItem();
			$item->title = $title." - ".$version; 
			$item->link = XOOPS_URL.'/modules/adresses/singlefile.php?lid='.$link;
			$item->description = $description;
			
			$rss->addItem($item); 
		}
		$rsave = $rss->saveFeed("RSS0.91", XOOPS_ROOT_PATH."/modules/adresses/cache/adresses.xml",false);
	}
}
}
//---------------------------------------------------------------------------------------//
$op = !empty($_POST['op']) ? $_POST['op'] : $_GET['op'];
switch($op) {
case "delNewAdress":
	delNewAdress();
	break;
case "approve":
	approve();
	break;
case "addCat":
	addCat();
	break;
case "addSubCat":
	addSubCat();
	break;
case "addAdress":
	addAdress();
	break;
case "listBrokenadresses":
	listBrokenadresses();
	break;
case "delBrokenadresses":
	delBrokenadresses();
	break;
case "ignoreBrokenadresses":
	ignoreBrokenadresses();
	break;
case "listModReq":
	listModReq();
	break;
case "changeModReq":
	changeModReq();
	break;
case "ignoreModReq":
	ignoreModReq();
	break;
case "delCat":
	delCat();
	break;
case "modCat":
	modCat();
	break;
case "modCatS":
	modCatS();
	break;
case "modAdresses":
	modAdresses();
	break;
case "modadress":
	modadress();
	break;
case "delAdress":
	delAdress();
	break;
case "delVote":
	delVote();
	break;
case "adressesConfigAdmin":
	adressesConfigAdmin();
	break;
case "adressesConfigChange":
	adressesConfigChange();
	break;
case "adressesConfigMenu":
	adressesConfigMenu();
	break;
case "listNewadresses":
	listNewadresses();
	break;
default:
	adresses();
	break;
}
?>
