<?php

/********************************************************/
/* NSN Theme for PHP-Nuke 6.5.0                         */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2002 by NukeScripts Network              */
/********************************************************/

if (eregi("theme.php", $_SERVER['PHP_SELF'])) { Header("Location: index.php"); die(); }
global $nv, $theme_width, $new_topic, $catid, $topic, $categories, $topics, $side, $pos, $storyhome, $loonr, $kokku, $NameOfTheme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2, $textcolor3, $textcolor4, $prefix, $db, $querylang;
if ($topics==1) {
    $kokku = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_stories WHERE topic='$topic' $querylang LIMIT $storyhome"));
} elseif($categories==1) {
    $kokku = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_stories WHERE catid='$catid' $querylang LIMIT $storyhome"));
} elseif($new_topic > 0) {
    $kokku = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_stories WHERE topic='$new_topic' $querylang LIMIT $storyhome"));
} else {
    $kokku = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_stories WHERE sid='*' $querylang LIMIT 0, $storyhome"));
}

$nv = 1; // 1 for graphical, 2 for textual
$theme_width = 1; // 1 for single column, 2 for dual column
$NameOfTheme = basename(dirname(__FILE__));
include("themes/$NameOfTheme/colors.php");
include("themes/$NameOfTheme/tables.php");
if ($kokku == "") { $kokku = $storyhome; }
if ($loonr == "") { $loonr = "0"; }
if (isset($newlang)) { $language = $newlang; } elseif (isset($lang)) { $language = $lang; } elseif (isset($currentlang)) { $language = $currentlang; }
if(file_exists("themes/$NameOfTheme/language/lang-$language.php")) { include("themes/$NameOfTheme/language/lang-$language.php"); } else { include("themes/$NameOfTheme/language/lang-french.php"); }


