<?php
/************************************************************************/
/* PHP-NUKE: Xmas2 theme pack for nuke 6.5 & up                         */
/* ============================================                         */
/* Copyright (c) 2003 by Mtechnik                                       */
/* http://mtechnik.net                                                  */
/* Made for PHP-NUKE 6.5: Advanced Content Management System            */
/* ============================================                         */
/* Copyright (c) 2003 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/************************************************************************/
// Xmas2 Public Release theme pack
// Original Author of file: Mtechnik - http://mtechnik.net
// Purpose of file: Public Release phpnuke 6.5 and up Theme pack
// Copyright © 2003 by Mtechnik All Rights Reserved
// ----------------------------------------------------------------------
// THEME MODIFICATION 
// Users may alter or modify this theme at their own risk,
// but only for their own use. They may also hire Mtechnik to modify 
// their own copy of the theme.
//
// Although users may modify the code for their use,
// modified code may not be resold or distributed,
// without express written permission from Mtechnik.
//
// DISPLAY OF COPYRIGHT NOTICES REQUIRED
// All copyright notices used within the scripts that the scripts generate,
// MUST remain intact. Furthermore, these notices must remain visible.
//
// SUPPORT
// Mtechnik provide free support, BUT not mod on the theme,
// (includes consulting, troubleshooting and fixing problems).
//
// Mtechnik is not liable for any products or services offered by 
// means of the theme.
// The user must assume the entire risk of using the program.
//
// Mtechnik
// For commercial themes, exclusive themes, visit my theme shop www.the1theme.com
// For more free themes, visit my community at mtechnik.net
// www.mtechnik.net
// mtechnik@mtechnik.net
// ----------------------------------------------------------------------
/************************************************************/
/* Theme Colors Definition                                  */
/************************************************************/

$bgcolor1 = "#3C0505";
$bgcolor2 = "#3C0505";
$bgcolor3 = "#620909";
$bgcolor4 = "#3C0505";
$textcolor1 = "#ffffff";
$textcolor2 = "#ffffff";

/************************************************************/
/* OpenTable Functions                                      */
/************************************************************/

function OpenTable() {
    global $bgcolor1, $bgcolor2;
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
   <td><img name="tlc" src="themes/Xmas2/images/tlc.gif" width="15" height="15" border="0" alt=""></td> 
   <td width="100%" background="themes/Xmas2/images/tm.gif"><img name="tm" src="themes/Xmas2/images/spacer.gif" width="1" height="1" border="0" alt=""></td>
   <td><img name="trc" src="themes/Xmas2/images/trc.gif" width="15" height="15" border="0" alt=""></td>
  </tr>
  <tr>
    <td background="themes/Xmas2/images/tleft.gif"><img name="tleft" src="themes/Xmas2/images/spacer.gif" width="1" height="1" border="0" alt=""></td>
        <td valign="top" bgcolor="#3C0505">
<?
}



function OpenTable2() {
    global $bgcolor1, $bgcolor2;
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" ><tr><td class=extra>\n";
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"8\" ><tr><td>\n";
}

function CloseTable() {
?>
    </td>
    <td background="themes/Xmas2/images/tright.gif"><img name="tright" src="themes/Xmas2/images/spacer.gif" width="1" height="1" border="0" alt=""></td>
  </tr>
  <tr>
   <td><img name="blc" src="themes/Xmas2/images/blc.gif" width="15" height="15" border="0" alt=""></td>
    <td background="themes/Xmas2/images/btm.gif"><img name="btm" src="themes/Xmas2/images/spacer.gif" width="1" height="1" border="0" alt=""></td>
   <td><img name="brc" src="themes/Xmas2/images/brc.gif" width="15" height="15" border="0" alt=""></td>
  </tr></table>
<?
}

function CloseTable2() {
    echo "</td></tr></table></td></tr></table>\n";
}

/************************************************************/
/* FormatStory                                              */
/************************************************************/

