Esempio n. 1
0
 static function updateTU($rep = "http://www.orupaca.fr/ressources/tu/repository")
 {
     $lastVersion = "";
     try {
         $tabMatches = array();
         preg_match('/_maj_(.*)_hash_(.*)_/', XhamUpdater::getUrlContents($rep . '/last_version_' . BRANCHE . '.html?nocacheteweak=' . rand(1, 10000)), $tabMatches);
         $lastVersion = $tabMatches[1];
         $currentVersion = str_replace("\n", '', file_get_contents(URLLOCAL . 'version.txt'));
         $currentVersion = str_replace("\r", '', $currentVersion);
         $hash = $tabMatches[2];
         if (version_compare($lastVersion, $currentVersion, '>')) {
             echo "<br />Une nouvelle version:  {$lastVersion} est disponible. <br />Téléchargement dans " . URLLOCAL . "var/dist/... <br />";
             //	    ob_flush() ; flush() ;
             $hashvide = md5('');
             $nomFic = PREFIXEARCHIVE . '.maj.' . $lastVersion . '.tgz';
             $ficArchive = URLLOCAL . 'var/dist/' . $nomFic;
             //print 'http://www.orupaca.fr/ressources/tu/repository/'.$nomFic;
             $messageKo = '';
             while (!($hash == md5(file_get_contents($ficArchive)))) {
                 XhamUpdater::downloadFile($rep . '/' . $nomFic, $ficArchive, $messageKo);
             }
             echo "<font color=\"green\">CHECKSUM {$hash} OK</font> <a href='install.php?release={$lastVersion}'>Installer la nouvelle version</a><br /><br />";
         }
     } catch (Exception $e) {
     }
     return $lastVersion;
 }
Esempio n. 2
0
    $tabMatches = array();
    preg_match('/_maj_(.*)_hash_(.*)_/', XhamUpdater::getUrlContents(URL_MAJ . '/last_version_' . BRANCHE . '.html?nocacheteweak=' . rand(1, 10000)), $tabMatches);
    $lastVersion = $tabMatches[1];
    $currentVersion = str_replace("\n", '', file_get_contents(URLLOCAL . 'version.txt'));
    $currentVersion = str_replace("\r", '', $currentVersion);
    $hash = $tabMatches[2];
    //print strlen($currentVersion).'*'.$currentVersion.'*'.$lastVersion.'*'.strlen($lastVersion);
    if (version_compare($lastVersion, $currentVersion, '>')) {
        echo "<br />Une nouvelle version:  {$lastVersion} est disponible. <br />Téléchargement dans " . URLLOCAL . "var/dist/... <br />";
        ob_flush();
        flush();
        $hashvide = md5('');
        $nomFic = PREFIXEARCHIVE . '.maj.' . $lastVersion . '.tgz';
        $ficArchive = URLLOCAL . 'var/dist/' . $nomFic;
        //print 'http://www.orupaca.fr/ressources/tu/repository/'.$nomFic;
        $messageKo = '';
        XhamUpdater::downloadFile(URL_MAJ . '/' . $nomFic, $ficArchive, $messageKo);
        $hashrecu = md5(file_get_contents($ficArchive));
        if ($hashrecu == $hash) {
            echo "<font color=\"green\">CHECKSUM {$hash} OK</font> <a href='install.php?release={$lastVersion}'>Installer la nouvelle version</a><br /><br />";
        } else {
            if ($hashvide == $hashrecu) {
                $messageKo .= " Fichier reçu vide";
            }
            unlink($ficArchive);
            print "<font color=\"red\">KO (problème lors du téléchargement) hash attendu {$hash} , hash reçu {$hashrecu}  {$messageKo}</font>";
        }
    } else {
        print "<font color=\"green\">Votre TU est à jour.</font>";
    }
}