function themeheader() {
    global $nv, $user, $admin, $Version_Num, $banners, $sitename, $slogan, $cookie, $prefix, $user_prefix, $db, $NameOfTheme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2;
    cookiedecode($user);
    $username = $cookie[1];
    if ($username == "") {
        $username = "Anonymous";
    }
    echo "<body text=\"#000000\" link=\"#363636\" vlink=\"#363636\" alink=\"#d5ae83\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";
    if ($Version_Num >= "6.0") { $public_msg = public_message(); }
    if ($banners == 1) {
        $bresult = $db->sql_query("select * from ".$prefix."_banner WHERE type='0' AND active='1'");
        $numrows = $db->sql_numrows($bresult);
        if ($numrows>0) {
            if ($numrows==1) {
                list ($bannum) = $db->sql_fetchrow($bresult);
            } else if ($numrows>1) {
                $i = 1;
                while (list ($id) = $db->sql_fetchrow($bresult)) {
                    $abid[$i] = $id;
                    $i++;
                }
                $bannum = $abid[rand(1, $numrows)];
            }
        } else {
            $bannum = 0;
        }
        $bresult2 = $db->sql_query("select bid, imageurl, clickurl, alttext from ".$prefix."_banner WHERE bid='$bannum'");
        list($bid, $imageurl, $clickurl, $alttext) = $db->sql_fetchrow($bresult2);
        if (!is_admin($admin)) {
            $db->sql_query("update ".$prefix."_banner set impmade=impmade+1 where bid=$bid");
        }
        if($numrows>0) {
            $aborrar = $db->sql_query("select cid, imptotal, impmade, clicks, date from ".$prefix."_banner where bid=$bid");
            list($cid, $imptotal, $impmade, $clicks, $date) = $db->sql_fetchrow($aborrar);
            if (($imptotal <= $impmade) AND ($imptotal != 0)) {
                $db->sql_query("insert into ".$prefix."_bannerfinish values (NULL, '$cid', '$impmade', '$clicks', '$date', now())");
                $db->sql_query("delete from ".$prefix."_banner where bid=$bid");
            }
            $tbanners = "<a href=\"banners.php?op=click&amp;bid=$bid\" target=\"_blank\"><img src=\"$imageurl\" border=\"0\" alt=\"\"></a>";
        }
    }
    list($uid) = $db->sql_fetchrow($db->sql_query("select user_id from ".$user_prefix."_users where username='$username'"));
    $pnumrow = $db->sql_numrows($db->sql_query("select * from ".$prefix."_bbprivmsgs where privmsgs_to_userid='$uid'"));
    if ($username == "Anonymous") {
        $priv_msgs = "<font class=\"content\">"._TNOINFOFOR." $username</font>";
    } else {
        $priv_msgs = "<font class=\"content\">"._TYOUHAVE." <a href=\"modules.php?name=Private_Messages\">$pnumrow</a> "._TPRIVATEMSG."</font>";
    }
    $mnumrow = $db->sql_numrows($db->sql_query("select * from ".$user_prefix."_users"));
    $members = "<font class=\"content\">"._TREGUSERS." $mnumrow</font>";
    if ($username == "Anonymous") {
        $theuser = "<a href=\"modules.php?name=Your_Account&op=new_user\">"._TNEWUSER."</a> / <a href=\"modules.php?name=Your_Account\">"._TUSERLOGIN."</a>";
    } else {
        $theuser = ""._THELLO." $username: <a href=\"modules.php?name=Your_Account&op=logout\">"._TLOGOUT."</a>";
    }
    include("themes/$NameOfTheme/navbar.php");
    echo "<!-- START HEADER.HTML -->\n";
    echo "<center><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\"><tr bgcolor=\"#ffffff\"><td align=\"center\">\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor5\"><td width=\"10%\"><img src=\"themes/$NameOfTheme/images/logo.gif\" height=\"61\" width=\"468\" alt=\"\"._TWELCOMETO.\" $sitename\" border=\"0\"></td>\n";
    echo "<td align=\"right\" width=\"90%\">$tbanners</td></tr>\n";
    echo "</table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "$navbar[$nv]\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr valign=\"middle\" bgcolor=\"$bgcolor5\">\n";
    echo "<td width=\"20%\" nowrap><font class=\"content\" color=\"#363636\">&nbsp;&nbsp;$theuser</font></td>\n";
    echo "<td align=\"center\" height=\"20\" width=\"60%\"><font class=\"content\">$priv_msgs</font></td>\n";
    echo "<td align=\"right\" width=\"20%\"><font class=\"content\">$members&nbsp;&nbsp;</font></td>\n";
    echo "</tr>\n";
    echo "</table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"#ffffff\"><td height=\"20\" align=\"center\">";
    include("themes/$NameOfTheme/marquee.php");
    echo "</td></tr>\n";
    echo "</table>\n";
    echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\"><tr bgcolor=\"#ffffff\" valign=\"top\">\n";
    echo "<td bgcolor=\"#ffffff\" width=\"180\" valign=\"top\">\n";
    echo "<!-- END HEADER.HTML -->\n";
    blocks(left);
    echo "<!-- START CENTER_LEFT.HTML -->\n";
    echo "</td>\n";
    echo "<td><img src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\"></td>\n";
    echo "<td valign=\"top\" width=\"100%\">\n";
    echo "<!-- END CENTER_LEFT.HTML -->\n";
}


function themefooter() {
    global $nv, $copyright, $index, $foot1, $foot2, $foot3, $foot4, $NameOfTheme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2;
    echo "<!-- START CENTER_RIGHT.HTML -->\n";
    echo "</td>\n";
    echo "<td><img src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\"></td>\n";
    echo "<td valign=\"top\" width=\"180\">\n";
    echo "<!-- END CENTER_RIGHT.HTML -->\n";
//    if ($index == 1) {
        blocks(right);
//    }
    include("themes/$NameOfTheme/navbar.php");
    $footer_message = "$foot1<br>$foot2<br>$foot3<br>$foot4";
    echo "<!-- START FOOTER.HTML -->\n";
    echo "</td>\n";
    echo "</tr></table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr valign=\"middle\" bgcolor=\"$bgcolor5\"><td align=\"center\" height=\"20\" width=\"60%\"><font class=\"content\">$copyright</font></td></tr>\n";
    echo "</table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "$navbar[$nv]\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n";
    echo "<tr align=\"center\" bgcolor=\"$bgcolor5\"><td width=\"100%\">$footer_message</td></tr>\n";
    echo "</table>\n";
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n";
    echo "<tr bgcolor=\"$bgcolor6\"><td><IMG src=\"themes/$NameOfTheme/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td></tr>\n";
    echo "</table>\n";
    echo "</td></tr></table><br>$NameOfTheme "._TBY." <a href=\"http://www.nukescripts.net\" target=\"NSN\">NukeScripts Network</a></center>\n";
    echo "<!-- END FOOTER.HTML -->\n";
}