function FormatStory($thetext, $notes, $aid, $informant) {
    global $anonymous;
    if ($notes != "") {
        $notes = "<br><br><b>"._NOTE."</b> <i>$notes</i>\n";
    } else {
        $notes = "";
    }
    if ("$aid" == "$informant") {
        echo "<font class=\"content\" color=\"#505050\">$thetext$notes</font>\n";
    } else {
        if($informant != "") {
            $boxstuff = "<a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$informant\">$informant</a> ";
        } else {
            $boxstuff = "$anonymous ";
        }
        $boxstuff .= ""._WRITES." <i>\"$thetext\"</i>$notes\n";
        echo "<font class=\"content\" color=\"#505050\">$boxstuff</font>\n";
    }
}

/************************************************************/
/* Function themeheader()                                   */
/************************************************************/
    function themeheader() {
    global $user, $cookie, $prefix, $sitekey, $flash, $searchbox, $db, $dbi;
    
    cookiedecode($user);
    mt_srand ((double)microtime()*1000000);
    $maxran = 1000000;
    $random_num = mt_rand(0, $maxran);
    $datekey = date("F j");
    $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $random_num . $datekey));
    $code = substr($rcode, 2, 6);
    $username = $cookie[1];
    if ($username == "") {
        $username = "Anonymous";
    }
    $public_msg = public_message(); 
    echo "$public_msg";
    
    if ($username == "Anonymous") {
        $theuser = "<form action=\"modules.php?name=Your_Account\" method=\"post\"><input class=user type=\"text\" name=\"username\" value=\"username\" onFocus=\"if(this.value=='username')this.value='';\" value style=\"width:100;height:18;\">&nbsp;&nbsp;&nbsp;<input type=\"password\" class=user name=\"user_password\" value=\"password\" onFocus=\"if(this.value=='password')this.value='';\" value style=\"width:100;height:18;\">&nbsp;&nbsp;<input type=\"hidden\" name=\"random_num\" value=\"$random_num\"><input type=\"hidden\" name=\"gfx_check\" value=\"$code\"><input type=\"hidden\" name=\"op\" value=\"login\"><input type=\"image\" value=\"login\" class=noborder src=\"themes/Xmas2/images/login.gif\" border=\"0\"></TD></form>\n";
        
    
    } else {
        $theuser = "&nbsp;</TD>\n";
    }
    
$sql = "SELECT msg1, link1, link2, link3, link4, link5, link1url, link2url, link3url, link4url, link5url, searchbox, flash FROM ".$prefix."_themecp";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$msg1 = $row[msg1];
$link1 = $row[link1];
$link2 = $row[link2];
$link3 = $row[link3];
$link4 = $row[link4];
$link5 = $row[link5];
$link1url = $row[link1url];
$link2url = $row[link2url];
$link3url = $row[link3url];
$link4url = $row[link4url];
$link5url = $row[link5url];
$searchbox = $row[searchbox];
$flash = $row[flash];

if ($flash == 1) {
    $flash = "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" WIDTH=\"481\" HEIGHT=\"161\" id=\"logo\" ALIGN=\"\"><PARAM NAME=movie VALUE=\"themes/Xmas2/images/logo.swf\"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=best> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#AEBFCC> <EMBED src=\"themes/Xmas2/images/logo.swf\" menu=false quality=best wmode=transparent bgcolor=#AEBFCC  WIDTH=\"481\" HEIGHT=\"161\" NAME=\"logo\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>";
	} else {
	$flash = "<img src=\"themes/Xmas2/images/Xmas2-hd1_logo.jpg\" width=481 height=161>";
	}
if ($searchbox == 1) {
    $searchbox = "<form action=\"modules.php?op=modload&name=Search&file=index\" method=\"post\"><input type=\"text\" name=\"query\" value=\"type search here\" onFocus=\"if(this.value=='type search here')this.value='';\" value style=\"width:150;height:19;\"></TD><TD align=center background=\"themes/Xmas2/images/Xmas2-hd1_s2.jpg\" WIDTH=49 HEIGHT=21><input type=\"image\" value=\"search\" src=\"themes/Xmas2/images/search.gif\" class=noborder border=\"0\" alt=\"submit search\"></TD></form>\n";
	} else {
	$searchbox = "&nbsp;</TD><TD><img src=\"themes/Xmas2/images/Xmas2-hd1_s2.jpg\" WIDTH=49 HEIGHT=21></TD>\n";
	}	
   echo "<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" ONLOAD=\"populate();\">";
    include("themes/Xmas2/header.php");
    

