| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/seaside.pacim.de/web/crons/ |
Upload File : |
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once("../includes/config.inc.php");
$db = new MysqliDb( MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB );
if(!isset($_GET['token']) && $_GET['token'] != "eFD6dx2G4RFBkrYS7Z87") die();
// start import function
$arr_files = find_excel_files();
echo "<pre>";
print_r($arr_files);
echo "</pre>";
/**
* Sucht im Verzeichnis "aida" nach Excel-Dateien und sammelt Informationen darüber.
*
* @return array Ein assoziatives Array von Excel-Dateien, gruppiert nach Datum, oder false, wenn keine Dateien gefunden wurden.
*/
function find_excel_files() {
$dir = PATH_DATAS . '/aida/';
$arr_files = array();
$iCountAll = 0;
$iCountError = 0;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir)
);
foreach ($iterator as $file) {
if (!$file->isFile()) {
continue;
}
$filename = $file->getFilename();
$full_path = dirname(__DIR__) . '/datas/aida/' . $filename;
$date_obj = DateTime::createFromFormat('Ymd', preg_replace('/[^0-9]/', '', $filename));
if (!$date_obj || !$date_obj->format('Y-m-d')) {
$arr_files['error'][] = get_file_info($file, $full_path);
$iCountError++;
continue;
}
if (strpos($filename, "ParkingOperatorlist") !== false) {
$excel = new importExcel($full_path);
$date = $date_obj->format('Y-m-d');
$arr_files[$date][] = get_file_info($file, $full_path, $excel->getInfo());
$iCountAll++;
}
move_to_trash($file, $full_path);
}
if (empty($arr_files)) {
return false;
}
return $arr_files;
}
/**
* Gibt Informationen über eine Datei zurück.
*
* @param SplFileInfo $file Die Datei.
* @param string $full_path Der vollständige Pfad zur Datei.
* @param mixed $excel_info (optional) Informationen über das Excel-Blatt.
* @return object Informationen über die Datei.
*/
function get_file_info($file, $full_path, $excel_info = null) {
return (object) array(
'file' => $full_path,
'path' => $file->getFilename(),
'md5' => md5_file($full_path),
'size' => filesize($full_path),
'type' => filetype($full_path),
'excel' => $excel_info,
'file_content_date' => $date_obj,
);
}
/**
* Verschiebt eine Datei in den Ordner "trash" mit dem aktuellen Datum.
*
* @param SplFileInfo $file Die Datei.
* @param string $full_path Der vollständige Pfad zur Datei.
*/
function move_to_trash($file, $full_path) {
$trash_path = PATH_DATAS . "/trash/" . date('Y-m-d') . "/";
if (!is_dir($trash_path)) {
mkdir($trash_path);
sleep(1);
}
if (copy($full_path, $trash_path . $file->getFilename())) {
sleep(0.5);
unlink($full_path);
}
}