From 63b5c43ba4b67cf48df5c53005855a496133a2cf Mon Sep 17 00:00:00 2001
From: themohooks <81331307+themohooks@users.noreply.github.com>
Date: Wed, 16 Oct 2024 17:16:21 +0300
Subject: [PATCH] final update
---
.../Api/Admin/GetVehicleInputs.php | 8 +-
app/Controllers/Api/Images/Upload.php | 16 +-
app/Controllers/Api/Vehicles/Load.php | 2 +-
app/Models/Vehicle.php | 2 +-
app/Services/Upload.php | 20 +-
static/js/core_lk.js | 4 +-
views/pages/Admin/ModelsCreate.php | 89 ++++---
views/pages/Photo.php | 230 +++++++++++-------
views/pages/Top30.php | 2 +-
views/pages/Vehicle.php | 26 +-
views/pages/t.php | 149 ++++++------
11 files changed, 324 insertions(+), 224 deletions(-)
diff --git a/app/Controllers/Api/Admin/GetVehicleInputs.php b/app/Controllers/Api/Admin/GetVehicleInputs.php
index 459e8a5..69b5081 100644
--- a/app/Controllers/Api/Admin/GetVehicleInputs.php
+++ b/app/Controllers/Api/Admin/GetVehicleInputs.php
@@ -15,15 +15,19 @@ class GetVehicleInputs
$id = explode('/', $_SERVER['REQUEST_URI'])[4];
$vehicle = DB::query('SELECT * FROM entities WHERE id=:id', array(':id' => $id))[0];
$data = json_decode($vehicle['sampledata'], true);
+ $count = 1;
foreach ($data as $d) {
+
if ($d['important'] === "1") {
$imp = 'required';
}
echo '
-
+
-
+
';
+ $count++;
}
+
}
}
diff --git a/app/Controllers/Api/Images/Upload.php b/app/Controllers/Api/Images/Upload.php
index c6b1eef..f3e974a 100644
--- a/app/Controllers/Api/Images/Upload.php
+++ b/app/Controllers/Api/Images/Upload.php
@@ -21,6 +21,9 @@ class Upload
static $showtop = 'allowed';
static $subsnotify = 'allowed';
static $exif = 'exif';
+ static $entitydata_id = 0;
+ static $entityroute = NULL;
+ static $entitycomment = NULL;
public static function create($postbody, $content, $exif)
{
@@ -34,7 +37,7 @@ class Upload
} else {
$moderated = 1;
}
- DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, 0, :gallery, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup' => time(), ':moderated' => $moderated, ':gallery'=>$_POST['gallery']));
+ DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, 0, :gallery, :entityid, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup' => time(), ':moderated' => $moderated, ':gallery'=>$_POST['gallery'], ':entityid'=>self::$entitydata_id));
if (($moderated === 1) && (self::$subsnotify != 'disabled')) {
$followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid' => Auth::userid()));
foreach ($followers as $f) {
@@ -150,6 +153,15 @@ class Upload
if ((int)$_POST['disableexif'] === 1) {
self::$exif = 'disabled';
}
+ if ((int)$_POST['nid'] >= 1) {
+ if (DB::query('SELECT id FROM entities_data WHERE id=:id', array(':id'=>$_POST['nid']))[0]['id']) {
+ self::$entitydata_id = $_POST['nid'];
+ self::$entityroute = $_POST["route[".$_POST['nid']."]"];
+ self::$entitycomment = $_POST["notes[".$_POST['nid']."]"];
+ } else {
+ return;
+ }
+ }
if ($upload->getType() !== null) {
$content = Json::return(
array(
@@ -162,6 +174,8 @@ class Upload
'comments' => self::$comments,
'rating' => self::$rating,
'showtop' => self::$showtop,
+ 'entityroute' => self::$entityroute,
+ 'entitycomment' => self::$entitycomment
)
);
if (explode('/', $type)[0] === 'video') {
diff --git a/app/Controllers/Api/Vehicles/Load.php b/app/Controllers/Api/Vehicles/Load.php
index 3fcebd5..7df5ea3 100644
--- a/app/Controllers/Api/Vehicles/Load.php
+++ b/app/Controllers/Api/Vehicles/Load.php
@@ -27,7 +27,7 @@ class Load
'.$e['id'].'
|
- hhhhh |
+ '.$e['title'].' |
'.$e['comment'].'
|
diff --git a/app/Models/Vehicle.php b/app/Models/Vehicle.php
index e3d0fe4..4257cb9 100644
--- a/app/Models/Vehicle.php
+++ b/app/Models/Vehicle.php
@@ -9,7 +9,7 @@ class Vehicle {
$this->userid = $user_id;
}
public function i($table) {
- return DB::query("SELECT * FROM entities_data WHERE id=:id", array(':id'=>$this->userid))[0][$table];
+ return DB::query("SELECT * FROM entities WHERE id=:id", array(':id'=>$this->userid))[0][$table];
}
public function getvehicle($table) {
return DB::query("SELECT * FROM entities WHERE id=:id", array(':id'=>self::i('entityid')))[0][$table];
diff --git a/app/Services/Upload.php b/app/Services/Upload.php
index 3ba72c5..24ae352 100644
--- a/app/Services/Upload.php
+++ b/app/Services/Upload.php
@@ -77,26 +77,18 @@ class Upload
}
else
{
- echo $tmpname;
- $location = "your-location"; // Название локации
- $folder = "{$location}/" . basename($tmpname); // Создаем корректное имя для папки с файлом
+ $location = "your-location";
+ $folder = "{$location}/" . basename($tmpname);
- $uploadDir = "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}"; // Полный путь к директории
-
- // Создание директории, если она не существует
+ $uploadDir = "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}";
+
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
-
- // Путь к файлу, куда он должен быть перемещен
+
$destination = "{$uploadDir}/" . basename($tmpname);
- // Перемещение файла
- if (move_uploaded_file($tmpname, $destination)) {
- echo "Файл успешно перемещен!";
- } else {
- echo "Ошибка при перемещении файла.";
- }
+
$this->type = $type;
$this->src = "/uploads/{$folder}";
diff --git a/static/js/core_lk.js b/static/js/core_lk.js
index 56eeae1..b39f228 100644
--- a/static/js/core_lk.js
+++ b/static/js/core_lk.js
@@ -121,10 +121,10 @@ $(document).ready(function()
var html = '
\n';
html += '\n';
- html += '' + $('.num', this).html() + ' | \n';
+ html += '' + $('.num', this).html() + ' | \n';
html += '' + $('.mname', this).html() + ' | \n';
html += '' + _text['UP_ROUTE'] + ': | \n';
- html += ', | \n';
+ html += ', | \n';
html += '× | \n';
html += '
\n';
diff --git a/views/pages/Admin/ModelsCreate.php b/views/pages/Admin/ModelsCreate.php
index 290b63a..f502a17 100644
--- a/views/pages/Admin/ModelsCreate.php
+++ b/views/pages/Admin/ModelsCreate.php
@@ -7,51 +7,66 @@ use \App\Models\{User, Vehicle};
$vehicle = DB::query('SELECT * FROM entities WHERE id=:id', array(':id' => $_GET['id']))[0];
if (isset($_POST['create'])) {
- $postData = $_POST;
- $result = [];
+ $inputs = $_POST;
- foreach ($postData as $key => $value) {
- if (strpos($key, 'variable') === 0) {
- preg_match('/_(\d+)$/', $key, $matches);
- if (isset($matches[1])) {
- $index = $matches[1];
-
- if (!isset($result[$index])) {
- $result[$index] = [];
- }
- $newKey = preg_replace('/^variable/', '', $key);
- $newKey = preg_replace('/_\d+$/', '', $newKey);
-
- $result[$index][$newKey] = $value;
- }
+ $filteredInputs = [];
+ foreach ($inputs as $key => $value) {
+ if (strpos($key, 'modelinput_') === 0) {
+ $filteredInputs[$key] = $value;
}
}
-
- $jsonResult = json_encode($result, JSON_PRETTY_PRINT);
-
- DB::query('INSERT INTO entities VALUES (\'0\', :title, :createdate, :sampledata, :color)', array(':title' => $_POST['title'], ':createdate' => time(), ':sampledata' => $jsonResult, ':color' => $_POST['color']));
- header('Location: /admin?type=Entities');
+ ksort($filteredInputs);
+ $result = [];
+
+ $counter = 1;
+
+ foreach ($filteredInputs as $key => $value) {
+ $result[$counter] = [
+ 'value' => $value
+ ];
+ $counter++;
+ }
+ $jsonResult = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
+
+
+ DB::query('INSERT INTO entities_data VALUES (\'0\', :title, :createdate, :entityid, :comment, :content)', array(':title' => $_POST['title'], ':createdate'=>time(), ':entityid' => $_POST['entityid'], ':content' => $jsonResult, ':comment' => $_POST['comment']));
+ header('Location: /admin?type=Models');
}
?>
Создание модели
-
-