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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| FONCTION mySQLExec(sqlQuery, requestNumber)
LOCAL
v_nbfois est un entier = :MysqlNbFois
v_ligne est un chaîne
ResLancement est un booléen
v_chaineResult est une chaîne
v_indiceBind est un entier
retcode est un entier
v_indice est un entier = 1
v_colonne est un entier = 0
myRequestNumber est un entier
v_mySQL est une chaîne
v_ZipTemp est une chaîne =fRepExe()+"\"+"resultat.zip"
v_ZipTempLire est une chaîne ="resultat.txt"
resZip est un entier
IF (requestNumber > :myMaxRequestNumber) THEN
Erreur("Le numéro de requête doit être compris entre 0 et " + NumériqueVersChaîne(:myMaxRequestNumber) + ".....", "Veuillez corriger votre code.")
RENVOYER (False)
END
myRequestNumber = requestNumber+1
sqlQuery = :ExecLimit(sqlQuery)
:myOldQuery = sqlQuery
SI :modeUTF8Entree ALORS v_mySQL = :CrypteURL(ChaîneVersUTF8(sqlQuery))
SI PAS :modeUTF8Entree ALORS v_mySQL = :CrypteURL(sqlQuery)
HTTPCréeFormulaire("FORM")
SI :modeUTF8Entree ALORS
HTTPAjouteParamètre("FORM", "requete", ChaîneVersUTF8(v_mySQL))
HTTPAjouteParamètre("FORM", "typeBase", ChaîneVersUTF8(:TypeBase))
HTTPAjouteParamètre("FORM", "tNomBase", ChaîneVersUTF8(:myBase))
HTTPAjouteParamètre("FORM", "bind", ChaîneVersUTF8(:bind))
HTTPAjouteParamètre("FORM", "bindLen", ChaîneVersUTF8(:BindLen))
HTTPAjouteParamètre("FORM", "bindVal", ChaîneVersUTF8(:bindVal))
HTTPAjouteParamètre("FORM", "bindType", ChaîneVersUTF8(:BindType))
SI :methodeZip ALORS HTTPAjouteParamètre("FORM", "methode", ChaîneVersUTF8("zip")) SINON HTTPAjouteParamètre("FORM", "methode", ChaîneVersUTF8("NON"))
SI :CryptRetour ALORS HTTPAjouteParamètre("FORM", "crypteretour", ChaîneVersUTF8("OUI")) SINON HTTPAjouteParamètre("FORM", "crypteretour", ChaîneVersUTF8("NON"))
SI :dataHexa ALORS HTTPAjouteParamètre("FORM", "dataHexa", ChaîneVersUTF8("OUI")) SINON HTTPAjouteParamètre("FORM", "dataHexa", ChaîneVersUTF8("NON"))
SI :modeUTF8Sortie ALORS HTTPAjouteParamètre("FORM", "modeUTF8Sortie", ChaîneVersUTF8("OUI")) SINON HTTPAjouteParamètre("FORM", "modeUTF8Sortie", ChaîneVersUTF8("NON"))
FIN
SI PAS :modeUTF8Entree ALORS
HTTPAjouteParamètre("FORM", "requete", v_mySQL)
HTTPAjouteParamètre("FORM", "typeBase", :TypeBase)
HTTPAjouteParamètre("FORM", "tNomBase", :myBase)
HTTPAjouteParamètre("FORM", "bind", :bind)
HTTPAjouteParamètre("FORM", "bindLen", :BindLen)
HTTPAjouteParamètre("FORM", "bindVal", :bindVal)
HTTPAjouteParamètre("FORM", "bindType", :BindType)
SI :methodeZip ALORS HTTPAjouteParamètre("FORM", "methode", "zip") SINON HTTPAjouteParamètre("FORM", "methode", "NON")
SI :CryptRetour ALORS HTTPAjouteParamètre("FORM", "crypteretour", "OUI") SINON HTTPAjouteParamètre("FORM", "crypteretour", "NON")
SI :dataHexa ALORS HTTPAjouteParamètre("FORM", "dataHexa", "OUI") SINON HTTPAjouteParamètre("FORM", "dataHexa", "NON")
SI :modeUTF8Sortie ALORS HTTPAjouteParamètre("FORM", "modeUTF8Sortie", "OUI") SINON HTTPAjouteParamètre("FORM", "modeUTF8Sortie", "NON")
FIN
HTTPTimeOut(76000000)
ResLancement = HTTPEnvoieFormulaire("FORM", :URL)
SI ResLancement = Vrai ALORS
//------------------------------------------------------------------------------------------------------------
// traitement de la chaine si elle du ZIP ou du normale
// les données sont cryptée si crypt retour et le zip contient la meme chaine que si on a pas zip
//------------------------------------------------------------------------------------------------------------
SELON Vrai
CAS :methodeZip : v_chaineResult = HTTPDonneRésultat()
CAS :modeUTF8Sortie : v_chaineResult = UTF8VersChaîne(HTTPDonneRésultat())
AUTRE CAS : v_chaineResult = AnsiVersUnicode(HTTPDonneRésultat(httpRésultat),:alphabet)
FIN
//-----------------------------------------------------------------------------------------------------------
// gestion du zip normalement on doit avoir un retour blanc + fichier zip
// si on a une autre chose que chaine vide alors il y a eu un die dans le fichier php
// on oublie alors le zip et on continue pour traiter l'erreur
//-----------------------------------------------------------------------------------------------------------
SI methodeZip ALORS
fSauveTexte(v_ZipTemp,v_chaineResult)
resZip=zipOuvre("ZIP",v_ZipTemp,zipLecture)
SI resZip=0 ALORS
resZip=zipExtraitFichier("ZIP",v_ZipTempLire)
SI resZip=0 ALORS v_chaineResult=fChargeTexte(v_ZipTempLire)
zipFerme("ZIP")
FIN
fSupprime(v_ZipTemp)
fSupprime(v_ZipTempLire)
FIN
//-----------------------------------------------------------------------------------------------------------
// Gestion des erreurs
// soit la chaine est vide et on recupere l'entete
// soit elle ne contient pas les separateur et donc le Exec c'est mal passé
//-----------------------------------------------------------------------------------------------------------
SI Taille(v_chaineResult) = 0 ALORS
:ErreurText = HTTPDonneRésultat(httpEntête)
SI resZip<>0 ALORS :ErreurText = zipMsgErreur(resZip)
RENVOYER Faux
FIN
//-----------------------------------------------------------------------------------------------------------
// si on a pas les separateur alors il y a une une erreur
// on ne fait pas le traitement suivant on renvoie simplement le retour du script php
//----------------------------------------------------------------------------------------------------------
SI Position(v_chaineResult,"--DEBUTSQL--PHP4WDSEP") = 0 ALORS
:ErreurText = HTMLVersTexte(v_chaineResult)
RENVOYER(Faux)
FIN
//-----------------------------------------------------------------------------------------------------------
v_chaineResult = ExtraitChaîne(ExtraitChaîne(v_chaineResult,2,"--DEBUTSQL--PHP4WDSEP"),1,"--FINSQL--")
SINON
:ErreurText = ErreurInfo(errComplet)
RENVOYER Faux
FIN
:ligne[myRequestNumber] = 0
:colonne[myRequestNumber] = 0
retcode = Vrai
v_indCar est un entier = 1
v_indCour est un entier = 1
BOUCLE
Multitâche(-1)
// extraction de la valeur des colonnes
v_indCar = Position(v_chaineResult,"PHP4WDSEP",v_indCour)
v_ligne = v_chaineResult[[ v_indCour A v_indCar-1]]
SI v_indCar =0 ALORS SORTIR
v_indCour = v_indCour+Taille(v_ligne)+9
v_indCar+= v_indCour
SI v_ligne = "--BINDVARIABLE--" ALORS SORTIR
// traitement des valeur a recuperer la premiere fois on mettra les
// indice et nom de colonne ensuite on prend les valeur des lignes
SI v_ligne = "--LIGNES--" ALORS
:colonne[myRequestNumber] = v_colonne
:ligne[myRequestNumber] = 0
SINON
v_ligne = Remplace(v_ligne,"Ø","")
v_colonne ++
:ligne[myRequestNumber] ++
SELON myRequestNumber
CAS 1 : Dimension(:Resultat1,Dimension(:Resultat1)+1);:Resultat1[:colonne[myRequestNumber]+:ligne[myRequestNumber]] = v_ligne
CAS 2 : Dimension(:Resultat2,Dimension(:Resultat2)+1);:Resultat2[:colonne[myRequestNumber]+:ligne[myRequestNumber]] = v_ligne
CAS 3 : Dimension(:Resultat3,Dimension(:Resultat3)+1);:Resultat3[:colonne[myRequestNumber]+:ligne[myRequestNumber]] = v_ligne
CAS 4 : Dimension(:Resultat4,Dimension(:Resultat4)+1);:Resultat4[:colonne[myRequestNumber]+:ligne[myRequestNumber]] = v_ligne
CAS 5 : Dimension(:Resultat5,Dimension(:Resultat5)+1);:Resultat5[:colonne[myRequestNumber]+:ligne[myRequestNumber]] = v_ligne
FIN
FIN
FIN
// recuperation des variable bind dans le tableau
v_indiceBind=0
BOUCLE
v_indCar = Position(v_chaineResult,"PHP4WDSEP",v_indCour)
v_ligne = v_chaineResult[[ v_indCour A v_indCar-1]]
SI v_indCar =0 ALORS SORTIR
v_indCour = v_indCour+Taille(v_ligne)+9
v_indCar+= v_indCour
SI :CryptRetour ALORS v_ligne = :URLDecrypte(v_ligne)
v_indiceBind++
Dimension(:bindres,Dimension(:bindres)+1)
:bindres[v_indiceBind] = v_ligne
FIN
SI :ligne[myRequestNumber] > 0 ET :colonne[myRequestNumber] > 0 ALORS
:ligne[myRequestNumber] = :ligne[myRequestNumber] / :colonne[myRequestNumber]
:indiceEncour[myRequestNumber] = 1
SINON
:mySQLEnDehors = Vrai
FIN
:indiceEncour[myRequestNumber]=0
RENVOYER (retcode) |
Partager