hourly.php 1.3 KB
Newer Older
Ayolo's avatar
Ayolo committed
1
<?php
Ayolo's avatar
Ayolo committed
2
$_SERVER['SCRIPT_FILENAME']="/var/www/ae/www/ae2/phpcron";
Ayolo's avatar
Ayolo committed
3 4 5 6 7 8 9 10 11 12
/*
 * hourly
 */
$topdir="../";
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);
Feu's avatar
Feu committed
13 14 15
$_SERVER['SCRIPT_FILENAME']="/var/www/ae/www/ae2/phpcron";

require_once($topdir. "include/site.inc.php");
Ayolo's avatar
bleh  
Ayolo committed
16
require_once($topdir. "include/lib/magpierss/rss_fetch.inc.php");
Ayolo's avatar
Ayolo committed
17

Feu's avatar
Feu committed
18 19 20

$site = new site ();

Feu's avatar
Feu committed
21
// Tâche 1 [planet] : mettre à jour le cache
Ayolo's avatar
Ayolo committed
22 23
$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
24
  $rs=fetch_rss($url);
Ayolo's avatar
Ayolo committed
25

Feu's avatar
Feu committed
26 27


Feu's avatar
Feu committed
28
// Tâche 1 [planet] : nettoyage du cache
Ayolo's avatar
Ayolo committed
29 30 31 32 33 34
$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
35

Feu's avatar
Feu committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49
// 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();

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

Feu's avatar
Feu committed
50

Ayolo's avatar
Ayolo committed
51
?>