#####################################
##
## CONTROL SERVER VARIABLES
#####################################
/*
## korte versie, uitgebreidere volgt
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}*/
function stripslashes_array($data)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = stripslashes_array($value);
}
return $data;
} else {
return stripslashes($data);
}
}
#####################################
##
## CONSTANTS
#####################################
define(DOCUMENT_ROOT, $_SERVER['DOCUMENT_ROOT']);
define(PHP_SELF, $_SERVER['PHP_SELF']);
define(SITE, "http://www.nex.be");
define(TOP, "
top");
define(TPL, "includes/tpl/");
$ADMIN_IPS = array("10.33.183.44", "81.83.133.246");
#####################################
##
## SESSION START
#####################################
@session_start();
#####################################
##
## REQUIRED INCLUDES
#####################################
include_once(DOCUMENT_ROOT . "/includes/db.inc.php");
include_once(DOCUMENT_ROOT . "/includes/templatePower/class.TemplatePower.inc.php");
#####################################
##
## Count stuff
#####################################
function getIp()
{
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) $ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) $ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) $ip = $_SERVER['REMOTE_ADDR'];
else $ip = 0;
return $ip;
}
function getHost($ip)
{
$host = @gethostbyaddr($ip);
return $host;
}
function getReferer()
{
return $_SERVER['HTTP_REFERER'];
}
function getAgent()
{
return $_SERVER['HTTP_USER_AGENT'];
}
#####################################
##
## CLASS
## OLD FORM FUNCTIONS
#####################################
class FC
{
function pp($text)
{
$text = ereg_replace("‘", chr(39), $text);
$text = ereg_replace("’", chr(39), $text);
$text = ereg_replace("“", chr(34), $text);
$text = ereg_replace("”", chr(34), $text);
$text = ereg_replace("—", "--", $text);
$text = ereg_replace("―", "--", $text);
$text = ereg_replace("…", "...", $text);
/* -------------------------------------- */
//$text = ereg_replace(chr(171),chr(34), $text); --> niet meer activeren: � deelteken probleem, e accent aigue probeem
$text = ereg_replace(chr(171) . " ", chr(34), $text);
$text = ereg_replace(" " . chr(187), chr(34), $text);
$text = ereg_replace(chr(187), chr(34), $text);
$text = ereg_replace(chr(145), chr(39), $text);
$text = ereg_replace(chr(146), chr(39), $text);
$text = ereg_replace(chr(147), chr(34), $text);
$text = ereg_replace(chr(148), chr(34), $text);
$text = ereg_replace("`", chr(39), $text);
$text = ereg_replace("�", chr(39), $text);
$text = ereg_replace(chr(133), "...", $text);
$text = addslashes(trim($text));
return $text;
}
function fup($text)
{ // form echo
$text = htmlspecialchars(stripslashes($text));
return $text;
}
function up($text)
{ // embedded html echo
$text = nl2br(htmlspecialchars(stripslashes($text)));
return $text;
}
function is_url($url)
{
if (!($parts = @parse_url($url)))
return false;
else {
if ($parts[scheme] != "http" && $parts[scheme] != "https" && $parts[scheme] != "ftp" && $parts[scheme] != "gopher")
return false;
else if (!eregi("^[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$", $parts[host], $regs)) // ||[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
return false;
else if (!eregi("^([0-9a-z-]|[\_])*$", $parts[user], $regs))
return false;
else if (!eregi("^([0-9a-z-]|[\_])*$", $parts[pass], $regs))
return false;
else if (!eregi("^[0-9a-z/_\.@~\-]*$", $parts[path], $regs))
return false;
else if (!eregi("^[0-9a-z?&=#\,]*$", $parts[query], $regs))
return false;
}
return true;
}
function is_email($email)
{
return (eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]+$", $email));
}
function chkDatum($dag, $maand, $jaar)
{
if (checkdate($maand, $dag, $jaar) == 1) {
return 1;
}
}
function spamCheck($text)
{
if (preg_match("/.*(
)+.*/i", $text)) $spam = 1;
if (preg_match("/.*(magic number code)+.*/i", $text)) $spam = 1;
if (preg_match("/.*((content-type)+|(multipart\/mixed)+).*/i", $text)) $spam = 1;
if (preg_match("/.*([[:digit:]]{1,}@nex\.be)+.*/i", $text)) $spam = 1;
if (preg_match("/.*(\[url=(.*)])+.*/i", $text)) $spam = 1;
if (preg_match("/.*((http:\/\/)+|(www\.)+|(ftp:\/\/\.)+).*/i", $text)) $spam = 1;
if ($spam == 1) {
return 1;
} else {
return $text;
};
}
function formSelect($opties, $getVar)
{
foreach ($opties as $key => $value) {
$selected = ($value == $getVar) ? "selected" : "";
$html .= '';
}
return $html;
}
function addZero($nummer)
{
if ($nummer < 10 && strlen($nummer) == 1) {
$nummer = 0 . $nummer;
}
return $nummer;
}
}
#####################################
##
## CLASS
## MYSQL PAGED RESULT SET
#####################################
class PageNav
{
var $results;
var $pageSize;
var $page;
var $row;
var $db;
function PageNav($query, $pageSize, $db)
{
$page = $_GET['page'];
$query = preg_replace("/LIMIT (.*)/i", "", $query); // zelf toegevoegd
//print $query;
$this->results = @$db->query($query);
$this->pageSize = $pageSize;
if ((int)$page <= 0) $page = 1;
if ($page > $this->getNumPages())
$page = $this->getNumPages();
$this->setPageNum($page);
}
function getNumPages()
{
if (!$this->results) return FALSE;
return ceil(mysql_num_rows($this->results) /
(float)$this->pageSize);
}
function setPageNum($pageNum)
{
if ($pageNum > $this->getNumPages() or
$pageNum <= 0
) return FALSE;
$this->page = $pageNum;
$this->row = 0;
mysql_data_seek($this->results, ($pageNum - 1) * $this->pageSize);
}
function getPageNum()
{
return $this->page;
}
function isLastPage()
{
return ($this->page >= $this->getNumPages());
}
function isFirstPage()
{
return ($this->page <= 1);
}
function fetchArray()
{
if (!$this->results) return FALSE;
if ($this->row >= $this->pageSize) return FALSE;
$this->row++;
return mysql_fetch_array($this->results);
}
function getPageNav($queryvars = '')
{
$ampersant = ($queryvars == '') ? '' : '&';
$nav = '';
if (!$this->isFirstPage()) {
$nav .= "getPageNum() - 1) . "$ampersant" . $queryvars . '"><< ';
}
if ($this->getNumPages() > 1)
for ($i = 1; $i <= $this->getNumPages(); $i++) {
if ($i == $this->page)
$nav .= "$i ";
else
$nav .= "
{$i}\r\n ";
}
if (!$this->isLastPage()) {
$nav .= "
getPageNum() + 1) . "$ampersant" . $queryvars . '">>> ';
}
return $nav;
}
}