//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");
function index($cid) {
global $myts, $xoopsUser, $annoadd, $xoopsModule;
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/include/functions.php");
if (!$xoopsUser && $annoadd == 0) {
redirect_header(XOOPS_URL."/user.php",3,_CLA_FORMEMBERS2);
exit();
} else {
include(XOOPS_ROOT_PATH."/header.php");
OpenTable();
echo ""._CLA_MAIN." » "._CLA_ADDANNONCE3."
\n";
$condition = join('', file("./cache/condition.txt"));
echo "".$myts->makeTareaData4Show($condition, 1, 1, 1)."
";
echo "
[ "._CLA_CONDITIONOK." | "._CLA_CONDITIONNO." ]";
CloseTable();
copyright();
include(XOOPS_ROOT_PATH."/footer.php");
}
}
function addindex($cid) {
global $db, $bcoosConfig, $xoopsUser, $xoopsTheme, $photomax, $xoopsModule, $ynprice;
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/include/functions.php");
include_once(XOOPS_ROOT_PATH."/modules/MyAnnonces/class/arbre.php");
$mytree = new XoopsArbre($db->prefix("ann_categories"),"cid","pid");
if ($cid =="") {
redirect_header("index.php",1,_CLA_ADDANNONCE);
exit();
}
if (!$xoopsUser && $annoadd == 0) {
redirect_header(XOOPS_URL."/user.php",3,_CLA_FORMEMBERS2);
exit();
} else {
$photomax1=$photomax/1024;
include(XOOPS_ROOT_PATH."/header.php");
echo "";
list($numrows) = $db->fetchRow($db->query("select cid, title from ".$db->prefix("ann_categories").""));
if ($numrows>0) {
OpenTable();
echo ""._CLA_MAIN." » "._CLA_ADDANNONCE3."
";
if ($moderated == '1') {
echo ""._CLA_ANNMODERATE." $claday "._CLA_DAY."
";
} else {
echo ""._CLA_ANNNOMODERATE." $claday "._CLA_DAY."
";
}
echo "";
CloseTable();
copyright();
include(XOOPS_ROOT_PATH."/footer.php");
}
}
}
function AddAnnoncesOk($lid, $cat, $titre, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $usid, $town, $country, $valid, $photo, $photo_size, $photo_name, $_FILES) {
global $db, $bcoosConfig, $photomax, $destination, $myts;
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/include/functions.php");
$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/upload.class.php");
$upload = new Upload();
$upload->setAllowedMimeTypes(".gif|.jpeg|.jpg|.png");
$upload->setUploadPath(XOOPS_ROOT_PATH."/modules/MyAnnonces/images_ann");
$upload->setDestinationFileName('photo');
$upload->setFileName($lid);
$result = $upload->doUpload();
if ($result == false) {
$errors = $upload->getUploadErrors();
$errorstring = "";
$errorstring .= "::Errors occured::
\n";
while(list($filename,$values) = each($errors)) {
$errorstring .= "File: " . $filename . "
";
$count = count($values);
for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "
"; }
}
redirect_header("addannonces.php?cid=$cat", 3, $errorstring);
exit();
}
}
$db->query("INSERT INTO ".$db->prefix("ann_annonces")." values ('', '$cat', '$titre', '$type', '$description', '$tel', '$price', '$typeprix', '$date', '$email', '$submitter', '$usid', '$town', '$country', '$valid', '".$upload->FileName.".".$upload->getFileExtension()."', '0')");
redirect_header("index.php",1,_CLA_ANNADDED);
exit();
}
switch($op) {
case "AddAnnoncesOk":
AddAnnoncesOk($lid, $cid, $titre, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $usid, $town, $country, $valid, $photo, $photo_size, $photo_name, $_FILES);
break;
case "addindex":
addindex($cid);
break;
default:
index($cid);
break;
}
?>