malalam
Messages postés
10839
Date d'inscription
lundi 24 février 2003
Statut
Membre
Dernière intervention
2 mars 2010
25
27 oct. 2006 à 08:16
Bon on reprend :
$aExport = scandir ('exports');
$aImport = scandir ('imported');
$aExport = array_diff ($aExport, $aForbid);
$aImport = array_diff ($aImport, $aForbid);
$sLocalExp .= 'REPERTOIRE : EXPORTS';
foreach ($aExport as $sFile) {
if (strpos ($sFile, 'art')) {
$iJs = 3;
} elseif (strpos ($sFile, 'cmd')) {
$iJs = 2;
}
$sLocalExp .= <<<HTML
<li>{$sFile} [UP]</li>
HTML;
}
$sLocalExp .= '';
$sLocalImp .= 'REPERTOIRE : IMPORTS';
foreach ($aImport as $sFile) {
$sLocalImp .= <<<HTML
<li>{$sFile} [UP]</li>
HTML;
}
$sLocalImp .= '';
cette partie affiche une partie locale : donc, à priori, tu n'en as pas besoin. Ou alors faut changer les répertoires lus.
En reprenant du haut :
$rCon = @ftp_connect ('ftp.3d-upside-down.com');
if (false === $rCon) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_CONNECT_ERROR);
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_CONNECT_LOG);
}
if (false === @ftp_login ($rCon, $user, $password)) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_LOGIN_ERROR);
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_LOGIN_LOG);
}
if (false === @ftp_pasv($rCon, true )) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_PASV_ERROR);
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_PASV_LOG);
}
ici, je me connecte, je me logge, je me mets en mode passif.
Je logge les erreurs...dans un tableau, en récupérant des constantes représentant les messages d'erreurs. Faut définir ces constantes.
if (empty ($_POST['dir'])) {
$_POST['dir'] = '/';
}
if (empty ($_POST['upload'])) {
$_POST['upload'] = '';
}
ça, c'est pour le formulaire d'upload et de changement de répertoire sur le ftp. Par défaut, je me place à la racine.
if (false === @ftp_chdir ($rCon, $_POST['dir'])) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_CHDIR_ERROR.' '.$_POST['dir'].'');
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_CHDIR_LOG.' '.$_POST['dir'].'');
}
ça, c'est pour me placer sur le répertoire choisi.
if (isset ($_POST['act']) && !empty ($_POST['act'])) {
switch ($_POST['act']) {
case 1 :
if (false === @ftp_get ($rCon, 'imported/'.$_POST['upload'], $_POST['upload'], FTP_BINARY)) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_GET_ERROR.' '.$_POST['upload'].'');
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_GET_LOG.' '.$_POST['upload'].'');
}
break;
case 2 :
if (false === @ftp_put ($rCon, 'retour_commande/'.$_POST['upload'],
'exports_ogilvy/'.$_POST['upload'], FTP_BINARY)) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_GET_ERROR.' '.$_POST['upload'].'');
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_GET_LOG.' '.$_POST['upload'].'');
}
break;
case 3 :
if (false === @ftp_put ($rCon, 'stock/'.$_POST['upload'], 'exports_ogilvy/'.$_POST['upload'], FTP_BINARY)) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_GET_ERROR.' '.$_POST['upload'].'');
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_GET_LOG.' '.$_POST['upload'].'');
}
break;
}
}
ça, c'est la gestion des upload.
$sCurDir = @ftp_pwd ($rCon);
$aContents = @ftp_nlist($rCon, $sCurDir);
if (false === $aContents) {
$aMsg[] = array ('TYPE' => 0, 'MSG' => FTP_DIR_ERROR.' '.$sCurDir.'');
} else {
$aMsg[] = array ('TYPE' => 1, 'MSG' => FTP_DIR_LOG.' '.$sCurDir.'');
$sCmd .= 'REPERTOIRE : '.$sCurDir.'';
foreach ($aContents as $sCont) {
$sCmd .= <<<HTML
<li>{$sCont} [UP]</li>
HTML;
}
$sCmd .= '';
}
là, je répère le répertoire sur lequel je suis, puis je lis son contenu pour l'afficher.
Dans le html, tu as une fonction js gérant les clicks (sur quoi je clique, quoi).
Et surtout, l'affichage des variables déclarées en haut et stockant mes affichages : répertoires, etc. Aucun affichage ne se fait dans la partie du haut.
Dernier conseil, fous toi en error_reporting (E_ALL);, soit via cette fonction, soit dans ton php.ini. Ca aide quand même à debugger...