Example #1
0
    imagestring($im, $text_font, $startW, $startH, $str, $black);
    send_image('error', $im);
}
if ($img == 'graph') {
    $ts = mktime(0, 0, 0, $month, 1, $year);
    //
    // 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);
Example #2
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;
 }