$MAX_UPLOAD_SIZE )
{
$er = true;
$ERR = "ERR_603";
}
}
}
else
{
$ERR = "ERR_602";
$er = true;
}
if (!$er)
{
// really save this file
$ext = ($inf[2]==1)?".gif":".jpg";
$fname = $image_upload_path.$auction_id.$ext;
if ( file_exists($fname) )
unlink ($fname);
copy ( $userfile, $fname );
$uploaded_filename = $auction_id.$ext;
$file_uploaded = true;
}
else
{
// there is an error
unset($file_uploaded);
}
}
else
{
unset($file_uploaded);
}
}
}
/* if script called the first time OR
an error occured THEN
display form
*/
if ( empty($action) || (($action=='first')&&($$ERR)) )
{
// display form here
include "header.php";
$auc_id =$sessionVars["SELL_auction_id"];
$filename = "counter/".auction_id.".txt";
$newfile = fopen($filename, "w+") or die("Couldn't create file."); fclose($newfile);
$tfail = fopen("$filename", "w");
$faili = "1";
fwrite($tfail, "$faili", 500000);
fclose($tfail);
// prepare variables for templates/template
// simple fields
$titleH = htmlspecialchars($title);
$descriptionH = htmlspecialchars($description);
$pict_urlH = htmlspecialchars($pict_url);
// ------------------------------------- auction type
$T= "\n";
$TPL_auction_type = $T;
// ------------------------------------- duration
//--
$query = "select * from PHPAUCTION_durations order by days";
$res_durations = mysql_query($query);
if(!$res_durations)
{
print $ERR_001." - ".mysql_error();
}
$num_durations = mysql_num_rows($res_durations);
$i = 0;
$T= "\n";
$TPL_categories_list = $T;
// -------------------------------------- shipping
if ( intval($shipping)==1 )
$TPL_shipping1_value = "CHECKED";
if ( intval($shipping)==2 )
$TPL_shipping2_value = "CHECKED";
if ( !empty($international) )
$TPL_international_value = "CHECKED";
// -------------------------------------- reserved price
if ( $with_reserve=="yes" )
$TPL_with_reserve_selected = "CHECKED";
else
$TPL_without_reserve_selected = "CHECKED";
// -------------------------------------- photo source
if ( intval($imgtype)==1 )
$TPL_imgtype2_SELECTED = "CHECKED";
else
$TPL_imgtype1_SELECTED = "CHECKED";
$TPL_error_value = $$ERR;
// update current session
if ( isset($sessionVars["SELL_DATA_CORRECT"]) )
unset($sessionVars["SELL_DATA_CORRECT"]);
session_name($SESSION_NAME);
session_register("sessionVars");
//putSessionVars();
// include corresponding templates/template and exit
include "templates/template_sell_php.html";
include "footer.php";
exit;
}
/* all data is ok.
TODO: update current session variables and proceed further
*/
if ($action=="first" && !$$ERR)
{
// auction title
$sessionVars["SELL_title"] = strip_tags($title);
// auction description
$sessionVars["SELL_description"] = $description;
// image URL
if (!isset($file_uploaded))
{
$sessionVars["SELL_pict_url"] = $pict_url;
unset($sessionVars["SELL_original_filename"]);
}
else
{
// the URL is uploaded image
$sessionVars["SELL_pict_url"] = $uploaded_filename;
$sessionVars["SELL_original_filename"] = $userfile_name;
}
// data from "picture URL" input field
$sessionVars["SELL_pict_url_original"] = $pict_url;
// flag if file is uploaded
if (!isset($file_uploaded))
unset($sessionVars["SELL_file_uploaded"]);
else
$sessionVars["SELL_file_uploaded"] = true;
// auction type
$sessionVars["SELL_atype"] = $atype;
// quantity of items for sale
$sessionVars["SELL_iquantity"] = $iquantity;
// minimum bid
$sessionVars["SELL_minimum_bid"] = $minimum_bid;
// increments information
$sessionVars["SELL_increments"] = $increments;
$sessionVars["SELL_customincrement"] = $customincrement;
// reserved price flag
$sessionVars["SELL_with_reserve"] = ($with_reserve=="yes")?true:false;
// reserved price value
$sessionVars["SELL_reserve_price"] = $reserve_price;
// auction duration
$sessionVars["SELL_duration"] = $duration;
// country
$sessionVars["SELL_country"] = $country;
// zip code
$sessionVars["SELL_location_zip"] = $location_zip;
// shipping method
$sessionVars["SELL_shipping"] = $shipping;
// international shipping
$sessionVars["SELL_international"] = (strlen($international)==0)?false:true;
// payment methods: text and index
reset($payment);
while(list($key,$val) = each($payment))
{
$sessionVars["SELL_payment".$key] = $payment[$key];
}
// category ID
$sessionVars["SELL_category"] = $category;
// auction id
if (isset($auction_id))
$sessionVars["SELL_auction_id"] = $auction_id;
else
$sessionVars["SELL_auction_id"] = generate_id();
// image type
$sessionVars["SELL_imgtype"] = $imgtype;
// set that first step is passed
$sessionVars["SELL_DATA_CORRECT"] = true;
session_name($SESSION_NAME);
session_register("sessionVars");
//putSessionVars();
# print "Sessions vars are put";
}
// check second data - login and password
if ( $action=="second")
{
$nickH = htmlspecialchars($nick);
$result = mysql_query("SELECT * FROM PHPAUCTION_users WHERE nick='".AddSlashes($nick)."'");
if ($result)
$num = mysql_num_rows($result);
else
$num = 0;
if ($num==0)
$ERR = "ERR_025";
if ($num>0)
{
$pass = mysql_result ($result,0,"password");
$user_id = mysql_result ($result,0,"id");
if (md5($MD5_PREFIX.$password) != $pass)
{
$ERR = "ERR_026";
}
else
{
if(mysql_result($result,0,"suspended") > 0)
{
$ERR = "ERR_618";
}
}
}
}
if ( ($action=="first" && !$$ERR) || ($action=="second" && $$ERR) )
{
// display preview form
// error text
$TPL_error = $$ERR;
// title text
$TPL_title_value = strip_tags($sessionVars["SELL_title"]);
// description text
$TPL_description_shown_value = stripslashes(nl2br($sessionVars["SELL_description"]));
// picture URL
if( intval($sessionVars["SELL_imgtype"])==0 )
{
// print "URL";
// URL specified
if ( strlen($sessionVars["SELL_pict_url_original"])==0 )
$TPL_pict_URL_value = $MSG_114;
else
$TPL_pict_URL_value = "";
}
else
{
// a file uploaded
if ( empty($sessionVars["SELL_file_uploaded"]) )
$TPL_pict_URL_value = $MSG_114;
else
$TPL_pict_URL_value = "
";
}
/*
$TPL_pict_URL_value = (strlen($sessionVars["SELL_pict_url"])>0)
? "
"
: "no image";
*/
// minimum bid
$TPL_minimum_bid_value = print_money($sessionVars["SELL_minimum_bid"]);
// reserved price
if ($sessionVars["SELL_with_reserve"])
$TPL_reserve_price_displayed = "$std_font ".print_money($sessionVars["SELL_reserve_price"])."";
else
$TPL_reserve_price_displayed = "$std_font no ";
// auction duration
//--
$query = "select description from PHPAUCTION_durations where days=".$sessionVars["SELL_duration"];
$res_duration_descr = mysql_query($query);
$duration_descr = mysql_result($res_duration_descr,0,"description");
$TPL_durations_list = $duration_descr;
#// Bids increment
if($sessionVars["SELL_increments"] == 1)
{
$TPL_increments = $MSG_614;
}
else
{
$TPL_increments = print_money($sessionVars["SELL_customincrement"]);
}
// auction type
$TPL_auction_type = $auction_types[$sessionVars["SELL_atype"]];
if ( intval($sessionVars["SELL_atype"])==2 )
$TPL_auction_type .= "