diff --git a/app/Core/Routes.php b/app/Core/Routes.php index f03f14d..17ce6c2 100644 --- a/app/Core/Routes.php +++ b/app/Core/Routes.php @@ -38,6 +38,7 @@ class Routes Router::get('/article/$id', 'MainController@gallery'); Router::get('/voting', 'ContestsController@index'); Router::get('/voting/results', 'ContestsController@results'); + Router::get('/voting/waiting', 'ContestsController@waiting'); Router::get('/comments', 'MainController@comments'); if (Auth::userid() > 0) { $user = new \App\Models\User(Auth::userid()); @@ -52,6 +53,7 @@ class Routes Router::get('/search', 'SearchController@i'); Router::get('/fav', 'MainController@fav'); + Router::get('/voting/sendpretend', 'ContestsController@sendpretend'); Router::get('/vehicle/edit', 'VehicleController@iedit'); Router::get('/vehicle/dbedit', 'VehicleController@dbedit'); @@ -77,6 +79,8 @@ class Routes Router::any('/api/admin/getvehicleinputs/$id', 'ApiController@admingetvehicleinputs'); Router::any('/api/admin/geodb/create', 'ApiController@admingeodbcreate'); Router::any('/api/admin/geodb/load', 'ApiController@admingeodbload'); + Router::any('/api/admin/contests/createtheme', 'ApiController@admincontestscreatetheme'); + Router::any('/api/admin/contests/create', 'ApiController@admincontestscreate'); } Router::get('/logout', 'MainController@logout'); Router::get('/404', 'ExceptionRegister@notfound'); diff --git a/app/Models/Vote.php b/app/Models/Vote.php index 27d9f50..259a931 100644 --- a/app/Models/Vote.php +++ b/app/Models/Vote.php @@ -7,7 +7,23 @@ class Vote { public static function photo($user_id, $pid) { - $result = DB::query('SELECT type FROM photos_rates WHERE user_id=:uid AND photo_id=:pid', array(':uid' => $user_id, ':pid' => $pid)); + $result = DB::query('SELECT type FROM photos_rates WHERE user_id=:uid AND photo_id=:pid AND contest=0', array(':uid' => $user_id, ':pid' => $pid)); + if (!empty($result)) { + $type = $result[0]['type']; + if ($type < 0) { + $type = -1; + } + return $type; + } else { + return -1; + } + + + } + + public static function photoContest($user_id, $pid) + { + $result = DB::query('SELECT type FROM photos_rates WHERE user_id=:uid AND photo_id=:pid AND contest=1', array(':uid' => $user_id, ':pid' => $pid)); if (!empty($result)) { $type = $result[0]['type']; if ($type < 0) { diff --git a/views/pages/Main.php b/views/pages/Main.php index c0cd32c..e60945b 100644 --- a/views/pages/Main.php +++ b/views/pages/Main.php @@ -122,6 +122,78 @@ LIMIT 10;'); } ?> + + $contest['themeid']))[0]; + echo '

Фотоконкурс!

+ Закончится через:
+ Тематика: '.$theme['title'].'
+ Голосуйте за лучшие фотографии, которые должны стать победителями сегодняшнего конкурса!

+ Голосовать!'; + } else if (DB::query('SELECT status FROM contests WHERE status=1')[0]['status'] === 1) { + $contest = DB::query('SELECT * FROM contests WHERE status=1')[0]; + $theme = DB::query('SELECT * FROM contests_themes WHERE id=:id', array(':id'=>$contest['themeid']))[0]; + echo '

Фотоконкурс!

+ Начнётся через:
+ Тематика: '.$theme.'
+ Лучшие фотографии по мнению сообщества '.NGALLERY['root']['title'].' будут отмечены

+ Участвовать!'; + } + + + ?> + + + + +
+ +
diff --git a/views/pages/Photo.php b/views/pages/Photo.php index ea2b22a..8fb8b1f 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -258,15 +258,24 @@ if ($photo->i('id') !== null) { Мне не нравится - - + content('video') === null && $photo->i('user_id') != Auth::userid()) { ?> + Красиво, на конкурс! + Неконкурсное фото + i('user_id') === Auth::userid()) { ?> + + Выставить на конкурсНе участвовать в конкурсе +
$id)); + $votespos = DB::query('SELECT * FROM photos_rates WHERE photo_id=:pid AND type=1 AND contest=0 ORDER BY id DESC', array(':pid' => $id)); foreach ($votespos as $ps) { $uservote = new User($ps['user_id']); echo ' @@ -279,7 +288,7 @@ if ($photo->i('id') !== null) {
$id)); + $votespos = DB::query('SELECT * FROM photos_rates WHERE photo_id=:pid AND type=0 AND contest=0 ORDER BY id DESC', array(':pid' => $id)); foreach ($votespos as $ps) { $uservote = new User($ps['user_id']); echo '