}); Route::filter('after', function ($response) { // Do stuff after every request to your application... }); Route::filter('csrf', function () { if (Request::forged()) { return Response::error('500'); } }); Route::filter('auth', function () { if (Auth::guest()) { return Redirect::to('/'); } }); Route::filter('Sentry_auth', function () { if (Sentry::guest()) { return Redirect::to('/'); } }); Route::filter('ip', function () { // Create the Eloquent object Visit $visit = new Track(); $browser = new Browser(); $visit->location = Locate::get('city') . ', ' . Locate::get('state') . ', ' . Locate::get('country'); $visit->ip_address = Request::ip(); $visit->request = URI::current(); if (Auth::check()) { $visit->user_id = Auth::user()->id; } // Browser stats $visit->browser = $browser->getBrowser();
public function guest() { return Sentry::guest(); }
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!")); }