Mostra notizie nelle discussioni
Avatar
Scritto da
Non Autenticato
il 2010-07-19 15:07:00.0 alle 2010-07-19 15:07:00.0
Il contatore di insulae.net
mi sta facendo dannare.

Il file del conto ora è

1964|/index.php|20100719|20070118
26|/credits.php|20100719|20100630
24|/contact.php|20100719|20100630
4|-|20100501|20080221
55|/index.php|20100719|20100713
1|/contact.write.send.php|20100717|20100717

e come si vede si sono formate DUE righe per index.php, così sul sito mostra un conto di 55 invece che 1964+55.

Non riesco a capire perché. Arrabbiato

Il sorgente del contatore è

<?

// Adapted from MPCount 1.02 Sascha Blansjaar

$url = $_SERVER['PHP_SELF'];
if (!isset($url)) $url = "-";

// setting the same $url for all pages results in a same count for the whole site

$today = date("Ymd");
$written = FALSE;

$msg = '';

// Uses the daita() function, which must be defined in the including script

// Uses $_GET['c'] received calling url?c=no

if (file_exists($mpcountfile)) {

    $temparray = file($mpcountfile);

    for ($index = 0; $index < count($temparray); $index++) {

        $entry = explode("|", $temparray[$index]);

        if (!strcmp($entry[1], $url)) {

            if ($_GET['c'] != 'no') $entry[0]++;
            $entry[2] = $today;
            $tempentry = $entry;
            $temparray[$index] = implode($entry, "|");
            $fp = fopen($mpcountfile, "w");
            if (flock($fp, 2)) {
                for ($j = 0; $j < count($temparray); $j++) {
                    fputs($fp, $temparray[$j]);
                }
            } else {
                $msg = 'ERROR: flock write failure';
            }

            if (flock($fp, 3)) {
                fclose($fp);
            } else {
                $msg = 'ERROR: flock release failure';
            }

            $count = $tempentry[0];
            $since = str_replace("\n", '', $tempentry[3]);
            $since = daita($since);

            $written = TRUE;

        }

    }

    if ($written == FALSE) {
        $hits = "1";
        $entry = "$hits|$url|$today|$today\n";
        $fp = fopen($mpcountfile, "a");
        if (flock($fp, 2)) {
            fputs($fp, $entry, 1024);
        } else {
            $msg = 'ERROR: flock write failure';
        }
        if (flock($fp, 3)) {
            fclose($fp);
        } else {
            $msg = 'ERROR: flock release failure';
        }
        $count = $hits;
        $since = daita($today);
    }

} else {

    $fp = fopen($mpcountfile, "w");
    if (!$fp) {
        $msg = 'CNT error';
    } else {
        fclose ($fp);
        $msg = 'Count register created.';
    }

}

?>

La citata funzione daita() serve solo a trasformare la data in formato leggibile.

Succede spesso che si formino doppie righe, e non riesco a immaginare quale evento le provoca.

Arrabbiato Arrabbiato Arrabbiato

Pagina generata in 35 millisecondi

Utenti attivi: 11 nell'ultimo minuto, 19 negli ultimi cinque minuti, 43 negli ultimi 15 minuti