<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.4 www.exoops.info 2006/03 
// $Id: modfile.php,v 1.3 2003/02/28 06:02:38 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("header.php");
include_once(XOOPS_ROOT_PATH."/class/fileupload.php");
include_once(XOOPS_ROOT_PATH."/class/module.errorhandler.php");
include_once(XOOPS_ROOT_PATH."/class/xoopsform/formdhtmltextarea.php");
$eh     = new ErrorHandler();
$mytree = new XoopsTree($db->prefix("adresses_cat"), "cid", "pid");
if ( !empty($_POST['submit']) ) {
	if (!$xoopsUser) {
		redirect_header(XOOPS_URL."/user.php", 2, _MUSTREGISTERFIRST);
		exit();
		} else {
			$modifysubmitter = $xoopsUser->uid();
		}
$lid         = intval($_POST["lid"]);
$cid         = intval($_POST["cid"]);
$homepage    = formatURL($myts->makeTboxData4Save($_POST["homepage"]));
$url         = $myts->makeTboxData4Save($_POST["url"]);
$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']);
$logourl     = formatURL($myts->makeTboxData4Save($_POST['logourl']));
// Check if Title exist
if ( empty($title) ) {
	$eh->show("2001");
}
// Check if Adres exist
if ( empty($adres) ) {
	$eh->show("1004");
}
// Check if City exist
if ( empty($city) ) {
	$eh->show("1005");
}
// Check if Zip exist
if ( empty($zip) ) {
	$eh->show("1007");
}
// Check if Country exist
if ( empty($country) ) {
	$eh->show("2002");
}
// Check if Description exist
if ( empty($description) ) {
	$eh->show("1008");
}
if ( ($adressesConfig['allow_upload'] == 1) && !empty($_FILES['download']['name']) ) {
	$upload = new fileupload();
	$upload->set_upload_dir("./cache/files/", 'download');
	$upload->set_accepted($adressesConfig['accepted_files'], 'download');
	$upload->set_overwrite(1, 'download');
	$result = $upload->upload();
	if ($result['download']['filename']) {
		$url  = $result['download']['filename'];
		$size = $result['download']['size'];
		} else {
			redirect_header("modfile.php?lid=$lid", 3, $upload->errors());
			exit();
		}
}
//* Uitgeschakeld *//
// Check if URL exist
//if ( empty($url) ) {
//	$eh->show("1016");
//}
$newid = $db->genId($db->prefix("adresses_mod")."_requestid_seq");
$sql   = "
	INSERT INTO
	".$db->prefix("adresses_mod")."
	SET
	requestid=$newid,
	lid=$lid,
	cid=$cid,
	title='$title',
	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',
	description='$description',
	modifysubmitter=$modifysubmitter";
$db->query($sql) or $eh->show("0013");
redirect_header("index.php", 2, _MD_THANKSFORINFO);
exit();
} else {
$lid = intval($_GET['lid']);
if (!$xoopsUser) {
	redirect_header(XOOPS_URL."/user.php", 2, _MUSTREGISTERFIRST);
	exit();
}
include_once(XOOPS_ROOT_PATH."/header.php");
OpenTable();
echo "<b>"._MI_MYADRESSES_NAME."</b>";
echo "<table width='80%' align='center'>"._REQUESTMODIFICATION."<br /><br />";
$result = $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." AND status>0");
list($cid, $title, $description, $url, $homepage, $adres, $zip, $city, $country, $phone, $mobile, $fax, $email, $opentime, $banner, $logourl, $submitter) = $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);
$description = $myts->makeTboxData4Edit($description);
$banner      = $myts->makeTboxData4Edit($banner);
$logourl     = $myts->makeTboxData4Edit($logourl);
                                     //** VANAF HIER NOG BEWERKEN !! **//
