1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
CLASS checkUpdates
{
PUBLIC FUNCTION __construct(){
$this->countFolders = fopen('test.txt', 'r+');
}
PUBLIC FUNCTION fileInitialize($dir){
$this->realArray = array();
$string = "";
array_push($this->realArray,'1337','1338','1339');
/***********************
* Lecture sur le Fichier
***********************/
$o = 0;
fseek($this->countFolders, 0);
while(!feof($this->countFolders)) {
$string .= fgets($this->countFolders, 4096);
$o++;
}
$this->checkArray = explode("\n", $string);
# Dans le fichier texte
$this->all = $this->checkArray[0]; // Extrait le nombre de dossiers au total
$this->parents = $this->checkArray[1]; // Extrait le nombre de dossiers parents
$this->children = $this->checkArray[2]; // Extrait le nombre de dossiers enfants
if($this->all != $this->realArray[0]){
fseek($this->countFolders, 0); // Remise du curseur au début du fichier pour écraser les données
fputs($this->countFolders,$this->realArray[0]); // Ajoute le total des dossiers au début du fichier
fputs($this->countFolders,"\n");
/*
fseek($this->countFolders, 0);
while(!feof($this->countFolders)) {
//echo $this->realArray[$o];
//$replace .= fgets($this->countFolders, 4096); // Récupération des lignes du fichier texte
//fputs($replace,$this->realArray[$o]); // Ajoute le total des dossiers au début du fichier
//fputs($replace,"\n");
//$o++;
}
*/
$this->exitApp = false; // Si le fichier a été modifié, on continue pour effectuer toutes les opérations sur l'arborescence
}else{
$this->exitApp = true; // Si aucune modification n'a été faite, on arrête le script
}
}
} |
Partager