<?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: partners.php,v 1.4.2.7 2004/08/15 12:58:21 kirilt Exp $




######################################################################
# Partner-Addon for PHP-NUKE Version 1.0 Beta
# ===========================
#
# Copyright (c) 2001 by Dietrich Bojko (webmaster@jimmy-net.de)
# http://www.jimmy-net.de
#
# 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.
######################################################################


function PartnerAdmin() {
    global $admin, $bgcolor1, $bgcolor2, $mpnTables,$phpEx;


    OpenTable();
    echo "<center><font size=3><b>".translate("Partner Admin")."</b></center>";
    echo "<br><br>";

    echo "<table width=95% border=0 align=center><tr>
        <td bgcolor=\"$bgcolor1\"><font size=2><b>" .translate("ID")."</b></td>
        <td bgcolor=\"$bgcolor1\"><font size=2><b>" .translate("Hits")."</b></td>
        <td bgcolor=\"$bgcolor1\"><font size=2><b>" .translate("URL")."</b></td>
        <td bgcolor=\"$bgcolor1\"><font size=2><b>" .translate("Image")."</b></td>
        <td bgcolor=\"$bgcolor1\"><font size=2><b>" .translate("Description")."</b></td>
        <td bgcolor=\"$bgcolor1\"><font size=2><b></b></td><tr>";
        $result = mysql_query("SELECT num, hits, url, image, text FROM ".$mpnTables['click']." order by num");

        while(list($num, $hits, $url, $image, $text) = mysql_fetch_row($result))
        {
            if ( 0 === strpos( $image, '/' )  && is_file( $image ) )
            {
                $image = substr( $image, 1 );
            }

            echo "
            <td bgcolor=\"$bgcolor2\"><font size=1>$num</td>
            <td bgcolor=\"$bgcolor2\"><font size=1>$hits</td>
            <td bgcolor=\"$bgcolor2\"><font size=1>$url</td>
            <td bgcolor=\"$bgcolor2\">\n";

            if ( ! is_file( __ROOT__ . $image ) )
            {
                echo '<span class="look" title="' . $image . '">';
                echo translate( 'Image Not At Specified Location' );
                echo '</span>';
            }
            else
            {
                $image = _MPN_ROOT_URI . $image;
                echo "<img src=\"" . $image . "\" alt=\"" . $image . "\" /></td>\n";
            }

            echo "<td bgcolor=\"$bgcolor2\"><font size=1>$text</td>
            <td bgcolor=\"$bgcolor2\"><font size=1>
            <a href=admin.$phpEx?fct=partners&op=PartnerEdit&num=$num class=linkstyle>".translate("Edit")."</a>|<a href=admin.$phpEx?fct=partners&op=PartnerDel&num=$num&ok=0 class=linkstyle>".translate("Delete")."</a></td><tr>
            ";
        }
        echo "</td></tr></table></td></tr></table></td></tr></table><br>";

    OpenTable();
    echo "<b>".translate("Add a New Partner")."</b></center><br><br>
        <font size=2>
        <form action=admin.$phpEx?op=PartnerAdd method=post>";
        echo "".translate("Image URL: ")."<input class=textbox type=text name=image size=50 maxlength=100><br>
        ".translate("Click URL: ")."<input class=textbox type=text name=url size=50 maxlength=200><br>
        ".translate("Description: ")."<br><textarea class=textbox name=text cols=60 rows=10></textarea><br>
        <input type=hidden name=op value=PartnerAdd>
        <input type=hidden name=fct value=partners>
        <input class='button' type=submit value=\"".translate("Add Partner")."\">";

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

}

function PartnerEdit($num) {
        global $mpnTables,$phpEx;
        OpenTable();

        $result=mysql_query("SELECT num, hits, url, image, text FROM ".$mpnTables['click']." where num='$num'");
        list($num, $hits, $url, $image, $text) = mysql_fetch_row($result);

        echo "<font size=3>
        <center><b>".translate("Edit Partner")."</b><br><br>
        <img src=$image border=0><br><br>
        <font size=2></center>
        <form action=admin.$phpEx method=post>";

        echo translate("Hits: ")."<input class=textbox type=text name=hits size=3 maxlength=10 value=$hits><br>
        " .translate("URL:")." &nbsp;&nbsp;&nbsp;<input class=textbox type=text name=url size=50 maxlength=100 value=$url><br>
        " .translate("Image:")." <input class=textbox type=text name=image size=50 maxlength=100 value=$image><br>
        ".translate("Description: ")."<br><textarea class=textbox name=text cols=60 rows=10>$text</textarea><br>
        <input type=hidden name=num value=$num>
        <input type=hidden name=op value=PartnerChange>
        <input type=hidden name=fct value=partners>
        <input class='button' type=submit value=\"".translate("Edit Partner")."\">
        </form></td></tr></table></td></tr></table>
        ";
}

function PartnerChange($num, $hits, $url, $image, $text) {
    global $mpnTables,$phpEx;
        mysql_query("update ".$mpnTables['click']." set num='$num', hits='$hits', url='$url', image='$image', text='$text' where num='$num'");

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


function PartnerAdd($num, $hits, $url, $image, $text) {
    global $mpnTables,$phpEx;
    mysql_query("INSERT INTO ".$mpnTables['click']." (num, hits, url, image, text) VALUES ('', '0','$url','$image','$text')");
    if (mysql_errno() > 0) { echo mysql_errno() . " --- " . mysql_error() . "<br>"; }

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


function PartnerDel($num, $ok=0) {
    global $mpnTables,$phpEx;
    if($ok==1) {
        mysql_query("DELETE FROM ".$mpnTables['click']." WHERE num='$num'");

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

    } else {
        OpenTable();
        echo "<center><br>";
        echo "<font size=2 color=Red>";
        echo "<b>".translate("WARNING: Are you sure you want to delete this Partner?")."</b><br><br></font>";
        echo "[ <a href=admin.$phpEx?fct=partners&op=PartnerDel&num=$num&ok=1>".translate("Yes")."</a> | <a href=admin.$phpEx?fct=partners>".translate("No")."</a> ]<br><br>";
        echo "</TD></TR></TABLE></TD></TR></TABLE>";
    }
}

?>
