update photo page

This commit is contained in:
themohooks 2024-07-05 09:49:49 +03:00
parent 7e55916b73
commit 4ba325ea42
8 changed files with 291 additions and 205 deletions

View file

@ -17,7 +17,7 @@ class Upload
public static function create($postbody, $content, $exif) public static function create($postbody, $content, $exif)
{ {
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :exif, 0, :content, :country, :city)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':country' => $_POST['country'], ':city' => $_POST['city'])); DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :exif, 0, :place, :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']));
echo json_encode( echo json_encode(
array( array(
'errorcode' => 0, 'errorcode' => 0,
@ -28,17 +28,19 @@ class Upload
public function __construct() public function __construct()
{ {
if ($_FILES['filebody']['error'][0] != 4) { if ($_FILES['image']['error'] != 4) {
$exif = new EXIF($_FILES['filebody']['tmp_name']); $exif = new EXIF($_FILES['image']['tmp_name']);
$upload = new UploadPhoto($_FILES['filebody'], 'cdn/img'); $upload = new UploadPhoto($_FILES['image'], 'cdn/img');
if ($upload['type'] !== null) { if ($upload->getType() !== null) {
$content = Json::return( $content = Json::return(
array( array(
'type' => 'none' 'type' => 'none',
'copyright' => $_POST['license'],
'comment' => $_POST['comment'],
) )
); );
self::$photourl = $upload['src']; self::$photourl = $upload->getSrc();
self::create($_POST['descr'], $content, $exif); self::create($_POST['descr'], $content, $exif->getData());
} }
} else { } else {
echo json_encode( echo json_encode(

19
app/Models/Photo.php Normal file
View file

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use \App\Services\DB;
class Photo {
public $photoid;
function __construct(int $user_id) {
$this->photoid = $user_id;
}
public function i($table) {
return DB::query("SELECT * FROM photos WHERE id=:id", array(':id'=>$this->photoid))[0][$table];
}
public function content($table) {
$content = json_decode(self::i('content'), true);
return $content[$table];
}
}

View file

@ -2,10 +2,9 @@
namespace App\Services; namespace App\Services;
class EXIF class EXIF
{ {
private $data;
public function __construct($file) public function __construct($file)
{ {
@ -18,8 +17,14 @@ class EXIF
$jsonData["$key.$name"] = $val; $jsonData["$key.$name"] = $val;
} }
} }
return json_encode($jsonData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); $this->data = json_encode($jsonData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
} } else {
return null; $this->data = null;
}
}
public function getData()
{
return $this->data;
} }
} }

View file

@ -6,6 +6,10 @@ namespace App\Services;
class Upload class Upload
{ {
public $type;
public $src;
public $size;
public $name;
private static function human_filesize($bytes, $dec = 2): string private static function human_filesize($bytes, $dec = 2): string
{ {
@ -37,11 +41,29 @@ class Upload
'Key' => $folder, 'Key' => $folder,
'SourceFile' => $file['tmp_name'] 'SourceFile' => $file['tmp_name']
]); ]);
return [ $this->type = explode('/', $file['type'])[0];
'type' => explode('/', $file['type'])[0], $this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn;
'src' => NGALLERY['root']['storage']['s3']['domains']['public'].'/'.$location . $filecdn, $this->size = self::human_filesize(filesize($file['tmp_name']));
'size' => self::human_filesize(filesize($file['tmp_name'])), $this->name = $file['name'];
'name' => $file['name'] }
]; public function getType()
{
return $this->type;
}
public function getSrc()
{
return $this->src;
}
public function getSize()
{
return $this->size;
}
public function getName()
{
return $this->name;
} }
} }

153
static/css/comments.css Normal file
View file

@ -0,0 +1,153 @@
#comfilter { float:right; margin-top:-60px; }
.comment, .cmt-write, .cmt-subscribe { border-top:#f7f7f7; }
.comment { padding:10px 11px 23px; position:relative; }
.rank { font-size:11px; color:#808080; }
.message-text { margin-top: 20px; overflow-wrap: anywhere; }
.pp-item-header { padding:3px 11px; margin:0; }
.cmt-write { padding-top:5px; }
.cmt-submit { font-size:11px; color:#777; }
.cmt-subscribe { padding:11px; }
#wtext { width:100%; height:150px; margin-bottom:10px; }
.wvote { margin-left:5px; position:relative; z-index:10; }
.w-rating, .w-btn, .w-btn span { box-sizing:border-box; width:34px; text-align:center; white-space:nowrap; }
.w-rating { position:relative; height:15px; font-size:10px; line-height:12px; font-weight:bold; color:#aaa; border:solid 1px #ccc; -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none; }
.w-rating.active { background-color:#fbfbfb; cursor:default; }
.w-rating-ext { width:0; height:15px; position:absolute; top:0; right:37px; transition:width 0.2s ease; overflow:hidden; text-align:right; }
.w-rating-ext div { display:inline-block; vertical-align:top; height:15px; font-size:10px; padding:1px 5px; white-space:nowrap; background-color:#f7f7f7; color:#aaa; word-spacing:-1px; }
.w-rating-ext.active, .w-rating-ext.active-locked { width:100px; }
.w-btn { display:block; height:0; position:absolute; transition:height 0.2s ease; overflow:hidden; outline:none; }
.w-btn.voted, .w-btn.voted:hover { background-color:#d7d7d7 !important; }
.w-btn.active { height:25px; }
.w-btn[vote="1"] { bottom:15px; }
.w-btn[vote="0"] { top:15px; }
.w-btn span { color:#000; position:absolute; left:0; }
.w-btn.voted span { color:#888; }
.w-btn[vote="1"] span { top:4px; }
.w-btn[vote="0"] span { bottom:4px; }
.pro { color:#0a0; }
.con { color:#d00; }
.compl { display:block; box-sizing:border-box; border:solid 1px #ccc; width:16px; height:15px; font-weight:bold; font-size:10px; line-height:12px; text-align:center; }
.compl:hover, .compl:visited:hover { border-color:#fa3; background-color:#fe9; }
.gold, .compl { color:#edad23; }
.grey { color:#08e; }
.wvote-tools { position:absolute; top:18px; right:37px; z-index:500; text-align:right; font-size:11px; padding:3px 6px; white-space:nowrap; }
.no-politics { color:#e00; margin-bottom:7px; }
.no-quote-last { color:#c00; font-size:11px; margin-top:15px; }
.toggle {
display:inline-block;
vertical-align:middle;
position:relative;
border-radius:10px;
background-color:#c5c5c5;
width:35px;
height:20px;
overflow:hidden;
-webkit-transition:all .25s linear; -moz-transition:all .25s linear; -o-transition:all .25s linear; transition:all .25s linear;
cursor:pointer;
-webkit-touch-callout:none;
-webkit-user-select:none; -khtml-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none;
}
.toggle .handle {
width:16px;
height:16px;
border-radius:8px;
position:absolute;
top:2px;
left:2px;
background-color:#fff;
-webkit-transition: all 0.4s cubic-bezier(0.33, 1.6, 0.66, 1); -moz-transition: all 0.4s cubic-bezier(0.33, 1.6, 0.66, 1); -o-transition: all 0.4s cubic-bezier(0.33, 1.6, 0.66, 1); transition: all 0.4s cubic-bezier(0.33, 1.6, 0.66, 1);
}
.toggle.on { background-color:#6bc86b; }
.toggle.on .handle { left:17px; }
.pc-links, .pc-topost { font-size:11px; }
/*@media (min-width:700px)
{*/
.p-comment { display:flex; margin-bottom:15px; }
.pc-photo { width:250px; padding:15px; }
.pc-content { display:flex; flex-direction:column; flex-grow:1; position:relative; }
.pc-text { padding:13px 15px 20px 5px; flex-grow:1; }
.pc-links { padding:0 0 15px 5px; }
.pc-topost { position:absolute; right:15px; top:12px; }
.pc-compl { position:absolute; right:15px; bottom:15px; }
.comment-votes-block { float:right; display:flex; position:relative; }
.cmt-cons, .cmt-mark { margin-right:11px; }
/*}
@media (max-width:700px)
{
.p-comment { display:flex; flex-direction:column; align-items:center; }
.pc-photo { padding-bottom:7px; }
.pc-content { display:flex; flex-wrap:wrap; }
.pc-text { order:2; width:100%; border-top:solid 1px #ddd; border-bottom:solid 1px #ddd; padding:10px 0; margin-bottom:7px; }
.pc-links { order:1; width:100%; text-align:center; padding-bottom:10px; }
.pc-topost { order:3; margin-top:3px; flex-grow:1; }
.pc-compl { order:4; margin-top:3px; }99999
.cmt-aname { display:block; }
.cmt-dot { display:none !important; }
.cmt-date { display:inline !important; }
#title { padding-left:0; }
#title3 { display:none; }
#title2 { display:inline-block; }
#navtop_frame { display:flex; flex-direction:column; justify-content:space-around; padding:3px 0 }
#languages { float:none; padding:0 10px 5px; }
#title_s { display:block; margin:-3px 0 3px !important; }
#navtop { padding-left:0; }
#navtop a[href="/photo/"] { padding-left:0; float:none !important; position:absolute; top:0; right:0; font-size:11px; color:#fff; }
.main { padding:0 10px; }
h1 { font-size:30px; }
h2 { font-size:26px; }
.pages { line-height:20px; }
.pg, .ps { padding:7px 10px; }
#comfilter { float:none; margin:0 0 15px; }
.p20p { padding:10px !important; margin-bottom:-10px; }
.p5h { padding:0 !important; }
.p5h > table, .p5h > table > tbody, .p5h > table > tbody > tr, .p5h > table > tbody > tr > td { display:block; width:100%; }
.p5h > tr { display:flex; flex-direction:column; align-items:center; }
.pb_pre, .pb_photo, .pb_descr, .pb_tools { display:block; padding:0; text-align:center; }
.pb_pre { padding:10px 0 7px; }
.pb_descr p { margin:7px 0; }
.pb_descr p.sm { margin:9px 0 5px; }
.pb_tools { margin-top:15px; }
.pb_tools a { display:inline-block; font-size:13px; padding:5px 10px; background-image:url('/img/yellow_stripes.png'); }
.pb_tools > .s3 { display:block; position:static !important; font-size:11px; padding:0 !important; margin:3px 0 0 0 !important; background:transparent; color:#bbb !important; }
.pc_pre { display:none; }
.message_text.feed { margin-top:10px; }
}*/

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" href="/static/css/trans.css"> <link rel="stylesheet" href="/static/css/trans.css">
<link rel="stylesheet" href="/static/css/photo.css"> <link rel="stylesheet" href="/static/css/photo.css">
<link rel="stylesheet" href="/static/css/notie.css"> <link rel="stylesheet" href="/static/css/notie.css">
<link rel="stylesheet" href="/static/css/comments.css">
<script src="/static/js/jquery.js"></script> <script src="/static/js/jquery.js"></script>
<script src="/static/js/jquery-ui.js"></script> <script src="/static/js/jquery-ui.js"></script>
<script src="/static/js/jquery.form.min.js"></script> <script src="/static/js/jquery.form.min.js"></script>

View file

@ -1,3 +1,11 @@
<?php
use App\Services\{DB, Auth, Date, Json};
$photo = new \App\Models\Photo(explode('/', $_SERVER['REQUEST_URI'])[2]);
$photouser = new \App\Models\User($photo->i('user_id'));
?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ru"> <html lang="ru">
@ -74,7 +82,7 @@
<div style="display:inline-block"> <div style="display:inline-block">
<div id="underphoto_frame"> <div id="underphoto_frame">
<div id="ph_frame"> <div id="ph_frame">
<img id="ph" src="/photo/13/61/06/1361063.jpg" alt="Москва, ЗиУ-683Б [Б00] № 4608; Москва, ЗиУ-682В-012 [В0А] № 4238; Москва — Троллейбусные баррикады в августе 1991" title="Москва, ЗиУ-683Б [Б00] № 4608; Москва, ЗиУ-682В-012 [В0А] № 4238; Москва — Троллейбусные баррикады в августе 1991"> <img id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
</div> </div>
</div> </div>
</div> </div>
@ -116,28 +124,17 @@
<div style="line-height:15px; margin-bottom:10px"> <div style="line-height:15px; margin-bottom:10px">
<table class="pwrite"> <table class="pwrite">
<tr> <tr>
<td class="nw" valign="top" align="right"><a href="/country/1/"><img class="flag" src="/img/r/1.gif" title="Россия"></a>&nbsp; <b><a href="/city/1/">Москва</a></b>,&nbsp;</td> <td class="nw" valign="top" align="right"><b><?= $photo->i('place') ?></b></td>
<td class="nw" valign="top" align="right"><span class="s5">&nbsp;ЗиУ-683Б [Б00]</span></td>
<td class="nw s5" align="left" valign="top">&nbsp; <b><a href="/vehicle/78618/#n76272">4608</a></b>&nbsp;</td>
<td class="nw" align="left" valign="top"></td>
</tr>
<tr>
<td class="nw" valign="top" align="right" colspan="2"><span class="s5">&nbsp;ЗиУ-682В-012 [В0А]</span></td>
<td class="nw s5" align="left" valign="top">&nbsp; <b><a href="/vehicle/71937/#n70204">4238</a></b>&nbsp;</td>
<td class="nw" align="left" valign="top"></td> <td class="nw" align="left" valign="top"></td>
</tr> </tr>
</table> </table>
<div><a href="/articles/183/">Троллейбусные баррикады в августе 1991</a></div>
</div> </div>
</div> </div>
<div><b>Новинский бульвар</b> <div>
<div style="padding-top:8px">Еще целые троллейбусы.<br /> <div style="padding-top:8px"><?= $photo->content('comment') ?></div>
<br />
Автор : А.И.Авдеев<br />
Источник <a href="https://pastvu.com/p/807429" target="_blank">https://pastvu.com/p/807429</a>
</div>
</div><br> </div><br>
<div>Прислал <a href="/author/14224/">Максим Дорофеев ( ФанатВ )</a> &middot; <span class="flag"><img src="/img/r/1.gif" title="Россия"> Калуга</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Дата: <b>19 августа 1991 г., понедельник (примерно)</b></div> <div>Прислал <a href="/author/<?= $photo->i('user_id') ?>/"><?= $photouser->i('username') ?></a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Дата: <b><?= Date::zmdate($photo->i('posted_at')) ?></b></div>
<table id="pp-items"> <table id="pp-items">
<tr> <tr>
<td id="pp-left-col"> <td id="pp-left-col">
@ -369,118 +366,29 @@
</td> </td>
<td id="pp-main-col"> <td id="pp-main-col">
<div id="pp-item-vdata"> <div id="pp-item-vdata">
<div class="p0">
<h4 class="pp-item-header"><b><a href="/vehicle/78618/#n76272">Москва, ЗиУ-683Б [Б00] 4608</a></b></h4>
<div class="pp-item-body">
<table class="linetable">
<col width="25%">
<tr class="s11 h21">
<td class="ds nw">Депо/Парк:</td>
<td class="ds"><b><a href="/list.php?did=10">4-й троллейбусный парк имени П.М. Щепетильникова</a></b></td>
</tr>
<tr class="s1 h21">
<td class="ds nw">С...:</td>
<td class="ds"><b>01.1989</b></td>
</tr>
<tr class="s11 h21">
<td class="ds nw">Модель:</td>
<td class="ds"><b><a href="/model/66/">ЗиУ-683Б [Б00]</a></b></td>
</tr>
<tr class="s1 h21">
<td class="ds nw">Построен:</td>
<td class="ds"><b>12.1988</b></td>
</tr>
<tr class="s11 h21">
<td class="ds nw">Заводской :</td>
<td class="ds"><b>158</b></td>
</tr>
<tr class="s1 h21">
<td class="ds nw">Текущее состояние:</td>
<td class="ds" style="padding-left:7px; padding-top:1px"><span class="state s5">Списан (<b>10.09.1992</b>)</span></td>
</tr>
<tr class="s11 h21">
<td class="ds nw">Назначение:</td>
<td class="ds">Пассажирский</td>
</tr>
<tr class="s1">
<td colspan="2" class="ds" style="padding:9px 11px">Заводская окраска изображена на фото <a href="https://transphoto.org/photo/1194603/" target="_blank">https://transphoto.org/photo/1194603/</a> .<br />
<br />
Капитальных ремонтов не проходил.<br />
<br />
Работал на маршрутах Б,10.<br />
<br />
Разбит во время событий августа 1991 г.
</td>
</tr>
</table>
</div>
</div>
<div class="p0">
<h4 class="pp-item-header"><b><a href="/vehicle/71937/#n70204">Москва, ЗиУ-682В-012 [В0А] 4238</a></b></h4>
<div class="pp-item-body">
<table class="linetable">
<col width="25%">
<tr class="s11 h21">
<td class="ds nw">Депо/Парк:</td>
<td class="ds"><b><a href="/list.php?did=10">4-й троллейбусный парк имени П.М. Щепетильникова</a></b></td>
</tr>
<tr class="s1 h21">
<td class="ds nw">С...:</td>
<td class="ds"><b>1988</b></td>
</tr>
<tr class="s11 h21">
<td class="ds nw">Модель:</td>
<td class="ds"><b><a href="/model/104/">ЗиУ-682В-012 [В0А]</a></b></td>
</tr>
<tr class="s1 h21">
<td class="ds nw">Построен:</td>
<td class="ds"><b>1988</b></td>
</tr>
<tr class="s11 h21">
<td class="ds nw">Заводской :</td>
<td class="ds"><b>31447</b></td>
</tr>
<tr class="s1 h21">
<td class="ds nw">Текущее состояние:</td>
<td class="ds" style="padding-left:7px; padding-top:1px"><span class="state s5">Списан (<b>09.1992</b>)</span></td>
</tr>
<tr class="s11 h21">
<td class="ds nw">Назначение:</td>
<td class="ds">Пассажирский</td>
</tr>
<tr class="s1">
<td colspan="2" class="ds" style="padding:9px 11px">Заводская окраска бело-красный в &quot;шипиловской&quot; схеме.<br />
<br />
Капитальных ремонтов не проходил.<br />
<br />
Работал на маршрутах Б,10.<br />
<br />
&quot;Баррикада&quot; в путче 1991 года
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="p0" id="pp-item-exif"> <div class="p0" id="pp-item-exif">
<h4 class="pp-item-header">Параметры съёмки</h4> <h4 class="pp-item-header">Параметры съёмки</h4>
<div class="pp-item-body"> <div class="pp-item-body">
<table class="linetable" id="exif"> <table class="linetable" id="exif">
<tr class="s11 h21" style="display:none"> <?php
<td class="ds nw" width="30%">Производитель камеры:</td> $data = json_decode($photo->i('exif'), true);
<td class="ds">Epson</td>
</tr> foreach ($data as $key => $value) {
if ($key === 'FILE.FileDateTime') {
$value = Date::zmdate($value);
}
echo '
<tr class="s11 h21"> <tr class="s11 h21">
<td class="ds nw" width="30%">Модель камеры:</td> <td class="ds nw" width="30%">' . htmlspecialchars($key) . ':</td>
<td class="ds">Perfection3200</td> <td class="ds">' . htmlspecialchars($value) . '</td>
</tr> </tr>';
<tr class="s1 h21" style="display:none"> }
<td class="ds nw" width="30%">Программное обеспечение:</td>
<td class="ds">Adobe Photoshop CC 2018 (Windows)</td>
</tr> ?>
<tr class="s1 h21">
<td class="ds" colspan="2"><a id="showexif" href="#">Показать весь EXIF</a></td>
</tr>
</table> </table>
</div> </div>
</div> </div>

View file

@ -574,16 +574,7 @@ $user = new User(Auth::userid());
</table> </table>
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td style="padding:5px 2px 10px">
<input type="checkbox" name="naa" id="naa" value="1" onclick="toggleNAA()"> <label for="naa">Я не автор этой фотографии</label>
<div id="naa_hint" style="display:none">
<div class="sm" style="margin-top:5px; line-height:14px"><b>Не забудьте указать источник и имя автора в поле «Описание»!</b><br />Если Вы не являетесь автором фотографии, убедитесь, что автор дал Вам разрешение публиковать её на СТТС.<br />Загрузка фотографий без разрешения их автора <u>запрещена</u>.<br><br><b>Разрешение на публикацию на Transphoto</b> (ссылка или пояснение):</div>
<input type="text" name="naa_allow" id="naa_allow" style="width:506px" value="">
</div>
</td>
</tr>
<tr> <tr>
<td colspan="2" style="height:7px"></td> <td colspan="2" style="height:7px"></td>
<tr> <tr>
@ -607,13 +598,7 @@ $user = new User(Auth::userid());
<tr> <tr>
<td colspan="2" class="narrow" style="font-size:20px; padding:10px 15px 5px">Шаг 3. <b>Выберите опции загрузки:</b></td> <td colspan="2" class="narrow" style="font-size:20px; padding:10px 15px 5px">Шаг 3. <b>Выберите опции загрузки:</b></td>
</tr> </tr>
<tr>
<td></td>
<td style="padding-right:15px; padding-bottom:15px">
<input type="checkbox" name="up-comment-link" id="up-comment-link" value="1"> <label for="up-comment-link">Добавить комментарий при публикации</label><span id="up-comment-row" style="display:none">:<br>
<textarea name="comment" id="comment" rows="5" style="width:100%; margin-top:5px"></textarea></span>
</td>
</tr>
<tr> <tr>
<td class="lcol">Лицензия:</td> <td class="lcol">Лицензия:</td>
<td style="padding-bottom:7px"> <td style="padding-bottom:7px">
@ -631,16 +616,7 @@ $user = new User(Auth::userid());
</select> &nbsp; &nbsp;<a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a> </select> &nbsp; &nbsp;<a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a>
</td> </td>
</tr> </tr>
<tr>
<td class="lcol">
Пояснения модератору:
<div class="sm" style="color:#999; margin:3px 5px 0 0">(если требуются)</div>
</td>
<td style="padding-right:15px">
<textarea name="notes_mod" id="notes_mod" style="width:100%; height:40px"></textarea>
<div class="sm" style="color:#999; margin-top:3px">Можно пояснить ценность фотографии, если на ней изображёно что-то редкое или уникальное (ведь фотомодераторам это может быть неизвестно).</div>
</td>
</tr>
<tr> <tr>
<td></td> <td></td>
@ -678,7 +654,7 @@ var continuepost = 0;
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/api/posts/create', url: '/api/upload',
data: formData, data: formData,
xhr: function() { xhr: function() {