Je gère un parc de machines dans un lycée et suite à des demandes de professeurs, j'ai installé sur le serveur web un cahier de textes écrit en php. L'année dernière l'installation s'est bien déroulée et tout à bien fonctionné, mais cette année suite à une mise à jour pour gérer les nouveaux formats de fichiers contenant les données des élèves et des professeurs cela ne fonctionne plus. J'ai fait la mise à jour nécessaire et lorsque j'essaye d'importer le fichier contenant toutes les données élèves, j'ai droit au message d'erreur suivant :
Parse error : parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/www/html/lycee/moutiers/cdt/espace_perso/inc/fonction_sconet.php on line 3
Je préfère être honnête : en php je n'y connais rien mais j'ai tout de même regardé le fichier en cause et lu sur différents sites d'où cela pouvait provenir mais je n'ai rien trouvé et je ne vois pas où peut-être le problème en ligne 3.
Voici le code du fichier fonction_sconet.php :
<?
class fic_sconet {
public $lgfic;
public $contenu;
public $lg_entete;
public $lg_reccord;
public $nb_champ;
public $nb_reccords;
public $reccord_courant;
public $nom_champ;
public $affect;
public $change_carac;
//Constructeur
function fic_dbf() {
$lgfic=0;
$contenu = array() ;
$lg_entete=0;
$lg_reccord=0;
$nb_champ=0;
$reccord_courant = 0;
$affect = 0;
}
// init de la classe
//
function init_fic_sconet($nom_fic) {
//echo "**$nom_fic";
$this->lgfic=0;
if($fd = fopen($nom_fic, "rb")) {
// echo "<br> dans le if<br>";
$this->lgfic =filesize ($nom_fic);
// echo "<br> lg fic : $this->lgfic<br>";
//echo fgets($fd, 4096);
$this->contenu[] = fgets($fd, 4096);
$i=0;
while (!feof($fd)) {
$this->contenu[] = fgets($fd, 4096);
//echo $this->contenu[$i]."<br>";
$i++;
}
$this->nb_reccords = $i;
/*
$this->contenu = fread($fd, filesize ($nom_fic));
fclose($fd);
$data = substr($this->contenu,8,2);
echo "<br>$data";
$this->lg_entete=0; //ord($data[0])+(ord($data[1])<<8);
// $data = substr($this->contenu,10,2);
$this->lg_reccord=0;//ord($data[0])+(ord($data[1])<<8);
// $data = substr($this->contenu,4,4);
$this->nb_reccords=$i; //ord($data[0])+(ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24);
$table_champ = explode($this->contenu[0]);
$this->nb_champ = count($this->contenu) -1; //($this->lg_entete -34)/32;
*/
}
//@$this->change_carac = $liste_car;
//echo "fin du init";
return ($this->lgfic);
}
function nb_reccords_sconet() {
return ($this->nb_reccords);
}
function lg_fichier_sconet() {
return ($this->lgfic);
}
function lg_reccord_sconet() {
return 0; //$this->lg_reccord;
}
function lg_entete_sconet() {
return 0; //$this->lg_entete;
}
function nb_champ_sconet() {
return ($this->nb_champ);
}
/*
function carac_champ_dbf($num) {
// $tab;
if ($num < $this->nb_champ) {
$position = 32 + ($num*32);
$ligne = substr($this->contenu,$position,32);
// nom du champ
$tab["nom"] = substr($ligne,0,11);
$pos = strpos($tab["nom"],chr(0));
if ($pos === FALSE) {// nota trois ===
$pos=11;
}
$tab["nom"] = substr($tab["nom"],0,$pos);
//forme du champ
$tab["forme"] = substr($ligne,11,1);
// adresse du champ
$data= substr($ligne,12,4);
$tab["adresse"]=ord($data[0])+(ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24);
//largeur du champ
$tab["largeur"] = ord(substr($ligne,16,1));
//largeur decimal du champ
$tab["decimal"] = ord(substr($ligne,17,1));
}
return $tab;
}
*/
// affectation d'un tableau qui contient le nom des champs
// on utilise en lecture $tab[nom_du_champ] directement
/*
function affect_champ_dbf() {
for ($i=0; $i < $this->nb_champ; $i++) {
$val = $this->carac_champ_dbf($i);
$this->nom_champ[$i]["nom"]=$val["nom"];
$this->nom_champ[$i]["forme"]=$val["forme"];
$this->nom_champ[$i]["adresse"]=$val["adresse"];
$this->nom_champ[$i]["largeur"]=$val["largeur"];
$this->nom_champ[$i]["decimal"]=$val["decimal"];
if ($i) {
$this->nom_champ[$i]["index"]=$this->nom_champ[$i-1]["index"] + $this->nom_champ[$i-1]["largeur"];
}
else {
$this->nom_champ[$i]["index"]=0;
}
}
$this->affect = 1;
}
*/
function lect_reccord_sconet($num) {
$tab_caract = array(
chr(128)=>"Ç",
chr(129)=>"ü",
chr(130)=>"é",
chr(131)=>"â",
chr(132)=>"ä",
chr(133)=>"à",
chr(134)=>"å",
chr(135)=>"ç",
chr(136)=>"ê",
chr(137)=>"ë",
chr(138)=>"è",
chr(139)=>"ï",
chr(140)=>"î",
chr(141)=>"ì",
chr(142)=>"Ä",
chr(143)=>"Å",
chr(144)=>"É",
chr(145)=>"æ",
chr(146)=>"Æ",
chr(147)=>"ô",
chr(148)=>"ö",
chr(149)=>"ò",
chr(150)=>"û",
chr(151)=>"ù");
$ligne="";
// if (!$this->affect) {
// $this->affect_champ_dbf();
// }
if ($num < $this->nb_reccords) {
$ligne = $this->contenu[$num];
$ret = explode(";",$ligne);
// $position = $this->lg_entete + ( $this->lg_reccord * $num);
// $ligne = substr($this->contenu,$position,$this->lg_reccord);
// for ($i=0; $i < $this->nb_champ; $i++) {
// $contenu = substr($ligne,$this->nom_champ[$i]["index"]+1,$this->nom_champ[$i]["largeur"]);
// echo "<br>contenu = $contenu";
// $contenu = trim(strtr($contenu, $tab_caract));
// $ret[$this->nom_champ[$i]["nom"]] = $contenu;
// echo "<br>contenu = $contenu";
// }
}
return($ret);
}
/*
function liste_champ_dbf() {
return ($this->nom_champ);
}
*/
} // fin déclaration de la classe
/* à conserver
//retour les code ASCII d'une chaine
function ascii_encode($string) {
for ($i=0; $i < strlen($string); $i++) {
$encoded .= '&'.ord(substr($string,$i)).';';
}
return $encoded;
}
//transfert d'un BDF dans la la viariable $contenu
// retourne la taille du fichier
function lecture_dbf($nom_fic)
{
$this->$lgfic=0;
if($fd = @fopen($nom_fic, "rb")) {
$this->lgfic =filesize ($nom_fic);
$this->contenu = fread($fd, filesize ($filename));
}
fclose($fd);
}
*/
?>
Par avance merci si quelqu'un peut me dépanner, Benoît.