Exemplo n.º 1
0
 // Réglages de l'image
 //
 $imageW = 560;
 $imageH = 260;
 $title_font = 3;
 $text_font = 2;
 //
 // Récupération des statistiques
 //
 $filename = filename_stats($year . '_' . date('F', $ts), $listdata['liste_id']);
 if (!file_exists(WA_STATSDIR . '/' . $filename)) {
     create_stats($listdata, $month, $year);
 }
 if (($filesize = filesize(WA_STATSDIR . '/' . $filename)) > 0 && ($fp = @fopen(WA_STATSDIR . '/' . $filename, 'r'))) {
     $contents = fread($fp, $filesize);
     $stats = clean_stats($contents);
     fclose($fp);
 } else {
     display_img_error('An error has occured while generating image!');
 }
 // C'est parti
 $im = imagecreate($imageW, $imageH);
 $black = imagecolorallocate($im, 0, 0, 0);
 $gray = imagecolorallocate($im, 200, 200, 200);
 $back_2 = imagecolorallocate($im, 240, 240, 240);
 $white = imagecolorallocate($im, 255, 255, 255);
 $back_1 = convertToRGB('036');
 $back_1 = imagecolorallocate($im, $back_1->red, $back_1->green, $back_1->blue);
 $color1 = convertToRGB('F80');
 $color1 = imagecolorallocate($im, $color1->red, $color1->green, $color1->blue);
 $color2 = convertToRGB('02F');
Exemplo n.º 2
0
// Pauzu veću od ovoliko sekundi računamo kao ovoliko sekundi
$file_content_limit = 100000;
// Ignorišemo fajlove veće od 100k
$split_folder = array("OR");
//$svn_base = $workspace_path . "/svn";
$prefix = "";
// Parameters
if ($argc == 1) {
    debug_log("username missing");
    die("ERROR: userstats.php expects at least one parameter\n");
}
$username = $argv[1];
//$stat_path = $conf_base_path . "/stats/$username_efn.stats";
debug_log("read stats");
read_stats($username);
clean_stats();
debug_log("azuriraj_statistiku");
update_stats($username);
debug_log("ksort");
ksort($stats);
debug_log("file_put_contents " . $conf_base_path . "/stats/{$username}.stats");
write_stats($username);
exit(0);
// Functions
// Read stats file
function read_stats($username)
{
    global $stats, $conf_stats_path;
    $username_efn = escape_filename($username);
    $stat_file = $conf_stats_path . "/" . "{$username_efn}.stats";
    $stats = NULL;
Exemplo n.º 3
0
 /**
  * remove_stats()
  * 
  * Suppression/déplacement de stats (lors de la suppression d'une liste) 
  * 
  * @param integer $liste_from  Id de la liste dont on supprime/déplace les stats
  * @param mixed   $liste_to    Id de la liste de destination ou boolean (dans ce cas, on supprime)
  * 
  * @return boolean
  */
 function remove_stats($liste_from, $liste_to = false)
 {
     global $nl_config;
     if ($nl_config['disable_stats'] || !extension_loaded('gd')) {
         return false;
     }
     @set_time_limit(300);
     if ($browse = dir(WA_STATSDIR . '/')) {
         require WA_ROOTDIR . '/includes/class.attach.php';
         $old_stats = array();
         while (($filename = $browse->read()) !== false) {
             if (preg_match("/^([0-9]{4}_[a-zA-Z]+)_list{$liste_from}\\.txt\$/i", $filename, $match)) {
                 if ($liste_to && ($fp = @fopen(WA_STATSDIR . '/' . $filename, 'r'))) {
                     $old_stats[$match[1]] = clean_stats(fread($fp, filesize(WA_STATSDIR . '/' . $filename)));
                     fclose($fp);
                 }
                 Attach::remove_file(WA_STATSDIR . '/' . $filename);
             }
         }
         $browse->close();
         if ($liste_to !== false && count($old_stats)) {
             foreach ($old_stats as $date => $stats_from) {
                 $filename = filename_stats($date, $liste_to);
                 if ($fp = @fopen(WA_STATSDIR . '/' . $filename, 'r')) {
                     $stats_to = clean_stats(fread($fp, filesize(WA_STATSDIR . '/' . $filename)));
                     fclose($fp);
                     for ($i = 0; $i < count($stats_to); $i++) {
                         $stats_to[$i] += $stats_from[$i];
                     }
                     @chmod(WA_STATSDIR . '/' . $filename, 0666);
                     if ($fw = @fopen(WA_STATSDIR . '/' . $filename, 'w')) {
                         fwrite($fw, implode("\n", $stats_to));
                         fclose($fw);
                     }
                 }
             }
         }
         return true;
     }
     return false;
 }