mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
fix ftp send printer command
This commit is contained in:
@ -9,6 +9,8 @@ use DOMDocument;
|
|||||||
use DOMElement;
|
use DOMElement;
|
||||||
use DOMText;
|
use DOMText;
|
||||||
use DOMNode;
|
use DOMNode;
|
||||||
|
use Error;
|
||||||
|
use Exception;
|
||||||
use phpseclib3\Net\SFTP;
|
use phpseclib3\Net\SFTP;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@ -81,13 +83,25 @@ class ImpresoraEtiquetaService extends BaseService
|
|||||||
}
|
}
|
||||||
protected function sendToImpresoraEtiqueta(string $name, string $content, ImpresoraEtiquetaEntity $impresoraEtiqueta): bool
|
protected function sendToImpresoraEtiqueta(string $name, string $content, ImpresoraEtiquetaEntity $impresoraEtiqueta): bool
|
||||||
{
|
{
|
||||||
$ftp = new SFTP($impresoraEtiqueta->ip, $impresoraEtiqueta->port);
|
$conn = @ftp_connect($impresoraEtiqueta->ip,$impresoraEtiqueta->port);
|
||||||
$isLoginSuccess = $ftp->login(username: $impresoraEtiqueta->user, password: $impresoraEtiqueta->pass ?? '');
|
if(!$conn){
|
||||||
if ($isLoginSuccess) {
|
throw new Exception('Error al establecer conexión FTP');
|
||||||
$status = $ftp->put($name, $content);
|
|
||||||
} else {
|
|
||||||
$status = false;
|
|
||||||
}
|
}
|
||||||
|
$isLoginSuccess = @ftp_login($conn, $impresoraEtiqueta->user, $impresoraEtiqueta->pass);
|
||||||
|
if ($isLoginSuccess) {
|
||||||
|
} else {
|
||||||
|
throw new Exception('Error haciendo login en el servidor FTP');
|
||||||
|
}
|
||||||
|
if (!ftp_pasv($conn, true)) {
|
||||||
|
throw new Exception('Error entrando en modo pasivo');
|
||||||
|
}
|
||||||
|
if (ftp_put($conn, $name, $content, FTP_ASCII) === FALSE) {
|
||||||
|
$status = false;
|
||||||
|
ftp_close($conn);
|
||||||
|
}else{
|
||||||
|
$status = true;
|
||||||
|
}
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user