<?php
if(!defined('DRK'))die('Hacking attempt...');
$uid=IdFromSes($ses);
if($mode=="propose")
{
$request=get_var("request");
$length=12;
$m=$mod.$mode;
$return="chapel";
$msg="<img src=\"./images/point.gif\" alt=\"[!]\"/><small>NOTE: that this is just for entertainment purposes and does NOT constitute a valid marrage!!</small>";
$user=get_var("user");
if($request==1){
if(!SignupChars($user))$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>Illegal chars found!!</small><br/>";
else if(num_rows("id",chapel,"fromid=$uid OR uid=$uid"))$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>you are wappied what are you doing!!</small><br/>";
else if(empty($user)||strlen($user)<=0)$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>username can not be blank!!</small><br/>";
else if(IdFromUser($user)==$uid)$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>you can not propose to yourself!!</small><br/>";
else if(num_rows("id",chapel,"accepted='N' AND (fromid=".IdFromUser($user)." OR uid=".IdFromUser($user).")"))$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>$user has already been asked!!</small><br/>";
else if(num_rows("id",chapel,"accepted='Y' AND (fromid=".IdFromUser($user)." OR uid=".IdFromUser($user).")"))$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>$user is already wappied!!</small><br/>";
else{
$user_id=IdFromUser($user);
if(!insert(chapel,"NULL,$uid,$user_id,'N',NULL"))$msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>unable to send your proposal!!</small><br/>";
else $msg="<img src=\"./images/ok.gif\" alt=\"[ok]\"/><small>$user has been sent your proposal!!</small><br/>";
}
}
$what=Array("sitename","username","msg","length","m","user","return");
$with=Array($sitename,users_table("username",$uid),$msg,$length,$m,$user,$return);
Template($what,$with,"propose");
exit;
}
else if($mode=="accept")
{
$time=time();
$nick=UserFromId(fetch_array("fromid",chapel,"uid=$uid"));
if(update(chapel,"accepted='Y',date=$time","uid=$uid"))$msg="<img src=\"./images/ok.gif\" alt=\"[ok]\"/><small>CONGRATULATIONS, you and $nick are now wappied!!</small><br/>";
else $msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>unable to accept proposal!!</small><br/>";
}
else if($mode=="deny")
{
$time=time();
$nick=UserFromId(fetch_array("fromid",chapel,"uid=$uid"));
if(delete(chapel,"accepted='N' AND uid=$uid"))$msg="<img src=\"./images/ok.gif\" alt=\"[ok]\"/><small>you have rejected $nick proposal!!</small><br/>";
else $msg="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>unable to deny proposal!!</small><br/>";
}
else if($mode=="about")
{
$what=Array("sitename","username");
$with=Array($sitename,users_table("username",$uid));
Template($what,$with,"aboutchapel");
exit;
}
/////CHAPEL/////
if(num_rows("id",chapel,"uid=$uid AND accepted='N'")>0){
$row=fetch_array("*",chapel,"uid=$uid");
if(profiles_table("sex",$row['fromid'])=="M")$color=" style=\"color:#0000FF;\"";
else if(profiles_table("sex",$row['fromid'])=="F")$color=" style=\"color:#FF0066;\"";
$nick=UserFromId($row['fromid']);
$request="<span$color>$nick</span> has requested to get wappied to you,<br/>\n";
$request.="do you accept:<br/>\n";
$request.="<a href=\"".$action."chapel".$mod."accept".$session."\">i do</a><br/>\n";
$request.="<a href=\"".$action."chapel".$mod."deny".$session."\">i cant</a><br/>\n";
}
else if(num_rows("id",chapel,"uid=$uid OR fromid=$uid AND accepted='Y'")>0){
if(num_rows("id",chapel,"fromid=$uid")>0)$user_id=fetch_array("uid",chapel,"fromid=$uid");
else $user_id=fetch_array("fromid",chapel,"uid=$uid");
if(profiles_table("sex",$user_id)=="M")$color=" style=\"color:#0000FF;\"";
else if(profiles_table("sex",$user_id)=="F")$color=" style=\"color:#FF0066;\"";
$nick=UserFromId($user_id);
$request="<a href=\"".$action."chapel".$mod."divorce".$session."\">divorce <span$color>$nick</span></a><br/>";
}
else if(num_rows("id",chapel,"fromid=$uid AND accepted='N'")>0){
$nick=UserFromId(fetch_array("uid",chapel,"fromid=$uid"));
$request.="<img src=\"./images/point.gif\" alt=\"[!]\"/><small>$nick has not decided on your proposal yet!!</small><br/>";
}
else $request="<a href=\"".$action."chapel".$mod."propose".$session."\">get wappied</a><br/>";
if($mode=="divorce")
{
$sure=get_var("sure");
$request="are you sure you want a divorce?<br/>\n";
$request.="<a href=\"".$action."chapel".$mod."divorce&sure=yes".$session."\">yes</a><br/>\n";
$request.="<a href=\"".$action."chapel".$session."\">no</a><br/>";
if($sure=="yes"){
if(delete(chapel,"uid=$uid OR fromid=$uid"))$request="<img src=\"./images/ok.gif\" alt=\"[ok]\"/><small>DONE... we wish you the best, always remember that there are plenty more fish in the sea</small><br/>";
else $request="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>unable to get a divorce!!</small><br/>";
}
//else $request="<img src=\"./images/error.gif\" alt=\"[x]\"/><small>unable to get a divorce!!</small><br/>";
}
?>