diff --git a/app/Controllers/Api/Images/Upload.php b/app/Controllers/Api/Images/Upload.php index 4f2b7b0..00cfb5f 100644 --- a/app/Controllers/Api/Images/Upload.php +++ b/app/Controllers/Api/Images/Upload.php @@ -17,7 +17,7 @@ class Upload 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( array( 'errorcode' => 0, @@ -28,17 +28,19 @@ class Upload public function __construct() { - if ($_FILES['filebody']['error'][0] != 4) { - $exif = new EXIF($_FILES['filebody']['tmp_name']); - $upload = new UploadPhoto($_FILES['filebody'], 'cdn/img'); - if ($upload['type'] !== null) { + if ($_FILES['image']['error'] != 4) { + $exif = new EXIF($_FILES['image']['tmp_name']); + $upload = new UploadPhoto($_FILES['image'], 'cdn/img'); + if ($upload->getType() !== null) { $content = Json::return( array( - 'type' => 'none' + 'type' => 'none', + 'copyright' => $_POST['license'], + 'comment' => $_POST['comment'], ) ); - self::$photourl = $upload['src']; - self::create($_POST['descr'], $content, $exif); + self::$photourl = $upload->getSrc(); + self::create($_POST['descr'], $content, $exif->getData()); } } else { echo json_encode( diff --git a/app/Models/Photo.php b/app/Models/Photo.php new file mode 100644 index 0000000..69ece93 --- /dev/null +++ b/app/Models/Photo.php @@ -0,0 +1,19 @@ +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]; + } + +} \ No newline at end of file diff --git a/app/Services/EXIF.php b/app/Services/EXIF.php index 28ec703..07dcd90 100644 --- a/app/Services/EXIF.php +++ b/app/Services/EXIF.php @@ -2,24 +2,29 @@ namespace App\Services; - class EXIF - { + private $data; public function __construct($file) { $exif = exif_read_data($file, 0, true); $jsonData = []; - + if ($exif !== false) { foreach ($exif as $key => $section) { foreach ($section as $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 { + $this->data = null; } - return null; + } + + public function getData() + { + return $this->data; } } diff --git a/app/Services/Upload.php b/app/Services/Upload.php index 6c80b9f..5201889 100644 --- a/app/Services/Upload.php +++ b/app/Services/Upload.php @@ -6,6 +6,10 @@ namespace App\Services; class Upload { + public $type; + public $src; + public $size; + public $name; private static function human_filesize($bytes, $dec = 2): string { @@ -37,11 +41,29 @@ class Upload 'Key' => $folder, 'SourceFile' => $file['tmp_name'] ]); - return [ - 'type' => explode('/', $file['type'])[0], - 'src' => NGALLERY['root']['storage']['s3']['domains']['public'].'/'.$location . $filecdn, - 'size' => self::human_filesize(filesize($file['tmp_name'])), - 'name' => $file['name'] - ]; + $this->type = explode('/', $file['type'])[0]; + $this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn; + $this->size = self::human_filesize(filesize($file['tmp_name'])); + $this->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; } } + diff --git a/static/css/comments.css b/static/css/comments.css new file mode 100644 index 0000000..ca3848e --- /dev/null +++ b/static/css/comments.css @@ -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; } +}*/ \ No newline at end of file diff --git a/views/components/LoadHead.php b/views/components/LoadHead.php index 4b67245..0759126 100644 --- a/views/components/LoadHead.php +++ b/views/components/LoadHead.php @@ -10,6 +10,7 @@ + diff --git a/views/pages/Photo.php b/views/pages/Photo.php index dd2a0a1..66aa484 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -1,17 +1,25 @@ +i('user_id')); +?> +
- + + -
<
>
-
+
Новинский бульвар
-
+
+ = $photo->content('comment') ?>
- Прислал Максим Дорофеев ( ФанатВ ) · Калуга Дата: 19 августа 1991 г., понедельник (примерно)
+ Прислал = $photouser->i('username') ?> Дата: = Date::zmdate($photo->i('posted_at')) ?>
|
Комментарии · 1
++ Ссылка +
Ваш комментарий
-Комментарии могут оставлять только зарегистрированные пользователи. +
Ваш комментарий
+Комментарии могут оставлять только зарегистрированные пользователи. +