hourly.php 1.3 KB
Newer Older
Ayolo's avatar
Ayolo committed
1 2 3 4 5 6
<?php

/*
 * hourly
 */
$topdir="../";
Feu's avatar
Feu committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
$_SERVER['SCRIPT_FILENAME']="/var/www/ae/www/ae2/phpcron";
require_once($topdir. "include/site.inc.php");
$site = new site ();

// Tâche 2 [galaxy] : màj, et cycles
require_once($topdir. "include/galaxy.inc.php");

$galaxy = new galaxy($site->db,$site->dbrw);

$galaxy->update();

for($i=0;$i<45;$i++) // Environs 1100 cycles/jours
  $galaxy->cycle();

print_r($galaxy);

$galaxy->mini_render($topdir."var/mini_galaxy.png");

print_r($galaxy);

// Tâche 1 [planet]
Ayolo's avatar
Ayolo committed
28 29 30 31 32 33
define('MAGPIE_CACHE_DIR', '/var/www/ae/www/var/cache/planet/');
define('MAGPIE_CACHE_ON', true);
define('MAGPIE_CACHE_AGE', 50*60); //50minutes pour etre certain d'avoir un truc à jour :)
define('MAGPIE_OUTPUT_ENCODING', "UTF-8");
define('MAX_NUM',20);
define('MAX_SUM_LENGHT',200);
Ayolo's avatar
bleh  
Ayolo committed
34
require_once($topdir. "include/lib/magpierss/rss_fetch.inc.php");
Ayolo's avatar
Ayolo committed
35

Feu's avatar
Feu committed
36
// Tâche 1 [planet] : mettre à jour le cache
Ayolo's avatar
Ayolo committed
37 38
$req = new requete($site->db,"SELECT `url` FROM `planet_flux` WHERE `modere`='1'");
while ( list($url) = $req->get_row() )
Ayolo's avatar
bleh  
Ayolo committed
39
  $rs=fetch_rss($url);
Ayolo's avatar
Ayolo committed
40

Feu's avatar
Feu committed
41
// Tâche 1 [planet] : nettoyage du cache
Ayolo's avatar
Ayolo committed
42 43 44 45 46 47
$cache = opendir(MAGPIE_CACHE_DIR);
while ($file = readdir($cache))
  if ( is_file(MAGPIE_CACHE_DIR.$file) && filemtime(MAGPIE_CACHE_DIR.$file) < (time()-MAGPIE_CACHE_AGE) )
    unlink(MAGPIE_CACHE_DIR.$file);
closedir($cache);

Feu's avatar
Feu committed
48 49


Ayolo's avatar
Ayolo committed
50
?>