0)) { $this->Id = intval($v); } } function Init() { if ($Nfo = parent::Init()) { $this->SetOrigine($Nfo['origine_upload_master']); $this->SetDestination($Nfo['destination_upload_master']); $this->SetEmail($Nfo['email_upload_master']); $this->SetTime($Nfo['time_upload_master']); $this->SetFtp($Nfo['ftp_upload_master']); return true; } else { return false; } } function SetId($v) { $this->Id = intval($v); } function GetId() { return $this->Id; } function SetOrigine($v) { $this->Origine = strval(stripslashes($v)); } function GetOrigine() { if (!$this->IsInit) $this->Init(); return $this->Origine; } function SetDestination($v) { $this->Destination = strval(stripslashes($v)); } function GetDestination() { if (!$this->IsInit) $this->Init(); return $this->Destination; } function SetEmail($v) { $this->Email = strval(stripslashes($v)); } function GetEmail() { if (!$this->IsInit) $this->Init(); return $this->Email; } function SetTime($v) { $this->Time = strval(stripslashes($v)); } function GetTime() { if (!$this->IsInit) $this->Init(); return $this->Time; } function SetFtp($v) { $this->Ftp = strval(stripslashes($v)); } function GetFtp() { if (!$this->IsInit) $this->Init(); return $this->Ftp; } function Save() { $A = array( 'origine_upload_master' => addslashes(strval($this->GetOrigine())), 'destination_upload_master' => addslashes(strval($this->GetDestination())), 'email_upload_master' => addslashes(strval($this->GetEmail())), 'time_upload_master' => addslashes(strval($this->GetTime())), ); if ($this->Id > 0) { $this->UpdateInTbl($A); } else { $this->Id = $this->InsertInTbl($A); } } function Upload() { if (!$this->IsInit) $this->Init(); ## Récupération des paramètres de connexion : ## FTP : login:password@host if (!ereg('.+:.+@.+', $this->GetFtp())) { echo 'Erreur: Paramètre FTP incorrect'."\n"; return false; } $Login = substr($this->GetFtp(), 0, strpos($this->GetFtp(), ':')); $Password = substr($this->GetFtp(), strpos($this->GetFtp(), ':') + 1, strpos($this->GetFtp(), '@') - strlen($this->GetFtp())); $Host = substr($this->GetFtp(), strpos($this->GetFtp(), '@') + 1); ## Connexion $ftp = ftp_connect($Host); ## Identification $login_result = ftp_login($ftp, $Login, $Password); ## Vérification de la connexion if ((!$ftp) || (!$login_result)) { echo 'La connexion FTP a échoué !'."\n"; return false; } else { ## Transfert $file_name = basename($this->GetOrigine()); $transfert = ftp_put($ftp, $this->GetDestination().$file_name, $this->GetOrigine(), FTP_BINARY); ## Fermeture ftp_close($ftp); if ($transfert) { $this->SetTime(date('Y-m-d H:i:s')); $this->Save(); return true; } else { echo 'Le transfert FTP de '.$this->GetOrigine().' a échoué !'."\n"; return false; } } } } ?>