?>
<form action="modfile.php" method="post">
<table width="80%"><tr>
<td align="right"><b><?php echo _FILEID;?></b></td>
<td><?php echo $lid;?></td>
</tr><tr>
<td align="right"><b><?php echo _MD_ADRESSTITLE;?></b></td>
<td><input type="text" class="text" name="title" size="60" maxlength="100" value="<?php echo $title;?>" /></td>
</tr><!-- DISABLED<tr>
<td align="right" valign="top" nowrap><b><?php echo _DOWNLOADURL;?></b></td>
<td>
<input type="text" class="text" name="url" size="50" maxlength="255" value="<?php echo $url;?>" />
<?php
if ( (($xoopsUser->uid() == $submitter) || $xoopsUser->isAdmin($xoopsModule->mid())) && ($adressesConfig['allow_upload'] == 1) ) {
	$upload = new fileupload();
	$upload->set_max_file_size($adressesConfig['upload_limit'], 'download');
	echo "<br />";
	$upload->render(1, 'download');
}
?>
</td>
</tr> --><tr>
<td align="right"><b><?php echo _CATEGORY.': ';?></b></td>
<td><?php $mytree->makeMySelBox("title", "title", $cid);?></td>
</tr><tr>
<td align="right"><b><?php echo _MD_ADRESC;?></b></td>
<td><input type="text" class="text" name="adres" value="<?php echo $adres;?>" size="60" maxlength="100" /></td>
</tr><tr>
<td align="right"><b><?php echo _MD_ZIPC;?></b></td>
<td><input type="text" class="text" name="zip" value="<?php echo $zip;?>" size="15" maxlength="15" /></td>
</tr><tr>
<td align="right"><b><?php echo _MD_CITYC;?></b></td>
<td><input type="text" class="text" name="city" value="<?php echo $city;?>" size="60" maxlength="80" /></td>
</tr><tr>
<td align="right"><b><?php echo _MD_COUNTRYC;?></b></td>
<td><input type="text" class="text" name="country" value="<?php echo $country;?>" size="60" maxlength="80" /></td>
</tr><tr>
<td align="right"><b><?php echo _MD_PHONEC;?></b></td>
<td><input type="text" class="text" name="phone" value="<?php echo $phone;?>" size="40" maxlength="50" /></td>
</tr><tr>
<td align="right"><b><?php echo _MD_MOBILEC;?></b></td>
<td><input type="text" class="text" name="mobile" value="<?php echo $mobile;?>" size="40" maxlength="50" /></td>
</tr><tr>
<td align="right"><b><?php echo _MD_FAXC;?></b></td>
<td><input type="text" class="text" name="fax" value="<?php echo $fax;?>" size="40" maxlength="50" /></td>
</tr><tr>
<td align="right"><b><?php echo _EMAIL.':';?></b></td>
<td><input type="text" class="text" name="email" value="<?php echo $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="<?php echo $homepage;?>" /></td>
</tr><tr>
<td align="right" Valign="top"><b><?php echo _MD_OPENTIMEC;?></b></td>
<td><textarea cols="40" rows="4" class="text" name="opentime" value="<?php echo $opentime;?>"><?php echo $opentime;?></textarea></td>
</tr><!-- DISABLED <tr>
<td align="right"><b><?php echo _MD_BANNERC;?></b></td>
<td><input type="text" class="text" name="size" value="<?php echo $banner;?>" size="10" maxlength="100" /></td>
</tr> --><tr>
<td align="right" valign="top"><b><?php echo _DESCRIPTION.':';?></b></td>
<td>
<?php
$desc = new XoopsFormDhtmlTextArea('', 'filedesc', $description, 10, 50);
echo $desc->render();
?>
</td>
</tr><tr>
<td align="right"><b><?php echo _MD_SHOTIMAGEC;?></b></td>
<td>
<input type="text" class="text" name="logourl" value="<?php echo $logourl;?>" size="60" maxlength="255" />
</td>
</tr><tr>
<td>&nbsp;</td>
<td><?php echo _MD_SHOTSUBMIT;?></td>
</tr><tr>
<td colspan="2" align="center"><br />
<input type="hidden" name="lid" value="<?php echo $lid;?>" />
<input name="submit" class="button" type="submit" value="<?php echo _SUBMIT;?>" />
<input type="button" class="button" value="<?php echo _CANCEL;?>" onclick="javascript:history.go(-1)" />
</form></td></tr></table>
<?php
CloseTable();
}
include_once("footer.php");
?>
