Adopted composer autoload way
Split up classes into separate way, to allow autoloader to do it's work Signed-off-by: Diederik de Groot <ddegroot@talon.nl>
This commit is contained in:
@@ -2,13 +2,21 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once("lib/tftp.php");
|
||||
require_once("lib/config.php");
|
||||
require_once("lib/resolve.php");
|
||||
require(implode(DIRECTORY_SEPARATOR, array(
|
||||
__DIR__,
|
||||
'..',
|
||||
'..',
|
||||
'vendor',
|
||||
'autoload.php'
|
||||
)));
|
||||
|
||||
use SCCP\TFTP as TFTP;
|
||||
use SCCP\Resolve as Resolve;
|
||||
class TFTPProvisioner extends TFTP\TFTPServer
|
||||
use PROVISION\TFTP;
|
||||
use PROVISION\ConfigParser;
|
||||
use PROVISION\Resolve;
|
||||
use PROVISION\Logger;
|
||||
use PROVISION\Utilts;
|
||||
|
||||
class TFTPProvisioner extends TFTP\Server
|
||||
{
|
||||
private $_debug;
|
||||
private $_resolve;
|
||||
@@ -23,7 +31,7 @@ class TFTPProvisioner extends TFTP\TFTPServer
|
||||
parent::__construct($server_url, $logger);
|
||||
$this->_debug = $debug;
|
||||
$this->max_put_size = 60000000;
|
||||
$this->_resolve = new Resolve\Resolve($config);
|
||||
$this->_resolve = new Resolve($config);
|
||||
$this->_settings_path = $this->_config['main']['base_path'] . DIRECTORY_SEPARATOR
|
||||
. $this->_config['subdirs']['settings']['path'] . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
@@ -83,13 +91,13 @@ class TFTPProvisioner extends TFTP\TFTPServer
|
||||
|
||||
}
|
||||
|
||||
global $base_path;
|
||||
$host = "127.0.0.1";
|
||||
$port = 10069;
|
||||
$url = "udp://$host:$port";
|
||||
$base_path = realpath(__DIR__ . DIRECTORY_SEPARATOR . "../..");
|
||||
|
||||
echo "\nStarting TFTP Provisioner...\n";
|
||||
$configParser = new SCCP\Config\ConfigParser($base_path, "config.ini");
|
||||
$configParser = new ConfigParser($base_path, "config.ini");
|
||||
$server = new TFTPProvisioner($url, $configParser->getConfiguration(), $logger);
|
||||
if(!$server->loop($error))
|
||||
die("$error\n");
|
||||
|
@@ -1,9 +1,19 @@
|
||||
<?php
|
||||
include_once("../../lib/config.php");
|
||||
include_once("../../lib/resolve.php");
|
||||
|
||||
require(implode(DIRECTORY_SEPARATOR, array(
|
||||
__DIR__,
|
||||
'..',
|
||||
'..',
|
||||
'vendor',
|
||||
'autoload.php'
|
||||
)));
|
||||
|
||||
use PROVISION\ConfigParser;
|
||||
use PROVISION\Resolve;
|
||||
$request = $_REQUEST ?? null;
|
||||
|
||||
function send_fallback_html($message) {
|
||||
global $request;
|
||||
while (ob_get_level()) {ob_end_clean();}
|
||||
if (ob_get_length() === false) {
|
||||
ob_start();
|
||||
@@ -50,10 +60,11 @@ if (!$request || empty($request) || !array_key_exists('filename',$request) || em
|
||||
exit();
|
||||
}
|
||||
try {
|
||||
global $base_path;
|
||||
$base_path = realpath(__DIR__ . DIRECTORY_SEPARATOR . "../..");
|
||||
//global $base_path;
|
||||
$req_filename=$request['filename'];
|
||||
$configParser = new SCCP\Config\ConfigParser($base_path, "config.ini");
|
||||
$resolve = new SCCP\Resolve\Resolve($configParser->getConfiguration());
|
||||
$configParser = new ConfigParser($base_path, "config.ini");
|
||||
$resolve = new Resolve($configParser->getConfiguration());
|
||||
if (($filename = $resolve->resolve($req_filename))) {
|
||||
sendfile($filename);
|
||||
}
|
||||
|
Reference in New Issue
Block a user