//LEFT SIDE BACKGROUND
    echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n"
		."<tr valign=\"top\">\n"
        ."<td width=\"20\" valign=\"top\" background=\"themes/Xmas2/images/lt.gif\"><img name=\"lt\" src=\"themes/Xmas2/images/spacer.gif\" width=\"20\" height=\"19\" border=\"0\" alt=\"\"></td>\n"
		."<td width=\"165\" bgcolor=\"#620909\" valign=\"top\">\n";
    blocks(left);
    echo "</td>\n"
    	."<td width=\"5\" valign=\"top\" background=\"themes/Xmas2/images/spacer.gif\"><img src=\"themes/Xmas2/images/spacer.gif\" width=\"5\" height=\"1\" border=\"0\"></td>\n"
    	."<td width=\"100%\">\n";
}


/************************************************************/
/* Function themefooter()                                   */
/************************************************************/

function themefooter() {
    global $index, $user, $banners, $cookie, $prefix, $dbi, $db, $admin,  $adminmail, $nukeurl;

if ($banners == 1) {
    $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_banner WHERE type='0' AND active='1'"));
   /* Get a random banner if exist any. */ 
   /* More efficient random stuff, thanks to Cristian Arroyo from http://www.planetalinux.com.ar */ 

    if ($numrows>1) { 
   $numrows = $numrows-1; 
   mt_srand((double)microtime()*1000000); 
   $bannum = mt_rand(0, $numrows); 
    } else { 
   $bannum = 0; 
    } 
    $sql = "SELECT bid, imageurl, clickurl, alttext FROM ".$prefix."_banner WHERE type='0' AND active='1' LIMIT $bannum,1"; 
    $result = $db->sql_query($sql); 
    $row = $db->sql_fetchrow($result); 
    $bid = $row[bid]; 
    $imageurl = $row[imageurl]; 
    $clickurl = $row[clickurl]; 
    $alttext = $row[alttext]; 
    
    if (!is_admin($admin)) { 
       $db->sql_query("UPDATE ".$prefix."_banner SET impmade=impmade+1 WHERE bid='$bid'"); 
    } 
    if($numrows>0) { 
   $sql2 = "SELECT cid, imptotal, impmade, clicks, date FROM ".$prefix."_banner WHERE bid='$bid'"; 
   $result2 = $db->sql_query($sql2); 
   $row2 = $db->sql_fetchrow($result2); 
   $cid = $row2[cid]; 
   $imptotal = $row2[imptotal]; 
   $impmade = $row2[impmade]; 
   $clicks = $row2[clicks]; 
   $date = $row2[date]; 

/* Check if this impression is the last one and print the banner */ 

   if (($imptotal <= $impmade) AND ($imptotal != 0)) { 
       $db->sql_query("UPDATE ".$prefix."_banner SET active='0' WHERE bid='$bid'"); 
       $sql3 = "SELECT name, contact, email FROM ".$prefix."_bannerclient WHERE cid='$cid'"; 
       $result3 = $db->sql_query($sql3); 
       $row3 = $db->sql_fetchrow($result3); 
       $c_name = $row3[name]; 
       $c_contact = $row3[contact]; 
       $c_email = $row3[email]; 
       if ($c_email != "") { 
      $from = "$sitename <$adminmail>"; 
      $to = "$c_contact <$c_email>"; 
      $message = ""._HELLO." $c_contact:\n\n"; 
      $message .= ""._THISISAUTOMATED."\n\n"; 
      $message .= ""._THERESULTS."\n\n"; 
      $message .= ""._TOTALIMPRESSIONS." $imptotal\n"; 
      $message .= ""._CLICKSRECEIVED." $clicks\n"; 
      $message .= ""._IMAGEURL." $imageurl\n"; 
      $message .= ""._CLICKURL." $clickurl\n"; 
      $message .= ""._ALTERNATETEXT." $alttext\n\n"; 
      $message .= ""._HOPEYOULIKED."\n\n"; 
      $message .= ""._THANKSUPPORT."\n\n"; 
      $message .= "- $sitename "._TEAM."\n"; 
      $message .= "$nukeurl"; 
      $subject = "$sitename: "._BANNERSFINNISHED.""; 
      mail($to, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion()); 
       } 
   } 
    $showbanners = "<a href=\"banners.php?op=click&bid=$bid\" target=\"_blank\"><img src=\"$imageurl\" border=\"0\" alt='$alttext' title='$alttext'></a>"; 
    }
}
 



    
    
    if ($index == 1) {
	echo "</td>\n"
	    ."<td width=\"5\" valign=\"top\" background=\"themes/Xmas2/images/spacer.gif\"><img src=\"themes/Xmas2/images/spacer.gif\" width=\"5\" height=\"1\" border=\"0\"></td>\n"
	    ."<td width=\"165\" valign=\"top\">\n";
	blocks(right);
    }
    echo "</td>\n"
        ."<td width=\"20\" valign=\"top\" background=\"themes/Xmas2/images/rt.gif\"><img src=\"themes/Xmas2/images/rt.gif\" width=\"20\" height=\"19\" border=\"0\"></td>\n"
	    ."</tr>\n"
	    ."</table>\n\n\n";
    
    
    include("themes/Xmas2/footer.php");
    
}

