<?
include "../../mysql_inc.php";
include "config.php";
?>


<?

$nick = $_GET['nick'];
$pass = $_GET['pass'];
$club = $_GET["club"];
$key = $_GET['key'];

$ch = $_GET['ch'];
$number = $_GET["number"];

       if(!empty($_GET['page'])) { $page = $_GET["page"];}
        else {$page = $_POST["page"];}


$admincheck = mysql_num_rows(mysql_query("select * from users WHERE nick='$nick' and pass='$pass' and (status='admin' OR status='moderator' OR status='hijacker')"));
$lockedcheck = mysql_num_rows(mysql_query("select * from users WHERE nick='$nick' and pass='$pass' and (status='admin' OR status='moderator' OR status='hijacker')"));
//====================deleting==================================

if($ch == "no" and $admincheck > 0) {
        echo "<p align=\"left\">$check <small><a href=\"$PHP_SELF?number=$number&amp;nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum&amp;ch=yes\">$yes</a></small><br/>";
        include "../../bottom_inc.php";
        return FALSE;
                                    }


if($ch == "yes" and $admincheck > 0) {


       $query = "DELETE FROM $topics WHERE nr = '$number'";
       $result = mysql_query($query) or die("Error");

       $query = "DELETE FROM $messages WHERE raktas = '$key'";
       $result = mysql_query($query) or die("Error");

                                    }



//==================================================================


//====================uzrakinimas==================================

    //    $query = "SELECT * FROM $topics";
	//$result = mysql_query($query) or die ("Error");
	//while ($row = mysql_fetch_array($result)){

	//$locked = $row[locked];

       //           }


	//if ($locked > 0) {

       // echo "<small><a href=\"$PHP_SELF?number=$nr&amp;nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum&amp;ch=no\">*lock*</a></small><br/></p></card></wml>";
         //                 return FALSE;
         //         }


        // if ($lockedcheck > 0) {echo "<small><a href=\"$PHP_SELF?number=$nr&amp;nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum&amp;ch=no\">*lock*</a></small><br/>"; }


      // $query = "UPDATE $topics SET locked = '1'";
      // $result = mysql_query($query) or die("Error");

                                    

//=======================uzrakinimo pabaiga===========================================


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


       if ($forum == "en") {echo "<small>[^]<a href=\"en_index.php?nick=$nick&amp;pass=$pass&amp;forum=$forum\">Forums</a></small><br/><br/>";}
       if ($forum == "lt") {echo "<small>[^]<a href=\"lt_index.php?nick=$nick&amp;pass=$pass&amp;forum=$forum\">Forumai</a></small><br/><br/>";}


?>


<?
$max_entries = "5";

$messages = mysql_num_rows(mysql_query("select * from $messages where club='$club'"));
$total = mysql_num_rows(mysql_query("select * from $topics where club='$club'"));
if (!$page) { $page=1; }
$start=($max_entries * $page)-$max_entries;
if ($total <= $max_entries) { $num_page=1; }
else if (($total % $max_entries)==0) { $num_page=$total/$max_entries; }
else { $num_page=$total/$max_entries + 1; }

$query = "select * from $topics WHERE club='$club' ORDER BY date DESC LIMIT $start, $max_entries";
$result = mysql_query($query) or die ("Error");


while ($row = mysql_fetch_array($result)){

        $key = $row[raktas];
        $topic = $row[topic];
        $number = $row[number];
      //  $locked = $row[locked];


        if ($admincheck < 1) {

        echo "<small><a href=\"messages.php?nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum\">$topic</a></small><small> ($number)</small><br/>"; }

         elseif ($admincheck > 0) {echo "<small><a href=\"messages.php?nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum\">$topic</a></small><small> ($number)</small>
                                     <small><a href=\"$PHP_SELF?number=$nr&amp;nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum&amp;ch=no\">*Del*</a></small><br/>"; }

                                  
                
	// if ($locked == 0) {echo "<small><a href=\"locked.php?number=$nr&amp;nick=$nick&amp;pass=$pass&amp;key=$key&amp;club=$club&amp;forum=$forum&amp;ch=no\">*lock*</a></small><br/>"; }
                                         




  }




echo "<br/>";

$totalas = $total / $max_entries;

$next = $page + 1;

$previous = $page - 1;

if($total > $max_entries){

if($totalas > $page){

echo "<small><a href=\"$PHP_SELF?nick=$nick&amp;pass=$pass&amp;club=$club&amp;page=$next&amp;forum=$forum\">$next1</a></small><br/>";

}

}

if($page > 1){

echo "<small><a href=\"$PHP_SELF?nick=$nick&amp;pass=$pass&amp;club=$club&amp;page=$previous&amp;forum=$forum\">$prev1</a></small><br/>";

}

//--------------------

if($total >$max_entries) {

        settype($num_page,"integer");

        echo"<br/>
        <small>$page3 $page/$num_page </small><input name=\"page\" title=\"page\"/><br/>
        <anchor title=\"Go\">$submit<go href=\"$PHP_SELF?nick=$nick&amp;pass=$pass&amp;club=$club&amp;forum=$forum\" method=\"post\">
        <postfield name=\"page\" value=\"$(page)\"/>
        </go></anchor>";

        }
//--------------------
echo "<small><br/><a href=\"search.php?nick=$nick&amp;pass=$pass&amp;club=$club&amp;forum=$forum\">$search1</a></small>";
echo "<small><b><br/><a href=\"newtopic.php?nick=$nick&amp;pass=$pass&amp;club=$club&amp;forum=$forum\">$newtopic</a></b></small>";

?>

<?
mysql_close($db);
include "../../bottom_inc.php";
?>