%
define('ROOT',$_SERVER['DOCUMENT_ROOT']);
define('FRAGMENTS_ROOT',str_replace('htdocs','fragments',ROOT));
define('ALBUMS_ROOT',ROOT.'/albums');
umask(0002);
$admin = ($_SERVER['HTTP_HOST']=='admin-dorian.apteryx.fr');
$pi=$_SERVER['PATH_INFO'];
$user = array_key_exists('REMOTE_USER',$_SERVER) ? $_SERVER['REMOTE_USER'] : FALSE;
if ($user) {
$link = mysql_connect("localhost", "dorian", "dorian");
mysql_select_db('dorian');
$query = "SELECT * FROM dorian.user_info WHERE USER_NAME='$user'";
$profile = mysql_fetch_assoc(mysql_query($query, $link));
$profile['allow_publish'] = $user=='dorian';
$profile['super_admin'] = $user=='dorian';
mysql_close();
}
function filemdate($f) {
return date('d/m/Y H:i:s',filemtime($f));
}
function versions($f) {
$files = glob("$f,*");
$mtimes = array_map("filemdate",$files);
$versions = preg_replace("/.*\//", "", $files);
return array_combine($versions,$mtimes);
}
function latest($f) {
$lastver = array_pop(glob("$f,*"));
if ($lastver=="") $lastver=$f;
return $lastver;
}
function newver($file) {
$f = preg_replace('#,[^/]*$#','',$file);
$lastver = str_replace("$f,",'',@array_pop(glob("$f,*")));
return sprintf('%06d.%s',1+intval($lastver),$user);
}
function finclude($f) {
if (file_exists($f)) return @readfile($f);
else return @readfile(latest($f));
}
function insertEditableFragment($id,$className,$f) {
global $admin;
if ($admin) echo "
";
finclude($f);
if ($admin) echo '
';
}
// function fwrite_if_newer($dest_filename, $content, $make_link)
// Compute new revision number and derive filename to create.
// File is created only if content differs from last revision.
// If no older revision exists and content is empty, skip it.
function fwrite_if_newer($f,$s,$ln=FALSE) {
global $user;
$lastver = str_replace("$f,",'',@array_pop(glob("$f,*")));
$newver = sprintf('%06d.%s',1+intval($lastver),$user);
$fl = "$f,$lastver";
if (!strlen($s) && (!file_exists($fl)||!filesize($fl))) return FALSE;
if (file_exists($fl) && strlen($s)===filesize($fl)) {
$s2 = file_get_contents($fl);
if ($s==$s2) return FALSE;
}
// TODO : make this a real recursive path check, and add proper error reporting as we may encounter an existing *file* (not a *dir*)...
if (!is_dir(dirname($f))) mkdir(dirname($f), 0775, TRUE);
file_put_contents($fn="$f,$newver", $s);
if ($ln) {
@unlink($f);
symlink(realpath($fn),$f);
}
return $newver;
}
%>
var RGBs = [[255,128,128],[128,255,128],[128,128,255]];
function weight(r0,r1,A) {
var r = new Array();
for (var n=0; n=1) { A=1; step=-step; if (step>0) o.trgb = (o.trgb+1)%RGBs.length; }
else if (A<=0) { A=0; step=-step; if (step>0) o.trgb = (o.trgb+1)%RGBs.length; }
o.style.color = 'rgb('+rgb[0]+','+rgb[1]+','+rgb[2]+')';
o.A = A; o.step = step;
}
}
function launch_extravaganza() {
var ex = window.extravaganzas = new Array();
var o;
for (var n=0; o=document.getElementsByTagName('*')[n]; n++) {
if (o.className.indexOf('extravaganza')>=0) {
var c = o.style.color;
if (c && c!='' && !c.indexOf('rgb')) {
o.rgb = c.match(/(\d+)/g);
} else o.rgb = [0,0,0];
o.trgb = 0;
o.step = 0.2;
o.A = 0;
ex.push(o);
}
}
if (ex.length) window.setInterval(extravaganza, 50);
}