function themeindex ($aid, $informant, $time, $title, $counter, $topic, $thetext, $notes, $morelink, $topicname, $topicimage, $topictext) {
    global $theme_width, $cookie, $loonr, $vasak, $parem, $kokku, $admin, $sid, $anonymous, $tipath, $NameOfTheme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2;
    $loonr = ($loonr+1);
    if (isset($cookie[3])) {
        $storynum = $cookie[3];
    } else {
        $storynum = $storyhome;
    }
    $ridaaa1 = round($loonr/2);
    if ($notes != "") {
        $notes = "<br><br><b>"._TNOTE."</b> <i>$notes</i>\n";
    } else {
        $notes = "";
    }
    if ("$aid" == "$informant") {
        $content = "$thetext$notes\n";
    } else {
        if($informant != "") {
            $content = "<a href=\"modules.php?name=Your_Account&op=userinfo&amp;uname=$informant\">$informant</a> ";
        } else {
            $content = "$anonymous ";
        }
        $content .= ""._TWRITES." \"$thetext\"$notes\n";
    }
    $posted = ""._TPOSTEDBY." ";
    $posted .= get_author($aid);
    $posted .= " "._TON." $time $timezone ($counter "._TREADS.")";

    if ($theme_width > 1) {
        if (($ridaaa1*2) != $loonr) {
            $vasak .= "<!-- START STORY_HOME.HTML -->\n";
            $vasak .= "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"$bgcolor6\" width=\"100%\">\n";
            $vasak .= "<tr bgcolor=\"$bgcolor2\"><td align=\"left\"><font class=\"option\" color=\"#363636\"><b>$title</b></font></td></tr>\n";
            $vasak .= "<tr bgcolor=\"#ffffff\"><td align=\"left\"><font class=\"content\"><a href=\"search.php?query=&amp;topic=$topic\"><img src=\"$tipath$topicimage\" border=\"0\" Alt=\"$topictext\" align=\"right\" hspace=\"10\" vspace=\"10\"></a>$content</font></td></tr>\n";
            $vasak .= "<tr bgcolor=\"$bgcolor1\"><td align=\"right\"><font class=\"content\">$posted</font><br>\n";
            $vasak .= "<font class=\"content\">$morelink</font></td></tr>\n";
            $vasak .= "</table><br>\n";
            $vasak .= "<!-- END STORY_HOME.HTML -->\n";
        } else {
            $parem .= "<!-- START STORY_HOME.HTML -->\n";
            $parem .= "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"$bgcolor6\" width=\"100%\">\n";
            $parem .= "<tr bgcolor=\"$bgcolor2\"><td align=\"left\"><font class=\"option\" color=\"#363636\"><b>$title</b></font></td></tr>\n";
            $parem .= "<tr bgcolor=\"#ffffff\"><td align=\"left\"><font class=\"content\"><a href=\"search.php?query=&amp;topic=$topic\"><img src=\"$tipath$topicimage\" border=\"0\" Alt=\"$topictext\" align=\"right\" hspace=\"10\" vspace=\"10\"></a>$content</font></td></tr>\n";
            $parem .= "<tr bgcolor=\"$bgcolor1\"><td align=\"right\"><font class=\"content\">$posted</font><br>\n";
            $parem .= "<font class=\"content\">$morelink</font></td></tr>\n";
            $parem .= "</table><br>\n";
            $parem .= "<!-- END STORY_HOME.HTML -->\n";
        }
        if ($loonr == $storynum OR $loonr == $kokku) {
            echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
            echo "<td width=\"49%\" valign=\"top\">$vasak</td>";
            echo "<td width=\"2%\" valign=\"top\">&nbsp;</td>";
            echo "<td width=\"49%\" valign=\"top\">$parem</td>";
            echo "</tr></table>";
        }
    } else {
        echo "<!-- START STORY_HOME.HTML -->\n";
        echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"$bgcolor6\" width=\"100%\">\n";
        echo "<tr bgcolor=\"$bgcolor2\"><td align=\"left\"><font class=\"option\" color=\"#363636\"><b>$title</b></font></td></tr>\n";
        echo "<tr bgcolor=\"#ffffff\"><td align=\"left\"><font class=\"content\"><a href=\"search.php?query=&amp;topic=$topic\"><img src=\"$tipath$topicimage\" border=\"0\" Alt=\"$topictext\" align=\"right\" hspace=\"10\" vspace=\"10\"></a>$content</font></td></tr>\n";
        echo "<tr bgcolor=\"$bgcolor1\"><td align=\"right\"><font class=\"content\">$posted</font><br>\n";
        echo "<font class=\"content\">$morelink</font></td></tr>\n";
        echo "</table><br>\n";
        echo "<!-- END STORY_HOME.HTML -->\n";
    }
}


