//v1.8 www.exoops.info 2006/03
//
// ------------------------------------------------------------------------- //
// E-Xoops: Content Management for the Masses //
// < http://www.e-xoops.com > //
// ------------------------------------------------------------------------- //
// Original Author: Pascal Le Boustouller
// Author Website : http://www.perso-search.com/e-xoopsien/
// Licence Type : GPL
// ------------------------------------------------------------------------- //
include("header.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
function AnnoncesDel($lid, $ok) {
global $db, $xoopsUser, $bcoosConfig, $xoopsTheme;
$result = $db->query("SELECT usid, photo FROM ".$db->prefix("ann_annonces")." where lid=$lid");
list($usid, $photo) = $db->fetchRow($result);
if ($xoopsUser) {
$calusern = $xoopsUser->getVar("uid", "E");
if ($usid == $calusern) {
if($ok==1) {
$db->query("delete from ".$db->prefix("ann_annonces")." where lid=$lid");
if($photo){
$destination = XOOPS_ROOT_PATH."/modules/MyAnnonces/images_ann";
if (file_exists("$destination/$photo")) {
unlink("$destination/$photo");
}
}
redirect_header("index.php",1,_CLA_ANNDEL);
exit();
} else {
include(XOOPS_ROOT_PATH."/header.php");
OpenTable();
echo "
";
echo ""._CLA_SURDELANN."
";
}
echo "[ "._YES." | "._NO." ]
";
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
}
}
}
function ModAnnonce($lid) {
global $db, $xoopsModule, $bcoosConfig, $xoopsUser, $monnaie, $moderated, $photomax, $ynprice, $xoopsTheme, $myts;
include(XOOPS_ROOT_PATH."/header.php");
echo "";
include_once(XOOPS_ROOT_PATH."/modules/MyAnnonces/class/arbre.php");
$mytree = new XoopsArbre($db->prefix("ann_categories"),"cid","pid");
$photomax1=$photomax/1024;
$result = $db->query("select lid, cid, title, type, description, tel, price, typeprix, date, email, submitter, usid, town, country, valid, photo from ".$db->prefix("ann_annonces")." where lid=$lid");
list($lid, $cide, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $usid, $town, $country, $valid, $photo_old) = $db->fetchRow($result);
if ($xoopsUser) {
$calusern = $xoopsUser->uid();
if ($usid == $calusern) {
OpenTable();
echo ""._CLA_MODIFANN."
";
$title = $myts->makeTboxData4Edit($title);
$type = $myts->makeTboxData4Edit($type);
$description = $myts->makeTboxData4Edit($description);
$tel = $myts->makeTboxData4Edit($tel);
$price = $myts->makeTboxData4Edit($price);
$typeprix = $myts->makeTboxData4Edit($typeprix);
$submitter = $myts->makeTboxData4Edit($submitter);
$town = $myts->makeTboxData4Edit($town);
$country = $myts->makeTboxData4Edit($country);
$useroffset = "";
if($xoopsUser) {
$timezone = $xoopsUser->timezone();
if(isset($timezone)){
$useroffset = $xoopsUser->timezone();
}else{
$useroffset = $bcoosConfig['default_TZ'];
}
}
$dates = ($useroffset*3600) + $date;
$dates = formatTimestamp($date,"s");
echo "
";
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
}
}
}
function ModAnnonceS($lid, $cat, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $valid, $photo, $photo_old, $photoS_size, $photoS_name, $_FILES, $supprim) {
global $db, $bcoosConfig, $photomax, $myts;
$destination = XOOPS_ROOT_PATH."/modules/MyAnnonces/images_ann";
if($supprim == "yes"){
if (file_exists("$destination/$photo_old")) {
unlink("$destination/$photo_old");
}
$photo_old = "";
}
$title = $myts->makeTboxData4Save($title);
$type = $myts->makeTboxData4Save($type);
$description = $myts->makeTboxData4Save($description);
$tel = $myts->makeTboxData4Save($tel);
$price = $myts->makeTboxData4Save($price);
$typeprix = $myts->makeTboxData4Save($typeprix);
$submitter = $myts->makeTboxData4Save($submitter);
$town = $myts->makeTboxData4Save($town);
$country = $myts->makeTboxData4Save($country);
if ( !empty($_FILES['photo']['name']) ) {
include_once(XOOPS_ROOT_PATH."/class/fileupload.php");
$upload = new fileupload();
$upload->set_upload_dir("$destination/", 'photo');
$upload->set_accepted("gif|jpg|png", 'photo');
$upload->set_overwrite(1, 'photo');
$result = $upload->upload();
if (!$result['photo']['filename']) {
redirect_header("supprann.php?op=ModAnnonce&lid=$lid", 3, $upload->errors());
exit();
} else {
if ($photo_old) {
if (@file_exists("$destination/$photo_old")) {
unlink("$destination/$photo_old");
}
}
$photo_old = $result['photo']['filename'];
}
}
$db->query("update ".$db->prefix("ann_annonces")." set cid='$cat', title='$title', type='$type', description='$description', tel='$tel', price='$price', typeprix='$typeprix', email='$email', submitter='$submitter', town='$town', country='$country', valid='$valid', photo='$photo_old' where lid=$lid");
redirect_header("index.php",1,_CLA_ANNMOD2);
exit();
}
switch ($op) {
case "ModAnnonce":
ModAnnonce($lid);
break;
case "ModAnnonceS":
ModAnnonceS($lid, $cid, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $valid, $photo, $photo_old, $photo_size, $photo_name, $_FILES, $supprim);
break;
case "AnnoncesDel":
AnnoncesDel($lid, $ok);
break;
default:
redirect_header("index.php",1,""._RETURNANN."");
break;
}
?>