* Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/ftp/admin/ftpclient.php * \ingroup ftp * \brief Admin page to setup FTP client module */ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); $langs->load("admin"); $langs->load("ftp"); // Security check if (!$user->admin) accessforbidden(); $def = array(); $lastftpentry=0; $action = GETPOST("action"); $entry = GETPOST("numero_entry"); // Positionne la variable pour le nombre de rss externes $sql ="select MAX(name) as name from ".MAIN_DB_PREFIX."const"; $sql.=" WHERE name like 'FTP_SERVER_%'"; $result=$db->query($sql); if ($result) { $obj = $db->fetch_object($result); preg_match('/([0-9]+)$/i',$obj->name,$reg); if ($reg[1]) $lastftpentry = $reg[1]; } else { dol_print_error($db); } if ($action == 'add' || GETPOST("modify")) { $ftp_name = "FTP_NAME_" . $entry;// $_POST["numero_entry"]; $ftp_server = "FTP_SERVER_" . $entry; //$_POST["numero_entry"]; $error=0; $mesg=''; if (! GETPOST("$ftp_name")) { $error=1; $mesg.='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")).'
'; } if (! GETPOST("$ftp_server")) { $error=1; $mesg.='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Server")).'
'; } if (! $error) { $ftp_port = "FTP_PORT_" . $entry; $ftp_user = "FTP_USER_" . $entry; $ftp_password = "FTP_PASSWORD_" . $entry; $db->begin(); $result1=dolibarr_set_const($db, "FTP_PORT_" . $entry,GETPOST($ftp_port),'chaine',0,'',$conf->entity); if ($result1) $result2=dolibarr_set_const($db, "FTP_SERVER_" . $entry, GETPOST($ftp_server),'chaine',0,'',$conf->entity); if ($result2) $result3=dolibarr_set_const($db, "FTP_USER_" . $entry,GETPOST($ftp_user),'chaine',0,'',$conf->entity); if ($result3) $result4=dolibarr_set_const($db, "FTP_PASSWORD_" . $entry,GETPOST($ftp_password),'chaine',0,'',$conf->entity); if ($result4) $result5=dolibarr_set_const($db, "FTP_NAME_" . $entry,GETPOST($ftp_name),'chaine',0,'',$conf->entity); if ($result1 && $result2 && $result3 && $result4 && $result5) { $db->commit(); //$mesg='
'.$langs->trans("Success").'
'; header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { $db->rollback(); dol_print_error($db); } } } if ($_POST["delete"]) { if($entry) { $db->begin(); $result1=dolibarr_del_const($db,"ftp_port_" . $entry,$conf->entity); if ($result1) $result2=dolibarr_del_const($db,"ftp_server_" . $entry,$conf->entity); if ($result2) $result3=dolibarr_del_const($db,"ftp_user_" . $entry,$conf->entity); if ($result3) $result4=dolibarr_del_const($db,"ftp_password_" . $entry,$conf->entity); if ($result4) $result5=dolibarr_del_const($db,"ftp_name_" . $entry,$conf->entity); if ($result1 && $result2 && $result3 && $result4 && $result5) { $db->commit(); //$mesg='
'.$langs->trans("Success").'
'; header("Location: ftpclient.php"); exit; } else { $db->rollback(); dol_print_error($db); } } } /* * View */ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("FTPClientSetup"), $linkback, 'setup'); print '
'; if (! function_exists('ftp_connect')) { print $langs->trans("FTPFeatureNotSupportedByYourPHP"); } else { // Formulaire ajout print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; ?> '; print ''; ?>
'."\n"; $sql ="select name, value, note from ".MAIN_DB_PREFIX."const"; $sql.=" WHERE name like 'FTP_SERVER_%'"; $sql.=" ORDER BY name"; dol_syslog("ftpclient select ftp setup sql=".$sql,LOG_DEBUG); $resql=$db->query($sql); if ($resql) { $num =$db->num_rows($resql); $i=0; while ($i < $num) { $obj = $db->fetch_object($resql); preg_match('/([0-9]+)$/i',$obj->name,$reg); $idrss = $reg[0]; //print "x".join(',',$reg)."=".$obj->name."=".$idrss; $var=true; print ""; print ''; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; $var=!$var; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $i++; } } else { dol_print_error($db); } print '
'.$langs->trans("NewFTPClient").''.$langs->trans("Example").'
'.$langs->trans("Label").'My FTP access
'.$langs->trans("Server").'localhost
'.$langs->trans("Port").'21
'.$langs->trans("User").'myftplogin
'.$langs->trans("Password").'myftppassword
">
".$langs->trans("FTP")." ".($idrss)."
".$langs->trans("Name")."
".$langs->trans("Server")."
".$langs->trans("Port")."
".$langs->trans("User")."
".$langs->trans("Password")."
"; print "trans("Modify")."\">"; print "   "; print "trans("Delete")."\">"; print ""; print "
'; } dol_htmloutput_mesg($mesg); $db->close(); llxFooter(); ?>