<?php

@( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: phpbbrank.php,v 1.4.2.5 2004/08/15 12:58:04 kirilt Exp $




/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)            */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* =========================                                            */
/* Part of phpBB integration                                            */
/* Copyright (c) 2001 by                                                */
/*    Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)         */
/*    Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)                 */
/* http://www.phpnuke.web.id                                            */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

checkAccess( 'forum', array( 'forum' ) );

/*********************************************************/
/* PHPBB Forum Admin Function                            */
/*********************************************************/

function RankForumAdmin() {
    global $hlpfile, $admin, $bgcolor4, $mpnTables,$phpEx;
    include ("config.$phpEx");
    include ("header.$phpEx");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "
    <center><font size=4><b>".translate("Forum Ranking System")."</b></font></center>
    <form action=admin.$phpEx method=post>
    <center><table border=1 width=100%><tr>
    <td bgcolor=$bgcolor4><center>".translate("Title")."</td>
    <td bgcolor=$bgcolor4><center>".translate("Min. Posts")."</td>
    <td bgcolor=$bgcolor4><center>".translate("Max. Posts")."</td>
    <td bgcolor=$bgcolor4><center>".translate("Special Ranks")."</td><td>&nbsp</td></tr>";

    $result = mysql_query("select rank_id, rank_title, rank_min, rank_max, rank_special from ".$mpnTables['ranks']." order by rank_id");
    while(list($rank_id, $rank_title, $rank_min, $rank_max, $rank_special) = mysql_fetch_row($result)) {
        echo "
    <td align=center>$rank_title</td>
    <td align=center>$rank_min</td>
    <td align=center>$rank_max</td>";
    if ($rank_special ==1) {
    echo"
    <td align=center>on</td>";}
    else {
    echo"
    <td align=center>off</td>";}
    echo"
    <td align=center><a href=admin.$phpEx?op=RankForumEdit&rank_id=$rank_id>".translate("Edit")."</a> | <a href=admin.$phpEx?op=RankForumDel&rank_id=$rank_id&ok=0>".translate("Delete")."</a></td><tr>";
    }
    echo "</form></td></tr></table>
    <br><br>
    </center><font size=4><b>".translate("Add New Ranks")."</b><br><br>
    <font size=2>
    <form action=admin.$phpEx method=post>
    <table border=0 width=100%><tr><td>
    ".translate("Rank Title:")." </td><td><input type=text name=rank_title size=31></td></tr><tr><td>
    ".translate("Min. Posts:")." </td><td><input type=text name=rank_min size=3 maxsize=3></td></tr><tr><td>
    ".translate("Max. Posts:")." </td><td><input type=text name=rank_max size=3 maxsize=3></td></tr><tr><td>
    ".translate("Special:")." </td><td><input type=checkbox name=rank_special value=1></td></tr><tr><td>
    </td></tr></table>
    <input type=hidden name=op value=RankForumAdd>
    <input class='button' type=submit value=".translate("Add").">
    </form>
    </td></tr></table></td></tr></table>";
    include("footer.$phpEx");
}

function RankForumAdd($rank_title,$rank_min,$rank_max,$rank_special) {
    global $mpnTables,$phpEx;
    if ($rank_special == 1) {
    mysql_query("insert into ".$mpnTables['ranks']." values (NULL, '$rank_title', '-1' ,'-1' ,'$rank_special')");
    } else {
    mysql_query("insert into ".$mpnTables['ranks']." values (NULL, '$rank_title', '$rank_min' ,'$rank_max' ,'0')");
    }

    $_SERVER['F_LIB'] -> redirectRequest( 'admin.php?op=RankForumAdmin' );

}

function RankForumEdit($rank_id) {
    global $hlpfile, $admin,$mpnTables,$phpEx;
    include ("config.$phpEx");
    $hlpfile = "manual/$language/rankphpbb.html";
    include ("header.$phpEx");
    GraphicAdmin($hlpfile);
    $result = mysql_query("select rank_title, rank_min, rank_max, rank_special from ".$mpnTables['ranks']." where rank_id='$rank_id'");
    list($rank_title, $rank_min, $rank_max, $rank_special) = mysql_fetch_row($result);
    OpenTable();
    echo "
    <center><font size=4><b>".translate("Edit Ranks")."</b></font></center>
    <form action=admin.$phpEx method=post>
    <input type=hidden name=rank_id value=$rank_id>
    <table border=0 width=100%><tr><td>
    ".translate("Rank Title:")." </td><td><input type=text name=rank_title size=31 value=\"$rank_title\"></td></tr>";
    if ($rank_special == 1) {
    echo "<tr><td>".translate("Special:")." </td><td>active</td></tr>
    <input type=hidden name=rank_min value=\"$rank_min\">
    <input type=hidden name=rank_max value=\"$rank_max\">
    <input type=hidden name=rank_special value=$rank_special>";
    } else {
    echo "<tr><td>".translate("Min. Posts:")." </td><td><input type=text name=rank_min size=3 value=\"$rank_min\"></td></tr>
    <tr><td>".translate("Max. Posts:")." </td><td><input type=text name=rank_max size=3 value=\"$rank_max\"></td></tr>
    <tr><td>".translate("Special:")." </td><td><input type=checkbox name=rank_special value=1></td></tr>";
    }
    echo"
    <tr><td></td></tr></table>
    <input type=hidden name=op value=RankForumSave>
    <input class='button' type=submit value=".translate("Save Changes").">
    </form>
    </td></tr></table></td></tr></table>";
    include("footer.$phpEx");
}

function RankForumSave($rank_id, $rank_title, $rank_min, $rank_max, $rank_special) {
    global $mpnTables,$phpEx;
    mysql_query("update ".$mpnTables['ranks']." set rank_title='$rank_title',rank_min='$rank_min',rank_max='$rank_max',rank_special='$rank_special' where rank_id='$rank_id'");

    $_SERVER['F_LIB'] -> redirectRequest( 'admin.php?op=RankForumAdmin' );

}

function RankForumDel($rank_id, $ok=0) {
    global $mpnTables,$phpEx;
    if($ok==1) {
    mysql_query("delete from ".$mpnTables['ranks']." where rank_id=$rank_id");

    $_SERVER['F_LIB'] -> redirectRequest( 'admin.php?op=ForumAdmin' );

    } else {
    include("header.$phpEx");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><br>";
    echo "<font size=3 color=Red>";
    echo "<b>".translate("WARNING: Are you sure you want to delete this Ranking?")."</b><br><br><font color=Black>";
    }
    echo "[ <a href=admin.$phpEx?op=RankForumDel&rank_id=$rank_id&ok=1>".translate("Yes")."</a> | <a href=admin.$phpEx?op=RankForumAdmin>".translate("No")."</a> ]<br><br>";
    echo "</TD></TR></TABLE></TD></TR></TABLE>";
    include("footer.$phpEx");
}

?>
