//classifieds.php
/**************************************************************************\
Copyright (c) 2002 Geodesic Solutions, Inc.
All rights reserved
license http://www.gnu.org/copyleft/gpl.html GNU/GPL
http://www.geodesicsolutions.com
\**************************************************************************/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
include_once("config.php");
include_once("classes/adodb.inc.php");
include_once("classes/site_class.php");
$db = &ADONewConnection('mysql');
//$db = &ADONewConnection('access');
//$db = &ADONewConnection('ado');
//$db = &ADONewConnection('ado_mssql');
//$db = &ADONewConnection('borland_ibase');
//$db = &ADONewConnection('csv');
//$db = &ADONewConnection('db2');
//$db = &ADONewConnection('fbsql');
//$db = &ADONewConnection('firebird');
//$db = &ADONewConnection('ibase');
//$db = &ADONewConnection('informix');
//$db = &ADONewConnection('mssql');
//$db = &ADONewConnection('mysqlt');
//$db = &ADONewConnection('oci8');
//$db = &ADONewConnection('oci8po');
//$db = &ADONewConnection('odbc');
//$db = &ADONewConnection('odbc_mssql');
//$db = &ADONewConnection('odbc_oracle');
//$db = &ADONewConnection('oracle');
//$db = &ADONewConnection('postgres7');
//$db = &ADONewConnection('postgress');
//$db = &ADONewConnection('proxy');
//$db = &ADONewConnection('sqlanywhere');
//$db = &ADONewConnection('sybase');
//$db = &ADONewConnection('vfp');
//$db->debug = true;
if (!$db->Connect($db_host, $db_username, $db_password, $database))
{
echo "could not connect to database
";
echo $db->ErrorMsg()." is the error
\n";
exit;
}
if (isset($HTTP_COOKIE_VARS))
{
$_COOKIE = $HTTP_COOKIE_VARS;
}
if (!$_COOKIE["classified_session"])
{
$current_time = time();
$sql_query = "delete from geodesic_sessions WHERE last_time < ".($current_time - 3600);
//echo $sql_query." is the query
\n";
$delete_session_result = $db->Execute($sql_query);
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
//set session in db
srand((double)microtime()*1000000);
do {
$custom_id = md5(uniqid(rand(),1));
$custom_id = substr( $custom_id, 0,32);
$sql_query = "SELECT classified_session FROM geodesic_sessions WHERE classified_session = \"".$custom_id."\"";
//echo $sql_query." is the query
\n";
$custom_id_result = $db->Execute($sql_query);
if (!$custom_id_result)
{
//echo $sql_query."
\n";
return false;
}
} while ($custom_id_result->RecordCount() > 0);
//$ip = getenv("REMOTE_ADDR");
$ip = 0;
$sql_query = "insert into geodesic_sessions
(classified_session,user_id,last_time,ip,level)
values
(\"".$custom_id."\",0,".$current_time.",\"".$ip."\",0)";
//echo $sql_query." is the query
\n";
$insert_session_result = $db->Execute($sql_query);
if (!$insert_session_result)
{
//echo $sql_query."
\n";
return false;
}
$expires = time() + 31536000;
$user_id = 0;
$user_level = 0;
$classified_session = $custom_id;
header("Set-Cookie: classified_session=".$custom_id."; path=/; domain=".$_SERVER["HTTP_HOST"]."; expires=".gmstrftime("%A, %d-%b-%Y %H:%M:%S GMT",$expires));
}
else
{
$current_time = time();
$sql_query = "delete from geodesic_sessions WHERE last_time < ".($current_time - 3600);
$delete_session_result = $db->Execute($sql_query);
//echo $sql_query." is the query 2
\n";
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
//get session information
$sql_query = "SELECT * FROM geodesic_sessions WHERE classified_session = \"".$_COOKIE["classified_session"]."\"";
$session_result = $db->Execute($sql_query);
//echo $sql_query." is the query
\n";
if (!$session_result)
{
//echo $sql_query."
\n";
return false;
}
elseif ($session_result->RecordCount() == 1)
{
//$current_ip = getenv("REMOTE_ADDR");
$current_ip = 0;
$show = $session_result->FetchNextObject();
$sql_query = "update geodesic_sessions set last_time = ".$current_time." where classified_session = \"".$_COOKIE["classified_session"]."\"";
$update_session_result = $db->Execute($sql_query);
//echo $sql_query." is the query
\n";
if (!$update_session_result)
{
//echo $sql_query."
\n";
return false;
}
elseif ($session_result->RecordCount() == 1)
{
if (($show->LAST_TIME < ($current_time + 60)) && ($current_ip == $show->IP))
{
$user_id = $show->USER_ID;
$user_level = $show->LEVEL;
$classified_session = $_COOKIE["classified_session"];
}
else
{
//change session
setcookie("classified_session","",0,"/",$_SERVER["HTTP_HOST"]);
$sql_query = "delete from geodesic_sessions where classified_session = \"".$_COOKIE["classified_session"]."\"";
$delete_session_result = $db->Execute($sql_query);
//echo $sql_query." is the query
\n";
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
header("Location: ".$auth->configuration_data->CLASSIFIEDS_URL."?".$QUERY_STRING);
}
}
else
{
setcookie("classified_session","",0,"/",$_SERVER["HTTP_HOST"]);
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
header("Location: ".$auth->configuration_data->CLASSIFIEDS_URL."?".$QUERY_STRING);
}
}
else
{
$ip = 0;
$sql_query = "insert into geodesic_sessions
(classified_session,user_id,last_time,ip,level)
values
(\"".$_COOKIE["classified_session"]."\",0,".$current_time.",\"".$ip."\",0)";
//echo $sql_query." is the query
\n";
$insert_session_result = $db->Execute($sql_query);
if (!$insert_session_result)
{
//echo $sql_query."
\n";
return false;
}
//setcookie("classified_session","",0,"/",$_SERVER["HTTP_HOST"]);
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
header("Location: ".$auth->configuration_data->CLASSIFIEDS_URL."?".$QUERY_STRING);
}
}
if ($_REQUEST["set_language_cookie"])
{
$expires = time() + 31536000;
setcookie("language_id","",0);
setcookie("language_id",$_REQUEST["set_language_cookie"],$expires);
//echo $set_language_cookie." is set_language_cookie2
\n";
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$_REQUEST["set_language_cookie"]);
$auth->reset_language($db,$_REQUEST["set_language_cookie"]);
//header("Location: ".$auth->configuration_data->CLASSIFIEDS_URL."?".$QUERY_STRING);
$language_id = $_REQUEST["set_language_cookie"];
$_COOKIE["language_id"] = $_REQUEST["set_language_cookie"];
}
if ($_COOKIE["language_id"])
{
$language_id = $_COOKIE["language_id"];
}
else
{
//get default language
$sql_query = "SELECT language_id FROM geodesic_text_languages where default_language = 1";
$default_language_result = $db->Execute($sql_query);
//echo $sql_query."
";
if (($default_language_result) && ($default_language_result->RecordCount() == 1))
{
$show_language_id = $default_language_result->FetchNextObject();
$expires = time() + 31536000;
setcookie("language_id",$show_language_id->LANGUAGE_ID,$expires);
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$show_language_id->LANGUAGE_ID);
$auth->reset_language($db,$show_language_id->LANGUAGE_ID);
$language_id = $show_language_id->LANGUAGE_ID;
}
else
{
$language_id = 1;
}
}
switch ($_REQUEST["a"]) {
case 1:
//put an ad into the classifieds
if ($user_id)
{
include_once("classes/classified_sell_class.php");
$sell = new Classified_sell($db,$user_id,$language_id,$_COOKIE["classified_session"]);
if (strlen(trim($sell->setup_error)) == 0)
{
if ($_REQUEST["paypal_return"])
{
$sell->header($db);
$sell->sell_success($db,0,0,0,$_REQUEST["paypal_return"]);
$sell->footer($db);
$sell->remove_sell_session($db,$_REQUEST["paypal_return"]);
$db->Close();
exit;
}
if (!$sell->configuration_data->USE_EXPLORER_CATEGORY_PROCESS)
{
//this is the process where the category selection is a
//dropdown box at the top of the classified details collection page
if ((!$sell->classified_details_collected) || (!$sell->terminal_category))
{
$sell->header($db);
if (($_REQUEST["b"]) && (is_array($_REQUEST["b"])))
{
$sell->get_badword_array($db);
$sell->get_html_disallowed_array($db);
$sell->check_extra_questions($db);
$sell->get_form_variables($_REQUEST["b"]);
//$sell->save_form_variables($db);
$b = $_REQUEST["b"];
if (($sell->classified_detail_check($db)) && ($sell->check_category_selection($db,$b[category_id])))
{
$sell->save_form_variables($db);
$sell->update_classified_details_collected($db,1);
if (!$sell->classified_images_collected)
$sell->display_classified_image_form($db);
else
$sell->classified_approval_display($db);
}
else
{
$sell->save_form_variables($db);
$sell->display_classified_detail_form($db);
}
}
else
{
//detail form has not been submitted yet
$sell->display_classified_detail_form($db);
}
$sell->footer($db);
$db->Close();
exit;
}
}
else
{
//this is sell process where the category choice is a process
//by itself before the classified details collection form
if (!$sell->terminal_category)
{
$sell->header($db);
if (($_REQUEST["b"]) && ($_REQUEST["c"] == "terminal") && (is_numeric($_REQUEST["b"])))
{
if ($sell->set_terminal_category($db,$_REQUEST["b"]))
{
if (!$sell->classified_details_collected)
$sell->display_classified_detail_form($db);
elseif (!$sell->classified_images_collected)
$sell->display_classified_image_form($db);
else
$sell->classified_approval_display($db);
}
else
$sell->sell_error();
}
elseif (($_REQUEST["b"]) && ($_REQUEST["b"] != "accepted") && (is_numeric($_REQUEST["b"])))
{
if (!$sell->choose_category($db,$_REQUEST["b"]))
$sell->sell_error();
}
else
{
if (!$sell->choose_category($db))
$sell->sell_error();
}
$sell->footer($db);
$db->Close();
exit;
}
elseif (!$sell->classified_details_collected)
{
$sell->header($db);
if (($_REQUEST["b"]) && (is_array($_REQUEST["b"])))
{
$sell->get_badword_array($db);
$sell->get_html_disallowed_array($db);
$sell->check_extra_questions($db);
$sell->get_form_variables($_REQUEST["b"]);
//$sell->save_form_variables($db);
if ($sell->classified_detail_check($db))
{
$sell->save_form_variables($db);
$sell->update_classified_details_collected($db,1);
if (!$sell->classified_images_collected)
$sell->display_classified_image_form($db);
else
$sell->classified_approval_display($db);
}
else
{
$sell->save_form_variables($db);
$sell->display_classified_detail_form($db);
}
}
else
{
//detail form has not been submitted yet
$sell->display_classified_detail_form($db);
}
$sell->footer($db);
$db->Close();
exit;
}
}
if (!$sell->classified_details_collected)
{
$sell->header($db);
if (($_REQUEST["b"]) && (is_array($_REQUEST["b"])))
{
$sell->get_badword_array($db);
$sell->get_html_disallowed_array($db);
$sell->check_extra_questions($db);
$sell->get_form_variables($_REQUEST["b"]);
//$sell->save_form_variables($db);
if ($sell->classified_detail_check($db))
{
$sell->save_form_variables($db);
$sell->update_classified_details_collected($db,1);
if (!$sell->classified_images_collected)
$sell->display_classified_image_form($db);
else
$sell->classified_approval_display($db);
}
else
{
$sell->save_form_variables($db);
$sell->display_classified_detail_form($db);
}
}
else
{
//detail form has not been submitted yet
$sell->display_classified_detail_form($db);
}
$sell->footer($db);
$db->Close();
exit;
}
if (!$sell->classified_images_collected)
{
$sell->header($db);
$sell->get_form_variables($_REQUEST["b"]);
$sell->save_form_variables($db);
if (($_REQUEST["f"]) && ($_REQUEST["g"]))
{
//remove the image
$sell->remove_image($db,$_REQUEST["f"],$_REQUEST["g"]);
$sell->display_classified_image_form($db);
}
elseif (($_REQUEST["c"]) || ($_FILES["d"]))
{
if (isset ($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
$sell->process_images($db,$_REQUEST["c"],$_FILES);
if ($sell->classified_images_collected)
{
$sell->classified_approval_display($db);
}
else
$sell->display_classified_image_form($db);
}
elseif ($sell->classified_images_collected)
{
$sell->classified_approval_display($db);
}
else
$sell->display_classified_image_form($db);
$sell->footer($db);
}
elseif (!$sell->classified_approved)
{
$sell->header($db);
if ($_REQUEST["b"])
{
if ($_REQUEST["b"] == "ad_accepted")
{
if ($sell->insert_classified($db))
{
if (!$sell->configuration_data->ALL_ADS_ARE_FREE)
{
if (!$sell->classified_billing_form($db))
$sell->sell_error();
}
else
{
include_once("classes/user_management_class.php");
$user_management = new User_management($db,$language_id,$auth->classified_user_id);
$user_management->check_ad_filters($db,$sell->classified_id);
if (!$sell->sell_success($db))
$sell->sell_error();
}
}
else
{
if (!$sell->classified_approval_display($db))
$sell->sell_error();
}
}
elseif ($_REQUEST["b"] == "edit_details")
{
$sell->update_images_collected($db,0);
$sell->update_classified_details_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->display_classified_detail_form($db);
}
elseif ($_REQUEST["b"] == "edit_image")
{
$sell->update_images_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->display_classified_image_form($db);
}
elseif ($_REQUEST["b"] == "edit_category")
{
$sell->update_terminal_category($db,0);
$sell->update_classified_details_collected($db,0);
$sell->update_images_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->choose_category($db);
}
else
{
if (!$sell->classified_approval_display($db))
$sell->sell_error();
}
}
else
{
if (!$sell->classified_approval_display($db))
$sell->sell_error();
}
$sell->footer($db);
}
elseif (!$sell->billing_approved)
{
$sell->header($db);
if ($_REQUEST["b"])
{
$sell->get_form_variables($_REQUEST["c"]);
$sell->save_form_variables($db);
if (($_REQUEST["b"] == "billing_accepted") && ($_REQUEST["z"]))
{
if ($sell->check_transaction_variables($db))
{
//show the final approval
//try the card
if (!$sell->final_approval_form($db))
{
if (!$sell->classified_billing_form($db))
$sell->sell_error();
}
}
else
{
if (!$sell->classified_billing_form($db))
$sell->sell_error();
}
}
elseif ($_REQUEST["b"] == "edit_details")
{
$sell->update_classified_approved($db,0);
$sell->update_images_collected($db,0);
$sell->update_classified_details_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->display_classified_detail_form($db);
}
elseif ($_REQUEST["b"] == "edit_category")
{
$sell->update_classified_approved($db,0);
$sell->update_images_collected($db,0);
$sell->update_classified_details_collected($db,0);
$sell->update_terminal_category($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->choose_category($db);
}
elseif ($_REQUEST["b"] == "edit_image")
{
$sell->update_classified_approved($db,0);
$sell->update_images_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->display_classified_image_form($db);
}
else
{
if (!$sell->classified_billing_form($db))
$sell->sell_error();
}
}
else
{
if (!$sell->classified_billing_form($db))
$sell->sell_error();
}
$sell->footer($db);
}
elseif (!$sell->final_approval)
{
//this is a cash, check or money order transaction
//or the user is wanting to edit the category, details, images or transaction data
$sell->get_form_variables($_REQUEST["c"]);
$sell->save_form_variables($db);
if ($_REQUEST["b"])
{
if ($_REQUEST["b"] == "final_accepted")
{
//do the cash, check or money order hold routine
//display the cash, check or money order success messages
if ($sell->check_transaction_variables($db))
{
//show the final approval
//try the card
if ($sell->transaction_approved($db))
{
$sell->header($db);
include_once("classes/user_management_class.php");
$user_management = new User_management($db,$language_id,$auth->classified_user_id);
$user_management->check_ad_filters($db,$sell->classified_id);
$sell->sell_success($db);
}
else
{
$sell->header($db);
if (!$sell->final_approval_form($db))
$sell->sell_error();
}
}
else
{
$sell->header($db);
if (!$sell->classified_billing_form($db))
$sell->sell_error();
}
}
elseif ($_REQUEST["b"] == "edit_category")
{
$sell->header($db);
$sell->update_classified_approved($db,0);
$sell->update_images_collected($db,0);
$sell->update_classified_details_collected($db,0);
$sell->update_terminal_category($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->choose_category($db);
}
elseif ($_REQUEST["b"] == "edit_details")
{
$sell->header($db);
$sell->update_classified_approved($db,0);
$sell->update_images_collected($db,0);
$sell->update_classified_details_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->display_classified_detail_form($db);
}
elseif ($_REQUEST["b"] == "edit_image")
{
$sell->header($db);
$sell->update_classified_approved($db,0);
$sell->update_images_collected($db,0);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->display_classified_image_form($db);
}
elseif ($_REQUEST["b"] == "edit_transaction")
{
$sell->header($db);
$sell->update_billing_approved($db,0);
$sell->update_final_approval($db,0);
$sell->classified_billing_form($db);
}
else
{
$sell->header($db);
if (!$sell->final_approval_form($db))
{
$sell->sell_error();
}
}
}
elseif ($_REQUEST["credit_approval"])
{
$sell->header($db);
include_once("classes/user_management_class.php");
$user_management = new User_management($db,$language_id,$auth->classified_user_id);
$user_management->check_ad_filters($db,$sell->classified_id);
$sell->sell_success($db,$_REQUEST["credit_approval"],$_REQUEST["declined"]);
}
else
{
$sell->header($db);
if (!$sell->final_approval_form($db))
{
$sell->sell_error();
}
}
$sell->footer($db);
}
else
{
$sell->header($db);
if ($_REQUEST["credit_approval"])
{
include_once("classes/user_management_class.php");
$user_management = new User_management($db,$language_id,$auth->classified_user_id);
$user_management->check_ad_filters($db,$sell->classified_id);
$sell->sell_success($db,$_REQUEST["credit_approval"],$_REQUEST["declined"]);
}
else
{
$sell->update_final_approval($db,0);
if (!$sell->final_approval_form($db))
{
$sell->sell_error();
}
}
$sell->footer($db);
}
}
else
{
$sell->remove_sell_session($db,$sell->session_id);
$sell->header($db);
$sell->setup_sell_error_display();
$sell->footer($db);
}
}
else
{
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
$auth->header($db);
$auth->login_form();
$auth->footer($db);
}
$db->Close();
exit;
break;
case 2:
//display a classified
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id,0,$page,$_REQUEST["b"]);
$browse->classified_close($db);
$browse->header($db);
if ($_REQUEST["b"])
{
if ($browse->classified_exists($db,$_REQUEST["b"]))
{
if (!$browse->display_classified($db,$_REQUEST["b"]))
$browse->browse_error();
}
else
{
$browse->browse_error();
}
}
else
{
//display the home page
if (!$browse->main($db))
$browse->browse_error();
}
$browse->footer($db);
break;
case 3:
//send communication
include_once("classes/user_management_class.php");
$communication = new User_management($db,$language_id,$user_id);
$communication->header($db);
$communication->user_management_header($db,$_REQUEST["b"]);
if (($_REQUEST["b"]) && ($_REQUEST["d"]))
{
if (!$communication->send_communication($db,$_REQUEST["b"],$_REQUEST["d"]))
$communication->site_error();
else
if (!$communication->communication_success($db))
$communication->site_error();
}
elseif (($_REQUEST["b"]))
{
//display the home page
if (!$communication->send_communication_form($db,$_REQUEST["b"],$_REQUEST["c"]))
$communication->site_error();
}
else
{
$communication->site_error();
}
$communication->user_management_footer($db);
$communication->footer($db);
break;
case "4":
//user management
//b is the secondary switch within user management
if ($user_id)
{
include_once("classes/user_management_class.php");
$user_management = new User_management($db,$language_id,$user_id);
$user_management->header($db);
$user_management->user_management_header($db,$_REQUEST["b"]);
switch ($_REQUEST["b"])
{
case 1:
//show current ads
if (!$user_management->list_current_ads($db))
$user_management->site_error();
break;
case 2:
//show past ads
if ($_REQUEST["c"])
{
if (!$user_management->show_expired_ad($db,$_REQUEST["c"]))
$user_management->site_error();
}
elseif (!$user_management->list_expired_ads($db))
$user_management->site_error();
break;
case 3:
//show user info
if (!$user_management->display_user_data($db))
$user_management->site_error();
break;
case 4:
//edit user info
if ($_REQUEST["c"])
{
//update the current user_info
if ($user_management->check_info($db,$_REQUEST["c"]))
{
$user_management->update_user($db,$_REQUEST["c"],$_REQUEST["d"]);
if (!$user_management->display_user_data($db))
$user_management->site_error();
}
elseif (!$user_management->edit_user_form($db,$_REQUEST["c"]))
$user_management->site_error();
}
else
{
//show edit form
if (!$user_management->edit_user_form($db))
$user_management->site_error();
}
break;
case 5:
//edit a classified ad
if ($_REQUEST["e"])
{
switch ($_REQUEST["c"])
{
case 1:
//edit the classified ads details
if ($_REQUEST["d"])
{
$user_management->get_badword_array($db);
$user_management->get_html_disallowed_array($db);
$user_management->get_form_variables($_REQUEST["d"]);
$user_management->check_extra_questions($db);
if ($user_management->classified_detail_check($db))
{
if (!$user_management->update_classified_ad_details($db,$_REQUEST["e"]))
$user_management->site_error();
else
if (!$user_management->edit_classified_ad_home($db,$_REQUEST["e"]))
$user_management->site_error();
}
else
{
if (!$user_management->edit_classified_ad_detail($db,$_REQUEST["e"]))
$user_management->site_error();
}
}
else
if (!$user_management->edit_classified_ad_detail($db,$_REQUEST["e"]))
$user_management->site_error();
break;
case 2:
//edit the classified ads images
if (!$user_management->edit_classified_ad_images($db,$_REQUEST["e"]))
$user_management->site_error();
break;
case 3:
//edit the classified ads category
if ($_REQUEST["d"])
{
if (!$user_management->update_classified_ad_category($db,$_REQUEST["d"],$_REQUEST["e"]))
$user_management->site_error();
else
if (!$user_management->edit_classified_ad_home($db,$_REQUEST["e"]))
$user_management->site_error();
}
else
if (!$user_management->edit_classified_ad_category($db,$_REQUEST["e"]))
$user_management->site_error();
break;
case 4:
//delete classified ads images
if ($_REQUEST["d"])
{
//delete image
if (!$user_management->delete_classified_ad_image($db,$_REQUEST["d"],$_REQUEST["e"]))
$user_management->site_error();
else
if (!$user_management->edit_classified_ad_images($db,$_REQUEST["e"]))
$user_management->site_error();
}
else
if (!$user_management->edit_classified_ad_images($db,$_REQUEST["e"]))
$user_management->site_error();
break;
case 5:
//add classified ads image
if ($_REQUEST["e"])
{
if (isset ($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
//add image
if (!$user_management->process_images($db,$_REQUEST["d"],$_REQUEST["e"],$_FILES))
$user_management->site_error();
else
if (!$user_management->edit_classified_ad_images($db,$_REQUEST["e"]))
$user_management->site_error();
}
else
{
if (!$user_management->edit_classified_ad_images($db,$_REQUEST["e"]))
$user_management->site_error();
}
break;
default:
if (!$user_management->edit_classified_ad_home($db,$_REQUEST["e"]))
$user_management->site_error();
break;
}
}
else
{
if (!$user_management->list_current_ads($db))
$user_management->site_error();
}
break;
case 6:
//delete a classified ad
if (($_REQUEST["c"]) && ($_REQUEST["z"]))
{
//go ahead and delete
if (!$user_management->remove_current_ad($db,$_REQUEST["c"]))
{
if (!$user_management->verify_remove_current_ad($db,$_REQUEST["c"]))
$user_management->site_error();
}
else
if (!$user_management->verify_remove_success())
$user_management->site_error();
}
else
{
if (!$user_management->verify_remove_current_ad($db,$_REQUEST["c"]))
$user_management->site_error();
}
break;
case 7:
//communication configuration
if (($_REQUEST["c"]) && ($_REQUEST["z"]))
{
//go ahead and delete
if (!$user_management->update_communication_configuration($db,$_REQUEST["c"]))
$user_management->site_error();
else
if (!$user_management->list_communications($db))
$user_management->site_error();
}
else
{
if (!$user_management->communications_configuration($db))
$user_management->site_error();
}
break;
case 8:
//communication management and viewing
switch ($_REQUEST["c"])
{
case 1:
//view message
if ($_REQUEST["d"])
if (!$user_management->view_this_communication($db,$_REQUEST["d"]))
$user_management->site_error();
else
if (!$user_management->list_communications($db))
$user_management->site_error();
break;
case 2:
//delete message
if ($_REQUEST["d"])
if (!$user_management->delete_this_communication($db,$_REQUEST["d"]))
$user_management->site_error();
else
if (!$user_management->list_communications($db))
$user_management->site_error();
break;
case 3:
//respond to message
break;
case 4:
//send a message
$d = $_REQUEST["d"];
if (!$user_management->send_communication($db,$d["to"],$d))
$user_management->site_error();
else
if (!$user_management->list_communications($db))
$user_management->site_error();
break;
default:
//show communications list
if (!$user_management->list_communications($db))
$user_management->site_error();
break;
}
break;
case 9:
//view, edit and update ad filters
switch ($_REQUEST["c"])
{
case 1:
//ad filter form
if (!$user_management->add_new_filter_form($db))
$user_management->site_error();
break;
case 2:
//delete filter
if (!$user_management->delete_ad_filter($db,$_REQUEST["d"]))
$user_management->site_error();
else
if (!$user_management->display_all_ad_filters($db))
$user_management->site_error();
break;
case 3:
//remove all ad filters
if (!$user_management->clear_ad_filters($db))
$user_management->site_error();
else
if (!$user_management->display_all_ad_filters($db))
$user_management->site_error();
break;
case 4:
//insert an ad filter
if (!$user_management->insert_new_filter($db,$_REQUEST["d"]))
$user_management->site_error();
else
if (!$user_management->display_all_ad_filters($db))
$user_management->site_error();
break;
default:
//view all filters
if (!$user_management->display_all_ad_filters($db))
$user_management->site_error();
}
break;
case 10:
//view, edit and update ad filters
$user_management->expire_old_favorites($db);
switch ($_REQUEST["c"])
{
case 1:
//delete favorite
if (!$user_management->delete_favorite($db,$_REQUEST["d"]))
$user_management->site_error();
elseif (!$user_management->display_all_favorites($db))
$user_management->site_error();
break;
default:
//view all filters
if (!$user_management->display_all_favorites($db))
$user_management->site_error();
}
break;
default:
//display user management home
if (!$user_management->user_management_home($db))
$user_management->site_error();
} //end of switch
$user_management->user_management_footer($db);
$user_management->footer($db);
}
else
{
//no user id
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
$auth->header($db);
$auth->login_form();
$auth->footer($db);
}
$db->Close();
exit;
break;
case "5":
//display a category
//b will contain the category id
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id,$_REQUEST["b"],$_REQUEST["page"]);
$browse->classified_close($db);
$browse->header($db);
if ($_REQUEST["b"])
{
if (!$browse->browse($db,$_REQUEST["b"]))
$browse->browse_error();
}
else
{
if (!$browse->main($db))
$browse->browse_error();
}
$browse->footer($db);
$db->Close();
exit;
break;
case "6":
//display sellers other ads
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id,0,$_REQUEST["page"]);
$browse->header($db);
if ($_REQUEST["b"])
{
if (!$browse-> browse_sellers_other_ads($db,$_REQUEST["b"]))
$browse->site_error($db);
}
else
{
if (!$browse->main($db))
$browse->browse_error();
}
$browse->footer($db);
$db->Close();
exit;
break;
case 10:
//login
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
if (!$user_id)
{
if ($_REQUEST["b"])
{
$b = $_REQUEST["b"];
$username = $b[username];
$password = $b[password];
$authorized = $auth->login($db,$username,$password,$classified_session);
if ($authorized)
{
if ($_REQUEST["c"])
{
header("Location: ".$browse->configuration_data->CLASSIFIEDS_URL."?".urldecode($_REQUEST["c"]));
}
else
{
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$authorized,$language_id);
$browse->header($db);
$browse->main($db);
}
}
else
{
$auth->header($db);
$b = $_REQUEST["b"];
$username = $b[username];
$password = $b[password];
$auth->login_form($username, $password);
}
}
else
{
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
$auth->login_form();
}
}
else
{
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
$auth->already_logged_in();
}
$auth->footer($db);
$db->Close();
exit;
break;
case 12:
//notify a friend
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
if (($_REQUEST["b"]) && ($_REQUEST["c"]))
{
if ($browse->verify_notify_friend($db,$_REQUEST["b"],$_REQUEST["c"]))
{
if ($browse->notify_friend($db,$_REQUEST["b"],$_REQUEST["c"]))
$browse->notify_success($_REQUEST["b"]);
else
$browse->site_error();
}
elseif (!$browse->notify_friend_form($db,$_REQUEST["b"]))
$browse->site_error();
}
elseif ($_REQUEST["b"])
{
$browse->notify_friend_form($db,$_REQUEST["b"]);
}
else
{
}
$browse->footer($db);
$db->Close();
exit;
break;
case 13:
//send a message to seller
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
if (($_REQUEST["b"]) && ($_REQUEST["c"]))
{
if ($browse->notify_seller($db,$_REQUEST["b"],$_REQUEST["c"]))
$browse->notify_seller_success($_REQUEST["b"]);
elseif (!$browse->send_a_message_to_seller_form($db,$_REQUEST["b"]))
$browse->site_error();
}
elseif ($_REQUEST["b"])
{
$browse->send_a_message_to_seller_form($db,$_REQUEST["b"]);
}
else
{
}
$browse->footer($db);
$db->Close();
exit;
break;
case 17:
//log this user out
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
if ($user_id)
{
//destroy the cookie
//setcookie("classified_session","",0,"/","$HTTP_HOST");
$sql_query = "delete from geodesic_sessions where classified_session = \"".$_COOKIE["classified_session"]."\"";
$delete_session_result = $db->Execute($sql_query);
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
$sql_query = "delete from geodesic_classifieds_sell_session where session = \"".$_COOKIE["classified_session"]."\"";
$delete_session_result = $db->Execute($sql_query);
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
$sql_query = "delete from geodesic_classifieds_sell_session_questions where session = \"".$_COOKIE["classified_session"]."\"";
$delete_session_result = $db->Execute($sql_query);
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
$sql_query = "delete from geodesic_classifieds_sell_session_images where session = \"".$_COOKIE["classified_session"]."\"";
$delete_session_result = $db->Execute($sql_query);
if (!$delete_session_result)
{
//echo $sql_query."
\n";
return false;
}
header("Location: ".$browse->configuration_data->CLASSIFIEDS_URL);
$db->Close();
exit;
}
else
{
$browse->header($db);
$browse->main($db);
}
$browse->footer($db);
$db->Close();
exit;
break;
case 18:
//lost password
include_once("classes/classified_browse_class.php");
include_once("classes/authenticate_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
$auth = new Auth($db,$language_id);
if (!$user_id)
{
if ($_REQUEST["b"])
{
if (!$auth->lostpassword($db,$_REQUEST["b"]))
$auth->lostpassword_form();
else
$browse->main($db);
}
else
{
//show the lost password form
$auth->lostpassword_form();
}
}
else
{
//show the edit userdata form
if (!$browse->main($db))
$browse->browse_error();
}
$browse->footer($db);
$db->Close();
exit;
break;
case 19:
//search
include_once("classes/search_class.php");
$search_the_classifieds = new Search_classifieds($db,$language_id,$user_id,$_REQUEST["c"]);
$search_the_classifieds->header($db);
if ($_REQUEST["b"])
{
$search_the_classifieds->search($db,$_REQUEST["b"]);
if (!$search_the_classifieds->search_form($db,$_REQUEST["c"]))
$search_the_classifieds->site_error();
}
else
{
//show the edit userdata form
if (!$search_the_classifieds->search_form($db,$_REQUEST["c"]))
$search_the_classifieds->site_error();
}
$search_the_classifieds->footer($db);
$db->Close();
exit;
break;
case 20:
//add to favorites
if ($user_id)
{
if ($_REQUEST["b"])
{
include_once("classes/user_management_class.php");
$add_to_favorites = new User_management($db,$language_id,$user_id);
$add_to_favorites->header($db);
if (!$add_to_favorites->insert_favorite($db,$_REQUEST["b"]))
$add_to_favorites->site_error();
elseif (!$add_to_favorites->display_all_favorites($db))
$add_to_favorites->site_error();
$add_to_favorites->footer($db);
}
else
{
//show the edit userdata form
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
if (!$browse->main($db))
$browse->browse_error();
$browse->footer($db);
}
}
else
{
include_once("classes/authenticate_class.php");
$auth = new Auth($db,$language_id);
$auth->header($db);
if ($_REQUEST["b"])
$auth->login_form(0,0,"a=20&b=".$_REQUEST["b"]);
else
$auth->login_form();
$auth->footer($db);
}
$db->Close();
exit;
break;
case 21:
//choose languages
$site = new Site($db,0,$language_id,$user_id);
$site->header($db);
//show the edit userdata form
if (!$site->choose_language_form($db))
$site->site_error();
$site->footer($db);
$db->Close();
exit;
break;
case 22:
//extra page
$site = new Site($db,0,$language_id,$user_id);
$site->header($db);
if (!$site->extra_page($db,$_REQUEST["b"]))
{
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->header($db);
if (!$browse->main($db))
$browse->browse_error();
}
$site->footer($db);
$db->Close();
exit;
break;
case 23:
//click through of banner ad
include_once("classes/classified_browse_class.php");
$click_through = new Classified_browse($db,$user_id,$language_id);
if ($_REQUEST["banner_id"])
{
$click_to = $click_through->update_banner_click($db,$_REQUEST["banner_id"]);
if ($click_to)
{
header("Location: ".$click_to);
$db->Close();
exit;
}
else
{
$click_through->header($db);
if (!$click_through->main($db))
$click_through->browse_error();
$click_through->footer($db);
}
}
else
{
$click_through->header($db);
if (!$click_through->main($db))
$click_through->browse_error();
$click_through->footer($db);
}
$db->Close();
exit;
break;
case 98:
//end this sell process
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
if ($user_id)
{
include_once("classes/classified_sell_class.php");
$sell = new Classified_sell($db,$user_id,$language_id,$classified_session);
if (strlen(trim($sell->setup_error)) == 0)
{
$sell->header($db);
$sell->end_sell_process($db);
}
else
{
$browse->header($db);
$browse->main($db);
}
}
else
{
$browse->main($db);
}
$browse->footer($db);
$db->Close();
exit;
break;
case 99:
//this is the admin
//trying to delete a classified
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id,$_REQUEST["c"]);
$browse->header($db);
if (($user_level == 1) && ($user_id == 1))
{
if ($_REQUEST["b"])
{
if ($browse->admin_delete_classified($db,$_REQUEST["b"]))
{
if (!$browse->main($db))
$browse->browse_error();
}
else
{
$browse->browse_error();
}
}
else
{
$browse->main($db);
}
}
else
{
$browse->main($db);
}
$browse->footer($db);
$db->Close();
exit;
break;
default:
include_once("classes/classified_browse_class.php");
$browse = new Classified_browse($db,$user_id,$language_id);
$browse->classified_close($db);
$browse->header($db);
$browse->main($db);
$browse->footer($db);
$db->Close();
exit;
} //end of switch ($_REQUEST["a"])
?>