View file wapirate/wml/genproc.php

File size: 82.61Kb
<?php

include("head.php");

if($action=="newtopic")

{

  $fid = $_POST["fid"];

  $ntitle = $_POST["ntitle"];

  $tpctxt = $_POST["tpctxt"];

  if(!canaccess(getuid_sid($sid), $fid))

    {

        echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      echo "You Don't Have Permission To View The Contents Of This Forum<br/><br/>";

      echo "<a href=\"index.php?action=main\">Home</a>";

      echo "</p>";

      echo "</card>";

      echo "</wml>";

      exit();

    }

  addonline(getuid_sid($sid),"Created New Topic","");

    echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      $crdate = time();

      //$uid = getuid_sid($sid);

      $texst = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE name LIKE '".$ntitle."' AND fid='".$fid."'"));

      if($texst[0]==0)

      {

        $res = false;

      

        $ltopic = mysql_fetch_array(mysql_query("SELECT crdate FROM ibwf_topics WHERE authorid='".$uid."' ORDER BY crdate DESC LIMIT 1"));

        global $topic_af;

        $antiflood = time()-$ltopic[0];

        if($antiflood>$topic_af)

{

  if((trim($ntitle)!="")||(trim($tpctxt)!=""))

      {

      $res = mysql_query("INSERT INTO ibwf_topics SET name='".$ntitle."', fid='".$fid."', authorid='".$uid."', text='".$tpctxt."', crdate='".$crdate."', lastpost='".$crdate."'");

     }

       if($res)

      {

        $usts = mysql_fetch_array(mysql_query("SELECT posts, plusses FROM ibwf_users WHERE id='".$uid."'"));

        $ups = $usts[0]+1;

        $upl = $usts[1]+1;

        mysql_query("UPDATE ibwf_users SET posts='".$ups."', plusses='".$upl."' WHERE id='".$uid."'");

        $tnm = htmlspecialchars($ntitle);

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Topic <b>$tnm</b> Created Successfully";

        $tid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_topics WHERE name='".$ntitle."' AND fid='".$fid."'"));

        echo "<br/><br/><a href=\"index.php?action=viewtpc&amp;tid=$tid[0]\">";

echo "View Topic</a>";

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error Creating New Thread";

      }

      }else{

        $af = $topic_af -$antiflood;

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Antiflood Control: $af";

      }

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Topic Name already Exists";

      }



      







      $fname = getfname($fid);

      echo "<br/><br/><a href=\"index.php?action=viewfrm&amp;fid=$fid\">";

echo "$fname</a><br/>";

      echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

      echo "</p>";

      echo "</card>";

}

else if($action=="post")

{

    $tid = $_POST["tid"];

    $tfid = mysql_fetch_array(mysql_query("SELECT fid FROM ibwf_topics WHERE id='".$tid."'"));

if(!canaccess(getuid_sid($sid), $tfid[0]))

    {

        echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      echo "You Don't Have Permission To View The Contents Of This Forum<br/><br/>";

      echo "<a href=\"index.php?action=main\">Home</a>";

      echo "</p>";

      echo "</card>";

      echo "</wml>";

      exit();

    }

  $reptxt = $_POST["reptxt"];

  $qut = $_POST["qut"];

  addonline(getuid_sid($sid),"Posted A Reply","");

  echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      $crdate = time();

      $fid = getfid($tid);

      //$uid = getuid_sid($sid);

      $res = false;

      $closed = mysql_fetch_array(mysql_query("SELECT closed FROM ibwf_topics WHERE id='".$tid."'"));

      

      if(($closed[0]!='1')||(isstatus5($uid)))

      {

      

        $lpost = mysql_fetch_array(mysql_query("SELECT dtpost FROM ibwf_posts WHERE uid='".$uid."' ORDER BY dtpost DESC LIMIT 1"));

        global $post_af;

        $antiflood = time()-$lpost[0];

        if($antiflood>$post_af)

{

  if(trim($reptxt)!="")

      {

      $res = mysql_query("INSERT INTO ibwf_posts SET text='".$reptxt."', tid='".$tid."', uid='".$uid."', dtpost='".$crdate."', quote='".$qut."'");

}

      if($res)

      {

        $usts = mysql_fetch_array(mysql_query("SELECT posts, plusses FROM ibwf_users WHERE id='".$uid."'"));

        $ups = $usts[0]+1;

        $upl = $usts[1]+1;

        mysql_query("UPDATE ibwf_users SET posts='".$ups."', plusses='".$upl."' WHERE id='".$uid."'");

        mysql_query("UPDATE ibwf_topics SET lastpost='".$crdate."' WHERE id='".$tid."'");

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Message Posted Successfully";

        echo "<br/><br/><a href=\"index.php?action=viewtpc&amp;tid=$tid&amp;go=last\">";

echo "View Topic</a>";

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error Posting Message";

      }

      }else{

$af = $post_af -$antiflood;

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Antiflood Control: $af";

      }

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Topic is closed for posting";

      }

      

      $fname = getfname($fid);

      echo "<br/><br/><a href=\"index.php?action=viewfrm&amp;fid=$fid\">";

echo "$fname</a><br/>";

      echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

      echo "</p>";

      echo "</card>";

  

}

////////////////////////////////////////USER ADDRESS

else if ($action=="uadd")

{

    $ucon = $_POST["ucon"];

    $ucit = $_POST["ucit"];

    $ustr = $_POST["ustr"];

    $utzn = $_POST["utzn"];

    $uphn = $_POST["uphn"];

    addonline(getuid_sid($sid),"My Address","");

    echo "<card id=\"main\" title=\"My Address\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_xinfo WHERE uid='".$uid."'"));

    if($exs[0]>0)

    {

        $res = mysql_query("UPDATE ibwf_xinfo SET country='".$ucon."', city='".$ucit."', street='".$ustr."', timezone='".$utzn."', phoneno='".$uphn."' WHERE uid='".$uid."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Address Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }else{

        $res = mysql_query("INSERT INTO ibwf_xinfo SET uid='".$uid."', country='".$ucon."', city='".$ucit."', street='".$ustr."', timezone='".$utzn."', phoneno='".$uphn."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Address Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }

    echo "<a href=\"index.php?action=uxset\">";

echo "Extended Settings</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

//////////////////////////////////MODERATING CLUB MEMBER

else if($action=="gcp")

{

    $clid = $_GET["clid"];

    $who = $_GET["who"];

    $giv = $_POST["giv"];

    $pnt = $_POST["pnt"];

    addonline(getuid_sid($sid),"Moderating Club Member","");

    echo "<card id=\"main\" title=\"Moderate Member\">";

    echo "<p align=\"center\">";

    $whnick = getnick_uid($who);

    echo "<b>$whnick</b>";

    echo "</p>";

    echo "<p>";

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$who."' AND clid=".$clid.""));

$cow = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner||coowner='".$uid."' AND id=".$clid.""));

if($exs[0]>0 && $cow[0]>0)

{

    $mpt = mysql_fetch_array(mysql_query("SELECT points FROM ibwf_clubmembers WHERE uid='".$who."' AND clid='".$clid."'"));

    if($giv=="1")

    {

      $pnt = $mpt[0]+$pnt;

    }else{

        $pnt = $mpt[0]-$pnt;

        if($pnt<0)$pnt=0;

    }

    $res = mysql_query("UPDATE ibwf_clubmembers SET points='".$pnt."' WHERE uid='".$who."' AND clid='".$clid."'");

    if($res)

    {

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Club points updated successfully!";

    }else{

      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Database Error!";

    }

    }else{

      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Missing Info!";

    }

    echo "</p>";



    echo "<p align=\"center\">";

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}



else if($action=="gpl")

{

    $clid = $_GET["clid"];

    $who = $_GET["who"];

    $pnt = $_POST["pnt"];

    addonline(getuid_sid($sid),"Moderating Club Member","");

    echo "<card id=\"main\" title=\"Moderate Member\">";

    echo "<p align=\"center\">";

    $whnick = getnick_uid($who);

    echo "<b>$whnick</b>";

    echo "</p>";

    echo "<p>";

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$who."' AND clid=".$clid.""));

$cow = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner||coowner='".$uid."' AND id=".$clid.""));

if($exs[0]>0 && $cow[0]>0)

