DE BESTE SEXSITES
ALGEMEEN
astrobob
boerenmeiden
bouwvukkers
brabantsex
desktopporno
grotemeiden
hetevoetbalvrouwen
ikvoelmezelf
jongneuktoud
luistersexverhalen
madsexparty
memmenparade
mooiesnol
pornobizar
pornomakeover
priveclubholland
sex
AMATEUR
ANAL
BABES
boerenmeiden
bouwvukkers
brabantsex
desktopporno
grotemeiden
hetevoetbalvrouwen
ikvoelmezelf
jongneuktoud
luistersexverhalen
madsexparty
memmenparade
mooiesnol
pornobizar
pornomakeover
priveclubholland
sex
clubvivid
darkbianca
f1babes
lievebobbi
lievesintia
lievewendy
newporndiva
sexylaura
sexylisa
sexymanon
sexymarianne
sexymelizza
sexyramona
vicsbabes
xlboobs
BLACK
CUM
EXTREME
FETISH
GAY
darkbianca
f1babes
lievebobbi
lievesintia
lievewendy
newporndiva
sexylaura
sexylisa
sexymanon
sexymarianne
sexymelizza
sexyramona
vicsbabes
xlboobs
boy4you
gay-star
gayandnight
gayextreem
gayextreme
gaygloryhole
gaysandgays
guysgonuts
hardcoregay
hardepikken
heteboy
hotangel
lekkereboys
lekkeregays
sexyjongens
shemaleclub
smboys
trekjeknaap
zonderrubber
GRANNY
HARDCORE
gay-star
gayandnight
gayextreem
gayextreme
gaygloryhole
gaysandgays
guysgonuts
hardcoregay
hardepikken
heteboy
hotangel
lekkereboys
lekkeregays
sexyjongens
shemaleclub
smboys
trekjeknaap
zonderrubber
chicksmovies
dirtyteen
fistfuck
fistfuckmovies
girlsgoextreme
hardcore-sex
hardcorefeest
iloverocco
opgerekt
pornoextreem
supersletten
LESBIAN
MOVIE
PROSTITUTE
REALITY
dirtyteen
fistfuck
fistfuckmovies
girlsgoextreme
hardcore-sex
hardcorefeest
iloverocco
opgerekt
pornoextreem
supersletten
amateurladies
bendovermovies
bijstandsslet
boerenwillenhoeren
donenadsfavorieten
dronkengeneukt
hitchingbitches
hoewasze
huurinnatura
meidenvanplezier
moviesdegonzo
nickinhetland
pornobobextreem
pornobobsex
rijbewijssex
rijpehuisvrouwtjes
sexbuitendedeur
sexinhetopenbaar
sexmondjes
sletruilen
spuitcastings
stellenvandestraat
stoutdagboek
verbodensex
TEEN
VOYEUR
WEBCAM
bendovermovies
bijstandsslet
boerenwillenhoeren
donenadsfavorieten
dronkengeneukt
hitchingbitches
hoewasze
huurinnatura
meidenvanplezier
moviesdegonzo
nickinhetland
pornobobextreem
pornobobsex
rijbewijssex
rijpehuisvrouwtjes
sexbuitendedeur
sexinhetopenbaar
sexmondjes
sletruilen
spuitcastings
stellenvandestraat
stoutdagboek
verbodensex
Geile foto's en perverse filmpjes, Babenight plaatst ze hier voor jou. Regelmatige updates zorgen ervoor dat je altijd een plek hebt om te gaan als echt even wilt rukken of vingeren bij het allergeilste materiaal op het internet
MEER PORNO
Meer en extra geile high quality content zien? Of lekker geilen op Nicole en Donna? Klik dan hier BABENIGHT EXCLUSIEF
###################### Template Class ####################
#
# Met de class Template is het mogelijk om in een template bestand bepaalde variable-waarden te plaatsen.
# dit maakt het makkelijker voor disgners om een layout te veranderen zonder php te hoeven gebruiken.
# De template file kan elk normaal ascii bestand zijn en kan bestaan uit HTML, gewone tekst etc etc.
# Het model wat word vervangen heeft het volgende formaat: %[(a-z)]%
#
# Vereiste variabelen:
# $vars -- Een array gevuld met sleutel waarden die in het template bestand moeten worden
# vervangen en de daarbijbehordende nieuwe waarden.
#
# Het systeem is:
# - Hoofdletter ongevoelig,
# - Alfanumerieke tekens en _ worden geaccepteerd,
#
# Vb.:
# $var = new Template("textfile.template.html");
# print $var->parse( // aanroep om "dailer.template.htm" te parsen
# array(
# "link" => $templateLink, // in het template bestand word "%[link]% vervangen door de waarde in $templateLink
# )
# );
#
######
# Door: Willem de Vries
# Voor: Virtual Pc Services
#
######
# Changelog:
# 1.0 (WdV 7-11-2003): statische functie ombouwen naar object
# 1.1 (WdV 13-2-2004): parsen moet ook zonder parameters kunnen
# 1.2 (JF 15-2-2004): Set functie toegevoegd om variablen aan template toe te voegen, aaroep: set(variablenaam, value)
# 1.3 (JF 24-3-2004): Endless loop bug gefixed, bij openen van template kwam hij bij lege file of file zonder
# regeleinde niet bij eof bij lezen van filesize.
# 1.4 (WdV 04-3-2005): Nieuwe functie om default-waardes uit een HTML-comment veld te halen.
# 2.0 (WdV 09-2-2005): grotendeels herschreven refresh() en parse() routine. Nu 50% sneller!
# 2.1 (WdV 15-2-2005): Mogelijkheid om een template aan te maken vanuit een string ipv. een file uit te lezen
# 2.2 (WdV 28-10-2005): On-the-fly compressie om geheugen te sparen, kleinere array properties
# 2.3 (WdV 15-12-2005): Gebruik van de "TEMPLATE_SEARCH" superglobal om een (relatief) zoekpad op te geven waarin
# templates gezocht moeten worden.
# 2.4 (WdV: 3-5-2006): bugfix - gebruik geen som-tekens met arrays!
###############################################################
function _slashjoin() {
$out = array();
foreach(func_get_args() as $param) {
if ($param)
$out[] = $param;
}
return preg_replace('#([/]+)#', '/', join('/', $out));
}
function _dirlist($str, $regex = '.*') {
$out = array();
$dh = (is_dir($str)) ? @opendir($str) : null;
while ($dh and $fil = readdir($dh)) {
$out[] = _slashjoin($str, $fil);
}
if ( !$out) return;
list($item) = array_values(preg_grep("|$regex|i", $out));
# error_log(__FUNCTION__ . " Matching items for |$regex|");
# error_log(__FUNCTION__ . " Subdirs in $str: " . join('|', $out));
# error_log(__FUNCTION__ . " Found dir '$item'");
return ($item) ? $item : $str;
}
class Template {
var $fn = null;
var $filename = null;
var $ch = null;
var $error = null;
var $searchpath = null;
var $searchdir = null;
var $inf = null;
var $def = null;
var $me = 'object';
var $vars = array();
function Template($name) {
# Compatibility
$this->filename =& $this->fn;
$this->me = strtoupper(get_class($this));
$this->searchpath = $GLOBALS[$this->me . "_SEARCH"];
if (defined($this->me . "_COMPRESS")) {
foreach(array(array('gzcompress', 'gzuncompress'), array('gzdeflate', 'gzinflate')) as $grp) {
if (function_exists($grp[0])) {
$this->def = $grp[0];
$this->inf = $grp[1];
break;
}
}
}
$this->fn = $name;
$this->refresh();
}
function set($varname, $value = ''){
$this->vars[$varname] = $value;
}
function get($varname) {
return $this->vars[$varname];
}
function refresh() {
if (!preg_match('/\.([^\.\/\s]+)$/', $this->fn, $found) ) {
$this->cached($this->fn);
$this->fn = null;
$this->error = null;
return;
}
# Implementatie zoekpad
$subdirs = preg_split('/([\s]*;[\s]*)/', $this->searchpath);
if (! $subdirs)
$subdirs = array('');
list($a, $up, $b, $path) = preg_match('/^(([\.]+\/)*)(.+)/', $this->fn, $found) ? $found : array('', '', '', $found[0]);
foreach($subdirs as $subdir) {
$sub = _slashjoin($up, $subdir);
# Wanneer de basis zoekdirectory niet bestaat, dan controleren we nog even
# of deze naam niet partieel voorkomt ergens in de boom. Zie functie _dirlist().
if ($subdir and !is_dir($sub)) {
$sub = _dirlist(dirname($sub), preg_replace('/([^0-9a-z]+)$/', '', $subdir) );
}
$this->searchdir = _slashjoin($sub, $path);
$exists = (file_exists($this->searchdir) and filesize($this->searchdir) > 0);
if ($exists) {
$this->searchpath = $sub;
break;
}
}
$readable = ($exists and is_readable($this->searchdir) );
$soort = ($readable) ? filetype($this->searchdir) : "";
if ($readable and $soort == "file") {
$this->cached( join('', file($this->searchdir)) );
$this->error = null;
} elseif (!$exists) {
$this->error( sprintf("'%s' bestaat niet.", $this->searchdir) );
} elseif (!$readable) {
$this->error( sprintf("'%s' kan niet worden gelezen.", $this->searchdir) );
} elseif ($exists && $soort != "file") {
$this->error( sprintf("'%s' is geen geldig bestand; %s", $this->searchdir, $soort) );
}
return;
}
function error($str) {
$text = sprintf('%s %s [in %s]', $this->me, $str, $_SERVER['SCRIPT_NAME']);
$this->error = $text;
if ($_SERVER['IS_DEVEL'] and $this->error) error_log($this->error);
}
function parse($vars = array()) {
$vars = array_merge($vars, $this->vars);
if ($this->searchpath)
# Voeg een slash toe aan het einde van het pad - templates verwachten dit!
$vars['_searchpath'] = trim(_slashjoin($this->searchpath, ' '));
$match = array();
$repl = array();
foreach(array_keys($vars) as $key){
$match[] = sprintf("/(%%\[%s\]%%)/i", preg_quote($key));
$repl[] = $vars[$key];
}
$match[] = '/%\[[^\[\]]+\]%/'; # Catch all
$repl[] = '';
return preg_replace($match, $repl, $this->cached());
}
function extractData() {
$reg = '/<\!--(\s*([^=\s\<\>]+)[\s=]+[\'"]?([^\'"\s\<\>]+))+\s*-->/';
$comment = '/<\!--\s*(.+)\s*-->/';
$fields = '/([^=\s<>]+)[\s=]+([\'\"])?([^\s<>\2]+)/';
if (! preg_match_all($comment, $this->cached(), $found) )
return false;
foreach($found[1] as $line) {
preg_match_all($fields, $line, $res);
for($i=0; $i < sizeof($res[0]); $i++) {
$this->vars[$res[1][$i]] = $res[3][$i];
}
}
return $this->vars;
}
function cached($str = null) {
if (is_null($str)) {
#request
$do = $this->inf;
return ($this->compressed() and $this->ch) ? $do($this->ch) : $this->ch;
}
$do = $this->def;
$this->ch = ($this->compressed()) ? $do($str, 9) : $str;
}
function compressed() {
return ($this->inf || $this->def);
}
}
# EOF
?>
define('RANDOMCHARS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
function make_randomkey($length=32,$customkeys=false) {
$keychars = ($customkeys) ? $customkeys : RANDOMCHARS;
$randkey = "";
for ($i=0;$i<$length;$i++)
$randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);
return $randkey;
}
function scan_dir($dir,$showfiles = true) {
$files = glob("$dir/*", (!$showfiles) ? GLOB_ONLYDIR : null);
$out = array();
while($files and $path = array_shift($files)) {
$fil = array_pop(explode('/', $path));
$out[$fil] = $path;
}
return $out;
}
function read_specs($dir) {
$specs = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
if(file_exists("$dir/$fil/disabled.txt")) {
continue;
}
$specs[] = $fil;
}
if ($dh) closedir($dh);
sort($specs);
$out = array();
foreach($specs as $spec) {
$sdir = sprintf('%s/%s',$dir,$spec);
$tmp = read_dir($sdir,false);
$my = array();
foreach(array_keys($tmp) as $item) {
$my[] = $item;
}
$out[$spec] = $my;
}
return $out;
}
function read_dir($dir,$showfiles=true) {
$files = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($showfiles) {
if($fil{0} == '.' or is_dir("$dir/$fil") ) continue;
} else {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
}
if(file_exists("$dir/$fil/disabled.txt")) {
#var_dump("$dir/$fil = disabled");
continue;
}
$files[] = $fil;
}
if ($dh) closedir($dh);
sort($files);
$out = array();
foreach($files as $fil) {
$out[$fil] = sprintf('%s/%s',$dir,$fil);
}
return $out;
}
function ad_templates($dir='templates') {
$files = read_dir($dir);
$tpls = array();
if(count($files)>0) {
foreach(array_keys($files) as $tpl) {
$t = str_replace('.template.html','',$tpl);
$tpls[$t] = new Template($files[$tpl]);
}
}
return $tpls;
}
function readXML($XMLfile) {
$tpl = new Template($XMLfile);
return fromXML($tpl->parse());
$data = (file_exists($XMLfile)) ? array_map("trim", file($XMLfile)) : array();
if (! $data) $data = array();
$content = join("", $data);
$content = preg_replace('/\<\?.+\?\>/', '', $content);
$content = preg_replace('/&/', '&', $content);
$struct = fromXML(str_replace('&', '&', $content));
return $struct;
}
function ad_data($dir) {
$configfile = sprintf('%s/%s', $dir, DATA_FILE);
if (! file_exists($configfile) ) {
error_log("Geen configfile in $dir");
return;
}
$txt = join('', @file($configfile));
$config = fromXML($txt);
if (is_null($config) ) return;
$config['dir'] = ( preg_match('/docs(\/.+)$/', $dir, $found) ) ? $found[1] : $dir;
# als xml geen 'name' tag heeft dan klopt onderstaande regel dus niet, moet ff fixen nog eens
$config['episode'] = ($item = explode('/', $dir) ) ? $item[sizeof($item)-1] : $config['name'];
return $config;
}
function custom_styles($css,$post) {
if(!$css) return array();
$out = array();
foreach(array_keys($css) as $style) {
$out[$style] = ($post[$style]) ? $post[$style] : $css[$style];
}
return $out;
}
function fontsize($font='Verdana') {
$sizes = array(
'Arial' => 11,
'Georgia' => 11,
'Tahoma' => 11,
'Times New Roman' => 11,
'Verdana' => 11,
);
return ($sizes[$font]) ? $sizes[$font] : 11;
}
function fix_url($url,$CGI) {
$chk = explode('?',$url);
$params = sprintf('p=%s&pi=%s',$CGI['p'],$CGI['pi']);
$chk[1] = ($chk[1]) ? sprintf('%s&%s',$chk[1],$params) : $params;
return join('?',$chk);
}
function create_ad($css=array(),$files=array(),$data,$params,$tpl) {
$trailer_url = ($data['trailer_url']) ? sprintf('http://%s/?trailer=%s&%s',$data['trailer_url'],$data['episode'],$params)
: sprintf('http://%s/?%s',$data['site_url'],$params);
$vars = array(
'key' => make_randomkey(10),
'params' => $params,
'site_url' => $data['site_url'],
'site_naam' => $data['site_naam'],
'trailer_url' => $trailer_url,
'trailer_txt' => ($data['trailer_url']) ? 'Trailer' : 'Website',
'episode' => $data['episode'],
'voice_url' => $data['voice_url'],
'datum' => strftime("%e %b %Y",strtotime($data['datum'])),
'tekst' => htmlentities($data['tekst']),
'textsize' => fontsize($css['textfont']),
);
return $tpl->parse(array_merge($vars,$files,$css));
}
?> Hardcore Foto:
###################### Template Class ####################
#
# Met de class Template is het mogelijk om in een template bestand bepaalde variable-waarden te plaatsen.
# dit maakt het makkelijker voor disgners om een layout te veranderen zonder php te hoeven gebruiken.
# De template file kan elk normaal ascii bestand zijn en kan bestaan uit HTML, gewone tekst etc etc.
# Het model wat word vervangen heeft het volgende formaat: %[(a-z)]%
#
# Vereiste variabelen:
# $vars -- Een array gevuld met sleutel waarden die in het template bestand moeten worden
# vervangen en de daarbijbehordende nieuwe waarden.
#
# Het systeem is:
# - Hoofdletter ongevoelig,
# - Alfanumerieke tekens en _ worden geaccepteerd,
#
# Vb.:
# $var = new Template("textfile.template.html");
# print $var->parse( // aanroep om "dailer.template.htm" te parsen
# array(
# "link" => $templateLink, // in het template bestand word "%[link]% vervangen door de waarde in $templateLink
# )
# );
#
######
# Door: Willem de Vries
# Voor: Virtual Pc Services
#
######
# Changelog:
# 1.0 (WdV 7-11-2003): statische functie ombouwen naar object
# 1.1 (WdV 13-2-2004): parsen moet ook zonder parameters kunnen
# 1.2 (JF 15-2-2004): Set functie toegevoegd om variablen aan template toe te voegen, aaroep: set(variablenaam, value)
# 1.3 (JF 24-3-2004): Endless loop bug gefixed, bij openen van template kwam hij bij lege file of file zonder
# regeleinde niet bij eof bij lezen van filesize.
# 1.4 (WdV 04-3-2005): Nieuwe functie om default-waardes uit een HTML-comment veld te halen.
# 2.0 (WdV 09-2-2005): grotendeels herschreven refresh() en parse() routine. Nu 50% sneller!
# 2.1 (WdV 15-2-2005): Mogelijkheid om een template aan te maken vanuit een string ipv. een file uit te lezen
# 2.2 (WdV 28-10-2005): On-the-fly compressie om geheugen te sparen, kleinere array properties
# 2.3 (WdV 15-12-2005): Gebruik van de "TEMPLATE_SEARCH" superglobal om een (relatief) zoekpad op te geven waarin
# templates gezocht moeten worden.
# 2.4 (WdV: 3-5-2006): bugfix - gebruik geen som-tekens met arrays!
###############################################################
function _slashjoin() {
$out = array();
foreach(func_get_args() as $param) {
if ($param)
$out[] = $param;
}
return preg_replace('#([/]+)#', '/', join('/', $out));
}
function _dirlist($str, $regex = '.*') {
$out = array();
$dh = (is_dir($str)) ? @opendir($str) : null;
while ($dh and $fil = readdir($dh)) {
$out[] = _slashjoin($str, $fil);
}
if ( !$out) return;
list($item) = array_values(preg_grep("|$regex|i", $out));
# error_log(__FUNCTION__ . " Matching items for |$regex|");
# error_log(__FUNCTION__ . " Subdirs in $str: " . join('|', $out));
# error_log(__FUNCTION__ . " Found dir '$item'");
return ($item) ? $item : $str;
}
class Template {
var $fn = null;
var $filename = null;
var $ch = null;
var $error = null;
var $searchpath = null;
var $searchdir = null;
var $inf = null;
var $def = null;
var $me = 'object';
var $vars = array();
function Template($name) {
# Compatibility
$this->filename =& $this->fn;
$this->me = strtoupper(get_class($this));
$this->searchpath = $GLOBALS[$this->me . "_SEARCH"];
if (defined($this->me . "_COMPRESS")) {
foreach(array(array('gzcompress', 'gzuncompress'), array('gzdeflate', 'gzinflate')) as $grp) {
if (function_exists($grp[0])) {
$this->def = $grp[0];
$this->inf = $grp[1];
break;
}
}
}
$this->fn = $name;
$this->refresh();
}
function set($varname, $value = ''){
$this->vars[$varname] = $value;
}
function get($varname) {
return $this->vars[$varname];
}
function refresh() {
if (!preg_match('/\.([^\.\/\s]+)$/', $this->fn, $found) ) {
$this->cached($this->fn);
$this->fn = null;
$this->error = null;
return;
}
# Implementatie zoekpad
$subdirs = preg_split('/([\s]*;[\s]*)/', $this->searchpath);
if (! $subdirs)
$subdirs = array('');
list($a, $up, $b, $path) = preg_match('/^(([\.]+\/)*)(.+)/', $this->fn, $found) ? $found : array('', '', '', $found[0]);
foreach($subdirs as $subdir) {
$sub = _slashjoin($up, $subdir);
# Wanneer de basis zoekdirectory niet bestaat, dan controleren we nog even
# of deze naam niet partieel voorkomt ergens in de boom. Zie functie _dirlist().
if ($subdir and !is_dir($sub)) {
$sub = _dirlist(dirname($sub), preg_replace('/([^0-9a-z]+)$/', '', $subdir) );
}
$this->searchdir = _slashjoin($sub, $path);
$exists = (file_exists($this->searchdir) and filesize($this->searchdir) > 0);
if ($exists) {
$this->searchpath = $sub;
break;
}
}
$readable = ($exists and is_readable($this->searchdir) );
$soort = ($readable) ? filetype($this->searchdir) : "";
if ($readable and $soort == "file") {
$this->cached( join('', file($this->searchdir)) );
$this->error = null;
} elseif (!$exists) {
$this->error( sprintf("'%s' bestaat niet.", $this->searchdir) );
} elseif (!$readable) {
$this->error( sprintf("'%s' kan niet worden gelezen.", $this->searchdir) );
} elseif ($exists && $soort != "file") {
$this->error( sprintf("'%s' is geen geldig bestand; %s", $this->searchdir, $soort) );
}
return;
}
function error($str) {
$text = sprintf('%s %s [in %s]', $this->me, $str, $_SERVER['SCRIPT_NAME']);
$this->error = $text;
if ($_SERVER['IS_DEVEL'] and $this->error) error_log($this->error);
}
function parse($vars = array()) {
$vars = array_merge($vars, $this->vars);
if ($this->searchpath)
# Voeg een slash toe aan het einde van het pad - templates verwachten dit!
$vars['_searchpath'] = trim(_slashjoin($this->searchpath, ' '));
$match = array();
$repl = array();
foreach(array_keys($vars) as $key){
$match[] = sprintf("/(%%\[%s\]%%)/i", preg_quote($key));
$repl[] = $vars[$key];
}
$match[] = '/%\[[^\[\]]+\]%/'; # Catch all
$repl[] = '';
return preg_replace($match, $repl, $this->cached());
}
function extractData() {
$reg = '/<\!--(\s*([^=\s\<\>]+)[\s=]+[\'"]?([^\'"\s\<\>]+))+\s*-->/';
$comment = '/<\!--\s*(.+)\s*-->/';
$fields = '/([^=\s<>]+)[\s=]+([\'\"])?([^\s<>\2]+)/';
if (! preg_match_all($comment, $this->cached(), $found) )
return false;
foreach($found[1] as $line) {
preg_match_all($fields, $line, $res);
for($i=0; $i < sizeof($res[0]); $i++) {
$this->vars[$res[1][$i]] = $res[3][$i];
}
}
return $this->vars;
}
function cached($str = null) {
if (is_null($str)) {
#request
$do = $this->inf;
return ($this->compressed() and $this->ch) ? $do($this->ch) : $this->ch;
}
$do = $this->def;
$this->ch = ($this->compressed()) ? $do($str, 9) : $str;
}
function compressed() {
return ($this->inf || $this->def);
}
}
# EOF
?>
define('RANDOMCHARS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
function make_randomkey($length=32,$customkeys=false) {
$keychars = ($customkeys) ? $customkeys : RANDOMCHARS;
$randkey = "";
for ($i=0;$i<$length;$i++)
$randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);
return $randkey;
}
function scan_dir($dir,$showfiles = true) {
$files = glob("$dir/*", (!$showfiles) ? GLOB_ONLYDIR : null);
$out = array();
while($files and $path = array_shift($files)) {
$fil = array_pop(explode('/', $path));
$out[$fil] = $path;
}
return $out;
}
function read_specs($dir) {
$specs = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
if(file_exists("$dir/$fil/disabled.txt")) {
continue;
}
$specs[] = $fil;
}
if ($dh) closedir($dh);
sort($specs);
$out = array();
foreach($specs as $spec) {
$sdir = sprintf('%s/%s',$dir,$spec);
$tmp = read_dir($sdir,false);
$my = array();
foreach(array_keys($tmp) as $item) {
$my[] = $item;
}
$out[$spec] = $my;
}
return $out;
}
function read_dir($dir,$showfiles=true) {
$files = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($showfiles) {
if($fil{0} == '.' or is_dir("$dir/$fil") ) continue;
} else {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
}
if(file_exists("$dir/$fil/disabled.txt")) {
#var_dump("$dir/$fil = disabled");
continue;
}
$files[] = $fil;
}
if ($dh) closedir($dh);
sort($files);
$out = array();
foreach($files as $fil) {
$out[$fil] = sprintf('%s/%s',$dir,$fil);
}
return $out;
}
function ad_templates($dir='templates') {
$files = read_dir($dir);
$tpls = array();
if(count($files)>0) {
foreach(array_keys($files) as $tpl) {
$t = str_replace('.template.html','',$tpl);
$tpls[$t] = new Template($files[$tpl]);
}
}
return $tpls;
}
function readXML($XMLfile) {
$tpl = new Template($XMLfile);
return fromXML($tpl->parse());
$data = (file_exists($XMLfile)) ? array_map("trim", file($XMLfile)) : array();
if (! $data) $data = array();
$content = join("", $data);
$content = preg_replace('/\<\?.+\?\>/', '', $content);
$content = preg_replace('/&/', '&', $content);
$struct = fromXML(str_replace('&', '&', $content));
return $struct;
}
function ad_data($dir) {
$configfile = sprintf('%s/%s', $dir, DATA_FILE);
if (! file_exists($configfile) ) {
error_log("Geen configfile in $dir");
return;
}
$txt = join('', @file($configfile));
$config = fromXML($txt);
if (is_null($config) ) return;
$config['dir'] = ( preg_match('/docs(\/.+)$/', $dir, $found) ) ? $found[1] : $dir;
# als xml geen 'name' tag heeft dan klopt onderstaande regel dus niet, moet ff fixen nog eens
$config['episode'] = ($item = explode('/', $dir) ) ? $item[sizeof($item)-1] : $config['name'];
return $config;
}
function custom_styles($css,$post) {
if(!$css) return array();
$out = array();
foreach(array_keys($css) as $style) {
$out[$style] = ($post[$style]) ? $post[$style] : $css[$style];
}
return $out;
}
function fontsize($font='Verdana') {
$sizes = array(
'Arial' => 11,
'Georgia' => 11,
'Tahoma' => 11,
'Times New Roman' => 11,
'Verdana' => 11,
);
return ($sizes[$font]) ? $sizes[$font] : 11;
}
function fix_url($url,$CGI) {
$chk = explode('?',$url);
$params = sprintf('p=%s&pi=%s',$CGI['p'],$CGI['pi']);
$chk[1] = ($chk[1]) ? sprintf('%s&%s',$chk[1],$params) : $params;
return join('?',$chk);
}
function create_ad($css=array(),$files=array(),$data,$params,$tpl) {
$trailer_url = ($data['trailer_url']) ? sprintf('http://%s/?trailer=%s&%s',$data['trailer_url'],$data['episode'],$params)
: sprintf('http://%s/?%s',$data['site_url'],$params);
$vars = array(
'key' => make_randomkey(10),
'params' => $params,
'site_url' => $data['site_url'],
'site_naam' => $data['site_naam'],
'trailer_url' => $trailer_url,
'trailer_txt' => ($data['trailer_url']) ? 'Trailer' : 'Website',
'episode' => $data['episode'],
'voice_url' => $data['voice_url'],
'datum' => strftime("%e %b %Y",strtotime($data['datum'])),
'tekst' => htmlentities($data['tekst']),
'textsize' => fontsize($css['textfont']),
);
return $tpl->parse(array_merge($vars,$files,$css));
}
?> Tieners Foto:
###################### Template Class ####################
#
# Met de class Template is het mogelijk om in een template bestand bepaalde variable-waarden te plaatsen.
# dit maakt het makkelijker voor disgners om een layout te veranderen zonder php te hoeven gebruiken.
# De template file kan elk normaal ascii bestand zijn en kan bestaan uit HTML, gewone tekst etc etc.
# Het model wat word vervangen heeft het volgende formaat: %[(a-z)]%
#
# Vereiste variabelen:
# $vars -- Een array gevuld met sleutel waarden die in het template bestand moeten worden
# vervangen en de daarbijbehordende nieuwe waarden.
#
# Het systeem is:
# - Hoofdletter ongevoelig,
# - Alfanumerieke tekens en _ worden geaccepteerd,
#
# Vb.:
# $var = new Template("textfile.template.html");
# print $var->parse( // aanroep om "dailer.template.htm" te parsen
# array(
# "link" => $templateLink, // in het template bestand word "%[link]% vervangen door de waarde in $templateLink
# )
# );
#
######
# Door: Willem de Vries
# Voor: Virtual Pc Services
#
######
# Changelog:
# 1.0 (WdV 7-11-2003): statische functie ombouwen naar object
# 1.1 (WdV 13-2-2004): parsen moet ook zonder parameters kunnen
# 1.2 (JF 15-2-2004): Set functie toegevoegd om variablen aan template toe te voegen, aaroep: set(variablenaam, value)
# 1.3 (JF 24-3-2004): Endless loop bug gefixed, bij openen van template kwam hij bij lege file of file zonder
# regeleinde niet bij eof bij lezen van filesize.
# 1.4 (WdV 04-3-2005): Nieuwe functie om default-waardes uit een HTML-comment veld te halen.
# 2.0 (WdV 09-2-2005): grotendeels herschreven refresh() en parse() routine. Nu 50% sneller!
# 2.1 (WdV 15-2-2005): Mogelijkheid om een template aan te maken vanuit een string ipv. een file uit te lezen
# 2.2 (WdV 28-10-2005): On-the-fly compressie om geheugen te sparen, kleinere array properties
# 2.3 (WdV 15-12-2005): Gebruik van de "TEMPLATE_SEARCH" superglobal om een (relatief) zoekpad op te geven waarin
# templates gezocht moeten worden.
# 2.4 (WdV: 3-5-2006): bugfix - gebruik geen som-tekens met arrays!
###############################################################
function _slashjoin() {
$out = array();
foreach(func_get_args() as $param) {
if ($param)
$out[] = $param;
}
return preg_replace('#([/]+)#', '/', join('/', $out));
}
function _dirlist($str, $regex = '.*') {
$out = array();
$dh = (is_dir($str)) ? @opendir($str) : null;
while ($dh and $fil = readdir($dh)) {
$out[] = _slashjoin($str, $fil);
}
if ( !$out) return;
list($item) = array_values(preg_grep("|$regex|i", $out));
# error_log(__FUNCTION__ . " Matching items for |$regex|");
# error_log(__FUNCTION__ . " Subdirs in $str: " . join('|', $out));
# error_log(__FUNCTION__ . " Found dir '$item'");
return ($item) ? $item : $str;
}
class Template {
var $fn = null;
var $filename = null;
var $ch = null;
var $error = null;
var $searchpath = null;
var $searchdir = null;
var $inf = null;
var $def = null;
var $me = 'object';
var $vars = array();
function Template($name) {
# Compatibility
$this->filename =& $this->fn;
$this->me = strtoupper(get_class($this));
$this->searchpath = $GLOBALS[$this->me . "_SEARCH"];
if (defined($this->me . "_COMPRESS")) {
foreach(array(array('gzcompress', 'gzuncompress'), array('gzdeflate', 'gzinflate')) as $grp) {
if (function_exists($grp[0])) {
$this->def = $grp[0];
$this->inf = $grp[1];
break;
}
}
}
$this->fn = $name;
$this->refresh();
}
function set($varname, $value = ''){
$this->vars[$varname] = $value;
}
function get($varname) {
return $this->vars[$varname];
}
function refresh() {
if (!preg_match('/\.([^\.\/\s]+)$/', $this->fn, $found) ) {
$this->cached($this->fn);
$this->fn = null;
$this->error = null;
return;
}
# Implementatie zoekpad
$subdirs = preg_split('/([\s]*;[\s]*)/', $this->searchpath);
if (! $subdirs)
$subdirs = array('');
list($a, $up, $b, $path) = preg_match('/^(([\.]+\/)*)(.+)/', $this->fn, $found) ? $found : array('', '', '', $found[0]);
foreach($subdirs as $subdir) {
$sub = _slashjoin($up, $subdir);
# Wanneer de basis zoekdirectory niet bestaat, dan controleren we nog even
# of deze naam niet partieel voorkomt ergens in de boom. Zie functie _dirlist().
if ($subdir and !is_dir($sub)) {
$sub = _dirlist(dirname($sub), preg_replace('/([^0-9a-z]+)$/', '', $subdir) );
}
$this->searchdir = _slashjoin($sub, $path);
$exists = (file_exists($this->searchdir) and filesize($this->searchdir) > 0);
if ($exists) {
$this->searchpath = $sub;
break;
}
}
$readable = ($exists and is_readable($this->searchdir) );
$soort = ($readable) ? filetype($this->searchdir) : "";
if ($readable and $soort == "file") {
$this->cached( join('', file($this->searchdir)) );
$this->error = null;
} elseif (!$exists) {
$this->error( sprintf("'%s' bestaat niet.", $this->searchdir) );
} elseif (!$readable) {
$this->error( sprintf("'%s' kan niet worden gelezen.", $this->searchdir) );
} elseif ($exists && $soort != "file") {
$this->error( sprintf("'%s' is geen geldig bestand; %s", $this->searchdir, $soort) );
}
return;
}
function error($str) {
$text = sprintf('%s %s [in %s]', $this->me, $str, $_SERVER['SCRIPT_NAME']);
$this->error = $text;
if ($_SERVER['IS_DEVEL'] and $this->error) error_log($this->error);
}
function parse($vars = array()) {
$vars = array_merge($vars, $this->vars);
if ($this->searchpath)
# Voeg een slash toe aan het einde van het pad - templates verwachten dit!
$vars['_searchpath'] = trim(_slashjoin($this->searchpath, ' '));
$match = array();
$repl = array();
foreach(array_keys($vars) as $key){
$match[] = sprintf("/(%%\[%s\]%%)/i", preg_quote($key));
$repl[] = $vars[$key];
}
$match[] = '/%\[[^\[\]]+\]%/'; # Catch all
$repl[] = '';
return preg_replace($match, $repl, $this->cached());
}
function extractData() {
$reg = '/<\!--(\s*([^=\s\<\>]+)[\s=]+[\'"]?([^\'"\s\<\>]+))+\s*-->/';
$comment = '/<\!--\s*(.+)\s*-->/';
$fields = '/([^=\s<>]+)[\s=]+([\'\"])?([^\s<>\2]+)/';
if (! preg_match_all($comment, $this->cached(), $found) )
return false;
foreach($found[1] as $line) {
preg_match_all($fields, $line, $res);
for($i=0; $i < sizeof($res[0]); $i++) {
$this->vars[$res[1][$i]] = $res[3][$i];
}
}
return $this->vars;
}
function cached($str = null) {
if (is_null($str)) {
#request
$do = $this->inf;
return ($this->compressed() and $this->ch) ? $do($this->ch) : $this->ch;
}
$do = $this->def;
$this->ch = ($this->compressed()) ? $do($str, 9) : $str;
}
function compressed() {
return ($this->inf || $this->def);
}
}
# EOF
?>
define('RANDOMCHARS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
function make_randomkey($length=32,$customkeys=false) {
$keychars = ($customkeys) ? $customkeys : RANDOMCHARS;
$randkey = "";
for ($i=0;$i<$length;$i++)
$randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);
return $randkey;
}
function scan_dir($dir,$showfiles = true) {
$files = glob("$dir/*", (!$showfiles) ? GLOB_ONLYDIR : null);
$out = array();
while($files and $path = array_shift($files)) {
$fil = array_pop(explode('/', $path));
$out[$fil] = $path;
}
return $out;
}
function read_specs($dir) {
$specs = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
if(file_exists("$dir/$fil/disabled.txt")) {
continue;
}
$specs[] = $fil;
}
if ($dh) closedir($dh);
sort($specs);
$out = array();
foreach($specs as $spec) {
$sdir = sprintf('%s/%s',$dir,$spec);
$tmp = read_dir($sdir,false);
$my = array();
foreach(array_keys($tmp) as $item) {
$my[] = $item;
}
$out[$spec] = $my;
}
return $out;
}
function read_dir($dir,$showfiles=true) {
$files = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($showfiles) {
if($fil{0} == '.' or is_dir("$dir/$fil") ) continue;
} else {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
}
if(file_exists("$dir/$fil/disabled.txt")) {
#var_dump("$dir/$fil = disabled");
continue;
}
$files[] = $fil;
}
if ($dh) closedir($dh);
sort($files);
$out = array();
foreach($files as $fil) {
$out[$fil] = sprintf('%s/%s',$dir,$fil);
}
return $out;
}
function ad_templates($dir='templates') {
$files = read_dir($dir);
$tpls = array();
if(count($files)>0) {
foreach(array_keys($files) as $tpl) {
$t = str_replace('.template.html','',$tpl);
$tpls[$t] = new Template($files[$tpl]);
}
}
return $tpls;
}
function readXML($XMLfile) {
$tpl = new Template($XMLfile);
return fromXML($tpl->parse());
$data = (file_exists($XMLfile)) ? array_map("trim", file($XMLfile)) : array();
if (! $data) $data = array();
$content = join("", $data);
$content = preg_replace('/\<\?.+\?\>/', '', $content);
$content = preg_replace('/&/', '&', $content);
$struct = fromXML(str_replace('&', '&', $content));
return $struct;
}
function ad_data($dir) {
$configfile = sprintf('%s/%s', $dir, DATA_FILE);
if (! file_exists($configfile) ) {
error_log("Geen configfile in $dir");
return;
}
$txt = join('', @file($configfile));
$config = fromXML($txt);
if (is_null($config) ) return;
$config['dir'] = ( preg_match('/docs(\/.+)$/', $dir, $found) ) ? $found[1] : $dir;
# als xml geen 'name' tag heeft dan klopt onderstaande regel dus niet, moet ff fixen nog eens
$config['episode'] = ($item = explode('/', $dir) ) ? $item[sizeof($item)-1] : $config['name'];
return $config;
}
function custom_styles($css,$post) {
if(!$css) return array();
$out = array();
foreach(array_keys($css) as $style) {
$out[$style] = ($post[$style]) ? $post[$style] : $css[$style];
}
return $out;
}
function fontsize($font='Verdana') {
$sizes = array(
'Arial' => 11,
'Georgia' => 11,
'Tahoma' => 11,
'Times New Roman' => 11,
'Verdana' => 11,
);
return ($sizes[$font]) ? $sizes[$font] : 11;
}
function fix_url($url,$CGI) {
$chk = explode('?',$url);
$params = sprintf('p=%s&pi=%s',$CGI['p'],$CGI['pi']);
$chk[1] = ($chk[1]) ? sprintf('%s&%s',$chk[1],$params) : $params;
return join('?',$chk);
}
function create_ad($css=array(),$files=array(),$data,$params,$tpl) {
$trailer_url = ($data['trailer_url']) ? sprintf('http://%s/?trailer=%s&%s',$data['trailer_url'],$data['episode'],$params)
: sprintf('http://%s/?%s',$data['site_url'],$params);
$vars = array(
'key' => make_randomkey(10),
'params' => $params,
'site_url' => $data['site_url'],
'site_naam' => $data['site_naam'],
'trailer_url' => $trailer_url,
'trailer_txt' => ($data['trailer_url']) ? 'Trailer' : 'Website',
'episode' => $data['episode'],
'voice_url' => $data['voice_url'],
'datum' => strftime("%e %b %Y",strtotime($data['datum'])),
'tekst' => htmlentities($data['tekst']),
'textsize' => fontsize($css['textfont']),
);
return $tpl->parse(array_merge($vars,$files,$css));
}
?> Fetish Film:
###################### Template Class ####################
#
# Met de class Template is het mogelijk om in een template bestand bepaalde variable-waarden te plaatsen.
# dit maakt het makkelijker voor disgners om een layout te veranderen zonder php te hoeven gebruiken.
# De template file kan elk normaal ascii bestand zijn en kan bestaan uit HTML, gewone tekst etc etc.
# Het model wat word vervangen heeft het volgende formaat: %[(a-z)]%
#
# Vereiste variabelen:
# $vars -- Een array gevuld met sleutel waarden die in het template bestand moeten worden
# vervangen en de daarbijbehordende nieuwe waarden.
#
# Het systeem is:
# - Hoofdletter ongevoelig,
# - Alfanumerieke tekens en _ worden geaccepteerd,
#
# Vb.:
# $var = new Template("textfile.template.html");
# print $var->parse( // aanroep om "dailer.template.htm" te parsen
# array(
# "link" => $templateLink, // in het template bestand word "%[link]% vervangen door de waarde in $templateLink
# )
# );
#
######
# Door: Willem de Vries
# Voor: Virtual Pc Services
#
######
# Changelog:
# 1.0 (WdV 7-11-2003): statische functie ombouwen naar object
# 1.1 (WdV 13-2-2004): parsen moet ook zonder parameters kunnen
# 1.2 (JF 15-2-2004): Set functie toegevoegd om variablen aan template toe te voegen, aaroep: set(variablenaam, value)
# 1.3 (JF 24-3-2004): Endless loop bug gefixed, bij openen van template kwam hij bij lege file of file zonder
# regeleinde niet bij eof bij lezen van filesize.
# 1.4 (WdV 04-3-2005): Nieuwe functie om default-waardes uit een HTML-comment veld te halen.
# 2.0 (WdV 09-2-2005): grotendeels herschreven refresh() en parse() routine. Nu 50% sneller!
# 2.1 (WdV 15-2-2005): Mogelijkheid om een template aan te maken vanuit een string ipv. een file uit te lezen
# 2.2 (WdV 28-10-2005): On-the-fly compressie om geheugen te sparen, kleinere array properties
# 2.3 (WdV 15-12-2005): Gebruik van de "TEMPLATE_SEARCH" superglobal om een (relatief) zoekpad op te geven waarin
# templates gezocht moeten worden.
# 2.4 (WdV: 3-5-2006): bugfix - gebruik geen som-tekens met arrays!
###############################################################
function _slashjoin() {
$out = array();
foreach(func_get_args() as $param) {
if ($param)
$out[] = $param;
}
return preg_replace('#([/]+)#', '/', join('/', $out));
}
function _dirlist($str, $regex = '.*') {
$out = array();
$dh = (is_dir($str)) ? @opendir($str) : null;
while ($dh and $fil = readdir($dh)) {
$out[] = _slashjoin($str, $fil);
}
if ( !$out) return;
list($item) = array_values(preg_grep("|$regex|i", $out));
# error_log(__FUNCTION__ . " Matching items for |$regex|");
# error_log(__FUNCTION__ . " Subdirs in $str: " . join('|', $out));
# error_log(__FUNCTION__ . " Found dir '$item'");
return ($item) ? $item : $str;
}
class Template {
var $fn = null;
var $filename = null;
var $ch = null;
var $error = null;
var $searchpath = null;
var $searchdir = null;
var $inf = null;
var $def = null;
var $me = 'object';
var $vars = array();
function Template($name) {
# Compatibility
$this->filename =& $this->fn;
$this->me = strtoupper(get_class($this));
$this->searchpath = $GLOBALS[$this->me . "_SEARCH"];
if (defined($this->me . "_COMPRESS")) {
foreach(array(array('gzcompress', 'gzuncompress'), array('gzdeflate', 'gzinflate')) as $grp) {
if (function_exists($grp[0])) {
$this->def = $grp[0];
$this->inf = $grp[1];
break;
}
}
}
$this->fn = $name;
$this->refresh();
}
function set($varname, $value = ''){
$this->vars[$varname] = $value;
}
function get($varname) {
return $this->vars[$varname];
}
function refresh() {
if (!preg_match('/\.([^\.\/\s]+)$/', $this->fn, $found) ) {
$this->cached($this->fn);
$this->fn = null;
$this->error = null;
return;
}
# Implementatie zoekpad
$subdirs = preg_split('/([\s]*;[\s]*)/', $this->searchpath);
if (! $subdirs)
$subdirs = array('');
list($a, $up, $b, $path) = preg_match('/^(([\.]+\/)*)(.+)/', $this->fn, $found) ? $found : array('', '', '', $found[0]);
foreach($subdirs as $subdir) {
$sub = _slashjoin($up, $subdir);
# Wanneer de basis zoekdirectory niet bestaat, dan controleren we nog even
# of deze naam niet partieel voorkomt ergens in de boom. Zie functie _dirlist().
if ($subdir and !is_dir($sub)) {
$sub = _dirlist(dirname($sub), preg_replace('/([^0-9a-z]+)$/', '', $subdir) );
}
$this->searchdir = _slashjoin($sub, $path);
$exists = (file_exists($this->searchdir) and filesize($this->searchdir) > 0);
if ($exists) {
$this->searchpath = $sub;
break;
}
}
$readable = ($exists and is_readable($this->searchdir) );
$soort = ($readable) ? filetype($this->searchdir) : "";
if ($readable and $soort == "file") {
$this->cached( join('', file($this->searchdir)) );
$this->error = null;
} elseif (!$exists) {
$this->error( sprintf("'%s' bestaat niet.", $this->searchdir) );
} elseif (!$readable) {
$this->error( sprintf("'%s' kan niet worden gelezen.", $this->searchdir) );
} elseif ($exists && $soort != "file") {
$this->error( sprintf("'%s' is geen geldig bestand; %s", $this->searchdir, $soort) );
}
return;
}
function error($str) {
$text = sprintf('%s %s [in %s]', $this->me, $str, $_SERVER['SCRIPT_NAME']);
$this->error = $text;
if ($_SERVER['IS_DEVEL'] and $this->error) error_log($this->error);
}
function parse($vars = array()) {
$vars = array_merge($vars, $this->vars);
if ($this->searchpath)
# Voeg een slash toe aan het einde van het pad - templates verwachten dit!
$vars['_searchpath'] = trim(_slashjoin($this->searchpath, ' '));
$match = array();
$repl = array();
foreach(array_keys($vars) as $key){
$match[] = sprintf("/(%%\[%s\]%%)/i", preg_quote($key));
$repl[] = $vars[$key];
}
$match[] = '/%\[[^\[\]]+\]%/'; # Catch all
$repl[] = '';
return preg_replace($match, $repl, $this->cached());
}
function extractData() {
$reg = '/<\!--(\s*([^=\s\<\>]+)[\s=]+[\'"]?([^\'"\s\<\>]+))+\s*-->/';
$comment = '/<\!--\s*(.+)\s*-->/';
$fields = '/([^=\s<>]+)[\s=]+([\'\"])?([^\s<>\2]+)/';
if (! preg_match_all($comment, $this->cached(), $found) )
return false;
foreach($found[1] as $line) {
preg_match_all($fields, $line, $res);
for($i=0; $i < sizeof($res[0]); $i++) {
$this->vars[$res[1][$i]] = $res[3][$i];
}
}
return $this->vars;
}
function cached($str = null) {
if (is_null($str)) {
#request
$do = $this->inf;
return ($this->compressed() and $this->ch) ? $do($this->ch) : $this->ch;
}
$do = $this->def;
$this->ch = ($this->compressed()) ? $do($str, 9) : $str;
}
function compressed() {
return ($this->inf || $this->def);
}
}
# EOF
?>
define('RANDOMCHARS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
function make_randomkey($length=32,$customkeys=false) {
$keychars = ($customkeys) ? $customkeys : RANDOMCHARS;
$randkey = "";
for ($i=0;$i<$length;$i++)
$randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);
return $randkey;
}
function scan_dir($dir,$showfiles = true) {
$files = glob("$dir/*", (!$showfiles) ? GLOB_ONLYDIR : null);
$out = array();
while($files and $path = array_shift($files)) {
$fil = array_pop(explode('/', $path));
$out[$fil] = $path;
}
return $out;
}
function read_specs($dir) {
$specs = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
if(file_exists("$dir/$fil/disabled.txt")) {
continue;
}
$specs[] = $fil;
}
if ($dh) closedir($dh);
sort($specs);
$out = array();
foreach($specs as $spec) {
$sdir = sprintf('%s/%s',$dir,$spec);
$tmp = read_dir($sdir,false);
$my = array();
foreach(array_keys($tmp) as $item) {
$my[] = $item;
}
$out[$spec] = $my;
}
return $out;
}
function read_dir($dir,$showfiles=true) {
$files = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($showfiles) {
if($fil{0} == '.' or is_dir("$dir/$fil") ) continue;
} else {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
}
if(file_exists("$dir/$fil/disabled.txt")) {
#var_dump("$dir/$fil = disabled");
continue;
}
$files[] = $fil;
}
if ($dh) closedir($dh);
sort($files);
$out = array();
foreach($files as $fil) {
$out[$fil] = sprintf('%s/%s',$dir,$fil);
}
return $out;
}
function ad_templates($dir='templates') {
$files = read_dir($dir);
$tpls = array();
if(count($files)>0) {
foreach(array_keys($files) as $tpl) {
$t = str_replace('.template.html','',$tpl);
$tpls[$t] = new Template($files[$tpl]);
}
}
return $tpls;
}
function readXML($XMLfile) {
$tpl = new Template($XMLfile);
return fromXML($tpl->parse());
$data = (file_exists($XMLfile)) ? array_map("trim", file($XMLfile)) : array();
if (! $data) $data = array();
$content = join("", $data);
$content = preg_replace('/\<\?.+\?\>/', '', $content);
$content = preg_replace('/&/', '&', $content);
$struct = fromXML(str_replace('&', '&', $content));
return $struct;
}
function ad_data($dir) {
$configfile = sprintf('%s/%s', $dir, DATA_FILE);
if (! file_exists($configfile) ) {
error_log("Geen configfile in $dir");
return;
}
$txt = join('', @file($configfile));
$config = fromXML($txt);
if (is_null($config) ) return;
$config['dir'] = ( preg_match('/docs(\/.+)$/', $dir, $found) ) ? $found[1] : $dir;
# als xml geen 'name' tag heeft dan klopt onderstaande regel dus niet, moet ff fixen nog eens
$config['episode'] = ($item = explode('/', $dir) ) ? $item[sizeof($item)-1] : $config['name'];
return $config;
}
function custom_styles($css,$post) {
if(!$css) return array();
$out = array();
foreach(array_keys($css) as $style) {
$out[$style] = ($post[$style]) ? $post[$style] : $css[$style];
}
return $out;
}
function fontsize($font='Verdana') {
$sizes = array(
'Arial' => 11,
'Georgia' => 11,
'Tahoma' => 11,
'Times New Roman' => 11,
'Verdana' => 11,
);
return ($sizes[$font]) ? $sizes[$font] : 11;
}
function fix_url($url,$CGI) {
$chk = explode('?',$url);
$params = sprintf('p=%s&pi=%s',$CGI['p'],$CGI['pi']);
$chk[1] = ($chk[1]) ? sprintf('%s&%s',$chk[1],$params) : $params;
return join('?',$chk);
}
function create_ad($css=array(),$files=array(),$data,$params,$tpl) {
$trailer_url = ($data['trailer_url']) ? sprintf('http://%s/?trailer=%s&%s',$data['trailer_url'],$data['episode'],$params)
: sprintf('http://%s/?%s',$data['site_url'],$params);
$vars = array(
'key' => make_randomkey(10),
'params' => $params,
'site_url' => $data['site_url'],
'site_naam' => $data['site_naam'],
'trailer_url' => $trailer_url,
'trailer_txt' => ($data['trailer_url']) ? 'Trailer' : 'Website',
'episode' => $data['episode'],
'voice_url' => $data['voice_url'],
'datum' => strftime("%e %b %Y",strtotime($data['datum'])),
'tekst' => htmlentities($data['tekst']),
'textsize' => fontsize($css['textfont']),
);
return $tpl->parse(array_merge($vars,$files,$css));
}
?> Reality Film:
###################### Template Class ####################
#
# Met de class Template is het mogelijk om in een template bestand bepaalde variable-waarden te plaatsen.
# dit maakt het makkelijker voor disgners om een layout te veranderen zonder php te hoeven gebruiken.
# De template file kan elk normaal ascii bestand zijn en kan bestaan uit HTML, gewone tekst etc etc.
# Het model wat word vervangen heeft het volgende formaat: %[(a-z)]%
#
# Vereiste variabelen:
# $vars -- Een array gevuld met sleutel waarden die in het template bestand moeten worden
# vervangen en de daarbijbehordende nieuwe waarden.
#
# Het systeem is:
# - Hoofdletter ongevoelig,
# - Alfanumerieke tekens en _ worden geaccepteerd,
#
# Vb.:
# $var = new Template("textfile.template.html");
# print $var->parse( // aanroep om "dailer.template.htm" te parsen
# array(
# "link" => $templateLink, // in het template bestand word "%[link]% vervangen door de waarde in $templateLink
# )
# );
#
######
# Door: Willem de Vries
# Voor: Virtual Pc Services
#
######
# Changelog:
# 1.0 (WdV 7-11-2003): statische functie ombouwen naar object
# 1.1 (WdV 13-2-2004): parsen moet ook zonder parameters kunnen
# 1.2 (JF 15-2-2004): Set functie toegevoegd om variablen aan template toe te voegen, aaroep: set(variablenaam, value)
# 1.3 (JF 24-3-2004): Endless loop bug gefixed, bij openen van template kwam hij bij lege file of file zonder
# regeleinde niet bij eof bij lezen van filesize.
# 1.4 (WdV 04-3-2005): Nieuwe functie om default-waardes uit een HTML-comment veld te halen.
# 2.0 (WdV 09-2-2005): grotendeels herschreven refresh() en parse() routine. Nu 50% sneller!
# 2.1 (WdV 15-2-2005): Mogelijkheid om een template aan te maken vanuit een string ipv. een file uit te lezen
# 2.2 (WdV 28-10-2005): On-the-fly compressie om geheugen te sparen, kleinere array properties
# 2.3 (WdV 15-12-2005): Gebruik van de "TEMPLATE_SEARCH" superglobal om een (relatief) zoekpad op te geven waarin
# templates gezocht moeten worden.
# 2.4 (WdV: 3-5-2006): bugfix - gebruik geen som-tekens met arrays!
###############################################################
function _slashjoin() {
$out = array();
foreach(func_get_args() as $param) {
if ($param)
$out[] = $param;
}
return preg_replace('#([/]+)#', '/', join('/', $out));
}
function _dirlist($str, $regex = '.*') {
$out = array();
$dh = (is_dir($str)) ? @opendir($str) : null;
while ($dh and $fil = readdir($dh)) {
$out[] = _slashjoin($str, $fil);
}
if ( !$out) return;
list($item) = array_values(preg_grep("|$regex|i", $out));
# error_log(__FUNCTION__ . " Matching items for |$regex|");
# error_log(__FUNCTION__ . " Subdirs in $str: " . join('|', $out));
# error_log(__FUNCTION__ . " Found dir '$item'");
return ($item) ? $item : $str;
}
class Template {
var $fn = null;
var $filename = null;
var $ch = null;
var $error = null;
var $searchpath = null;
var $searchdir = null;
var $inf = null;
var $def = null;
var $me = 'object';
var $vars = array();
function Template($name) {
# Compatibility
$this->filename =& $this->fn;
$this->me = strtoupper(get_class($this));
$this->searchpath = $GLOBALS[$this->me . "_SEARCH"];
if (defined($this->me . "_COMPRESS")) {
foreach(array(array('gzcompress', 'gzuncompress'), array('gzdeflate', 'gzinflate')) as $grp) {
if (function_exists($grp[0])) {
$this->def = $grp[0];
$this->inf = $grp[1];
break;
}
}
}
$this->fn = $name;
$this->refresh();
}
function set($varname, $value = ''){
$this->vars[$varname] = $value;
}
function get($varname) {
return $this->vars[$varname];
}
function refresh() {
if (!preg_match('/\.([^\.\/\s]+)$/', $this->fn, $found) ) {
$this->cached($this->fn);
$this->fn = null;
$this->error = null;
return;
}
# Implementatie zoekpad
$subdirs = preg_split('/([\s]*;[\s]*)/', $this->searchpath);
if (! $subdirs)
$subdirs = array('');
list($a, $up, $b, $path) = preg_match('/^(([\.]+\/)*)(.+)/', $this->fn, $found) ? $found : array('', '', '', $found[0]);
foreach($subdirs as $subdir) {
$sub = _slashjoin($up, $subdir);
# Wanneer de basis zoekdirectory niet bestaat, dan controleren we nog even
# of deze naam niet partieel voorkomt ergens in de boom. Zie functie _dirlist().
if ($subdir and !is_dir($sub)) {
$sub = _dirlist(dirname($sub), preg_replace('/([^0-9a-z]+)$/', '', $subdir) );
}
$this->searchdir = _slashjoin($sub, $path);
$exists = (file_exists($this->searchdir) and filesize($this->searchdir) > 0);
if ($exists) {
$this->searchpath = $sub;
break;
}
}
$readable = ($exists and is_readable($this->searchdir) );
$soort = ($readable) ? filetype($this->searchdir) : "";
if ($readable and $soort == "file") {
$this->cached( join('', file($this->searchdir)) );
$this->error = null;
} elseif (!$exists) {
$this->error( sprintf("'%s' bestaat niet.", $this->searchdir) );
} elseif (!$readable) {
$this->error( sprintf("'%s' kan niet worden gelezen.", $this->searchdir) );
} elseif ($exists && $soort != "file") {
$this->error( sprintf("'%s' is geen geldig bestand; %s", $this->searchdir, $soort) );
}
return;
}
function error($str) {
$text = sprintf('%s %s [in %s]', $this->me, $str, $_SERVER['SCRIPT_NAME']);
$this->error = $text;
if ($_SERVER['IS_DEVEL'] and $this->error) error_log($this->error);
}
function parse($vars = array()) {
$vars = array_merge($vars, $this->vars);
if ($this->searchpath)
# Voeg een slash toe aan het einde van het pad - templates verwachten dit!
$vars['_searchpath'] = trim(_slashjoin($this->searchpath, ' '));
$match = array();
$repl = array();
foreach(array_keys($vars) as $key){
$match[] = sprintf("/(%%\[%s\]%%)/i", preg_quote($key));
$repl[] = $vars[$key];
}
$match[] = '/%\[[^\[\]]+\]%/'; # Catch all
$repl[] = '';
return preg_replace($match, $repl, $this->cached());
}
function extractData() {
$reg = '/<\!--(\s*([^=\s\<\>]+)[\s=]+[\'"]?([^\'"\s\<\>]+))+\s*-->/';
$comment = '/<\!--\s*(.+)\s*-->/';
$fields = '/([^=\s<>]+)[\s=]+([\'\"])?([^\s<>\2]+)/';
if (! preg_match_all($comment, $this->cached(), $found) )
return false;
foreach($found[1] as $line) {
preg_match_all($fields, $line, $res);
for($i=0; $i < sizeof($res[0]); $i++) {
$this->vars[$res[1][$i]] = $res[3][$i];
}
}
return $this->vars;
}
function cached($str = null) {
if (is_null($str)) {
#request
$do = $this->inf;
return ($this->compressed() and $this->ch) ? $do($this->ch) : $this->ch;
}
$do = $this->def;
$this->ch = ($this->compressed()) ? $do($str, 9) : $str;
}
function compressed() {
return ($this->inf || $this->def);
}
}
# EOF
?>
define('RANDOMCHARS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
function make_randomkey($length=32,$customkeys=false) {
$keychars = ($customkeys) ? $customkeys : RANDOMCHARS;
$randkey = "";
for ($i=0;$i<$length;$i++)
$randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);
return $randkey;
}
function scan_dir($dir,$showfiles = true) {
$files = glob("$dir/*", (!$showfiles) ? GLOB_ONLYDIR : null);
$out = array();
while($files and $path = array_shift($files)) {
$fil = array_pop(explode('/', $path));
$out[$fil] = $path;
}
return $out;
}
function read_specs($dir) {
$specs = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
if(file_exists("$dir/$fil/disabled.txt")) {
continue;
}
$specs[] = $fil;
}
if ($dh) closedir($dh);
sort($specs);
$out = array();
foreach($specs as $spec) {
$sdir = sprintf('%s/%s',$dir,$spec);
$tmp = read_dir($sdir,false);
$my = array();
foreach(array_keys($tmp) as $item) {
$my[] = $item;
}
$out[$spec] = $my;
}
return $out;
}
function read_dir($dir,$showfiles=true) {
$files = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($showfiles) {
if($fil{0} == '.' or is_dir("$dir/$fil") ) continue;
} else {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
}
if(file_exists("$dir/$fil/disabled.txt")) {
#var_dump("$dir/$fil = disabled");
continue;
}
$files[] = $fil;
}
if ($dh) closedir($dh);
sort($files);
$out = array();
foreach($files as $fil) {
$out[$fil] = sprintf('%s/%s',$dir,$fil);
}
return $out;
}
function ad_templates($dir='templates') {
$files = read_dir($dir);
$tpls = array();
if(count($files)>0) {
foreach(array_keys($files) as $tpl) {
$t = str_replace('.template.html','',$tpl);
$tpls[$t] = new Template($files[$tpl]);
}
}
return $tpls;
}
function readXML($XMLfile) {
$tpl = new Template($XMLfile);
return fromXML($tpl->parse());
$data = (file_exists($XMLfile)) ? array_map("trim", file($XMLfile)) : array();
if (! $data) $data = array();
$content = join("", $data);
$content = preg_replace('/\<\?.+\?\>/', '', $content);
$content = preg_replace('/&/', '&', $content);
$struct = fromXML(str_replace('&', '&', $content));
return $struct;
}
function ad_data($dir) {
$configfile = sprintf('%s/%s', $dir, DATA_FILE);
if (! file_exists($configfile) ) {
error_log("Geen configfile in $dir");
return;
}
$txt = join('', @file($configfile));
$config = fromXML($txt);
if (is_null($config) ) return;
$config['dir'] = ( preg_match('/docs(\/.+)$/', $dir, $found) ) ? $found[1] : $dir;
# als xml geen 'name' tag heeft dan klopt onderstaande regel dus niet, moet ff fixen nog eens
$config['episode'] = ($item = explode('/', $dir) ) ? $item[sizeof($item)-1] : $config['name'];
return $config;
}
function custom_styles($css,$post) {
if(!$css) return array();
$out = array();
foreach(array_keys($css) as $style) {
$out[$style] = ($post[$style]) ? $post[$style] : $css[$style];
}
return $out;
}
function fontsize($font='Verdana') {
$sizes = array(
'Arial' => 11,
'Georgia' => 11,
'Tahoma' => 11,
'Times New Roman' => 11,
'Verdana' => 11,
);
return ($sizes[$font]) ? $sizes[$font] : 11;
}
function fix_url($url,$CGI) {
$chk = explode('?',$url);
$params = sprintf('p=%s&pi=%s',$CGI['p'],$CGI['pi']);
$chk[1] = ($chk[1]) ? sprintf('%s&%s',$chk[1],$params) : $params;
return join('?',$chk);
}
function create_ad($css=array(),$files=array(),$data,$params,$tpl) {
$trailer_url = ($data['trailer_url']) ? sprintf('http://%s/?trailer=%s&%s',$data['trailer_url'],$data['episode'],$params)
: sprintf('http://%s/?%s',$data['site_url'],$params);
$vars = array(
'key' => make_randomkey(10),
'params' => $params,
'site_url' => $data['site_url'],
'site_naam' => $data['site_naam'],
'trailer_url' => $trailer_url,
'trailer_txt' => ($data['trailer_url']) ? 'Trailer' : 'Website',
'episode' => $data['episode'],
'voice_url' => $data['voice_url'],
'datum' => strftime("%e %b %Y",strtotime($data['datum'])),
'tekst' => htmlentities($data['tekst']),
'textsize' => fontsize($css['textfont']),
);
return $tpl->parse(array_merge($vars,$files,$css));
}
?> Amateur Film:
###################### Template Class ####################
#
# Met de class Template is het mogelijk om in een template bestand bepaalde variable-waarden te plaatsen.
# dit maakt het makkelijker voor disgners om een layout te veranderen zonder php te hoeven gebruiken.
# De template file kan elk normaal ascii bestand zijn en kan bestaan uit HTML, gewone tekst etc etc.
# Het model wat word vervangen heeft het volgende formaat: %[(a-z)]%
#
# Vereiste variabelen:
# $vars -- Een array gevuld met sleutel waarden die in het template bestand moeten worden
# vervangen en de daarbijbehordende nieuwe waarden.
#
# Het systeem is:
# - Hoofdletter ongevoelig,
# - Alfanumerieke tekens en _ worden geaccepteerd,
#
# Vb.:
# $var = new Template("textfile.template.html");
# print $var->parse( // aanroep om "dailer.template.htm" te parsen
# array(
# "link" => $templateLink, // in het template bestand word "%[link]% vervangen door de waarde in $templateLink
# )
# );
#
######
# Door: Willem de Vries
# Voor: Virtual Pc Services
#
######
# Changelog:
# 1.0 (WdV 7-11-2003): statische functie ombouwen naar object
# 1.1 (WdV 13-2-2004): parsen moet ook zonder parameters kunnen
# 1.2 (JF 15-2-2004): Set functie toegevoegd om variablen aan template toe te voegen, aaroep: set(variablenaam, value)
# 1.3 (JF 24-3-2004): Endless loop bug gefixed, bij openen van template kwam hij bij lege file of file zonder
# regeleinde niet bij eof bij lezen van filesize.
# 1.4 (WdV 04-3-2005): Nieuwe functie om default-waardes uit een HTML-comment veld te halen.
# 2.0 (WdV 09-2-2005): grotendeels herschreven refresh() en parse() routine. Nu 50% sneller!
# 2.1 (WdV 15-2-2005): Mogelijkheid om een template aan te maken vanuit een string ipv. een file uit te lezen
# 2.2 (WdV 28-10-2005): On-the-fly compressie om geheugen te sparen, kleinere array properties
# 2.3 (WdV 15-12-2005): Gebruik van de "TEMPLATE_SEARCH" superglobal om een (relatief) zoekpad op te geven waarin
# templates gezocht moeten worden.
# 2.4 (WdV: 3-5-2006): bugfix - gebruik geen som-tekens met arrays!
###############################################################
function _slashjoin() {
$out = array();
foreach(func_get_args() as $param) {
if ($param)
$out[] = $param;
}
return preg_replace('#([/]+)#', '/', join('/', $out));
}
function _dirlist($str, $regex = '.*') {
$out = array();
$dh = (is_dir($str)) ? @opendir($str) : null;
while ($dh and $fil = readdir($dh)) {
$out[] = _slashjoin($str, $fil);
}
if ( !$out) return;
list($item) = array_values(preg_grep("|$regex|i", $out));
# error_log(__FUNCTION__ . " Matching items for |$regex|");
# error_log(__FUNCTION__ . " Subdirs in $str: " . join('|', $out));
# error_log(__FUNCTION__ . " Found dir '$item'");
return ($item) ? $item : $str;
}
class Template {
var $fn = null;
var $filename = null;
var $ch = null;
var $error = null;
var $searchpath = null;
var $searchdir = null;
var $inf = null;
var $def = null;
var $me = 'object';
var $vars = array();
function Template($name) {
# Compatibility
$this->filename =& $this->fn;
$this->me = strtoupper(get_class($this));
$this->searchpath = $GLOBALS[$this->me . "_SEARCH"];
if (defined($this->me . "_COMPRESS")) {
foreach(array(array('gzcompress', 'gzuncompress'), array('gzdeflate', 'gzinflate')) as $grp) {
if (function_exists($grp[0])) {
$this->def = $grp[0];
$this->inf = $grp[1];
break;
}
}
}
$this->fn = $name;
$this->refresh();
}
function set($varname, $value = ''){
$this->vars[$varname] = $value;
}
function get($varname) {
return $this->vars[$varname];
}
function refresh() {
if (!preg_match('/\.([^\.\/\s]+)$/', $this->fn, $found) ) {
$this->cached($this->fn);
$this->fn = null;
$this->error = null;
return;
}
# Implementatie zoekpad
$subdirs = preg_split('/([\s]*;[\s]*)/', $this->searchpath);
if (! $subdirs)
$subdirs = array('');
list($a, $up, $b, $path) = preg_match('/^(([\.]+\/)*)(.+)/', $this->fn, $found) ? $found : array('', '', '', $found[0]);
foreach($subdirs as $subdir) {
$sub = _slashjoin($up, $subdir);
# Wanneer de basis zoekdirectory niet bestaat, dan controleren we nog even
# of deze naam niet partieel voorkomt ergens in de boom. Zie functie _dirlist().
if ($subdir and !is_dir($sub)) {
$sub = _dirlist(dirname($sub), preg_replace('/([^0-9a-z]+)$/', '', $subdir) );
}
$this->searchdir = _slashjoin($sub, $path);
$exists = (file_exists($this->searchdir) and filesize($this->searchdir) > 0);
if ($exists) {
$this->searchpath = $sub;
break;
}
}
$readable = ($exists and is_readable($this->searchdir) );
$soort = ($readable) ? filetype($this->searchdir) : "";
if ($readable and $soort == "file") {
$this->cached( join('', file($this->searchdir)) );
$this->error = null;
} elseif (!$exists) {
$this->error( sprintf("'%s' bestaat niet.", $this->searchdir) );
} elseif (!$readable) {
$this->error( sprintf("'%s' kan niet worden gelezen.", $this->searchdir) );
} elseif ($exists && $soort != "file") {
$this->error( sprintf("'%s' is geen geldig bestand; %s", $this->searchdir, $soort) );
}
return;
}
function error($str) {
$text = sprintf('%s %s [in %s]', $this->me, $str, $_SERVER['SCRIPT_NAME']);
$this->error = $text;
if ($_SERVER['IS_DEVEL'] and $this->error) error_log($this->error);
}
function parse($vars = array()) {
$vars = array_merge($vars, $this->vars);
if ($this->searchpath)
# Voeg een slash toe aan het einde van het pad - templates verwachten dit!
$vars['_searchpath'] = trim(_slashjoin($this->searchpath, ' '));
$match = array();
$repl = array();
foreach(array_keys($vars) as $key){
$match[] = sprintf("/(%%\[%s\]%%)/i", preg_quote($key));
$repl[] = $vars[$key];
}
$match[] = '/%\[[^\[\]]+\]%/'; # Catch all
$repl[] = '';
return preg_replace($match, $repl, $this->cached());
}
function extractData() {
$reg = '/<\!--(\s*([^=\s\<\>]+)[\s=]+[\'"]?([^\'"\s\<\>]+))+\s*-->/';
$comment = '/<\!--\s*(.+)\s*-->/';
$fields = '/([^=\s<>]+)[\s=]+([\'\"])?([^\s<>\2]+)/';
if (! preg_match_all($comment, $this->cached(), $found) )
return false;
foreach($found[1] as $line) {
preg_match_all($fields, $line, $res);
for($i=0; $i < sizeof($res[0]); $i++) {
$this->vars[$res[1][$i]] = $res[3][$i];
}
}
return $this->vars;
}
function cached($str = null) {
if (is_null($str)) {
#request
$do = $this->inf;
return ($this->compressed() and $this->ch) ? $do($this->ch) : $this->ch;
}
$do = $this->def;
$this->ch = ($this->compressed()) ? $do($str, 9) : $str;
}
function compressed() {
return ($this->inf || $this->def);
}
}
# EOF
?>
define('RANDOMCHARS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
function make_randomkey($length=32,$customkeys=false) {
$keychars = ($customkeys) ? $customkeys : RANDOMCHARS;
$randkey = "";
for ($i=0;$i<$length;$i++)
$randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);
return $randkey;
}
function scan_dir($dir,$showfiles = true) {
$files = glob("$dir/*", (!$showfiles) ? GLOB_ONLYDIR : null);
$out = array();
while($files and $path = array_shift($files)) {
$fil = array_pop(explode('/', $path));
$out[$fil] = $path;
}
return $out;
}
function read_specs($dir) {
$specs = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
if(file_exists("$dir/$fil/disabled.txt")) {
continue;
}
$specs[] = $fil;
}
if ($dh) closedir($dh);
sort($specs);
$out = array();
foreach($specs as $spec) {
$sdir = sprintf('%s/%s',$dir,$spec);
$tmp = read_dir($sdir,false);
$my = array();
foreach(array_keys($tmp) as $item) {
$my[] = $item;
}
$out[$spec] = $my;
}
return $out;
}
function read_dir($dir,$showfiles=true) {
$files = array();
if(!is_dir($dir)) return $files;
$dh = opendir($dir) or error_log("Geen dir: '$dir'");
while ($dh and $fil = readdir($dh)) {
if($showfiles) {
if($fil{0} == '.' or is_dir("$dir/$fil") ) continue;
} else {
if($fil{0} == '.' or !is_dir("$dir/$fil") ) continue;
}
if(file_exists("$dir/$fil/disabled.txt")) {
#var_dump("$dir/$fil = disabled");
continue;
}
$files[] = $fil;
}
if ($dh) closedir($dh);
sort($files);
$out = array();
foreach($files as $fil) {
$out[$fil] = sprintf('%s/%s',$dir,$fil);
}
return $out;
}
function ad_templates($dir='templates') {
$files = read_dir($dir);
$tpls = array();
if(count($files)>0) {
foreach(array_keys($files) as $tpl) {
$t = str_replace('.template.html','',$tpl);
$tpls[$t] = new Template($files[$tpl]);
}
}
return $tpls;
}
function readXML($XMLfile) {
$tpl = new Template($XMLfile);
return fromXML($tpl->parse());
$data = (file_exists($XMLfile)) ? array_map("trim", file($XMLfile)) : array();
if (! $data) $data = array();
$content = join("", $data);
$content = preg_replace('/\<\?.+\?\>/', '', $content);
$content = preg_replace('/&/', '&', $content);
$struct = fromXML(str_replace('&', '&', $content));
return $struct;
}
function ad_data($dir) {
$configfile = sprintf('%s/%s', $dir, DATA_FILE);
if (! file_exists($configfile) ) {
error_log("Geen configfile in $dir");
return;
}
$txt = join('', @file($configfile));
$config = fromXML($txt);
if (is_null($config) ) return;
$config['dir'] = ( preg_match('/docs(\/.+)$/', $dir, $found) ) ? $found[1] : $dir;
# als xml geen 'name' tag heeft dan klopt onderstaande regel dus niet, moet ff fixen nog eens
$config['episode'] = ($item = explode('/', $dir) ) ? $item[sizeof($item)-1] : $config['name'];
return $config;
}
function custom_styles($css,$post) {
if(!$css) return array();
$out = array();
foreach(array_keys($css) as $style) {
$out[$style] = ($post[$style]) ? $post[$style] : $css[$style];
}
return $out;
}
function fontsize($font='Verdana') {
$sizes = array(
'Arial' => 11,
'Georgia' => 11,
'Tahoma' => 11,
'Times New Roman' => 11,
'Verdana' => 11,
);
return ($sizes[$font]) ? $sizes[$font] : 11;
}
function fix_url($url,$CGI) {
$chk = explode('?',$url);
$params = sprintf('p=%s&pi=%s',$CGI['p'],$CGI['pi']);
$chk[1] = ($chk[1]) ? sprintf('%s&%s',$chk[1],$params) : $params;
return join('?',$chk);
}
function create_ad($css=array(),$files=array(),$data,$params,$tpl) {
$trailer_url = ($data['trailer_url']) ? sprintf('http://%s/?trailer=%s&%s',$data['trailer_url'],$data['episode'],$params)
: sprintf('http://%s/?%s',$data['site_url'],$params);
$vars = array(
'key' => make_randomkey(10),
'params' => $params,
'site_url' => $data['site_url'],
'site_naam' => $data['site_naam'],
'trailer_url' => $trailer_url,
'trailer_txt' => ($data['trailer_url']) ? 'Trailer' : 'Website',
'episode' => $data['episode'],
'voice_url' => $data['voice_url'],
'datum' => strftime("%e %b %Y",strtotime($data['datum'])),
'tekst' => htmlentities($data['tekst']),
'textsize' => fontsize($css['textfont']),
);
return $tpl->parse(array_merge($vars,$files,$css));
}
?>





