Problème de script

caracop Messages postés 13 Date d'inscription   Statut Membre Dernière intervention   -  
caracop Messages postés 13 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

Voilà c'est mon deuxième message à ce sujet, j'ai un problème de mise en ligne de mon site internet, site crée avec le logiciel Web to Date en php4.

Le soucis vient apparemment (d'après mes recherche de débutant tout naze) d'un problème de script.

Concrètement, mes pages principales s'ouvrent bien, mais lorsque j'appelle une page secondaire, j'ai un message d'erreur qui est le suivant:

Fatal error: Cannot re-assign $this in /home/gds/www/lesnouveauxarticles/w2drankingd2c483e3b78fbd68f661de6947ce89e5.php4 on line 57

Le message est toujours le même pour toutes les pages sauf que le numéro juste avant le .php4 change.

J'ai regardé toutes mes pages secondaires, et aà cahque fois, la ligne numéro 57 me rapporte à cette ligne :

$this = unserialize($data);

Pour une meilleur compréhension je vous mets ma page script entière (tout est fait par le logiciel, ca m'embête parce que si il y a des erreurs, cela vient du logiciel !!!)


<?php

define("DATA_FILE","../assets/plugindata/w2dranking31a0f8a30296e1daf8e69a26baadb13e.dat");
define("XML_PREAMBLE","<?xml version=\"1.0\" ?>\n");

class ranking {
// Struktur: Tages-Ranking

var $day;
var $month;
var $year;
var $count;
var $total;
var $access;

function ranking($day, $month, $year) {
// Konstruktor

$this->day=$day;
$this->month=$month;
$this->year=$year;
}
}

class result {
// Struktur: Ergebnis

var $average;
var $count;
}

class ipLock {
// Struktur: IP-Lock

var $time;
var $ip;

function ipLock($time, $ip) {
$this->time=$time;
$this->ip=$ip;
}
}

class rankings {
// Struktur: Alle Rankings

var $rankings=Array();
var $ipLocks=Array();

function melt() {
$fp=@fopen(DATA_FILE,"rb");
if ($fp) {
flock($fp, LOCK_SH);
$data = fread($fp,filesize(DATA_FILE));
flock($fp, LOCK_UN);
fclose($fp);
$this = unserialize($data);
}
}

function freeze() {
$data = serialize($this);
$fp = fopen(DATA_FILE, "wb+");
flock($fp, LOCK_EX);
fwrite($fp, $data);
flock($fp, LOCK_UN);
fclose($fp);
}

function checkIp($time, $ip) {
if (1==1) {
for ($i=0;$i<count($this->ipLocks);$i++) {
if ($this->ipLocks[$i]->ip==$ip) {
if ($time<$this->ipLocks[$i]->time+(60*60*24)) {
return false;
} else {
$this->ipLocks[$i]->time=$time;
return true;
}
}
}
$this->ipLocks[]=new ipLock($time, $ip);
return true;
} else {
return true;
}
}

function addRanking($time, $rank, $ip) {
$date=getdate($time);

$found=-1;

for ($i=0;$i<count($this->rankings);$i++) {
if ($this->rankings[$i]->day==$date['mday']) {
if ($this->rankings[$i]->month==$date['mon']) {
if ($this->rankings[$i]->year==$date['year']) {
$found=$i;
break;
}
}
}
}

if ($found==-1) {
$this->rankings[]=new ranking($date['mday'],$date['mon'],$date['year']);
$found=count($this->rankings)-1;
}

if ($rank>0) {
if ($this->checkIp($time,$ip)) {
$this->rankings[$found]->count++;
$this->rankings[$found]->total+=$rank;
return true;
} else {
return false;
}
} else {
$this->rankings[$found]->access++;
return true;
}
}


function result() {
$result = new result();
$result->count=0;
$result->average=0;

if (count($this->rankings)>0) {
for ($i=0;$i<count($this->rankings);$i++) {
$result->average+=$this->rankings[$i]->total;
$result->count+=$this->rankings[$i]->count;
}
$result->average=number_format($result->average/$result->count,2);
}

return ($result);
}

function resultXML() {
$result=$this->result();
$xml=XML_PREAMBLE;
$xml.="<result>\n";
$xml.="<status>ok</status>\n";
$xml.="<count>".$result->count."</count>\n";
$xml.="<average>".$result->average."</average>\n";
$xml.="</result>\n";

return $xml;
}

function errorXML($state) {
$xml=XML_PREAMBLE;
$xml.="<result>\n";
$xml.="<status>".$state."</status>\n";
$xml.="</result>\n";

return $xml;
}

function dumpXML() {
$result=$this->result();
$xml=XML_PREAMBLE;
$xml.="<result>\n";
$xml.="<status>ok</status>\n";
for ($i=0;$i<count($this->rankings);$i++) {
$xml.="<item>\n";
$xml.="<day>".$this->rankings[$i]->day."</day>\n";
$xml.="<month>".$this->rankings[$i]->month."</month>\n";
$xml.="<year>".$this->rankings[$i]->year."</year>\n";
$xml.="<count>".$this->rankings[$i]->count."</count>\n";
$xml.="<total>".$this->rankings[$i]->total."</total>\n";
$xml.="<access>".$this->rankings[$i]->access."</access>\n";
$xml.="</item>\n";
}

$xml.="</result>\n";

return $xml;
}

function handleRank() {
$this->melt();
$this->sendHeader();

if ($this->addRanking(time(),$_GET['rank'],$_SERVER['REMOTE_ADDR'])) {
echo($this->resultXML());
$this->freeze();
} else {
echo($this->errorXML('iplock'));
}
}

function handleAccess() {
$this->melt();

if ($this->addRanking(time(),'-1',$_SERVER['REMOTE_ADDR'])) {
$this->freeze();
}
}

function handleDump() {
$this->melt();
echo($this->dumpXML());
}

function sendHeader() {
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: text/xml");
}

function handleRequest() {

if (array_key_exists('mode',$_GET)) {
switch($_GET['mode']) {
case 'rank':
$this->handleRank();
break;
case 'dump':
$this->handleDump();
break;
default:
echo($this->errorXML('illegalmode'));
}
} else {
$this->handleAccess();
}
}
}

$rankings=new rankings();
$rankings->handleRequest();

?>


Désolé pour ce gros pavé, mais si cela peu m'aider, je vous en serait reconnaissant, j'ai besoin de mettre mon site en ligne pour ce week-end end et ça fait 5 jours que je rame dessus.


Merci
A voir également:

2 réponses

Utilisateur anonyme
 
abandonne tous ces logiciels sensés faciliter les choses et qui les compliquent en réalité
et reprend l'ecriture de tes pages de maniere basique
0
caracop Messages postés 13 Date d'inscription   Statut Membre Dernière intervention  
 
arf, oui je me doute qu'il vaut mieux faire comme tu dis, mais j'y connais rien, ou pas grand chose !!!
C'est bien pour cela que j'utilise ce genre de logiciel !!!
C'est fait pour nous les noobs !!! lol
0