commit
b2efb12390
3 changed files with 112 additions and 59 deletions
|
@ -13,6 +13,9 @@
|
||||||
// define( 'HEAD_TITLE', '');
|
// define( 'HEAD_TITLE', '');
|
||||||
// define( 'FOOTER', 'D\'après les premières versions de <a href="http://sebsauvage.net">SebSauvage</a> et <a href="http://bohwaz.net/">Bohwaz</a>.');
|
// define( 'FOOTER', 'D\'après les premières versions de <a href="http://sebsauvage.net">SebSauvage</a> et <a href="http://bohwaz.net/">Bohwaz</a>.');
|
||||||
|
|
||||||
|
// define( 'DOCS_CACHE_DURATION', 1800);
|
||||||
|
// define( 'AUTOBLOGS_CACHE_DURATION', 1800);
|
||||||
|
|
||||||
// define( 'ALLOW_FULL_UPDATE', TRUE );
|
// define( 'ALLOW_FULL_UPDATE', TRUE );
|
||||||
// define( 'ALLOW_CHECK_UPDATE', TRUE );
|
// define( 'ALLOW_CHECK_UPDATE', TRUE );
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ if (!defined('FOLDER_MAX_LENGTH')) define('FOLDER_MAX_LENGTH', 80);
|
||||||
date_default_timezone_set('Europe/Paris');
|
date_default_timezone_set('Europe/Paris');
|
||||||
setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'fr');
|
setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'fr');
|
||||||
|
|
||||||
|
if( !defined('DOCS_CACHE_DURATION')) define( 'DOCS_CACHE_DURATION', 1800 );
|
||||||
|
if( !defined('AUTOBLOGS_CACHE_DURATION')) define( 'AUTOBLOGS_CACHE_DURATION', 1800 );
|
||||||
|
|
||||||
if( !defined('ALLOW_FULL_UPDATE')) define( 'ALLOW_FULL_UPDATE', TRUE );
|
if( !defined('ALLOW_FULL_UPDATE')) define( 'ALLOW_FULL_UPDATE', TRUE );
|
||||||
if( !defined('ALLOW_CHECK_UPDATE')) define( 'ALLOW_CHECK_UPDATE', TRUE );
|
if( !defined('ALLOW_CHECK_UPDATE')) define( 'ALLOW_CHECK_UPDATE', TRUE );
|
||||||
|
|
||||||
|
|
165
index.php
165
index.php
|
@ -204,7 +204,7 @@ function svg_status($fill, $text, $back)
|
||||||
$svg_ok=svg_status('#008000', 'ok', '');
|
$svg_ok=svg_status('#008000', 'ok', '');
|
||||||
$svg_mv=svg_status('#0000ff', 'mv', '<rect width="100%" height="100%" fill="#ffd800"/>');
|
$svg_mv=svg_status('#0000ff', 'mv', '<rect width="100%" height="100%" fill="#ffd800"/>');
|
||||||
$svg_err=svg_status('#000000', 'err', '<rect width="100%" height="100%" fill="#ff0000"/>');
|
$svg_err=svg_status('#000000', 'err', '<rect width="100%" height="100%" fill="#ff0000"/>');
|
||||||
|
|
||||||
$errorlog="./".escape( $_GET['check'] ) ."/error.log";
|
$errorlog="./".escape( $_GET['check'] ) ."/error.log";
|
||||||
|
|
||||||
$oldvalue = null;
|
$oldvalue = null;
|
||||||
|
@ -261,8 +261,8 @@ if (isset($_GET['export'])) {
|
||||||
|
|
||||||
foreach($subdirs as $unit) {
|
foreach($subdirs as $unit) {
|
||||||
if(is_dir($unit)) {
|
if(is_dir($unit)) {
|
||||||
$unit=substr($unit, 2);
|
|
||||||
$ini = parse_ini_file($unit.'/vvb.ini');
|
$ini = parse_ini_file($unit.'/vvb.ini');
|
||||||
|
$unit=substr($unit, 2);
|
||||||
$config = new stdClass;
|
$config = new stdClass;
|
||||||
|
|
||||||
foreach ($ini as $key=>$value) {
|
foreach ($ini as $key=>$value) {
|
||||||
|
@ -327,7 +327,7 @@ if (isset($_GET['exportopml'])) // OPML
|
||||||
|
|
||||||
foreach($subdirs as $unit) {
|
foreach($subdirs as $unit) {
|
||||||
if(is_dir($unit)) {
|
if(is_dir($unit)) {
|
||||||
$unit=substr($unit, 2);
|
$unit=substr($unit, 2);
|
||||||
$ini = parse_ini_file($unit.'/vvb.ini');
|
$ini = parse_ini_file($unit.'/vvb.ini');
|
||||||
$config = new stdClass;
|
$config = new stdClass;
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ if (isset($_GET['sitemap']))
|
||||||
$subdirs = glob(AUTOBLOGS_FOLDER . "*");
|
$subdirs = glob(AUTOBLOGS_FOLDER . "*");
|
||||||
foreach($subdirs as $unit) {
|
foreach($subdirs as $unit) {
|
||||||
if(is_dir($unit)) {
|
if(is_dir($unit)) {
|
||||||
$unit=substr($unit, 2);
|
$unit=substr($unit, 2);
|
||||||
echo "<url>\n <loc>".$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."</loc>\n";
|
echo "<url>\n <loc>".$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."</loc>\n";
|
||||||
echo ' <lastmod>'.date('c', filemtime($unit))."</lastmod>\n";
|
echo ' <lastmod>'.date('c', filemtime($unit))."</lastmod>\n";
|
||||||
echo " <changefreq>hourly</changefreq>\n</url>\n\n";
|
echo " <changefreq>hourly</changefreq>\n</url>\n\n";
|
||||||
|
@ -832,7 +832,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
||||||
<input type="submit" value="Créer" />
|
<input type="submit" value="Créer" />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<?php }
|
<?php }
|
||||||
if(ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE == TRUE) { ?>
|
if(ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE == TRUE) { ?>
|
||||||
<section class="form" id="add_opmlfile">
|
<section class="form" id="add_opmlfile">
|
||||||
<header>
|
<header>
|
||||||
|
@ -847,7 +847,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
||||||
<input type='submit' value='Importer' />
|
<input type='submit' value='Importer' />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<?php }
|
<?php }
|
||||||
if(ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK == TRUE) { ?>
|
if(ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK == TRUE) { ?>
|
||||||
<section class="form" id="add_opmllink">
|
<section class="form" id="add_opmllink">
|
||||||
<header>
|
<header>
|
||||||
|
@ -862,7 +862,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
||||||
<input type="submit" value="Envoyer" />
|
<input type="submit" value="Envoyer" />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<?php }
|
<?php }
|
||||||
if(ALLOW_NEW_AUTOBLOGS_BY_BUTTON == TRUE) { ?>
|
if(ALLOW_NEW_AUTOBLOGS_BY_BUTTON == TRUE) { ?>
|
||||||
<section class="form" id="add_bookmark">
|
<section class="form" id="add_bookmark">
|
||||||
<header>
|
<header>
|
||||||
|
@ -878,37 +878,59 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
||||||
</section>
|
</section>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</section>
|
</section>
|
||||||
<?php } ?>
|
<?php }
|
||||||
<?php
|
$fichierCache = 'docs.cache';
|
||||||
$directory = DOC_FOLDER;
|
// si la page n'existe pas dans le cache ou si elle a expiré (durée paramétrable)
|
||||||
$docs = array();
|
// on lance la génération de la page et on la stoke dans un fichier
|
||||||
if( is_dir($directory) && !file_exists($directory . '.disabled') ) {
|
if (@filemtime($fichierCache)<time()-(DOCS_CACHE_DURATION)) {
|
||||||
$subdirs = glob($directory . "*");
|
// on démarre la bufferisation : rien n'est envoyé au navigateur
|
||||||
foreach($subdirs as $unit) {
|
ob_start();
|
||||||
if(!is_dir($unit) || file_exists( $unit . '/index.html' ) || file_exists( $unit . '/index.htm' ) || file_exists( $unit . '/index.php' ) ) {
|
|
||||||
$size = '';
|
$directory = DOC_FOLDER;
|
||||||
if ( is_file($unit) ) { $size = get_size($unit); }
|
$docs = array();
|
||||||
|
if( is_dir($directory) && !file_exists($directory . '.disabled') ) {
|
||||||
|
$subdirs = glob($directory . "*");
|
||||||
|
foreach($subdirs as $unit) {
|
||||||
|
if(!is_dir($unit) || file_exists( $unit . '/index.html' ) || file_exists( $unit . '/index.htm' ) || file_exists( $unit . '/index.php' ) ) {
|
||||||
|
$size = '';
|
||||||
|
if ( is_file($unit) ) { $size = get_size($unit); }
|
||||||
$docs[] = array('<a href="'. preg_replace('~ ~', '%20', $unit) . '">'. substr($unit, (strrpos($unit, '/')) + 1 ) .'</a>', $size);
|
$docs[] = array('<a href="'. preg_replace('~ ~', '%20', $unit) . '">'. substr($unit, (strrpos($unit, '/')) + 1 ) .'</a>', $size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if(!empty( $docs )) {
|
||||||
if(!empty( $docs )) {
|
echo ' <section id="docs">
|
||||||
echo '<section id="docs">
|
|
||||||
<header>
|
<header>
|
||||||
<h2>Autres documents</h2>
|
<h2>Autres documents</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<ul>'."\n";
|
<ul>'."\n";
|
||||||
foreach( $docs as $value ) {
|
|
||||||
$str = $value[0];
|
foreach( $docs as $value ) {
|
||||||
if ( !empty($value[1]) ) {
|
$str = $value[0];
|
||||||
$str = sprintf('%s (%s)', $value[0], $value[1]);
|
if ( !empty($value[1]) ) {
|
||||||
|
$str = sprintf('%s (%s)', $value[0], $value[1]);
|
||||||
|
}
|
||||||
|
echo ' <li>'. $str . "</li>\n";
|
||||||
}
|
}
|
||||||
echo ' <li>'. $str . "</li>\n";
|
|
||||||
}
|
echo ' </ul>
|
||||||
echo ' </ul>
|
|
||||||
</section>'."\n";
|
</section>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// on recuperre le contenu du buffer
|
||||||
|
$contenuCache = ob_get_contents();
|
||||||
|
ob_end_flush(); // on termine la bufferisation
|
||||||
|
$fd = fopen("$fichierCache", "w"); // on ouvre le fichier cache
|
||||||
|
if ($fd) {
|
||||||
|
fwrite($fd,$contenuCache); // on écrit le contenu du buffer dans le fichier cache
|
||||||
|
fclose($fd);
|
||||||
}
|
}
|
||||||
|
// sinon le fichier cache existe déjà, on ne génère pas la page
|
||||||
|
// et on envoie le fichier statique à la place
|
||||||
|
} else {
|
||||||
|
readfile($fichierCache); // affichage du contenu du fichier
|
||||||
|
echo ' <!-- Section « documents » (présente uniquement si non vide) servie par le cache -->'."\n"; // et un petit message
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<section id="autoblogs">
|
<section id="autoblogs">
|
||||||
<header>
|
<header>
|
||||||
|
@ -921,37 +943,44 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
||||||
<a href="?exportopml">export<sup>OPML</sup></a>
|
<a href="?exportopml">export<sup>OPML</sup></a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<ul>
|
<?php
|
||||||
<?php
|
$fichierCache = 'autoblogs.cache';
|
||||||
$subdirs = glob(AUTOBLOGS_FOLDER . "*");
|
// si la page n'existe pas dans le cache ou si elle a expiré (durée paramétrable)
|
||||||
$autoblogs = array();
|
// on lance la génération de la page et on la stoke dans un fichier
|
||||||
foreach($subdirs as $unit) {
|
if (@filemtime($fichierCache)<time()-(AUTOBLOGS_CACHE_DURATION)) {
|
||||||
if(is_dir($unit)) {
|
// on démarre la bufferisation : rien n'est envoyé au navigateur
|
||||||
if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) {
|
ob_start();
|
||||||
if( file_exists(ROOT_DIR . '/' . $unit . '/vvb.ini')) {
|
|
||||||
$ini = parse_ini_file(ROOT_DIR . '/' . $unit . '/vvb.ini');
|
echo '<ul>
|
||||||
if($ini) {
|
';
|
||||||
$config = new stdClass;
|
$subdirs = glob(AUTOBLOGS_FOLDER . "*");
|
||||||
$unit=substr($unit, 2);
|
$autoblogs = array();
|
||||||
foreach ($ini as $key=>$value) {
|
foreach($subdirs as $unit) {
|
||||||
$key = strtolower($key);
|
if(is_dir($unit)) {
|
||||||
$config->$key = $value;
|
if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) {
|
||||||
|
if( file_exists(ROOT_DIR . '/' . $unit . '/vvb.ini')) {
|
||||||
|
$ini = parse_ini_file(ROOT_DIR . '/' . $unit . '/vvb.ini');
|
||||||
|
if($ini) {
|
||||||
|
$config = new stdClass;
|
||||||
|
foreach ($ini as $key=>$value) {
|
||||||
|
$key = strtolower($key);
|
||||||
|
$config->$key = $value;
|
||||||
|
}
|
||||||
|
$autoblogs[$unit] = $config;
|
||||||
|
unset($ini);
|
||||||
}
|
}
|
||||||
$autoblogs[$unit] = $config;
|
|
||||||
unset($ini);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
uasort($autoblogs, "objectCmp");
|
||||||
uasort($autoblogs, "objectCmp");
|
$autoblogs_display = '';
|
||||||
$autoblogs_display = '';
|
|
||||||
|
if(!empty($autoblogs)){
|
||||||
if(!empty($autoblogs)){
|
foreach ($autoblogs as $key => $autoblog) {
|
||||||
foreach ($autoblogs as $key => $autoblog) {
|
$opml_link='<a href="'.$key.'/?opml">opml</a>';
|
||||||
$opml_link='<a href="'.$key.'/?opml">opml</a>';
|
$autoblogs_display .= '<li>
|
||||||
$autoblogs_display .= '<li>
|
|
||||||
<header>
|
<header>
|
||||||
<a title="'.escape($autoblog->site_title).'" href="'.$key.'/">
|
<a title="'.escape($autoblog->site_title).'" href="'.$key.'/">
|
||||||
<img width="15" height="15" alt="" src="'.RESOURCES_FOLDER.'icon-'.escape($autoblog->site_type).'.svg" />
|
<img width="15" height="15" alt="" src="'.RESOURCES_FOLDER.'icon-'.escape($autoblog->site_type).'.svg" />
|
||||||
|
@ -961,12 +990,30 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
||||||
</header>
|
</header>
|
||||||
<div class="source">config <sup><a href="'.$key.'/vvb.ini">ini</a> '.$opml_link.'</sup> | '.escape($autoblog->site_type).' source : <a href="'.escape($autoblog->site_url).'">'.escape($autoblog->site_url).'</a></div>
|
<div class="source">config <sup><a href="'.$key.'/vvb.ini">ini</a> '.$opml_link.'</sup> | '.escape($autoblog->site_type).' source : <a href="'.escape($autoblog->site_url).'">'.escape($autoblog->site_url).'</a></div>
|
||||||
</li>';
|
</li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo $autoblogs_display;
|
echo $autoblogs_display;
|
||||||
?>
|
|
||||||
</ul>
|
echo '
|
||||||
<?php echo "<p>".count($autoblogs)." autoblogs hébergés</p>"; ?>
|
</ul>
|
||||||
|
<p>'.count($autoblogs).' autoblogs hébergés</p>';
|
||||||
|
|
||||||
|
// on recuperre le contenu du buffer
|
||||||
|
$contenuCache = ob_get_contents();
|
||||||
|
ob_end_flush(); // on termine la bufferisation
|
||||||
|
$fd = fopen("$fichierCache", "w"); // on ouvre le fichier cache
|
||||||
|
if ($fd) {
|
||||||
|
fwrite($fd,$contenuCache); // on écrit le contenu du buffer dans le fichier cache
|
||||||
|
fclose($fd);
|
||||||
|
}
|
||||||
|
// sinon le fichier cache existe déjà, on ne génère pas la page
|
||||||
|
// et on envoie le fichier statique à la place
|
||||||
|
} else {
|
||||||
|
echo '<!-- Début du cache -->'."\n".' '; // un message de début
|
||||||
|
readfile($fichierCache); // affichage du contenu du fichier
|
||||||
|
echo "\n".' <!-- Fin du cache -->'."\n"; // et un petit message
|
||||||
|
}
|
||||||
|
?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
|
|
Loading…
Reference in a new issue