示例#1
0
 public function exportRegularly()
 {
     global $errs;
     $dateD = clDate::getInstance()->addDays('-' . $this->getExportRegularlyBackNumberDays());
     $dateF = new clDate();
     $data = array();
     $nomFic = '';
     self::getDataExport($this, $dateD, $dateF, $data, $nomFic);
     $localUrlFic = clFoRmXtOoLs::exportsGetCsvFromData($data, $nomFic, array('local_access' => true));
     try {
         XhamUpdater::sendFtpData($localUrlFic, 'enquetes');
         eko("depot ftp de {$localUrlFic} ok");
         //die ;
     } catch (Exception $e) {
         eko("erreur" . $e);
         $errs->addErreur($e);
     }
 }
示例#2
0
 static function decompact($release)
 {
     set_time_limit(0);
     ini_set('memory_limit', '512M');
     include_once "config.php";
     $version = $release;
     $version = str_replace('/', '', $version);
     require URLLOCAL . 'classes_ext/Tar.php';
     $ficArchive = URLLOCAL . 'var/dist/' . PREFIXEARCHIVE . '.maj.' . $version . '.tgz';
     $tmpInflatePath = URLLOCAL . 'temp/installdist/';
     if (file_exists($tmpInflatePath)) {
         if (!XhamUpdater::rmdir_recurse($tmpInflatePath)) {
             echo "Impossible de supprimer le répertoire {$tmpInflatePath} . Abandon.";
             die;
         }
     }
     //on décompresse
     mkdir($tmpInflatePath);
     $archive = new Archive_Tar($ficArchive);
     $res = $archive->extract($tmpInflatePath);
     if (!$res) {
         echo "Probleme lors de la décompression";
         die;
     }
     $tabFics = array();
     XhamUpdater::listFiles($tmpInflatePath, $tabFics);
     $listeFicsKo = array();
     $listeDossiersKo = array();
     $listeDossiersKoDroits = array();
     foreach ($tabFics as $file) {
         if (!file_exists(dirname(URLLOCAL . $file))) {
             if (!mkdir(dirname(URLLOCAL . $file), 0777, true)) {
                 $listeDossiersKo[] = dirname(URLLOCAL . $file);
             }
         }
         if (!file_exists(URLLOCAL . $file) && !is_writable(dirname(URLLOCAL . $file))) {
             $listeDossiersKoDroits[] = dirname(URLLOCAL . $file);
         } else {
             if (file_exists(URLLOCAL . $file) && !is_writable(URLLOCAL . $file)) {
                 $listeFicsKo[] = URLLOCAL . $file;
             }
         }
     }
     if (count($listeFicsKo) > 0 || count($listeDossiersKoDroits) > 0 || count($listeDossiersKo) > 0) {
         foreach ($listeFicsKo as $file) {
             print "<br /><font color=\"red\">{$file} n'est pas autorisé en écriture pour le user " . $_ENV["APACHE_RUN_USER"] . "</font>";
         }
         foreach ($listeDossiersKoDroits as $dossier) {
             print "<br /><font color=\"red\">Le dossier {$dossier} doit etre autorisé en écriture pour le user " . $_ENV["APACHE_RUN_USER"] . "</font>";
         }
         foreach ($listeDossiersKo as $dossier) {
             print "<br /><font color=\"red\">Le dossier {$dossier} n'a pas pu être créé par le user " . $_ENV["APACHE_RUN_USER"] . "</font>";
         }
         print "<br />La mise à jour  ne s'est pas effectuée.";
         die;
     }
     foreach ($tabFics as $file) {
         print "<br />Installing " . $tmpInflatePath . $file . '  on ' . URLLOCAL . $file;
         ob_flush();
         flush();
         if (!copy($tmpInflatePath . $file, URLLOCAL . $file)) {
             //TODO:
             //erreur de copie -> reprendre la sauvegarde précédente
         }
     }
     //pas de pb ? suppression de la décompression
     XhamUpdater::rmdir_recurse($tmpInflatePath);
 }
示例#3
0
 public function traitementReponse($chaineXML)
 {
     if (empty($chaineXML)) {
         return;
     }
     $xml = new DOMDocument();
     $xml->loadXML($chaineXML);
     if (!($root = $xml->documentElement)) {
         return;
     }
     $dir = "";
     if ($d = $root->getElementsByTagName("repository")) {
         $dir = $d->item(0)->nodeValue;
     }
     if (file_exists(URLLOCAL . "urlMaj.txt")) {
         unlink(URLLOCAL . "urlMaj.txt");
     }
     $file = fopen(URLLOCAL . "urlMaj.txt", "w+");
     fwrite($file, $dir);
     fclose($file);
     if ($v = $root->getElementsByTagName("versionDemandee")) {
         $versionDemandee = $v->item(0)->nodeValue;
         if ($versionDemandee != "" && version_compare($versionDemandee, $this->getVersion(), ">")) {
             echo "maj demandée";
             if (file_exists(URLLOCAL . "temp/maj.txt")) {
                 $var = file_get_contents(URLLOCAL . "temp/maj.txt");
                 echo $var;
                 echo time() - mktime(substr($var, 0, 2), substr($var, 3, 2), substr($var, -2));
                 if (time() - mktime(substr($var, 0, 2), substr($var, 3, 2), substr($var, -2)) >= 5 * 60) {
                     unlink(URLLOCAL . "temp/maj.txt");
                 }
             }
             echo "fin if";
             if (!file_exists(URLLOCAL . "temp/maj.txt")) {
                 echo "suppr fichier ok";
                 $file = fopen(URLLOCAL . "temp/maj.txt", "w+");
                 fwrite($file, date("G:i:s"));
                 fclose($file);
                 try {
                     $v = XhamUpdater::updateTU($dir);
                     echo "update TU";
                     XhamUpdater::decompact($v);
                     echo "decompact";
                     XhamUpdater::applyPatchs(TBIDSITE);
                     echo "patchs";
                 } catch (Exception $e) {
                 }
                 unlink(URLLOCAL . "temp/maj.txt");
             }
         }
     }
     if ($tab_enq = $root->getElementsByTagName("active_enquete")) {
         foreach ($tab_enq as $enquete) {
             $idEnq = $enquete->nodeValue;
             $enq = new clTuFormxTrigger($idEnq);
             $enq->start();
         }
     }
     if ($tab_opt_change = $root->getElementsByTagName("delete_option")) {
         foreach ($tab_opt_change as $opt) {
             $idOpt = $opt->getAttribute("id");
             $valeur = $opt->nodeValue;
             $obRequete = new clRequete(BASEXHAM, 'options', array(), MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
             $requete = "DELETE FROM options WHERE idoption=" . $idOpt;
             $obRequete->exec_requete($requete);
         }
     }
     if ($tab_opt_change = $root->getElementsByTagName("change_option")) {
         foreach ($tab_opt_change as $opt) {
             $idOpt = $opt->getAttribute("id");
             $valeur = $opt->nodeValue;
             $obRequete = new clRequete(BASEXHAM, 'options', array(), MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
             $requete = "UPDATE options SET valeur='" . $valeur . "' WHERE idoption=" . $idOpt;
             $obRequete->exec_requete($requete);
         }
     }
 }
示例#4
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>";
    }
}