/************************************************************/
/* Function themeindex()                                    */
/* This function format the stories on the Homepage         */
/************************************************************/
function themeindex ($aid, $informant, $time, $title, $counter, $topic, $thetext, $notes, $morelink, $topicname, $topicimage, $topictext) {
    global $anonymous, $tipath;

$ThemeSel = get_theme();
    if (file_exists("themes/$ThemeSel/images/topics/$topicimage")) {
	$t_image = "themes/$ThemeSel/images/topics/$topicimage";
    } else {
	$t_image = "$tipath$topicimage";
}
    if ($notes != "") {
        $notes = "<br><br><b>"._NOTE."</b> $notes\n";
    } else {
        $notes = "";
    }
    if ("$aid" == "$informant") {
        $content = "$thetext$notes\n";
    } else {
        if($informant != "") {
            $content = "<a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$informant\">$informant</a> ";
        } else {
            $content = "$anonymous ";
        }
        $content .= ""._WRITES." \"$thetext\"$notes\n";
    }
    //Code Changed - just show posted by
    $posted = ""._POSTEDBY." ";
    $posted .= get_author($aid);
    $posted .= " "._ON." $time  ";
    //End Code Change
    $datetime = substr($morelink, 0, strpos($morelink, "|") - strlen($morelink));
    $morelink = substr($morelink, strlen($datetime) + 2);
    $tmpl_file = "themes/Xmas2/story_home.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\$r_file=\"".$thefile."\";";
    eval($thefile);
    print $r_file;
}

/************************************************************/
/* Function themeindex()                                    */
/************************************************************/

function themearticle ($aid, $informant, $datetime, $title, $thetext, $topic, $topicname, $topicimage, $topictext) {
    global $admin, $sid, $tipath;
$ThemeSel = get_theme();
    if (file_exists("themes/$ThemeSel/images/topics/$topicimage")) {
	$t_image = "themes/$ThemeSel/images/topics/$topicimage";
    } else {
	$t_image = "$tipath$topicimage";
}
    $posted = ""._POSTEDON." $datetime "._BY." ";
    $posted .= get_author($aid);
    if ($notes != "") {
        $notes = "<br><br><b>"._NOTE."</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&amp;op=userinfo&amp;username=$informant\">$informant</a> ";
        } else {
            $content = "$anonymous ";
        }
        $content .= ""._WRITES." <i>\"$thetext\"</i>$notes\n";
    }
    $tmpl_file = "themes/Xmas2/story_page.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\$r_file=\"".$thefile."\";";
    eval($thefile);
    print $r_file;
}

/************************************************************/
/* Function themesidebox()                                  */
/************************************************************/

function themesidebox($title, $content) {
    $tmpl_file = "themes/Xmas2/blocks.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\$r_file=\"".$thefile."\";";
    eval($thefile);
    print $r_file;
}

?>