diff --git a/app/Controllers/Api/Images/Comment.php b/app/Controllers/Api/Images/Comment.php new file mode 100644 index 0000000..7331169 --- /dev/null +++ b/app/Controllers/Api/Images/Comment.php @@ -0,0 +1,67 @@ + $_POST['id'], ':postbody' => $_POST['wtext'], ':userid' => Auth::userid(), ':time' => time())); + } + public function __construct() + { + $id = $_POST['id']; + $postbody = $_POST['wtext']; + if ((int)$id === DB::query('SELECT id FROM photos WHERE id=:id', array(':id' => $id))[0]['id']) { + + + $content = Json::return( + array( + 'type' => 'none', + 'by' => 'user' + ) + ); + + if (strlen($postbody) < 4096 || strlen($postbody) > 1) { + if (trim($postbody) != '') { + $postbody = ltrim($postbody); + echo json_encode( + array( + 'errorcode' => '0', + 'error' => 0 + ) + ); + } else { + die(json_encode( + array( + 'errorcode' => '1', + 'error' => 1 + ) + )); + } + } else { + die(json_encode( + array( + 'errorcode' => '1', + 'error' => 1 + ) + )); + } + + self::create($content, $id); + } else { + die(json_encode( + array( + 'errorcode' => '1', + 'error' => 1 + ) + )); + } + } +} diff --git a/app/Controllers/Api/Images/CommentsLoad.php b/app/Controllers/Api/Images/CommentsLoad.php new file mode 100644 index 0000000..9411cc6 --- /dev/null +++ b/app/Controllers/Api/Images/CommentsLoad.php @@ -0,0 +1,22 @@ +explode('/', $_SERVER['REQUEST_URI'])[4])); + foreach ($comments as $c) { + $comm = new Comment($c); + $comm->i(); + } + } +} diff --git a/app/Controllers/Api/Images/Upload.php b/app/Controllers/Api/Images/Upload.php index 00cfb5f..3c4af46 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, :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'])); + DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :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'], ':timeup'=>time())); echo json_encode( array( 'errorcode' => 0, diff --git a/app/Controllers/ApiController.php b/app/Controllers/ApiController.php index 0545a00..9146f13 100644 --- a/app/Controllers/ApiController.php +++ b/app/Controllers/ApiController.php @@ -7,6 +7,8 @@ use \App\Core\Page; use \App\Controllers\Api\{Login, Register}; use \App\Controllers\Api\Images\{Upload}; use \App\Controllers\Api\Images\Rate as PhotoVote; +use \App\Controllers\Api\Images\Comment as PhotoComment; +use \App\Controllers\Api\Images\CommentsLoad as PhotoCommentLoad; class ApiController { @@ -23,6 +25,12 @@ class ApiController public static function photovote() { return new PhotoVote(); } + public static function photocomment() { + return new PhotoComment(); + } + public static function photocommentload() { + return new PhotoCommentLoad(); + } } \ No newline at end of file diff --git a/app/Core/Routes.php b/app/Core/Routes.php index d4c94ab..d4774e5 100644 --- a/app/Core/Routes.php +++ b/app/Core/Routes.php @@ -17,6 +17,7 @@ class Routes Router::get('/register', 'RegisterController@i'); Router::get('/photo/$id', 'PhotoController@i'); Router::get('/author/$id', 'ProfileController@i'); + Router::post('/api/login', 'ApiController@login'); Router::get('/api/photo/vote', 'ApiController@photovote'); Router::post('/api/register', 'ApiController@register'); @@ -27,8 +28,9 @@ class Routes if (Auth::userid() > 0) { Router::get('/lk', 'ProfileController@lk'); Router::get('/lk/upload', 'ProfileController@upload'); - Router::post('/api/upload', 'ApiController@upload'); + Router::post('/api/photo/comment', 'ApiController@photocomment'); + Router::post('/api/photo/getcomments/$id', 'ApiController@photocommentload'); } else { Router::redirect('/login?return='.$_SERVER['HTTP_REFERER']); } diff --git a/app/Models/Comment.php b/app/Models/Comment.php new file mode 100644 index 0000000..3f41012 --- /dev/null +++ b/app/Models/Comment.php @@ -0,0 +1,35 @@ +c = $user_id; + } + public function i() { + $user = new User($this->c['user_id']); + echo '
'.$uservote->i('username').' | + $id)); + foreach ($votespos as $ps) { + $uservote = new User($ps['user_id']); + echo '|
' . $uservote->i('username') . ' | +1 |
'.$uservote->i('username').' | + $id)); + foreach ($votespos as $ps) { + $uservote = new User($ps['user_id']); + echo '|
' . $uservote->i('username') . ' | -1 |
- - | -
- - - - | -
Главная Форум Правила Редколлегия - Мобильная версия Тёмная тема - © Администрация ТрансФото и авторы материалов, 2002—2024
- Использование фотографий и иных материалов, опубликованных на сайте, допускается только с разрешения их авторов.
- |
+