mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Config;
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
|
|
|
class PresupuestoSFTP extends BaseConfig
|
|
{
|
|
public string $host;
|
|
public int $port;
|
|
public string $username;
|
|
public string $password;
|
|
public string $base_dir;
|
|
public string $remote_base_dir = 'ficheros'; // subcarpeta específica para presupuestos
|
|
public int $id_offset;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->host = env("HIDRIVE_FILES_HOST", "sftp.hidrive.ionos.com");
|
|
$this->port = (int) env("HIDRIVE_FILES_PORT", 22);
|
|
$this->username = env("HIDRIVE_FILES_USER");
|
|
$this->password = env("HIDRIVE_FILES_PASS");
|
|
$this->id_offset = (int) env("BUDGET_FILES_OFFSET_ID", 1000000);
|
|
|
|
// Directorio base remoto: /users/usuario/dominio
|
|
$domain = parse_url(env("app.baseURL"), PHP_URL_HOST);
|
|
$this->base_dir = "/users/{$this->username}/{$domain}";
|
|
}
|
|
|
|
/**
|
|
* Devuelve la ruta completa del directorio remoto para un presupuesto
|
|
*/
|
|
public function getRemoteDirForPresupuesto(int $presupuestoId): string
|
|
{
|
|
return "{$this->base_dir}/{$this->remote_base_dir}/" . ($presupuestoId + $this->id_offset);
|
|
}
|
|
}
|