Skip to content

Commit

Permalink
Merge branch 'hotfix/1.9.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
oceanBigOne committed May 1, 2017
2 parents 6685dca + dae6e63 commit 4cb800e
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Candidature #MAVOIX v1.9.1
# Candidature #MAVOIX v1.9.2

Soumission et publication des inscriptions au tirage au sort [#MAVOIX](https://mavoix.info).

Expand All @@ -9,6 +9,10 @@ Version de test : https://candidature.maudry.fr

## Notes de version

### 1.9.2

- Hotfix script de récupération de fichiers manquants effacés (grâce à la sauvegarde)

### 1.9.1

- Hotfix faille de sécurité qui permettait la récupération des justificatifs des candidats
Expand Down
93 changes: 93 additions & 0 deletions pages/admin/candidature/hotfix-1-9-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
$aDataScript["out"] = "";
global $nCountFiles;
$nCountFiles=0;
$nCountCandidats=0;
if(!isset($_GET["action"])){
$_GET["action"]='';
}
function testPath($sPath,$sField,$nId){
global $nCountFiles;
$sOut="";
if(!file_exists($sPath) && $sPath!=""){
$sOut.="<div> IMPOSSIBLE DE TROUVER $sField : ".$sPath."</div>";
$nCountFiles++;
if( $_GET["action"]=="tentative-recup" || $_GET["action"]=="recup" ){
$sSql="SELECT $sField FROM `candidature-backup` WHERE id='".$nId."'";
$stmt=DbLink::getInstance()->prepare($sSql);
$stmt->execute(array());
$data=$stmt->fetchAll();
if(count($data)){
$sFile=$data[0][$sField];
if(file_exists($sFile)){
$sOut.="<div>--- Fichier récupérable $sField : ".$sFile."</div>";
if($_GET["action"]=="recup"){
$candidature=new Candidature(array("id"=>$nId));
$candidature->hydrateFromBDD(array("*"));
switch($sField){
case "path_pic": $candidature->setPath_pic($sFile); break;
case "path_certificate": $candidature->setPath_certificate($sFile); break;
case "path_idcard": $candidature->setPath_idcard($sFile); break;
case "path_idcard_verso": $candidature->setPath_idcard_verso($sFile); break;
case "path_criminal_record": $candidature->setPath_criminal_record($sFile); break;
}
$candidature->save();
$sOut.="<div>------- Fichier récupéré $sField : ".$sFile."</div>";

}
}else{
$sOut.="<div><b>--- Fichier irrécupérable $sField</b></div>";
if($_GET["action"]=="recup"){
$candidature=new Candidature(array("id"=>$nId));
$candidature->hydrateFromBDD(array("*"));
switch($sField){
case "path_pic": $candidature->setPath_pic(""); break;
case "path_certificate": $candidature->setPath_certificate(""); break;
case "path_idcard": $candidature->setPath_idcard(""); break;
case "path_idcard_verso": $candidature->setPath_idcard_verso(""); break;
case "path_criminal_record": $candidature->setPath_criminal_record(""); break;
}
$candidature->save();
}

}
}else{
$sOut.="<div> IMPOSSIBLE DE RECUPERER LA BACKUP $sField : ".$sPath."</div>";
}




}


}
return $sOut;
}

if( ConfigService::get("enable-script-hotfix-1-9-2") ) {

//liste les candidatures en base
$oListeCandidature = new CandidatureListe();
$oListeCandidature->applyRules4ListAdmin();
$aCandidatures = $oListeCandidature->getPage();
// parcrous les candidatures
foreach ($aCandidatures as $aCandidature) {
$sOut="";
$sOut.= testPath($aCandidature["path_pic"],"path_pic",$aCandidature["id"]);
$sOut.= testPath($aCandidature["path_certificate"],"path_certificate",$aCandidature["id"]);
$sOut.= testPath($aCandidature["path_idcard"],"path_idcard",$aCandidature["id"]);
$sOut.= testPath($aCandidature["path_idcard_verso"],"path_idcard_verso",$aCandidature["id"]);
$sOut.= testPath($aCandidature["path_criminal_record"],"path_criminal_record",$aCandidature["id"]);
if($sOut!=""){
$nCountCandidats++;
$aDataScript["out"] .="<hr />CANDIDATURE :".$aCandidature["id"].$sOut;
}
}
$aDataScript["out"] .= "<hr /><hr />";
$aDataScript["out"] .= "<div> candidatures : $nCountCandidats</div>";
$aDataScript["out"] .= "<div> fichiers : $nCountFiles</div>";

}else{
$aDataScript["out"] .= "<div>EXECUTION BLOQUE (cf. fichier de config)</div>";
}
2 changes: 1 addition & 1 deletion pages/visitor/candidature/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
$aResponse["message"]["type"] = "success";
//if edit clean old file
if($bEdit){
vars::removeDirectory(dirname($OldCandidature->getPath_pic()));
// vars::removeDirectory(dirname($OldCandidature->getPath_pic()));
$aResponse["message"]["text"] = "Modification enregistrée !";
}else{
$aResponse["message"]["text"] = "Candidature envoyée correctement !";
Expand Down
7 changes: 7 additions & 0 deletions templates/admin/candidature/hotfix-1-9-2.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "admin/base.html.twig" %}


{% block body %}
HOTFIX
{{ out|raw }}
{% endblock %}
3 changes: 2 additions & 1 deletion web/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
$_CONFIG["mime-type-limit"] = array('image/jpeg'=>'jpg','image/png'=>'png');
$_CONFIG["enable-captcha"] = true; //enable or disable captcha
$_CONFIG["enable-captcha-editlink"] = true; //enable or disable captcha for ask edit link form
$_CONFIG["enable-script-hotfix-1-9-1"] = false; //activer pour permettre l'execution du script de rattrapage du hotfix
$_CONFIG["enable-script-hotfix-1-9-1"] = false; //activer pour permettre l'execution du script de rattrapage du hotfix
$_CONFIG["enable-script-hotfix-1-9-2"] = false; //activer pour permettre l'execution du script de rattrapage du hotfix
2 changes: 1 addition & 1 deletion web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require_once 'maintenance.php';
}
if($bMaintenance){
echo "<h1>Under maintenance, please try later ...</h1>";
echo "<h1>Site Web en maintenance, merci de réessayer plus tard.</h1><p>Informations : [email protected]</p>";
}else{
//composer loader
require_once '../vendor/autoload.php';
Expand Down

0 comments on commit 4cb800e

Please sign in to comment.