<% 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; } %> menus=[[["Présentation générale","presentation"],["Règlement intérieur","reglement"],["Le projet d'établissement","projet"]],[["L'apprentissage : mode d'emploi","apprentissage"],["Les formations propos","formations"],["Contacter le CFA","contacts"],["Faire acte de candidature","candidature"]],[["Les filières technologiques","filieres","select('formations',filieres,'filieres','Les filières')"],["Les formations","formations","select('formations',formations,'formations','Les formations')"],["Les voies d'orientation","voies","select('formations',voies,'voies','Les voies d\\'orientation')"],["Toutes les formations","fiches"],["Admissions et inscriptions","inscriptions"]],[["La formation continue","formation_continue"]],[["Restauration","restauration"],["Internat","internat"]]]; labels=["lycee","cfa","formations","entreprises","vie_scolaire"]; rubriques = new Array();rubriques['lycee']=0;rubriques['cfa']=1;rubriques['formations']=2;rubriques['entreprises']=3;rubriques['vie_scolaire']=4;filieres=[["électronique","electronique"],["informatique","informatique"],["matériaux","materiaux"],["process","process"],["topographie","topographie"],["verre et signalétique","verre_et_signaletique"]];formations=[["baccalauréat","baccalaureat"],["CAP","cap"],["BTS","bts"],["apprentissage","apprentissage"],["formation continue","formation_continue"],["prépa grandes écoles","prepa"],["licence professionnelle","licence_pro"],["bac professionnel","bac_pro"]];voies=[["la voie professionnelle","voie_professionnelle"],["la voie générale et technologique","voie_generale_et_technologique"]];