<?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: smilies.php,v 1.4.2.5 2004/08/15 12:58:04 kirilt Exp $




######################################################################
# PHP-NUKE: Web Portal System
# ===========================
#
# Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
# http://phpnuke.org
#
# This modules is the main administration part
#
# 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.
######################################################################
# PHP-NUKE Add-On 2.0 :
# =====================
#
#              PHPBB Integration 1.0.BETA
#   Brought to you by PHPNuke Add-On Team
#
# Copyright (c) 2000 by Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)
#                       Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)
# http://www.phpnuke.web.id
#
#
############################################################################################################################################
# PHPBB 1.0.BETA
# ==============
#
# Copyright (C) 2000 by James Atkinson (james@totalgeek.org)
# http://www.phpbb.com
#
######################################################################

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

$url_smiles = "images/forum/smilies";

function SmilesAdmin() {
    global $hlpfile, $admin,$phpEx;
    global $url_smiles, $mpnTables;
    global $bgcolor1, $bgcolor2, $bgcolor, $textcolor1, $textcolor2;

    include ("header.$phpEx");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font size=4><b>".translate("Smiles Configuration")."</b></center>";
    echo "<br><br>";
    echo "<font size=2>";

    if ($getsmiles = mysql_query("SELECT * FROM ".$mpnTables['smiles'])) {
        if (($numsmiles = mysql_num_rows($getsmiles)) == "0") {
            // echo "<font size=2>No smiles currently. <a href='$PHP_SELF?mode=add'>Click here</a> to add some.</font>";
        } else {

            echo "<table border=1 cellspacing=0 cellpadding=3 bordercolor=000000 bordercolordark=000000 bordercolorlight=000000>";
            echo "<tr>";
            echo "<td bgcolor=\"$bgcolor1\"><font size=\"2\">" .translate("Code")."</font></td>";
            echo "<td bgcolor='$bgcolor2'><font size=2>" .translate("Smile")."</font></td>";
            echo "<td bgcolor='$bgcolor1'>&nbsp;</td>";
            echo "<td bgcolor='$bgcolor2'>&nbsp;</td>";
            echo "</tr>";

            while ($smiles = mysql_fetch_array($getsmiles)) {

                echo "<tr>";
                echo "<td bgcolor='$bgcolor1'><font size=\"2\">$smiles[code]</font></td>";
                echo "<td bgcolor='$bgcolor2'><img src=\"$url_smiles/$smiles[smile_url]\"></td>";
                echo "<td bgcolor='$bgcolor1'><a href=\"admin.$phpEx?op=SmilesEdit&id=$smiles[id]\">" .translate("Edit")."</a></td>";
                echo "<td bgcolor='$bgcolor2'><a href=\"admin.$phpEx?op=SmilesDel&id=$smiles[id]\">" .translate("Delete")."</a></td>";
                echo "</tr>";

            }
            echo "</table>";
        }
    } else {
        echo translate("Could not retrieve from the smile database.");
    }

    echo "<form action=admin.$phpEx method=post>";

    echo "" .translate("Smile Code:")." <input type=\"text\" name=\"code\"><br>";
    echo "" .translate("Smile URL:")." <input type=\"text\" name=\"smile_url\"><br>";
    echo "" .translate("Smile Emotion:")." <input type=\"text\" name=\"emotion\"><br>";

    echo "<input type=hidden name=op value=SmilesAdd>";
    echo "<input class='button' type=submit value=" . translate("Add") . ">";
    echo "</form>";

    echo "</td></tr></table></td></tr></table>";

    include("footer.$phpEx");
}

function SmilesEdit($id) {
    global $hlpfile, $admin,$phpEx;
    global $url_smiles, $mpnTables;
    global $bgcolor1, $bgcolor2, $bgcolor, $textcolor1, $textcolor2;

    include ("header.$phpEx");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font size=4><b>".translate("Smiles Configuration")."</b></center>";
    echo "<br><br>";
    echo "<font size=2>";

    if ($getsmiles = mysql_query("SELECT * FROM ".$mpnTables['smiles']." WHERE id = '$id'")) {
        if (($numsmiles = mysql_num_rows($getsmiles)) == "0") {
            // echo "<font size=2>No smiles currently. <a href='$PHP_SELF?mode=add'>Click here</a> to add some.</font>";
        } else {

            if ($smiles = mysql_fetch_array($getsmiles)) {

                echo "<form action=admin.$phpEx method=post>";

                echo "" .translate("Smile Code:")." <input type=\"text\" name=\"code\" value=\"$smiles[code]\"><br>";
                echo "" .translate("Smile URL:")." <input type=\"text\" name=\"smile_url\" value=\"$smiles[smile_url]\"><br>";
                echo "" .translate("Smile Emotion:")." <input type=\"text\" name=\"emotion\" value=\"$smiles[emotion]\"><br>";

                echo "<input type=hidden name=id value=\"$smiles[id]\">";
                echo "<input type=hidden name=op value=SmilesSave>";
                echo "<input class='button' type=submit value=" . translate("Save") . ">";
                echo "</form>";
            }

        }
    } else {
        echo translate("Could not retrieve from the smile database.");
    }

    echo "</td></tr></table></td></tr></table>";

    include("footer.$phpEx");
}

function SmilesAdd($code,$smile_url,$emotion) {
    global $mpnTables,$phpEx;
    $code = addslashes($code);
    $smile_url = addslashes($smile_url);
    $emotion = addslashes($emotion);

    mysql_query("INSERT INTO ".$mpnTables['smiles']." (id, code, smile_url, emotion) VALUES ('', '$code','$smile_url','$emotion')");

    if (mysql_errno() > 0) { echo mysql_errno() . " --- " . mysql_error() . "<br>"; }

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

}

function SmilesSave($id,$code,$smile_url,$emotion) {
    global $mpnTables,$phpEx;
    $code = addslashes($code);
    $smile_url = addslashes($smile_url);
    $emotion = addslashes($emotion);

    mysql_query("UPDATE ".$mpnTables['smiles']." SET code = '$code', smile_url = '$smile_url', emotion = '$emotion' WHERE id = $id");

    if (mysql_errno() > 0) { echo mysql_errno() . " --- " . mysql_error() . "<br>"; }

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

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

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

    } 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 Smile?")."</b><br><br><font color=Black>";
    }
    echo "[ <a href=admin.$phpEx?op=SmilesDel&id=$id&ok=1>".translate("Yes")."</a> | <a href=admin.$phpEx?op=SmileAdmin>".translate("No")."</a> ]<br><br>";
    echo "</TD></TR></TABLE></TD></TR></TABLE>";
    include("footer.$phpEx");
}


function ForumConfigChange($allow_html,$allow_bbcode,$allow_sig,$posts_per_page,$hot_threshold,$topics_per_page) {
    global $mpnTables,$phpEx;
    mysql_query("update ".$mpnTables['forumconfig']." set allow_html='$allow_html', allow_bbcode='$allow_bbcode', allow_sig='$allow_sig', posts_per_page='$posts_per_page', hot_threshold='$hot_threshold', topics_per_page='$topics_per_page'");
    $_SERVER['F_LIB'] -> redirectRequest( 'admin.php?op=ForumConfigAdmin' );

}

?>
