0 ) //IF SOME FORM WAS POSTED DO VALIDATION
{
$sbip_addr=$_SERVER['REMOTE_ADDR'];
$sbid_id=$_REQUEST["sbid_id"];
$sbscore=$_REQUEST["sbscore"];
// echo ("
".$sbid_id."
");
if($sbid_id == 1)
{
$sb_id=$_REQUEST["sb_id"];
$sbq_rat="select * from sbrecipe_ratings where recipe_id=$sb_id and ( ((TO_DAYS(NOW())-TO_DAYS(sbrated_on))< $sbip_expire_limit) and sbip_addr='$sbip_addr')";
$sbrs_rat=mysql_query($sbq_rat);
if(mysql_num_rows($sbrs_rat) > 0)
{
header("Location: popup.php?sb_id=$sb_id&msg=".urlencode("You can't rate a recipe twice"));
die();
}
$sbrated_on=date("YmdHis",time());
$query_update="insert into sbrecipe_ratings (recipe_id, sbscore, sbip_addr, sbrated_on) values ($sb_id, $sbscore, '$sbip_addr', $sbrated_on )";
}
//die($query_update);
$sbrs_update=mysql_query($query_update);
if(mysql_affected_rows() == 1)
{
if($sbid_id == 1)
{
header("Location: popup.php?sb_id=$sb_id&msg=".urlencode("Thanks for rating this Recipe"));
die();
}
}
else
{
header("Location: popup.php?sb_id=$sb_id&msg=".urlencode("Unable to complete operation, Please try again"));
die();
}
unset($_REQUEST["sbid_id"]);
} //end if count post
//----------checking whether some category came
$sbcat_id=0;
$sbcat_str="";
if(isset($_REQUEST["sbcat_id"]) && ($_REQUEST["sbcat_id"] != 0 ))
{
$sbcat_id=$_REQUEST["sbcat_id"];
//creating query string
$sbcat_str=" and sbcat_id=$sbcat_id ";
}
//----------checking whether some joke came
$sbjoke_str="";
if(isset($_REQUEST["sb_id"]) && ($_REQUEST["sb_id"] != 0 ))
{
$sbid_id=1;
$sb_id=$_REQUEST["sb_id"];
//creating query string
$sbjoke_str=" and sb_id=$sb_id ";
}
//----------checking whether some pic came
//------------whether a random joke or pic needed
$sbrandom_str="";
if( isset($_REQUEST["sbid_id"]) )
{
$sbid_id=$_REQUEST["sbid_id"];
$sbrandom=generate_random($sbid_id);
// echo $sbrandom;
// die();
if($sbid_id == 1)
{
$sbquery_jok="select * from sbrecipe_recipes where 1 and sb_approved='yes'";
$sbrs_jok=mysql_query($sbquery_jok);
$counter=1;
while(($sbrow_jok=mysql_fetch_array($sbrs_jok)) && ($counter <= $sbrandom))
{
$counter++;
$sb_id=$sbrow_jok["sb_id"];
//echo $sb_id.", ";
}
$sbjoke_str=" and sb_id=$sb_id ";
//echo $sbpic_str;
//die();
}
}
} //end if if pic/jok id came
//--ends---------whether a random joke or pic neede
function main()
{
global $sbico_rating1,$sbico_rating2,$sbcat_id,$sbcat_str,$sbjoke_str,$sb_id,$img_pmt,$sbmax_new_db,$sbmax_top_rated_db,$imgsrc;
// echo $ig_list;
$field=mysql_query("select * from sbrecipe_fieldsonoff where 1");
$onoff=array();
$required=array();
$i=0;
while($field_rs=mysql_fetch_array($field))
{
$onoff[$i]=$field_rs['sb_status_onoff'];
$required[$i]=$field_rs['sb_required'];
// echo $required[$i];
$i++;
}
//die();
?>