function themearticle ($aid, $informant, $datetime, $title, $thetext, $topic, $topicname, $topicimage, $topictext) {
    global $admin, $sid, $tipath, $NameOfTheme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2;
    $posted = ""._TPOSTEDBY." ";
    $posted .= get_author($aid);
    $posted .= " "._TON." $time $timezone ($counter "._TREADS.")";
    if (is_admin($admin)) {
        $posted .= " [ <a href=\"admin.php?op=EditStory&amp;sid=$sid\">"._TEDIT."</a> | <a href=\"admin.php?op=RemoveStory&amp;sid=$sid\">"._TDELETE."</a> ]\n";
    }
    if ($notes != "") {
        $notes = "<br><br><b>"._TNOTE."</b> <i>$notes</i>\n";
    } else {
        $notes = "";
    }
    if ("$aid" == "$informant") {
        $content = "$thetext$notes\n";
    } else {
        if($informant != "") {
            $content = "<a href=\"modules.php?name=Your_Account&op=userinfo&amp;uname=$informant\">$informant</a> ";
        } else {
            $content = "$anonymous ";
        }
        $content .= ""._TWRITES." \"$thetext\"$notes\n";
    }
    echo "<!-- START STORY_PAGE.HTML -->\n";
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"$bgcolor6\" width=\"100%\">\n";
    echo "<tr bgcolor=\"$bgcolor2\"><td align=\"left\"><font class=\"option\" color=\"#363636\"><b>$title</b></font><br>\n";
    echo "<font class=\"content\">$posted</font></td></tr>\n";
    echo "<tr bgcolor=\"#ffffff\"><td algin=\"left\"><font class=\"content\"><a href=\"search.php?query=&amp;topic=$topic\"><img src=\"$tipath$topicimage\" border=\"0\" Alt=\"$topictext\" align=\"right\" hspace=\"10\" vspace=\"10\"></a>$content</font></td></tr>\n";
    echo "</table><br>\n";
    echo "<!-- END STORY_PAGE.HTML -->\n";
}


function themesidebox($title, $content) {
    global $NameOfTheme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2;
    echo "<!-- START BLOCKS.HTML -->\n";
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"$bgcolor6\" width=\"180\">\n";
    echo "<tr bgcolor=\"$bgcolor5\"><td align=\"center\"><font class=\"content\" color=\"#363636\"><b>$title</b></font></td></tr>\n";
    echo "<tr valign=\"top\" bgcolor=\"#ffffff\"><td>$content</td></tr>\n";
    echo "</table><br>\n";
    echo "<!-- END BLOCKS.HTML -->\n";
}

?>