215 行
6.8 KiB
PHP
215 行
6.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class BoardController extends Controller {
|
|
public function getCategories() { // /api/rpc/board/category/getcategories
|
|
return DB::table('for_category')
|
|
->select('*')
|
|
->orderBy('order', 'asc')
|
|
->get();
|
|
}
|
|
|
|
public function getCategory($id) { // /api/rpc/board/category/getcategory/id
|
|
return DB::table('for_category')
|
|
->select('*')
|
|
->where('id', $id)
|
|
->get();
|
|
}
|
|
|
|
public function getCategoryName($id) { // /api/rpc/board/category/getcategoryname/id
|
|
return DB::table('for_category')
|
|
->select('title')
|
|
->where('id', $id)
|
|
->get();
|
|
}
|
|
|
|
public function getForums() { // /api/rpc/board/forum/getforums
|
|
return DB::table('for_forums')
|
|
->select('*')
|
|
->orderBy('order', 'asc')
|
|
->get();
|
|
}
|
|
|
|
public function getForum($id) { // /api/rpc/board/forum/getforum/id
|
|
return DB::table('for_forums')
|
|
->select('*')
|
|
->where('id', $id)
|
|
->orderBy('order', 'asc')
|
|
->get();
|
|
}
|
|
|
|
public function getForumName($id) { // /api/rpc/board/forum/getforumname/id
|
|
return DB::table('for_forums')
|
|
->select('cat_id', 'title')
|
|
->where('id', $id)
|
|
->orderBy('order', 'asc')
|
|
->get();
|
|
}
|
|
|
|
public function getForumsInCategory($cat_id) { // /api/rpc/board/forum/getforumsincategory/cat_id
|
|
return DB::table('for_forums')
|
|
->select('*')
|
|
->where('cat_id', $cat_id)
|
|
->get();
|
|
}
|
|
|
|
public function getTopics($for, $from, $to) { // /api/rpc/board/topic/gettopics/for/from/to
|
|
return DB::table('for_threads')
|
|
->select('*')
|
|
->where('for_id', $id)
|
|
->offset($from)
|
|
->limit($to)
|
|
->orderBy('last_date', 'desc')
|
|
->get();
|
|
}
|
|
|
|
public function getTopicsUnpinned($for_id, $from, $to) { // /api/rpc/board/topic/gettopicsunpinned/for_id
|
|
return DB::table('for_threads')
|
|
->select('*')
|
|
->where('for_id', $for_id)
|
|
->where('sticky', 0)
|
|
->offset($from)
|
|
->limit($to)
|
|
->orderBy('last_date', 'desc')
|
|
->get();
|
|
}
|
|
|
|
public function getTopicsPinned($for_id) { // /api/rpc/board/topic/gettopicspinned/for_id
|
|
return DB::table('for_threads')
|
|
->select('*')
|
|
->where('for_id', $for_id)
|
|
->where('sticky', 1)
|
|
->orderBy('last_date', 'desc')
|
|
->get();
|
|
}
|
|
|
|
public function countUnpinnedTopicsInForum($for_id) { // /api/rpc/board/topic/countunpinnedtopicsinforum/for_id
|
|
return DB::table('for_threads')
|
|
->where('for_id', $for_id)
|
|
->where('sticky', 0)
|
|
->count();
|
|
}
|
|
|
|
public function getTopic($id, $from, $to) { // /api/rpc/board/topic/gettopic/id/from/to
|
|
return DB::table('for_threads')
|
|
->select('*')
|
|
->where('id', $id)
|
|
->offset($from)
|
|
->limit($to)
|
|
->orderBy('last_date', 'desc')
|
|
->get();
|
|
}
|
|
|
|
public function getTopicLock($id) { // /api/rpc/board/topic/gettopiclock/id
|
|
return DB::table('for_threads')
|
|
->select('lock')
|
|
->where('id', $id)
|
|
->get();
|
|
}
|
|
|
|
public function getTopicName($id) { // /api/rpc/board/topic/gettopicname/id
|
|
return DB::table('for_threads')
|
|
->select('for_id', 'title')
|
|
->where('id', $id)
|
|
->get();
|
|
}
|
|
|
|
public function getPostsInTopic($top_id, $from, $to) { // /api/rpc/board/post/getpostsintopic/top_id/from/to
|
|
return DB::table('for_posts')
|
|
->select('*')
|
|
->where('top_id', $top_id)
|
|
->offset($from)
|
|
->limit($to)
|
|
->orderBy('post_date', 'asc')
|
|
->get();
|
|
}
|
|
|
|
public function countPostsInTopic($top_id) { // /api/rpc/board/post/countpostsintopic/top_id
|
|
return DB::table('for_posts')
|
|
->where('top_id', $top_id)
|
|
->count();
|
|
}
|
|
|
|
public function getPost($id) { // /api/rpc/board/post/getpost/id
|
|
return DB::table('for_posts')
|
|
->select('*')
|
|
->where('id', $id)
|
|
->get();
|
|
}
|
|
|
|
public function getUserPosts($top_id, $from, $to) { // /api/rpc/board/post/getuserposts/top/from/to
|
|
return DB::table('for_posts')
|
|
->join('users', 'for_posts.user_id', '=', 'users.id')
|
|
->join('usr_details', 'usr_details.user_id', '=', 'for_posts.user_id')
|
|
->join('usr_profile', 'usr_profile.user_id', '=', 'for_posts.user_id')
|
|
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'for_posts.user_id')
|
|
->where('for_posts.top_id', $top_id)
|
|
->offset($from)
|
|
->limit($to)
|
|
->orderBy('for_posts.post_date', 'asc')
|
|
->get(array(
|
|
"for_posts.id",
|
|
"top_id",
|
|
"users.id",
|
|
"post_date",
|
|
"message",
|
|
"delete",
|
|
"lastedit",
|
|
"ipaddress",
|
|
"delreason",
|
|
"nolayout",
|
|
"postcount",
|
|
"username",
|
|
"perm_id",
|
|
"total_posts",
|
|
"header",
|
|
"footer",
|
|
"member_title",
|
|
"gender",
|
|
"avatar",
|
|
"name_style",
|
|
"display_name",
|
|
"country"
|
|
));
|
|
}
|
|
|
|
public function getUserPost($id) { // /api/rpc/board/post/getuserpost/id
|
|
return DB::table('for_posts')
|
|
->join('users', 'for_posts.user_id', '=', 'users.id')
|
|
->join('usr_details', 'usr_details.user_id', '=', 'for_posts.user_id')
|
|
->join('usr_profile', 'usr_profile.user_id', '=', 'for_posts.user_id')
|
|
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'for_posts.user_id')
|
|
->where('for_posts.id', $id)
|
|
->orderBy('for_posts.post_date', 'asc')
|
|
->get(array(
|
|
"for_posts.id",
|
|
"top_id",
|
|
"users.id",
|
|
"post_date",
|
|
"message",
|
|
"delete",
|
|
"lastedit",
|
|
"ipaddress",
|
|
"delreason",
|
|
"nolayout",
|
|
"postcount",
|
|
"username",
|
|
"perm_id",
|
|
"total_posts",
|
|
"header",
|
|
"footer",
|
|
"member_title",
|
|
"gender",
|
|
"avatar",
|
|
"name_style",
|
|
"display_name",
|
|
"country"
|
|
));
|
|
}
|
|
}
|