{

  $cpl = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_clubs WHERE id='".$clid."'"));

  if($cpl[0]>=$pnt)

  {

    $mpt = mysql_fetch_array(mysql_query("SELECT gold FROM ibwf_users WHERE id='".$who."'"));

      $plt = $mpt[0]+$pnt;

    

    $res = mysql_query("UPDATE ibwf_users SET gold='".$plt."' WHERE id='".$who."'");

    if($res)

    {

      $cpl = $cpl[0]-$pnt;

      $res = mysql_query("UPDATE ibwf_clubs SET plusses='".$cpl."' WHERE id='".$clid."'");

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Gold updated successfully!";

    }else{

      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Database Error!";

    }

  }

  else{

      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Not enough Gold!";

    }

    }else{

      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Missing Info!";

    }

    echo "</p>";



    echo "<p align=\"center\">";

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}



else if ($action=="upre")

{

    $usds = $_POST["usds"];

    $usds = str_replace('"', "", $usds);

    $usds = str_replace("'", "", $usds);

    $ubon = $_POST["ubon"];

    $usxp = $_POST["usxp"];

    addonline(getuid_sid($sid),"Preferences","");

    echo "<card id=\"main\" title=\"Preferences\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_xinfo WHERE uid='".$uid."'"));

    if($exs[0]>0)

    {

        $res = mysql_query("UPDATE ibwf_xinfo SET sitedscr='".$usds."', budsonly='".$ubon."', sexpre='".$usxp."' WHERE uid='".$uid."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Preferences Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }else{

        $res = mysql_query("INSERT INTO ibwf_xinfo SET uid='".$uid."', sitedscr='".$usds."', budsonly='".$ubon."', sexpre='".$usxp."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Preferences Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }

    echo "<a href=\"index.php?action=uxset\">";

echo "Extended Settings</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

//////////////////////////////////////Gmail Settings

else if ($action=="gmset")

{

    $ugun = $_POST["ugun"];

    $ugpw = $_POST["ugpw"];

    $ugch = $_POST["ugch"];

    addonline(getuid_sid($sid),"G-Mail Settings","");

    echo "<card id=\"main\" title=\"G-Mail Settings\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_xinfo WHERE uid='".$uid."'"));

    if($exs[0]>0)

    {

        $res = mysql_query("UPDATE ibwf_xinfo SET gmailun='".$ugun."', gmailpw='".$ugpw."', gmailchk='".$ugch."', gmaillch='".time()."' WHERE uid='".$uid."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Gmail Settings Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }else{

        $res = mysql_query("INSERT INTO ibwf_xinfo SET uid='".$uid."', gmailun='".$ugun."', gmailpw='".$ugpw."', gmailchk='".$ugch."', gmaillch='".time()."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>G-Mail Settings Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }

    echo "<a href=\"index.php?action=uxset\">";

echo "Extended Settings</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

///////////////////////////////////////USER PERSONALITY

else if ($action=="uper")

{

    $uhig = $_POST["uhig"];

    $uwgt = $_POST["uwgt"];

    $urln = $_POST["urln"];

    $ueor = $_POST["ueor"];

    $ueys = $_POST["ueys"];

    $uher = $_POST["uher"];

    $upro = $_POST["upro"];

    

    addonline(getuid_sid($sid),"Personality","");

    echo "<card id=\"main\" title=\"Personality\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_xinfo WHERE uid='".$uid."'"));

    if($exs[0]>0)

    {

        $res = mysql_query("UPDATE ibwf_xinfo SET height='".$uhig."', weight='".$uwgt."', realname='".$urln."', eyescolor='".$ueys."', profession='".$upro."', racerel='".$ueor."',hairtype='".$uher."'  WHERE uid='".$uid."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Personal Info Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }else{

        $res = mysql_query("INSERT INTO ibwf_xinfo SET uid='".$uid."', height='".$uhig."', weight='".$uwgt."', realname='".$urln."', eyescolor='".$ueys."', profession='".$upro."', racerel='".$ueor."',hairtype='".$uher."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Personal Info Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }

    echo "<a href=\"index.php?action=uxset\">";

echo "Extended Settings</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

////////////////////////////////////////MORE ABOUT USER

else if ($action=="umin")

{

    $ulik = $_POST["ulik"];

    $ulik = str_replace('"', "", $ulik);

    $ulik = str_replace("'", "", $ulik);

    $udlk = $_POST["udlk"];

    $udlk = str_replace('"', "", $udlk);

    $udlk = str_replace("'", "", $udlk);

    $ubht = $_POST["ubht"];

    $ubht = str_replace('"', "", $ubht);

    $ubht = str_replace("'", "", $ubht);

    $ught = $_POST["ught"];

    $ught = str_replace('"', "", $ught);

    $ught = str_replace("'", "", $ught);

    $ufsp = $_POST["ufsp"];

    $ufsp = str_replace('"', "", $ufsp);

    $ufsp = str_replace("'", "", $ufsp);

    $ufmc = $_POST["ufmc"];

    $ufmc = str_replace('"', "", $ufmc);

    $ufmc = str_replace("'", "", $ufmc);

    $umtx = $_POST["umtx"];

    $umtx = str_replace('"', "", $umtx);

    $umtx = str_replace("'", "", $umtx);

    addonline(getuid_sid($sid),"More About Me","");

    echo "<card id=\"main\" title=\"More About Me\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_xinfo WHERE uid='".$uid."'"));

    if($exs[0]>0)

    {

        $res = mysql_query("UPDATE ibwf_xinfo SET likes='".$ulik."', deslikes='".$udlk."', habitsb='".$ubht."', habitsg='".$ught."', favsport='".$ufsp."', favmusic='".$ufmc."',moretext='".$umtx."'  WHERE uid='".$uid."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Info Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }else{

        $res = mysql_query("INSERT INTO ibwf_xinfo SET uid='".$uid."', likes='".$ulik."', deslikes='".$udlk."', habitsb='".$ubht."', habitsg='".$ught."', favsport='".$ufsp."', favmusic='".$ufmc."',moretext='".$umtx."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Info Updated Successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"O\"/>Database Error!<br/><br/>";

        }

    }

    echo "<a href=\"index.php?action=uxset\">";

echo "Extended Settings</a><br/>";

    echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

////////////////////////////////////////////CREATE ROOM

else if($action=="mkroom")

{

        $rname = mysql_escape_string($_POST["rname"]);

        $rpass = trim($_POST["rpass"]);

        addonline(getuid_sid($sid),"Creating Chatroom","");

        echo "<card id=\"viewforum\" title=\"Create room\">";

        echo "<p align=\"center\">";

        if ($rpass=="")

        {

          $cns = 1;

        }else{

            $cns = 0;

        }

        $prooms = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_rooms WHERE static='0'"));

        if($prooms[0]<10)

        {

        $res = mysql_query("INSERT INTO ibwf_rooms SET name='".$rname."', pass='".$rpass."', censord='".$cns."', static='0', lastmsg='".time()."'");

        if($res)

        {

          echo "<img src=\"images/ok.gif\" alt=\"O\"/>Room created successfully<br/><br/>";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>Database Error!<br/><br/>";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>There's already 10 user rooms<br/><br/>";

        }

        echo "<a href=\"index.php?action=uchat\"><img src=\"images/chat.gif\" alt=\"*\"/>Chatrooms</a><br/>";

        echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a>";

        echo "</p>";

        echo "</card>";

        

}

/////////////////////////////////////SIGN GUESTBOOK

else if($action=="signgb")

{

    $who = $_POST["who"];

   

if(!cansigngb(getuid_sid($sid), $who))

    {

        echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      echo "You cant sign this user guestbook<br/><br/>";

      echo "<a href=\"index.php?action=main\">Home</a>";

      echo "</p>";

      echo "</card>";

      echo "</wml>";

      exit();

    }

  $msgtxt = $_POST["msgtxt"];

  //$qut = $_POST["qut"];

  addonline(getuid_sid($sid),"Signing a Guestbook","");

  echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      $crdate = time();

      //$uid = getuid_sid($sid);

      $res = false;



      if(trim($msgtxt)!="")

      {

        

      $res = mysql_query("INSERT INTO ibwf_gbook SET gbowner='".$who."', gbsigner='".$uid."', dtime='".$crdate."', gbmsg='".$msgtxt."'");

      }

      if($res)

      {

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Message Posted Successfully";

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error Posting Message";

      }

      

      echo "<br/><br/>";

      echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

      echo "</p>";

      echo "</card>";



}

///////////////////////////////////POLL VOTING 

else if($action=="votepl")

{

  //$uid = getuid_sid($sid);

  $plid = $_GET["plid"];

  $ans = $_GET["ans"];

  addonline(getuid_sid($sid),"Pole Volting lol","");

  echo "<card id=\"main\" title=\"Poll Voting\">";

    echo "<p align=\"center\">";

    $voted = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_presults WHERE uid='".$uid."' AND pid='".$plid."'"));

    if($voted[0]==0)

    {

        $res = mysql_query("INSERT INTO ibwf_presults SET uid='".$uid."', pid='".$plid."', ans='".$ans."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Thanks for voting";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>You already voted in this poll";

    }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

////////////////////////////////////DELETE POLL

else if($action=="dlpoll")

{

  //$uid = getuid_sid($sid);

  addonline(getuid_sid($sid),"Deleting Poll","");

  echo "<card id=\"main\" title=\"Delete Poll\">";

    echo "<p align=\"center\">";

    $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_users WHERE id='".$uid."'"));

        $res = mysql_query("UPDATE ibwf_users SET pollid='0' WHERE id='".$uid."'");

        if($res)

        {

          $res = mysql_query("DELETE FROM ibwf_presults WHERE pid='".$pid[0]."'");

          $res = mysql_query("DELETE FROM ibwf_polls WHERE id='".$pid[0]."'");

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Poll Deleted";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

//////////////////////////////////DELETE ANOUNCEMENT

else if($action=="delan")

{

  //$uid = getuid_sid($sid);

  addonline(getuid_sid($sid),"Deleting Announcement","");

  echo "<card id=\"main\" title=\"Delete Announcement\">";

  $clid = $_GET["clid"];

  $anid = $_GET["anid"];

  $uid = getuid_sid($sid);

    echo "<p align=\"center\">";

    $pid = mysql_fetch_array(mysql_query("SELECT owner, coowner FROM ibwf_clubs WHERE id='".$clid."'"));

    $exs = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_announcements WHERE id='".$anid."' AND clid='".$clid."'"));

    if(($uid==$pid[0]||$pid[1])&&($exs[0]>0))

    {

        $res = mysql_query("DELETE FROM ibwf_announcements WHERE id='".$anid."'");

        if($res)

        {



            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Announcement Deleted";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't delete this announcement!";

    }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

////////////////////////////////////DELETE CLUB

else if($action=="dlcl")

{

  //$uid = getuid_sid($sid);

  addonline(getuid_sid($sid),"Deleting Club","");

  echo "<card id=\"main\" title=\"Delete Club\">";

  $clid = $_GET["clid"];

  $uid = getuid_sid($sid);

    echo "<p align=\"center\">";

    $pid = mysql_fetch_array(mysql_query("SELECT owner FROM ibwf_clubs WHERE id='".$clid."'"));

    if($uid==$pid[0])

    {

        $res = deleteClub($clid);

        if($res)

        {

          

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Club Deleted";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't delete this club!";

    }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

//////////////////////////////////UPDATE PWS

else if($action=="pws")

{

  //$uid = getuid_sid($sid);

  addonline(getuid_sid($sid),"Updating PWS","");

  echo "<card id=\"main\" title=\"P.W.S\">";

  $imgt = $_POST["imgt"];

  $imgo = $_POST["imgo"];

  $smsg = $_POST["smsg"];

  $thms = $_POST["thms"];

  

  $uid = getuid_sid($sid);

    echo "<p align=\"center\">";

    if($imgt=="idc")

	{

		$imgo = "http://wapirate.net/rwidc.php?id=$uid";

	}else if($imgt == "avt")

	{

		$av = mysql_fetch_array(mysql_query("SELECT avatar FROM ibwf_users WHERE id='".$uid."'"));

		if(strpos($av[0], "http://")===false)

		{

			$av[0] = "../".$av[0];

		}

		$imgo = $av[0];

	}else if($imgt=="sml")

	{

		$sml = mysql_fetch_array(mysql_query("SELECT imgsrc FROM ibwf_smilies WHERE scode='".strtolower(trim($imgo))."'"));

		$imgo = "../".$sml[0];

	}else

	{

		$imgo = strtolower(trim($imgo));

	}

    $smsg = trim($smsg);

	$isu = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_mypage WHERE uid='".$uid."'"));

	if ($isu[0]>0)

	{

		$res = mysql_query("UPDATE ibwf_mypage SET thid='".$thms."', mimg='".$imgo."', msg='".$smsg."' WHERE uid='".$uid."'");

	}else{

		$res = mysql_query("INSERT INTO ibwf_mypage SET uid='".$uid."', thid='".$thms."', mimg='".$imgo."', msg='".$smsg."'");

	}

	echo mysql_error();

    if($res)

    {

    echo "<img src=\"images/ok.gif\" alt=\"o\"/>Your Site updated successfully<br/><br/>";

	echo "<a href=\"users?".getnick_uid($uid)."\">View Your Site</a>";

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

    }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

//////////////////////////////////DELETE POLL

else if($action=="dltpl")

{

  //$uid = getuid_sid($sid);

  $tid = $_GET["tid"];

  addonline(getuid_sid($sid),"Deleting Poll","");

  echo "<card id=\"main\" title=\"Delete Poll\">";

    echo "<p align=\"center\">";

    $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_topics WHERE id='".$tid."'"));

        $res = mysql_query("UPDATE ibwf_topics SET pollid='0' WHERE id='".$tid."'");

        if($res)

        {

          $res = mysql_query("DELETE FROM ibwf_presults WHERE pid='".$pid[0]."'");

          $res = mysql_query("DELETE FROM ibwf_polls WHERE id='".$pid[0]."'");

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Poll Deleted";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

//////////////////////////////////////////JOIN CLUB

else if($action=="reqjc")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  addonline(getuid_sid($sid),"Joining A Club","");

  echo "<card id=\"main\" title=\"Join Club\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $isin = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$uid."' AND clid='".$clid."'"));

    if($isin[0]==0){

        $res = mysql_query("INSERT INTO ibwf_clubmembers SET uid='".$uid."', clid='".$clid."', accepted='0', points='0', joined='".time()."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Request sent! The club owner should accept your request";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You are already in this club or request sent and waiting for acception";

        }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

/////////////////////////////////////UNJOIN CLUB

else if($action=="unjc")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  addonline(getuid_sid($sid),"Unjoining Club","");

  echo "<card id=\"main\" title=\"Join Club\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $isin = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubmembers WHERE uid='".$uid."' AND clid='".$clid."'"));

    if($isin[0]>0){

        $res = mysql_query("DELETE FROM ibwf_clubmembers WHERE uid='".$uid."' AND clid='".$clid."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Unjoined club successfully";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You're not a member of this club!";

        }

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

///////////////////////////////ADD CLUB MEMBER 

else if($action=="acm")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  $who = $_GET["who"];

  addonline(getuid_sid($sid),"Adding A Member To Club","");

  echo "<card id=\"main\" title=\"Add Member\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $cowner = mysql_fetch_array(mysql_query("SELECT owner, coowner FROM ibwf_clubs WHERE id='".$clid."'"));

    if($cowner[0]||$cowner[1]==$uid){

        $res = mysql_query("UPDATE ibwf_clubmembers SET accepted='1' WHERE clid='".$clid."' AND uid='".$who."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Member added to your club";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This club ain't yours";

        }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}



///////////////////////////////ADD CO-OWNER

else if($action=="coowner")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  $who = $_GET["who"];

  addonline(getuid_sid($sid),"Adding A Member To Club","");

  echo "<card id=\"main\" title=\"Add Co-Owner\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $cowner = mysql_fetch_array(mysql_query("SELECT owner FROM ibwf_clubs WHERE id='".$clid."'"));

    if($cowner[0]==$uid){

        $res = mysql_query("UPDATE ibwf_clubs SET coowner='".$who."' WHERE id='".$clid."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Co-Owner added to your club";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This club ain't yours";

        }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}



///////////////////////////////DELETE CO-OWNER

else if($action=="delcoowner")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  $who = $_GET["who"];

  addonline(getuid_sid($sid),"Adding A Member To Club","");

  echo "<card id=\"main\" title=\"Delete Co-Owner\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $cowner = mysql_fetch_array(mysql_query("SELECT owner FROM ibwf_clubs WHERE id='".$clid."'"));

    if($cowner[0]==$uid){

        $res = mysql_query("UPDATE ibwf_clubs SET coowner='0' WHERE id='".$clid."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Co-Owner deleted from your club";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This club ain't yours";

        }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}





else if($action=="accall")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  

  addonline(getuid_sid($sid),"Adding A Member To Club","");

  echo "<card id=\"main\" title=\"Add Member\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $cowner = mysql_fetch_array(mysql_query("SELECT owner, coowner FROM ibwf_clubs WHERE id='".$clid."'"));

    if($cowner[0]||$cowner[1]==$uid){

        $res = mysql_query("UPDATE ibwf_clubmembers SET accepted='1' WHERE clid='".$clid."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>All Members Accepted";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This club ain't yours";

        }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

else if($action=="denall")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  

  addonline(getuid_sid($sid),"Adding A Member To Club","");

  echo "<card id=\"main\" title=\"Add Member\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $cowner = mysql_fetch_array(mysql_query("SELECT owner, coowner FROM ibwf_clubs WHERE id='".$clid."'"));

    if($cowner[0]||$cowner[1]==$uid){

        $res = mysql_query("DELETE FROM ibwf_clubmembers WHERE accepted='0' AND clid='".$clid."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>All Members Denied";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This club ain't yours";

        }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}

//////////////////////////////////DELETE CLUB MEMBER

else if($action=="dcm")

{

  //$uid = getuid_sid($sid);

  $clid = $_GET["clid"];

  $who = $_GET["who"];

  addonline(getuid_sid($sid),"Deleting A Member From Club","");

  echo "<card id=\"main\" title=\"Delete Member\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    $cowner = mysql_fetch_array(mysql_query("SELECT owner, coowner FROM ibwf_clubs WHERE id='".$clid."'"));

if($who==$cowner[0]){

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>NOT ALLOWED!";

}else if($cowner[0]||$cowner[1]==$uid){

        $res = mysql_query("DELETE FROM ibwf_clubmembers  WHERE clid='".$clid."' AND uid='".$who."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Member deleted from your club";

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

        }

        }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This club ain't yours";

        }

    echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

  echo "</card>";

}



///////////////////////////////////////////CREATE POLL

else if($action=="crpoll")

{

  addonline(getuid_sid($sid),"Creating Poll","");

    echo "<card id=\"main\" title=\"Create Poll\">";

    echo "<p align=\"center\">";

    //$uid = getuid_sid($sid);

    if(getgold(getuid_sid($sid))>=50)

    {

    $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_users WHERE id='".$uid."'"));

        if($pid[0] == 0)

        {

          $pques = $_POST["pques"];

          $opt1 = $_POST["opt1"];

          $opt2 = $_POST["opt2"];

          $opt3 = $_POST["opt3"];

          $opt4 = $_POST["opt4"];

          $opt5 = $_POST["opt5"];

          if((trim($pques)!="")&&(trim($opt1)!="")&&(trim($opt2)!=""))

          {

            $pex = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_polls WHERE pqst LIKE '".$pques."'"));

            if($pex[0]==0)

            {

              $res = mysql_query("INSERT INTO ibwf_polls SET pqst='".$pques."', opt1='".$opt1."', opt2='".$opt2."', opt3='".$opt3."', opt4='".$opt4."', opt5='".$opt5."', pdt='".time()."'");

              if($res)

              {

                $pollid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_polls WHERE pqst='".$pques."' "));

                mysql_query("UPDATE ibwf_users SET pollid='".$pollid[0]."' WHERE id='".$uid."'");

                echo "<img src=\"images/ok.gif\" alt=\"O\"/>Your poll created successfully";

              }else{

                echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

              }

                }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>There's already a poll with the same question";

          }



          }else{

             echo "<img src=\"images/notok.gif\" alt=\"x\"/>The poll must have a question, and at least 2 options";

          }

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You already has a poll";

          }

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You should have at least 50 Gold to create a poll<br/>To get Gold. Exchange Plusses at <a href=\"bank.php?action=bank\">&#187;Wapirate Bank</a>!";



          }

          echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

else if($action=="pltpc")

{

  $tid = $_GET["tid"];

  addonline(getuid_sid($sid),"Creating Poll","");

    echo "<card id=\"main\" title=\"Create Poll\">";

    echo "<p align=\"center\">";

    //$uid = getuid_sid($sid);

    if((getgold(getuid_sid($sid))>=500)||isstatus5($uid))

    {

    $pid = mysql_fetch_array(mysql_query("SELECT pollid FROM ibwf_topics WHERE id='".$tid."'"));

        if($pid[0] == 0)

        {

          $pques = $_POST["pques"];

          $opt1 = $_POST["opt1"];

          $opt2 = $_POST["opt2"];

          $opt3 = $_POST["opt3"];

          $opt4 = $_POST["opt4"];

          $opt5 = $_POST["opt5"];

          if((trim($pques)!="")&&(trim($opt1)!="")&&(trim($opt2)!=""))

          {

            $pex = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_polls WHERE pqst LIKE '".$pques."'"));

            if($pex[0]==0)

            {

              $res = mysql_query("INSERT INTO ibwf_polls SET pqst='".$pques."', opt1='".$opt1."', opt2='".$opt2."', opt3='".$opt3."', opt4='".$opt4."', opt5='".$opt5."', pdt='".time()."'");

              if($res)

              {

                $pollid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_polls WHERE pqst='".$pques."' "));

                mysql_query("UPDATE ibwf_topics SET pollid='".$pollid[0]."' WHERE id='".$tid."'");

                echo "<img src=\"images/ok.gif\" alt=\"O\"/>Your poll created successfully";

              }else{

                echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!";

              }

                }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>There's already a poll with the same question";

          }



          }else{

             echo "<img src=\"images/notok.gif\" alt=\"x\"/>The poll must have a question, and at least 2 options";

          }

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>This Topic Already Has A poll";

          }

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"x\"/>You should have at least 500 Gold to create a poll<br/>To get Gold. Exchange Plusses at the <a href=\"bank.php?action=bank\">&#187;Wapirate Bank</a>!";



          }

          echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

else if($action=="delpic")

{

    $vid = $_GET["vid"];

  addonline(getuid_sid($sid),"Deleting Gallery Pic","");

   echo "<card id=\"main\" title=\"Create Poll\">";

  echo "<p align=\"center\">";

  $itemowner = mysql_fetch_array(mysql_query("SELECT uid,file FROM gallery WHERE id='".$vid."'"));

  if(isstatus5(getuid_sid($sid))||getuid_sid($sid)==$itemowner[0])

  {

    $res = mysql_query("DELETE FROM gallery WHERE id='".$vid."'");

    if($res)

        {

        $myFile = "gallery/$itemowner[1]";

        unlink($myFile);





        echo "<img src=\"../images/ok.gif\" alt=\"o\"/>Pic Deleted From Gallery<br/>";

        }else{

          echo "<img src=\"../images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

  }else{

    echo "<img src=\"../images/notok.gif\" alt=\"X\"/>You can't delete this item";

  }

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"../images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}

/////////////////////////////////ADD BLOG

else if($action=="addblg")

{



if(!getgold(getuid_sid($sid))>50)

    {

        echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      echo "Only 50+ Gold can add blogs<br/>To get Gold. Exchange Plusses at the <a href=\"bank.php?action=bank\">&#187;Wapirate Bank</a>!<br/><br/>";

      echo "<a href=\"index.php?action=main\">Home</a>";

      echo "</p>";

      echo "</card>";

      echo "</wml>";

      exit();

    }

  $btitle = $_POST["btitle"];

  $msgtxt = $_POST["msgtxt"];

  //$qut = $_POST["qut"];

  addonline(getuid_sid($sid),"Adding A Blog","");

  echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      $crdate = time();

      $uid = getuid_sid($sid);

      $res = false;



      if((trim($msgtxt)!="")&&(trim($btitle)!=""))

      {

      $res = mysql_query("INSERT INTO ibwf_blogs SET bowner='".$uid."', bname='".$btitle."', bgdate='".$crdate."', btext='".$msgtxt."'");

      }

      if($res)

      {

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Message Posted Successfully";

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error Posting Message";

      }



      echo "<br/><br/>";

      echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

      echo "</p>";

      echo "</card>";



}

////////////////////////////////////////ADD VAULT

else if($action=="addvlt")

{



if(!getgold(getuid_sid($sid))>20)

    {

        echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      echo "Only 20+ plusses can add a vault item<br/>To get Gold. Exchange Plusses at the <a href=\"bank.php?action=bank\">&#187;Wapirate Bank</a>!<br/><br/>";

      echo "<a href=\"index.php?action=main\">Home</a>";

      echo "</p>";

      echo "</card>";

      echo "</wml>";

      exit();

    }

  $viname = $_POST["viname"];

  $vilink = $_POST["vilink"];

  //$qut = $_POST["qut"];

  addonline(getuid_sid($sid),"Adding A Vault Item","");

  echo "<card id=\"main\" title=\"wapirate\">";

      echo "<p align=\"center\">";

      $crdate = time();

      //$uid = getuid_sid($sid);

      $res = false;



      if((trim($vilink)!="")&&(trim($viname)!=""))

      {

      $res = mysql_query("INSERT INTO ibwf_vault SET uid='".$uid."', title='".mysql_escape_string($viname)."', pudt='".$crdate."', itemurl='".$vilink."'");

      }

      if($res)

      {

        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Item added Successfully";

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error adding an item";

      }



      echo "<br/><br/>";

      echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

      echo "</p>";

      echo "</card>";



}

//////////////////////////////////////////shout



else if($action=="shout")

{

  $shtxt = $_POST["shtxt"];

    addonline(getuid_sid($sid),"Shouting","");



    echo "<card id=\"main\" title=\"Shout\">";

    echo "<p align=\"center\">";

	

	if(getuid_sid($sid)==00)

        {

		  $nick = getnick_sid($sid);

          echo "Hey $nick<br/>";

		  echo "This is the new ";

		  echo "<b><small><a href=\"http://www.phonerotica.com\">ShoutBox</a></small></b>";

		  echo " link!";

        }

	

    elseif(getgold(getuid_sid($sid))<10)

    {

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>You should have at least 10 Gold to shout!<br/>To get Gold. Exchange Plusses at the <a href=\"bank.php?action=bank\">&#187;Wapirate Bank</a>!";

    }else{

$len = strlen($shtxt);

if($len>5){

      $shtxt = $shtxt;

    //$uid = getuid_sid($sid);

    $shtm = time();

    $res = mysql_query("INSERT INTO ibwf_shouts SET shout='".$shtxt."', shouter='".$uid."', shtime='".$shtm."'");

    if($res)

    {

    $shts = mysql_fetch_array(mysql_query("SELECT shouts from ibwf_users WHERE id='".$uid."'"));

    $shts = $shts[0]+1;

    mysql_query("UPDATE ibwf_users SET shouts='".$shts."' WHERE id='".$uid."'");

    echo "<img src=\"images/ok.gif\" alt=\"O\"/>Shout added successfully";

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Database Error";

    }

}else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Your Shout Is Too Short";

}

            }

         echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

    echo "</p>";

    echo "</card>";

}



//////////////////////////////////////////Announce



else if($action=="annc")

{

  $antx = $_POST["antx"];

  $clid = $_GET["clid"];

    addonline(getuid_sid($sid),"Announcing","");

$cow = mysql_fetch_array(mysql_query("SELECT owner, coowner FROM ibwf_clubs WHERE id='".$clid."'"));

    $uid = getuid_sid($sid);

    echo "<card id=\"main\" title=\"Announce\">";

    echo "<p align=\"center\">";

    if($cow[0]||$cow=$uid)

    {

      $shtxt = $shtxt;

    //$uid = getuid_sid($sid);

    $shtm = time();

    $res = mysql_query("INSERT INTO ibwf_announcements SET antext='".$antx."', clid='".$clid."', antime='".$shtm."'");

    if($res)

    {

    echo "<img src=\"images/ok.gif\" alt=\"O\"/>Announcement Added!";

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Database Error";

    }

    }else{

           echo "<img src=\"images/notok.gif\" alt=\"X\"/>This is not your club!";

         }

   echo "<br/><a href=\"index.php?action=gocl&amp;clid=$clid\">Back To Club</a><br/>";

         echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

    echo "</p>";

    echo "</card>";

}

/////////////////////////////////RATE BLOG

else if($action=="rateb")

{

  $brate = $_POST["brate"];

  $bid = $_GET["bid"];

  addonline(getuid_sid($sid),"Rating A Blog","");

  //$uid = getuid_sid($sid);

  

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  $vb = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_brate WHERE uid='".$uid."' AND blogid='".$bid."'"));

  if($vb[0]==0)

  {

    $res = mysql_query("INSERT INTO ibwf_brate SET uid='".$uid."', blogid='".$bid."', brate='".$brate."'");

    if($res)

    {

        echo "<img src=\"images/ok.gif\" alt=\"o\"/>Blog rated successfully<br/>";

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

    }

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>You have rated this blog before<br/>";

  }

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

  

}

//////////////////////////////////DELETE GUESTBOOK MEMBER

else if($action=="delfgb")

{

    $mid = $_GET["mid"];

  addonline(getuid_sid($sid),"Deleting GB Message","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  if(candelgb(getuid_sid($sid), $mid))

  {

    $res = mysql_query("DELETE FROM ibwf_gbook WHERE id='".$mid."'");

    if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Message Deleted From Guestbook<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"X\"/>You can't delete this message";

  }

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}

////////////////////////////////DELETE VAULT

else if($action=="delvlt")

{

    $vid = $_GET["vid"];

  addonline(getuid_sid($sid),"Deleting Vault Item","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  $itemowner = mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_vault WHERE id='".$vid."'"));

  if(isstatus4(getuid_sid($sid))||getuid_sid($sid)==$itemowner[0])

  {

    $res = mysql_query("DELETE FROM ibwf_vault WHERE id='".$vid."'");

    if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Item Deleted From Vault<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"X\"/>You can't delete this item";

  }

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}

/////////////////////////////////////DELETE BLOG

else if($action=="delbl")

{

    $bid = $_GET["bid"];

  addonline(getuid_sid($sid),"Deleting A Blog","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  if(candelbl(getuid_sid($sid), $bid))

  {

    $res = mysql_query("DELETE FROM ibwf_blogs WHERE id='".$bid."'");

    if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Blog Deleted<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"X\"/>You can't delete this blog";

  }

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}

/////////////////////////////////////REPORT POST

else if($action=="rpost")

{

  $pid = $_GET["pid"];

  addonline(getuid_sid($sid),"Reporting Post","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  $pinfo = mysql_fetch_array(mysql_query("SELECT reported FROM ibwf_posts WHERE id='".$pid."'"));

          if($pinfo[0]=="0")

          {

          $str = mysql_query("UPDATE ibwf_posts SET reported='1' WHERE id='".$pid."' ");

          if($str)

          {

            echo "<img src=\"images/ok.gif\" alt=\"O\"/>Post reported to mods successfully";

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>Can't report post at the moment";

          }

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>This Post is already reported";

          }

          echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

        

        

}



////////////////////////////////REPORT TOPIC

else if($action=="rtpc")

{

  $tid = $_GET["tid"];

  addonline(getuid_sid($sid),"Reporting Topic","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  $pinfo = mysql_fetch_array(mysql_query("SELECT reported FROM ibwf_topics WHERE id='".$tid."'"));

          if($pinfo[0]=="0")

          {

          $str = mysql_query("UPDATE ibwf_topics SET reported='1' WHERE id='".$tid."' ");

          if($str)

          {

            echo "<img src=\"images/ok.gif\" alt=\"O\"/>Topic reported to mods successfully";

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>Can't report topic at the moment";

          }

          }else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>This Topic is already reported";

          }

          echo "<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";





}

//////////////////////////////////////ADD BUD

else if($action=="bud")

{

  $todo = $_GET["todo"];

  $who = $_GET["who"];

  addonline(getuid_sid($sid),"Adding/Removing Buddy","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

    $unick = getnick_uid($uid);

    $tnick = getnick_uid($who);

  if($todo=="add")

  {

    if(budres($uid,$who)!=3){

    if(arebuds($uid,$who))

    {

      echo "<img src=\"images/notok.gif\" alt=\"x\"/>$tnick is already your buddy<br/>";

    }else if(budres($uid, $who)==0)

    {

        $res = mysql_query("INSERT INTO ibwf_buddies SET uid='".$uid."', tid='".$who."', reqdt='".time()."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>A request has been sent to $tnick<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't add $tnick to your buddy list<br/>";

        }

    }

else if(budres($uid, $who)==1)

    {

        $res = mysql_query("UPDATE ibwf_buddies SET agreed='1' WHERE uid='".$who."' AND tid='".$uid."'");

        if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>$tnick Added to your buddy list successfully<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't add $tnick to your buddy list<br/>";

        }

    }

    else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't add $tnick to your buddy list<br/>";

    }

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't add $tnick to your buddy list<br/>";

    }

  }else if($todo="del")

  {

    

        

      

      $res= mysql_query("DELETE FROM ibwf_buddies WHERE (uid='".$uid."' AND tid='".$who."') OR (uid='".$who."' AND tid='".$uid."')");

      if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>$tnick removed from your buddy list<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Can't remove $tnick from your buddy list<br/>";

        }



  }

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}



//////////////////////////////////////////Update buddy message

else if($action=="upbmsg")

{

    addonline(getuid_sid($sid),"Updating Buddy Message","");

    $bmsg = $_POST["bmsg"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  $res = mysql_query("UPDATE ibwf_users SET budmsg='".$bmsg."' WHERE id='".$uid."'");

  if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Buddy message updated successfully<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Can't update your buddy message<br/>";

        }

        echo "<br/>";

  echo "<a href=\"lists.php?action=buds\">";

echo "Buddies List</a><br/>";

     echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p>";

  echo "</card>";

}



//////////////////////////////////////////Select Avatar

else if($action=="upav")

{

    addonline(getuid_sid($sid),"Updating Avatar","");

    $avid = $_GET["avid"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  $avlnk = mysql_fetch_array(mysql_query("SELECT avlink FROM ibwf_avatars WHERE id='".$avid."'"));

  $res = mysql_query("UPDATE ibwf_users SET avatar='".$avlnk[0]."' WHERE id='".$uid."'");

  if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Avatar Selected<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

        echo "<br/>";

  

     echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p>";

  echo "</card>";

}



//////////////////////////////////////////Select Avatar

else if($action=="upcm")

{

    addonline(getuid_sid($sid),"Updating Chat Mood","");

    $cmid = $_GET["cmid"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  $res = mysql_query("UPDATE ibwf_users SET chmood='".$cmid."' WHERE id='".$uid."'");

  if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Mood Selected<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

        echo "<br/>";

echo "<a href=\"index.php?action=chat\">";

echo "Chatrooms</a><br/>";

     echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p>";

  echo "</card>";

}



//////////////////////////////////////////Give GPs

else if($action=="givegp")

{

    addonline(getuid_sid($sid),"Giving Game Plusses","");

    $who = $_GET["who"];

    $ptg = $_POST["ptg"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  $gpsf = mysql_fetch_array(mysql_query("SELECT gplus FROM ibwf_users WHERE id='".$uid."'"));

  $gpst = mysql_fetch_array(mysql_query("SELECT gplus FROM ibwf_users WHERE id='".$who."'"));

  if($gpsf[0]>=$ptg){

    $gpsf = $gpsf[0]-$ptg;

    $gpst = $gpst[0]+$ptg;

    $res = mysql_query("UPDATE ibwf_users SET gplus='".$gpst."' WHERE id='".$who."'");

  if($res)

        {

          $res = mysql_query("UPDATE ibwf_users SET gplus='".$gpsf."' WHERE id='".$uid."'");

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Game Plusses Updated Successfully<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

      }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>You don't have enough GPs to give<br/>";

        }



        echo "<br/>";

  

     echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p>";

  echo "</card>";

}



//////////////////// add club



else if($action=="addcl")

{

    addonline(getuid_sid($sid),"Adding Club","");

    $clnm = trim($_POST["clnm"]);

    $clnm = str_replace("$", "", $clnm);

    $clds = trim($_POST["clds"]);

    $clds = str_replace("$", "", $clds);

    $clrl = trim($_POST["clrl"]);

    $clrl = str_replace("$", "", $clrl);

    $cllg = trim($_POST["cllg"]);

    $cllg = str_replace("$", "", $cllg);

    echo "<card id=\"main\" title=\"Add Club\">";

    echo "<p align=\"center\">";

    $uid = getuid_sid($sid);

    if(getgold($uid)>=500)

    {

    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE owner='".$uid."'"));

      if($noi[0]<3)

      {

        if(($clnm=="")||($clds=="")||($clrl==""))

        {

          echo "<img src=\"images/notok.gif\" alt=\"X\"/>Please be sure to fill, club name, description and rules";

        }else{

          $nmex = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_clubs WHERE name LIKE '".$clnm."'"));

          if($nmex[0]>0)

          {

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>Club Name Already exist";

          }else{

            $res = mysql_query("INSERT INTO ibwf_clubs SET name='".$clnm."', owner='".$uid."', description='".$clds."', rules='".$clrl."', logo='".$cllg."', plusses='20', created='".time()."'");

            if($res)

            {

              $clid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_clubs WHERE owner='".$uid."' AND name='".$clnm."'"));

                echo "<img src=\"images/ok.gif\" alt=\"O\"/>Congratulations! You have your own club, your own rules, message board, chatroom, announcements board, 20 plusses as credit for your club so you can give them to the first registered users at your club, 5 plusses for you, and 50 club points also for you!";

mysql_query("UPDATE ibwf_users SET gold=gold-500 WHERE id='".$uid."'");

                mysql_query("INSERT INTO ibwf_clubmembers SET uid='".$uid."', clid='".$clid[0]."', accepted='1', points='50', joined='".time()."'");

                $ups = getplusses($uid);

                $ups += 5;

                mysql_query("UPDATE ibwf_users SET plusses='".$ups."' WHERE id='".$uid."'");

                $fnm = $clnm." Board";

                $cnm = $clnm." Chat";

                mysql_query("INSERT INTO ibwf_forums SET name='".$fnm."', position='0', cid='0', clubid='".$clid[0]."'");

                mysql_query("INSERT INTO ibwf_rooms SET name='".$cnm."', pass='', static='1', mage='0', chposts='0', perms='0', censord='0', freaky='0', lastmsg='".time()."', clubid='".$clid[0]."'");

            }else{

                echo "<img src=\"images/notok.gif\" alt=\"X\"/>Database Error!";

            }

          }

        }

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"X\"/>You already have 3 clubs";

      }

      }else{



      echo "<img src=\"images/notok.gif\" alt=\"X\"/>You cant add clubs";

      }



    

    echo "<br/><br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p>";

    echo "</card>";

}

//////////////////////////////////////////Give GPs

else if($action=="batp")

{

    addonline(getuid_sid($sid),"Giving Game Plusses","");

    $who = $_GET["who"];

    $ptg = $_POST["ptbp"];

    $giv = $_POST["giv"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  $judg = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_judges WHERE uid='".getuid_sid($sid)."'"));

  $gpst = mysql_fetch_array(mysql_query("SELECT battlep FROM ibwf_users WHERE id='".$who."'"));

  if(isstatus1(getuid_sid($sid))||$judg[0]>0)

  {

    if ($giv=="1")

    {

$bat = mysql_fetch_array(mysql_query("SELECT bp FROM ibwf_staff WHERE uid='".getuid_sid($sid)."'"));

if($bat[0]<$ptg){

$new = mysql_fetch_array(mysql_query("SELECT battlep FROM ibwf_users WHERE id='".getuid_sid($sid)."'"));

$pln = $new[0] - $ptg;

mysql_query("UPDATE ibwf_users SET battlep='".$pln."' WHERE id='".getuid_sid($sid)."'");

mysql_query("INSERT INTO ibwf_mlog SET action='Staff', details='<b>".getnick_uid(getuid_sid($sid))."</b> Updated there ".$unick."s Bp and Sacrificed ".$ptg." Bp lol', actdt='".time()."'");

}else{

$pln = $bat[0] - $ptg;

mysql_query("UPDATE ibwf_staff SET bp='".$pln."' WHERE uid='".getuid_sid($sid)."'");

}    

        $gpst = $gpst[0]+$ptg;

    }else{

        $gpst = $gpst[0]-$ptg;

        if($gpst<0)$gpst=0;

    }

    $res = mysql_query("UPDATE ibwf_users SET battlep='".$gpst."' WHERE id='".$who."'");

  if($res)

        {

          $vnick = getnick_uid($who);

          if ($giv=="1")

          {

            $ms1 = " Added $ptg points to ";

          }else{

            $ms1 = " Removed $ptg points from ";

          }



          mysql_query("INSERT INTO ibwf_mlog SET action='bpoints', details='<b>".getnick_uid(getuid_sid($sid))."</b> $ms1  $vnick', actdt='".time()."'");

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Battle Points Updated Successfully<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

      }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't do this<br/>";

        }



        echo "<br/>";



     echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p>";

  echo "</card>";

}



/////////////////////////////Add remove from ignoire list



else if($action=="ign")

{

    addonline(getuid_sid($sid),"Updating Ignore List","");

    $todo = $_GET["todo"];

    $who = $_GET["who"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  $tnick = getnick_uid($who);

  if($todo=="add")

  {

    if(ignoreres($uid, $who)==1)

    {

      $res= mysql_query("INSERT INTO ibwf_ignore SET name='".$uid."', target='".$who."'");

    if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>$tnick was added successfully to your ignore list<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Error Updating Database<br/>";

        }

    }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>You can't Add $tnick to your ignore list<br/>";

    }

  }else if($todo="del")

  {

    if(ignoreres($uid, $who)==2)

    {

      $res= mysql_query("DELETE FROM ibwf_ignore WHERE name='".$uid."' AND target='".$who."'");

      if($res)

        {

            echo "<img src=\"images/ok.gif\" alt=\"o\"/>$tnick was deleted successfully from your ignore list<br/>";

        }else{

          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Error Updating Database<br/>";

        }

      }else{

        echo "<img src=\"images/notok.gif\" alt=\"x\"/>$tnick is not ignored by you<br/>";

      }

  }

  echo "<br/><a href=\"lists.php?action=ignl\">";

echo "Ignore List</a><br/>";

     echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p>";

  echo "</card>";

}



//////////////////////////////////////////Update profile

else if($action=="uprof")

{

    addonline(getuid_sid($sid),"Updating Settings","");

    //$savat = $_POST["savat"];

    $semail = $_POST["semail"];

    $usite = $_POST["usite"];

    $ubday = $_POST["ubday"];

    $uloc = $_POST["uloc"];

    $usig = $_POST["usig"];

    $usex = $_POST["usex"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  //avatar='".$savat."',

  $res = mysql_query("UPDATE ibwf_users SET  email='".$semail."', site='".$usite."', birthday='".$ubday."', location='".$uloc."', signature='".$usig."', sex='".$usex."' WHERE id='".$uid."'");

  if($res)

  {

    echo "<img src=\"images$folder/ok.gif\" alt=\"o\"/><a href=\"index.php?action=viewuser&amp;who=$uid\">Your profile </a> Was Updated Successfully<br/>";

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>Error updating your profile<br/>";

  }

echo "<br/><a href=\"index.php?action=uset\">Re-Update Profile</a><br/>";

  echo "<br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}



//////////////////////////////////////////Change Password



else if($action=="upwd")

{

    addonline(getuid_sid($sid),"Updating Settings","");

    $npwd = $_POST["npwd"];

    $cpwd = $_POST["cpwd"];

    echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  //$uid = getuid_sid($sid);

  if($npwd!=$cpwd)

  {

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>Your Password and Confirmation Password Don't match<br/>";

    

  }else if((strlen($npwd)<4) || (strlen($npwd)>15)){

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>Your password should be between 4 and 15 letters only<br/>";



  }else{

    $pwd = md5($npwd);

    $res = mysql_query("UPDATE ibwf_users SET pass='".$pwd."' WHERE id='".$uid."'");

    if($res)

  {

    echo "<img src=\"images/ok.gif\" alt=\"o\"/>Your password was updated successfully<br/>";

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>Error updating your password<br/>";

  }

  }

  echo "<br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}



//////////////////////////////////////////Change Menu Images On



else if($action=="menu")

{

    addonline(getuid_sid($sid),"Looking for Treasure","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  

  

     $menu = 1;

    $res = mysql_query("UPDATE ibwf_users SET menu='".$menu."' WHERE id='".$uid."'");

    if($res)

  {

    echo "<img src=\"images/ok.gif\" alt=\"o\"/>Menu Images Turned On Successfully<br/>";

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>Error Updating Menu Images<br/>";

  }

  

  echo "<br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}



//////////////////////////////////////////Change Menu Images Off



else if($action=="nomenu")

{

    addonline(getuid_sid($sid),"Looking for Treasure","");

  echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  

  

     $menu = 0;

    $res = mysql_query("UPDATE ibwf_users SET menu='".$menu."' WHERE id='".$uid."'");

    if($res)

  {

    echo "<img src=\"images/ok.gif\" alt=\"o\"/>Menu Images Turned Off Successfully<br/>";

  }else{

    echo "<img src=\"images/notok.gif\" alt=\"x\"/>Error Updating Menu Images<br/>";

  }

  

  echo "<br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}



///////////////////////////////////add quiz words

else if($action=="addquiz"){

$question = $_POST["question"];

$answer = $_POST["answer"];

$points = $_POST["points"];

$qnick = $_POST["qnick"];

echo "<card id=\"main\" title=\"Wapirate\">";

echo "<p align=\"center\">";

echo "<br/>";

$res = mysql_query("INSERT INTO quizuser SET question='".$question."', answer='".$answer."', points='".$points."', who='".$qnick."'");

if($res){

echo "<img src=\"images/ok.gif\" alt=\"O\"/>Quiz Question added successfully<br/>Your points will be added as soon as your question is validated by a member of staff!";

}else{

echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error adding Quiz Question ";

}

echo "<br/><br/><a href=\"quiz.php?action=addquiz&amp;rid=1\">Add Another Quiz Question?</a><br/><br/>";

echo "<a href=\"quiz.php?rid=1\">Quiz</a><br/>";

echo "<br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p></card>";

}

////////////////////////////////////////blog comment

else if($action=="signblogcomment")

{

    $who = $_POST["who"];

   $bid = $_GET["bid"];

if(!cansignblogcomment(getuid_sid($sid), $who))

{

        echo "<card id=\"main\" title=\"$sitename\">";

      echo "<p align=\"center\">";

      echo "You cant Sign this user Blog<br/><br/>";

      echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>";

      echo "</p>";

      echo "</card>";

      echo "</wml>";

      exit();

    }

  $msgtxt = $_POST["msgtxt"];

  addonline(getuid_sid($sid),"Signing a User's Blog","");

  echo "<card id=\"main\" title=\"$sitename\">";

      echo "<p align=\"center\">";

      $crdate = time();

      $res = false;



      if(trim($msgtxt)!="")

      {

        

      $res = mysql_query("INSERT INTO ibwf_blogcomment SET blogowner='".$bid."', blogsigner='".$uid."', dtime='".$crdate."', blogmsg='".$msgtxt."'");

      }

      if($res)

      {

        echo "<img src=\"../images/ok.gif\" alt=\"O\"/>Comment Posted Successfully";

      }else{

        echo "<img src=\"../images/notok.gif\" alt=\"X\"/>Error Posting Comment";

      }

      amp;

      echo "<br/><br/>";

 echo "<a href=\"lists.php?action=allbl\">Back to Blogs</a><br/>";

      echo "<a href=\"index.php?action=main\"><img src=\"../images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

      echo "</p>";

      echo "</card>";



}

//////////////////////////////////////////delete blog comments

else if($action=="delblogcomment")

{

    $mid = $_GET["mid"];

  addonline(getuid_sid($sid),"Deleting Blog's Comment","");

  echo "<card id=\"main\" title=\"$sitename\">";

  echo "<p align=\"center\">";

  if(candelblogcomment(getuid_sid($sid), $mid))

  {

    $res = mysql_query("DELETE FROM ibwf_blogcomment WHERE id='".$mid."'");

    if($res)

        {

            echo "<img src=\"../images/ok.gif\" alt=\"o\"/>Comment Deleted From Blog<br/>";

        }else{

          echo "<img src=\"../images/notok.gif\" alt=\"x\"/>Database Error!<br/>";

        }

  }else{

    echo "<img src=\"../images/notok.gif\" alt=\"X\"/>You can't delete this Comment";

  }

  echo "<br/><br/>";

 echo "<a href=\"lists.php?action=allbl\">Back to Blogs</a><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"../images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}





//////////////////////////////////////////move to inbox

else if($action=="inbox")

{



  addonline(getuid_sid($sid),"Inboxing Posting","");

  echo "<card id=\"main\" title=\"$sitename\">";

  echo "<p align=\"center\">";

 echo "<b>Send Post To Inbox</b><br/>";

$pid = $_GET["pid"];

$tid = $_GET["tid"];

$who = $_POST["who"];

$who = getuid_nick($who);

if($who==""){

$nme = "1218";

$who = $uid;

}else{

$nme = $uid;

}

if($tid==""){

$pinfo = mysql_fetch_array(mysql_query("SELECT uid, tid, text  FROM ibwf_posts WHERE id='".$pid."'"));

$tinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_topics WHERE id='".$pinfo[1]."'"));

$tname = htmlspecialchars($tinfo[0]);

$res = mysql_query("INSERT INTO ibwf_private SET title='".$tname."', text='".$pinfo[2]."[br/][i]This Message Was Sent From Forum Post! [/i]', byuid='".$nme."', touid='".$who."', timesent='".$tm."'");

}else{

$tinfo = mysql_fetch_array(mysql_query("SELECT name, authorid, text FROM ibwf_topics WHERE id='".$tid."'"));

$tname = htmlspecialchars($tinfo[0]);

$res = mysql_query("INSERT INTO ibwf_private SET title='".$tname."', text='".$tinfo[2]."[br/][i]This Message Was Sent From Forum Post! [/i]', byuid='".$nme."', touid='".$who."', timesent='".$tm."'");

}

if($res){

    echo "<img src=\"images$folder/ok.gif\" alt=\"o\"/>Message Sent Successfully<br/>";

  }else{

    echo "<img src=\"images$folder/notok.gif\" alt=\"x\"/>Error Sending Message<br/>";

  }

echo "<a href=\"index.php?action=viewtpc&amp;tid=$tid&amp;page=1\">Back to $tname</a><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"../images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}



///////////////////////////////////LOGOUT

else if($action=="logout")

{

  $uid =getuid_sid($sid);

  if($uid>0)

  {

  addonline(getuid_sid($sid),"Logout","");

  }

  echo "<card id=\"main\" title=\"LOGOUT\">";

  echo "<p align=\"center\">";

  $res =  mysql_query("DELETE FROM ibwf_ses WHERE uid='".$uid."'");

  $res =  mysql_query("DELETE FROM ibwf_online WHERE userid='".$uid."'");

  if($res)

   {

session_destroy();

      echo "<img src=\"images/ok.gif\" alt=\"O\"/>You have logged out successfully!<br/>";

   }

      else{

            echo "<img src=\"images/notok.gif\" alt=\"X\"/>Failed to logout!";

	      }

  

    echo "<a href=\"index.php\"><img src=\"images/home.gif\" alt=\"*\"/>";

  echo "Home</a>";

  echo "</p>";

  echo "</card>";

}



////////////////////////////////////////////Edit Post



if($action=="edtpst"){

$pid = $_GET["pid"];

  $reason = $_POST["reason"];

$ptext = $_POST["ptext"];

$tid = gettid_pid($pid);

$fid = getfid_tid($tid);

echo "<card id=\"main\" title=\"wapirate\">";

echo "<p align=\"center\">";

$pinfo= mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_posts WHERE id='".$pid."'"));

if(($pinfo[0]==$uid)||(isstatus2(getuid_sid($sid)))){

if($reason==""){

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>No Edit Reason?";

}else{

  $res = mysql_query("UPDATE ibwf_posts SET text='".$ptext."', editreason='".$reason."', editby='".$uid."' WHERE id='".$pid."'");

  if($res)

          {

            $tname = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_topics WHERE id='".$tid."'"));

            mysql_query("INSERT INTO ibwf_mlog SET action='posts', details='<b>".getnick_uid(getuid_sid($sid))."</b> Edited Post Number $pid Of the thread ".mysql_escape_string($tname[0])." at the forum ".getfname($fid)."', actdt='".time()."'");

            echo "<img src=\"images$folder/ok.gif\" alt=\"O\"/>Post Message Edited";

          }else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>Database Error";

          }

}

}else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>You Do Not Have Permition To Do This!";

}



echo "<br/><br/>";

echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$tid\">";

echo "View Topic</a><br/>";

$fname = getfname($fid);

echo "<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$fid\">";

echo "$fname</a><br/>";

echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p></card>";

}



////////////////////////////////////////////Edit topic



else if($action=="edttpc"){

$tid = $_GET["tid"];

$ttext = $_POST["ttext"];

$fid = getfid_tid($tid);

$reason = $_POST["reason"];

echo "<card id=\"main\" title=\"wapirate\">";

echo "<p align=\"center\">";

$tinfo= mysql_fetch_array(mysql_query("SELECT authorid FROM ibwf_topics WHERE id='".$tid."'"));

if(($tinfo[0]==$uid)||(isstatus2(getuid_sid($sid)))){

if($reason==""){

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>No Edit Reason?";

}else{

  $res = mysql_query("UPDATE ibwf_topics SET text='".$ttext."', editreason='".$reason."', editby='".$uid."' WHERE id='".$tid."'");

  if($res)

          {

            mysql_query("INSERT INTO ibwf_mlog SET action='topics', details='<b>".getnick_uid(getuid_sid($sid))."</b> Edited the text Of the thread ".mysql_escape_string(gettname($tid))." at the forum ".getfname($fid)."', actdt='".time()."'");

            echo "<img src=\"images$folder/ok.gif\" alt=\"O\"/>Topic Message Edited";

          }else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>Database Error";

          }

}

}else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>You Do Not Have Permition To Do This!";

}

echo "<br/><br/>";

echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$tid\">";

echo "View Topic</a><br/>";

$fname = getfname($fid);

echo "<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=$fid\">";

echo "$fname</a><br/>";

echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p></card>";

}



///////////////////////////////////////Post per view posts 



else if($action=="paddppv")

{

  $pid = $_GET["pid"];

  $ppv = $_POST["ppv"];

  $tid = gettid_pid($pid);

  $fid = getfid_tid($tid);

echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";





$pinfo= mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_posts WHERE id='".$pid."'"));

if(($pinfo[0]==$uid)||(isstatus2(getuid_sid($sid)))){



  $res = mysql_query("UPDATE ibwf_posts SET ppv='".$ppv."' WHERE id='".$pid."'");

  if($res)

          {



            echo "<img src=\"images$folder/ok.gif\" alt=\"O\"/>Number Of Posts Added Succesfully";

          }else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>Database Error";

          }



}else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>You Do Not Have Permition To Do This!";

}

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=viewtpc&amp;tid=$tid\">";

echo "View Topic</a><br/>";

$fname = getfname($fid);

      echo "<a href=\"index.php?action=viewfrm&amp;fid=$fid\">";

echo "$fname</a><br/>";

echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p></card>";

}



////////////////////////////////////////////Post per view topic 



else if($action=="taddppv")

{

  $tid = $_GET["tid"];

$ppv = $_POST["ppv"];

  $fid = getfid_tid($tid);

echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

$tinfo= mysql_fetch_array(mysql_query("SELECT authorid FROM ibwf_topics WHERE id='".$tid."'"));

if(($tinfo[0]==$uid)||(isstatus2(getuid_sid($sid)))){



  $res = mysql_query("UPDATE ibwf_topics SET ppv='".$ppv."' WHERE id='".$tid."'");

  if($res)

          {



            echo "<img src=\"images$folder/ok.gif\" alt=\"O\"/>Number Of Posts Added Succesfully";

          }else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>Database Error";

          }



}else{

            echo "<img src=\"images$folder/notok.gif\" alt=\"X\"/>You Do Not Have Permition To Do This!";

}

  echo "<br/><br/>";

  echo "<a href=\"index.php?action=viewtpc&amp;tid=$tid\">";

echo "View Topic</a><br/>";

$fname = getfname($fid);

      echo "<a href=\"index.php?action=viewfrm&amp;fid=$fid\">";

echo "$fname</a><br/>";

echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

echo "</p></card>";

}



//////////////////////////////////////////////////////////////////////////////////////////

else{

   echo "<card id=\"main\" title=\"wapirate\">";

  echo "<p align=\"center\">";

  echo "I don't know how you got in here, but there's nothing to show<br/><br/>";

  echo "<a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";

echo "Home</a>";

  echo "</p></card>";

}





?>

</wml>