Пример #1
0
 public function post_create()
 {
     $posts = Input::all();
     $title = $posts['thread_name'];
     $contentRaw = $posts['inputarea'];
     if ($title != '' && strlen($contentRaw) > 10) {
         $alias = Str::slug($title, '-');
         $exist = Thread::where('alias', '=', $alias)->first();
         if ($exist != null) {
             return Redirect::to($exist->id);
         }
         $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s"));
         $thread = Thread::create($threadData);
         if ($thread != null) {
             $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id);
             $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0);
             $pst = Post::create($postData);
             if ($pst != null) {
                 return Redirect::to($thread->id);
             }
         }
     } else {
         return Redirect::to(URL::full());
     }
 }
Пример #2
0
 public function get_thread()
 {
     //Array ( [thread] => asdgasyhudjıkopağ )
     $inputs = Input::all();
     $key = $inputs['term'];
     $basliklar = Thread::where('title', 'LIKE', '%' . $key . '%')->order_by('title', 'asc')->take(10)->get(array('id', 'title'));
     $titles = array();
     foreach ($basliklar as $title) {
         $titleX = array('label' => $title->title, 'id' => $title->id);
         array_push($titles, $titleX);
     }
     return Response::json($titles);
 }
Пример #3
0
 public function showthread($name)
 {
     $info = HelperFunctions::forum_url_info($name);
     if ($info['forum'] == 0) {
         return Redirect::to("/dien-dan.html");
     }
     $threads = Thread::where('forum', $info['forum'])->orderBy('status', 'desc')->orderBy('updated_at', 'desc')->paginate(15);
     $view = ForumViewCount::find($info['forum']);
     $view->view = $view->view + 1.25;
     $view->save();
     $data = array('threads' => $threads, 'seo' => $info, 'forums' => HelperFunctions::forum_list(), 'page' => "Forum", 'id' => Session::get('idCok'), 'coin' => Session::get('coinCok'), 'name' => $name);
     return View::make('template.neon.thread')->with($data);
 }
Пример #4
0
 public function showthread($name)
 {
     $info = HelperFunctions::forum_url_info($name);
     if ($info['forum'] == 0) {
         return Redirect::to("/dien-dan.html");
     }
     $threads = Thread::where('forum', $info['forum'])->orderBy('status', 'desc')->orderBy('updated_at', 'desc')->paginate(2);
     $view = ForumViewCount::find($info['forum']);
     $view->view = $view->view + 1.25;
     $view->save();
     $seo['page'] = $info['h1'];
     $seo['title'] = $info['title'];
     $seo['discription'] = 'discription of this page';
     $seo['forum'] = $info['forum'];
     $data = array('threads' => $threads, 'seo' => $seo, 'forums' => HelperFunctions::forum_list());
     return View::make('template.flatkit.thread')->with($data);
 }
Пример #5
0
 public function post_post()
 {
     $data = json_decode(Input::get('json'));
     $fields = array('post' => $data->inputarea, 'threadid' => $data->thread_id);
     if (Sentry::guest()) {
         return json_encode(array("success" => 0, "msg" => "üye olda gel"));
     }
     //filter falan ama sonra ..
     $userid = Sentry::user()->id;
     $userip = Request::ip();
     $cThread = Thread::where('id', '=', $fields['threadid'])->first();
     /*FLOOD PROTECTION*/
     ####################
     /*$_messageTime = Post::where(function ($query) use ($cThread,$userid){
     				$query->where('thread_id','=',$cThread->id);
     				$query->where('user_id', '=',$userid);
     		})
     		->order_by('datetime','DESC')
     		->first(array('datetime'));
     		if($_messageTime){
     			$_timestamp = strtotime($_messageTime->datetime);
     			$_timeCalc = time()-10;
     			if($_timestamp >= $_timeCalc)
     			{
     				return json_encode(array("success" => 0,"msg" => "C*k hızlı giriyorsun babacan!"));
     			}
     		}*/
     ####################
     /*FLOOD PROTECTION*/
     // Check user has 10 post if he newbie member
     if (Sentry::user()->user_type == 0) {
         $fulled = false;
         $post = Post::where('user_id', '=', Sentry::user()->id);
         if ($post->count() >= 10) {
             return json_encode(array("success" => 0, "msg" => "Çaylak Olarak Bu kadar Yazdıgınız Yeter.\nLütfen Bir adminin onaylamasını bekleyiniz."));
         }
     }
     if (Sentry::user()->has_access('can_post') && $cThread->type == 0) {
         if (Sentry::user()->user_type == 0) {
             $post_type = 0;
         } else {
             $post_type = 1;
         }
         if (strlen(trim($fields['post'])) >= 5 || Sentry::user()->has_access('is_mod')) {
             $max = Post::where('thread_id', '=', $fields['threadid'])->max('count');
             $post = static::replace_at(BBCode2Html(strip_tags_attributes($fields['post'])), $fields['threadid']);
             $postData = array('thread_id' => $fields['threadid'], 'entry' => $post, 'userip' => $userip, 'user_id' => $userid, 'datetime' => date("Y-m-d H:i:s"), 'count' => $max + 1, 'type' => $post_type);
             /*
             	Update last message on thread table
             */
             $cThread->last_message_at = date("Y-m-d H:i:s");
             $cThread->save();
             $id = DB::table('posts')->insert_get_id($postData);
             $entry = Post::with('author')->where_id($id)->first();
             $threadid = $fields['threadid'];
             $count = Post::where(function ($query) use($threadid) {
                 $query->where('thread_id', '=', $threadid);
                 $query->where('type', '=', 1);
             })->count();
             // cache deki konuyu okumuş memberlari sil
             DB::query('DELETE FROM xr_threadsmembers WHERE thread_id=?', array($threadid));
             /*Page Function*/
             $pagenum = ceil($count / static::$per_page);
             //doing ajax callbacks
             //create view
             $view = array("id" => $entry->id, "count" => $entry->count, "entry" => $entry->entry, "author" => $entry->author->username, "date" => $entry->datetime, "page" => $pagenum);
             return Response::json($view);
         } else {
             return json_encode(array("success" => 0, "msg" => "entry çok kısa babacan"));
         }
     } else {
         return json_encode(array("success" => 0, "msg" => "yetki yok hocam"));
     }
     return json_encode(array("success" => 0, "msg" => "Undefined Error!"));
 }