Teller

Status
Niet open voor verdere reacties.

feijtel.d

Gebruiker
Lid geworden
12 feb 2001
Berichten
17
Hallo,

Zou iemand hier naar willen kijken, Ik heb de volgende php teller.
Nu krijg ik telkens de volgende foutmelding.
Wat gaat er hier fout?

Alvast bedankt.

Dennis

Parse error: syntax error, unexpected T_STRING in /storage/mijndomein/users/062261/public/sites/www.veiligvanatotz.nl/counter.php on line 22

Code:
*************************************************

Code:
<?php


class acounter {

    var $config = array();

    function acounter () {
	 //de map waar je gifjes staan
        $this->config['img'] = "number/";
	 //de map waar de bewegende gifjes staan
        $this->config['animated_img'] = "numbers/";

        $this->config['pad'] = 6;

        $this->config['width']  = 16;
        $this->config['height'] = 22;
	   //Mogen de hits van jezelf geblokkeerd worden? true of false
        $this->config['block_ip'] = false;
	 //pad naar bestandje ip.txt
        $this->config['logfile'] = "ip.txt";
	[COLOR="Red"]hoelang mag je jezelf niet meetellen?[/COLOR]
        $this->config['block_time'] = 15;
    }
    //na hier niets veranderen
    function is_new_visitor() {
        $is_new = true;
        $rows = @file($this->config['logfile']);
        $this_time = time();
        $ip = getenv("REMOTE_ADDR");
        $reload_dat = fopen($this->config['logfile'],"wb");
        flock($reload_dat, 2);
        for ($i=0; $i<sizeof($rows); $i++) {
            list($time_stamp,$ip_addr) = split("\|",$rows[$i]);
            if ($this_time < ($time_stamp+$this->config['block_time'])) {
                if (chop($ip_addr) == $ip) {
                    $is_new = false;
                } else {
                    fwrite($reload_dat,"$time_stamp|$ip_addr");
                }
            }
        }
        fwrite($reload_dat,"$this_time|$ip\n");
        flock($reload_dat, 3);
        fclose($reload_dat);
        return $is_new;
    }

    function read_counter_file($page) {
        $update = false;
        if (!file_exists("./data/$page.txt")) {
            $count_dat = fopen("./data/$page.txt","w+");
            $this->counter = 1;
            fwrite($count_dat,$this->counter);
            fclose($count_dat);
        } else {
            $fp = fopen("./data/$page.txt", "r+");
            flock($fp, 2);
            $this->counter = fgets($fp, 4096);
            flock($fp, 3);
            fclose($fp);
            if ($this->config['block_ip']) {
                if ($this->is_new_visitor()) {
                    $this->counter++;
                    $update = true;
                }
            } else {
                $this->counter++;
                $update = true;
            }
            if ($update) {
                $fp = fopen("./data/$page.txt", "r+");
                flock($fp, 2);
                rewind($fp);
                fwrite($fp, $this->counter);
                flock($fp, 3);
                fclose($fp);
            }
        }
        return $this->counter;
    }

    function create_output($page='') {
        if (empty($page)) {
            $page = "counter";
        }
        $this->read_counter_file($page);
        $this->counter = sprintf("%0"."".$this->config['pad'].""."d",$this->counter);
        $ani_digits = sprintf("%0"."".$this->config['pad'].""."d",$this->counter+1);
        $html_output = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr align=\"center\">\n";
        for ($i=0; $i<strlen($this->counter); $i++) {
            if (substr("$this->counter",$i,1) == substr("$ani_digits",$i,1)) {
                $digit_pos = substr("$this->counter",$i,1);
                $html_output .= "<td><img src=\"".$this->config['img']."$digit_pos.gif\"";
            } else {
                $digit_pos = substr("$ani_digits",$i,1);
                $html_output .= "<td><img src=\"".$this->config['animated_img']."$digit_pos.gif\"";
            }
            $html_output .= " width=\"".$this->config['width']."\" height=\"".$this->config['height']."\"></td>\n";
        }
        $html_output .= "</tr></table>\n";
        return $html_output;
    }

}

?>
 
Laatst bewerkt door een moderator:
Ik zet om te beginnen de code even tussen de phphaakjes.
PHP:
<?php


class acounter {

var $config = array();

function acounter () {
//de map waar je gifjes staan
$this->config['img'] = "number/";
//de map waar de bewegende gifjes staan
$this->config['animated_img'] = "numbers/";

$this->config['pad'] = 6;

$this->config['width'] = 16;
$this->config['height'] = 22;
//Mogen de hits van jezelf geblokkeerd worden? true of false
$this->config['block_ip'] = false;
//pad naar bestandje ip.txt
$this->config['logfile'] = "ip.txt";
hoelang mag je jezelf niet meetellen?
$this->config['block_time'] = 15;
}
//na hier niets veranderen
function is_new_visitor() {
$is_new = true;
$rows = @file($this->config['logfile']);
$this_time = time();
$ip = getenv("REMOTE_ADDR");
$reload_dat = fopen($this->config['logfile'],"wb");
flock($reload_dat, 2);
for ($i=0; $i<sizeof($rows); $i++) {
list($time_stamp,$ip_addr) = split("\|",$rows[$i]);
if ($this_time < ($time_stamp+$this->config['block_time'])) {
if (chop($ip_addr) == $ip) {
$is_new = false;
} else {
fwrite($reload_dat,"$time_stamp|$ip_addr");
}
}
}
fwrite($reload_dat,"$this_time|$ip\n");
flock($reload_dat, 3);
fclose($reload_dat);
return $is_new;
}

function read_counter_file($page) {
$update = false;
if (!file_exists("./data/$page.txt")) {
$count_dat = fopen("./data/$page.txt","w+");
$this->counter = 1;
fwrite($count_dat,$this->counter);
fclose($count_dat);
} else {
$fp = fopen("./data/$page.txt", "r+");
flock($fp, 2);
$this->counter = fgets($fp, 4096);
flock($fp, 3);
fclose($fp);
if ($this->config['block_ip']) {
if ($this->is_new_visitor()) {
$this->counter++;
$update = true;
}
} else {
$this->counter++;
$update = true;
}
if ($update) {
$fp = fopen("./data/$page.txt", "r+");
flock($fp, 2);
rewind($fp);
fwrite($fp, $this->counter);
flock($fp, 3);
fclose($fp);
}
}
return $this->counter;
}

function create_output($page='') {
if (empty($page)) {
$page = "counter";
}
$this->read_counter_file($page);
$this->counter = sprintf("%0"."".$this->config['pad'].""."d",$this->counter);
$ani_digits = sprintf("%0"."".$this->config['pad'].""."d",$this->counter+1);
$html_output = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr align=\"center\">\n";
for ($i=0; $i<strlen($this->counter); $i++) {
if (substr("$this->counter",$i,1) == substr("$ani_digits",$i,1)) {
$digit_pos = substr("$this->counter",$i,1);
$html_output .= "<td><img src=\"".$this->config['img']."$digit_pos.gif\"";
} else {
$digit_pos = substr("$ani_digits",$i,1);
$html_output .= "<td><img src=\"".$this->config['animated_img']."$digit_pos.gif\"";
}
$html_output .= " width=\"".$this->config['width']."\" height=\"".$this->config['height']."\"></td>\n";
}
$html_output .= "</tr></table>\n";
return $html_output;
}

}

?>

Je moet moet voor dat "hoelang mag jejezelf niet meetellen?" even twee slashes zetten: //. Zo weet PHP dat het hier om commentaar gaat en dat er niks mee gedaan moet worden.
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan