<?php
/*
 ########################################################################
#                                                                        #
#           Version 4       /                        /   /               #
#          -----------__---/__---__------__----__---/---/-               #
#           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
#          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
#                       Free Content / Management System                 #
#                                   /                                    #
#                                                                        #
#                                                                        #
#   Copyright 2005-2006 by webspell.org                                  #
#                                                                        #
#   visit webSPELL.org, webspell.info to get webSPELL for free           #
#   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
#   - It's NOT allowed to remove this copyright-tag                      #
#   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
#                                                                        #
#   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
#   Far Development by Development Team - webspell.org                   #
#                                                                        #
#   visit webspell.org                                                   #
#                                                                        #
 ########################################################################
*/

define(DEBUG, "OFF");
error_reporting(0); //0 = public mode, E_ALL = development-mode

// Verbindung mit mysql

mysql_connect($host, $user, $pwd) or system_error('ERROR: Can not connect to MySQL-Server');
mysql_select_db($db) or system_error('ERROR: Can not connect to database "'.$db.'"');

function safe_query($query="") {
    if(stristr($query, "union")===FALSE){
	if(empty($query)) return false;
	if(DEBUG == "OFF") $result = mysql_query($query) or die('Query failed!');
	else {
		$result = mysql_query($query) or die('Query failed: '
												.'<li>errorno='.mysql_errno()
												.'<li>error='.mysql_error()
												.'<li>query='.$query);
	}
	return $result;
    }
    else {
    die();
    }
}

function system_error($text,$system=1) {

	if($system) {
		include('version.php');
		$info='webSPELL version: '.$version.'<br>PHP version: '.phpversion().'<br>MySQL version: '.mysql_get_server_info().'<br>';
	}
	die('<html><body><center><br><table border="0" cellpadding="1" cellspacing="1" bgcolor="#eeeeee"><tr><td><img src="images/banner.gif"></td></tr><tr bgcolor="#ffffff"><td><div style="color:#333333;font-family: Tahoma, Verdana, Arial; font-size: 8pt;">'.$info.'<br><font color="red">'.$text.'</font><br>&nbsp;</div></td></tr><tr bgcolor="#ffffff"><td><div style="color:#333333;font-family: Tahoma, Verdana, Arial; font-size: 8pt;">For support visit <a href="http://webspell.org" target="_blank">webspell.org</a></div></td></tr></center></body></html>');
}

function systeminc($file) {

	if(!include('src/'.$file.'.php')) system_error('Could not get system file for '.$file);
}

function isignored($userID, $buddy) {

    $anz=mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."buddys WHERE buddy='$buddy' AND userID='$userID' "));
	if($anz) {
	    $ergebnis=safe_query("SELECT * FROM ".PREFIX."buddys WHERE buddy='$buddy' AND userID='$userID' ");
		$ds=mysql_fetch_array($ergebnis);
		if($ds[banned]==1) return 1;
		else return 0;
	}
	else return 0;
}

// settings:
$ergebnis=safe_query("SELECT * FROM ".PREFIX."settings");
$ds=mysql_fetch_array($ergebnis);

$maxshownnews=$ds[news]; if(!$maxshownnews) $maxshownnews=10;
$maxnewsarchiv=$ds[newsarchiv]; if(!$maxnewsarchiv) $maxnewsarchiv=20;
$maxheadlines=$ds[headlines]; if(!$maxheadlines) $maxheadlines=10;
$maxheadlinechars=$ds[headlineschars]; if(!$maxheadlinechars) $maxheadlinechars=22;
$maxarticles=$ds[articles]; if(!$maxarticles) $maxarticles=20;
$latestarticles=$ds[latestarticles]; if(!$latestarticles) $latestarticles=5;
$articleschars=$ds[articleschars]; if(!$articleschars) $articleschars=20;
$maxclanwars=$ds[clanwars]; if(!$maxclanwars) $maxclanwars=20;
$maxresults=$ds[results]; if(!$maxresults) $maxresults=5;
$maxupcoming=$ds[upcoming]; if(!$maxupcoming) $maxupcoming=5;
$maxguestbook=$ds[guestbook]; if(!$maxguestbook) $maxguestbook=20;
$maxshoutbox=$ds[shoutbox]; if(!$maxshoutbox) $maxshoutbox=5;
$maxsball=$ds[sball]; if(!$latestarticles) $latestarticles=5;
$sbrefresh=$ds[sbrefresh]; if(!$sbresfresh) $sbrefresh=60;
$maxtopics=$ds[topics]; if(!$maxtopics) $maxtopics=20;
$maxposts=$ds[posts]; if(!$maxposts) $maxposts=10;
$maxlatesttopics=$ds[latesttopics]; if(!$maxlatesttopics) $maxlatesttopics=10;
$hideinternboards=$ds[hideboards];
$maxfeedback=$ds[feedback]; if(!$maxfeedback) $maxfeedback=5;
$maxmessages=$ds[messages]; if(!$maxmessages) $maxmessages=5;
$maxusers=$ds[users]; if(!$maxusers) $maxusers=5;
$hp_url=$ds[hpurl];
$admin_name=$ds[adminname];
$admin_email=$ds[adminemail];
$myclantag=$ds[clantag];
$myclanname=$ds[clanname];
$maxarticles=$ds[articles]; if(!$maxarticles) $maxarticles=5;
$maxawards=$ds[awards]; if(!$maxawards) $maxawards=20;
$maxdemos=$ds[demos]; if(!$maxdemos) $maxdemos=20;
$profilelast=$ds[profilelast]; if(!$profilelast) $profilelast=20;
$topnewsID=$ds[topnewsID];
$sessionduration=$ds[sessionduration]; if(!$sessionduration) $sessionduration=24;
$closed=$ds[closed];
$gb_info=$ds[gb_info];
$imprint_type=$ds[imprint];
$picsize_l=$ds[picsize_l];
$picsize_h=$ds[picsize_h];
$gallerypictures=$ds[pictures];
$publicadmin=$ds[publicadmin];
$thumbwidth=$ds[thumbwidth];  if(!$thumbwidth) $thumbwidth=120;
$usergalleries=$ds[usergalleries];
$maxusergalleries=$ds[maxusergalleries];

// styles
$ergebnis=safe_query("SELECT * FROM ".PREFIX."styles");
$ds=mysql_fetch_array($ergebnis);

define(PAGETITLE, $ds[title]);
define(PAGEBG, $ds[bgpage]);
define(BORDER, $ds[border]);
define(BGHEAD, $ds[bghead]);
define(BGCAT, $ds[bgcat]);
define(BG_1, $ds[bg1]);
define(BG_2, $ds[bg2]);
define(BG_3, $ds[bg3]);
define(BG_4, $ds[bg4]);

$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;

$wincolor = $ds[win];
$loosecolor = $ds[loose];
$drawcolor = $ds[draw];
?>