コード例 #1
0
ファイル: stats.php プロジェクト: bibwho/MATPbootstrap
}
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);
    $white = imagecolorallocate($im, 255, 255, 255);
    $back_1 = convertToRGB('036');
コード例 #2
0
 /**
  * update_stats()
  * 
  * Mise à jour des données pour les statistiques 
  * 
  * @param array $listdata  Données de la liste concernée
  * 
  * @return boolean
  */
 function update_stats($listdata)
 {
     global $nl_config;
     if ($nl_config['disable_stats'] || !extension_loaded('gd')) {
         return false;
     }
     $filename = filename_stats(date('Y_F'), $listdata['liste_id']);
     if (file_exists(WA_STATSDIR . '/' . $filename)) {
         if ($fp = @fopen(WA_STATSDIR . '/' . $filename, 'r')) {
             $stats = clean_stats(fread($fp, filesize(WA_STATSDIR . '/' . $filename)));
             fclose($fp);
             $offset = date('j') - 1;
             $stats[$offset] += 1;
             if ($fw = @fopen(WA_STATSDIR . '/' . $filename, 'w')) {
                 fwrite($fw, implode("\n", $stats));
                 fclose($fw);
                 return true;
             }
         }
         return false;
     } else {
         return create_stats($listdata, date('m'), date('Y'));
     }
 }