Exemple #1
0
 public function getIndex()
 {
     $uid = Auth::user()->get()->uid;
     $missing_count = Missing::where('created_by', '=', $uid)->count();
     $found_count = Found::where('created_by', '=', $uid)->count();
     $data = array('missing_count' => $missing_count, 'found_count' => $found_count, 'total_reports_count' => (int) $missing_count + (int) $found_count);
     return View::make('user.home')->with('data', $data);
 }
Exemple #2
0
 public function getRedirect($id)
 {
     $data = Missing::where('uid', $id)->first()->id;
     if (empty($data)) {
         $data = Found::where('uid', $id)->first()->id;
         return Redirect::to('admin/found/edit-p/' . $data);
     }
     return Redirect::to('admin/missing/edit-p/' . $data);
 }
Exemple #3
0
 public function postMissing()
 {
     $input = Input::all();
     $logged_in_data = Auth::org()->get();
     $rules = array('name' => 'required|alpha_spaces|max:25', 'dob' => 'date_format:m/d/Y', 'parents_name' => 'alpha_spaces|max:25', 'police_station_number' => 'numeric', 'phone_number' => 'numeric', 'enquiry_office_number' => 'numeric', 'missing_since' => 'date_format:m/d/Y', 'state' => 'required', 'city' => 'required', 'gender' => 'required');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::back()->withInput(Input::all())->withErrors($v);
     }
     $input = $this->check_images_and_upload($input);
     $input['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $input['missing_since'] = GlobalFunc::set_date_format(Input::get('missing_since'));
     $input['report_type'] = 'Missing';
     $input['created_by'] = $logged_in_data->uid;
     $uid = strtoupper(Str::random(3)) . '_' . time();
     $input['uid'] = $uid;
     Missing::create($input);
     return Redirect::back()->with('success', 'Record Successfully Inserted');
 }
Exemple #4
0
 public function getFacebook($m_id)
 {
     // get data from input
     $code = Input::get('code');
     // get fb service
     $fb = OAuth::consumer('Facebook');
     // check if code is valid
     $data = Missing::find($m_id);
     $message = "A Kid Having a \n Name " . $data->name . " \n Age : '.{$data->age}.'\n State : " . $data->state . " \n City : " . $data->city . " \n Is Missing. Please Report On Our Website http://example.com. If You Got Any Information About It";
     // if code is provided get user data and sign in
     if (!empty($code)) {
         // This was a callback request from facebook, get the token
         $token = $fb->requestAccessToken($code);
         // Send a request with it
         $result = json_decode($fb->request('/me'), true);
         $postMessage = json_decode($fb->request("/me/feed?access_token", 'POST', array('message' => $message)), true);
         return Redirect::to('organization/report/show-missing?success=true');
     } else {
         // get fb authorization
         $url = $fb->getAuthorizationUri();
         // return to facebook login url
         return Redirect::to((string) $url);
     }
 }
Exemple #5
0
 public function getIndex($slug = '', $link_id = 0)
 {
     $debug = '';
     $bmStart = microtime(true);
     $perpage = intval(AppConfig::get('articles_per_page', 50));
     $branch_prefixes = explode(',', AppConfig::get('branch_prefixes'));
     $virtualPerpage = intval(AppConfig::get('virtual_per_page', 20));
     $page = Page::where('slug', '=', $slug)->cacheTags('pages')->remember(1440)->first();
     //$page = Page::where('slug', '=', Str::slug($slug))->first();
     if (count($page) > 0) {
         if ($filter_return = $this->authFilter($page->level)) {
             return $filter_return;
         }
         if ($page->redirect) {
             if (substr($page->redirect, 0, 1) == '{') {
                 $redir_arr = json_decode($page->redirect, true);
                 foreach ($redir_arr as $rlvl => $rslug) {
                     if (strpos($this->auth_lvl, $rlvl) !== false) {
                         return Redirect::to($rslug);
                     }
                 }
                 if (isset($redir_arr['def'])) {
                     return Redirect::to($redir_arr['def']);
                 }
             } else {
                 return Redirect::to($page->redirect);
             }
         }
         // get parameters from URL
         $page->category = Input::has('category') ? Input::get('category') : ($page->default_category ? $page->default_category : false);
         $page->section = Input::has('section') ? Input::get('section') : false;
         $page->keywordInput = $page->ddkeycol ? Input::get('keyword') : '';
         $page_vars = new stdClass();
         // separate slug into branch and section, if applicable
         $branch = $slug;
         if ($page->link_slug) {
             $branch = $page->link_slug;
         }
         $els = explode('/', $branch);
         if (in_array($els[0], $branch_prefixes) && count($els) > 1) {
             $branch = $els[0];
             if (!$page->section) {
                 $page->section = $els[1];
             }
         }
         $dta = normal::getTypes();
         // get list of categories, if there is a "ddlist"
         $categories = false;
         $normalized = false;
         if ($page->ddlist) {
             $fld = $page->ddlist;
             $catq = Link::where('branch', '=', $branch);
             if ($page->section) {
                 $catq->where('section', '=', $page->section);
             }
             if ($dtp = array_search($fld, $dta)) {
                 $catq->join('data', 'data.rec_id', '=', 'links.id')->where('data.table_name', '=', 'links')->where('data.type', '=', $dtp)->whereNull('data.deleted_at');
                 $fld = 'data_body';
                 $normalized = true;
             }
             $category_model = $catq->groupBy($fld)->whereRaw('trim(`' . $fld . '`) != ""')->cacheTags('links')->remember(1440)->get(array($fld));
             $categories = array('' => 'All');
             foreach ($category_model as $category_item) {
                 $categories[$category_item->{$fld}] = $category_item->{$fld};
             }
         }
         $links = false;
         $columns = false;
         // get list of links, specified by branch, section, category, state, and/or keyword
         if ($page->linkdef || $link_id && $page->detaildef) {
             // get column layout
             $columns = Listcolumns::where('def', '=', $link_id ? $page->detaildef : $page->linkdef)->cacheTags('links')->remember(1440)->orderBy('listorder')->get();
             $perlinkpage = intval(AppConfig::get('links_per_page', 50));
             $query = new Link();
             if ($link_id) {
                 $query = $query->where('id', '=', $link_id);
             } else {
                 if ($page->section) {
                     $query = $query->where('section', '=', $page->section);
                 }
                 if ($page->category) {
                     if ($normalized) {
                         $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', $dtp)->whereNull('d.deleted_at');
                     }
                     $query = $query->where(isset($fld) ? $fld : ($page->section ? 'category' : 'section'), '=', $page->category);
                 }
                 if ($page->state) {
                     $query = $query->where('state', '=', $page->state);
                 }
                 if ($page->keywordInput) {
                     if ($page->keywordInput == "by_date") {
                         $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', 7)->whereNull('d.deleted_at');
                         $month = Input::get('themonth');
                         $year = Input::get('theyear');
                         $pfx = $year . '-' . $month;
                         $start_date = $pfx . '-01';
                         $end_date = $pfx . '-' . cal_days_in_month(CAL_GREGORIAN, $month, $year);
                         $query = $query->whereRaw('d.`data_body`  BETWEEN ? AND ?', array($start_date, $end_date));
                         unset($page->keywordInput);
                         $page_vars->month = $month;
                         $page_vars->year = $year;
                     } else {
                         $query = $query->whereRaw('`' . $page->ddkeycol . '` RLIKE ?', array($page->keywordInput));
                     }
                 }
                 if (!$page->allowBroken) {
                     $query = $query->join('link_check', 'links.id', '=', 'link_check.id');
                     $query = $query->whereBetween('link_check.last_result', array('200', '399'));
                 }
             }
             $order = 'name';
             $orderdir = 'asc';
             if ($page->linkorder) {
                 $ordera = explode(',', $page->linkorder);
                 $order = $ordera[0];
                 if (count($ordera) > 1) {
                     $orderdir = $ordera[1];
                 }
                 if ($dtp = array_search($order, $dta)) {
                     $query = $query->join('data AS d2', 'd2.rec_id', '=', 'links.id')->where('d2.table_name', '=', 'links')->where('d2.type', '=', $dtp)->whereNull('d2.deleted_at');
                     $order = 'd2.data_body';
                 }
             }
             if ($page->where) {
                 $query = $query->whereRaw($page->where);
             }
             if ($page->remove_dupes) {
                 $query = $query->groupBy('name', 'url');
             }
             $links = $query->where('branch', '=', $branch)->select(array('links.*'))->orderBy($order, $orderdir)->cacheTags('links')->remember(1440)->paginate($perlinkpage);
             $ids = array();
             foreach ($links as $link) {
                 $ids[] = $link->id;
             }
             $xda = count($ids) ? Cache::tags('links')->remember('linkData|' . implode('-', $ids), 1440, function () use($ids) {
                 $xdata = Data::where('table_name', '=', 'links')->join('data_types', 'data_types.id', '=', 'data.type')->whereIn('rec_id', $ids)->whereNull('data_types.deleted_at')->cacheTags('data')->remember(10080)->get();
                 $xdda = array();
                 foreach ($xdata as $xrec) {
                     $xdda[$xrec->rec_id][$xrec->label] = $xrec->data_body;
                 }
                 return $xdda;
             }) : array();
             foreach ($links as $lid => $link) {
                 $id = $link->id;
                 if (isset($xda[$id])) {
                     foreach ($xda[$id] as $xid => $xdt) {
                         $links[$lid]->{$xid} = $xdt;
                     }
                 }
             }
         }
         $thumbs = false;
         if ($page->virtual_type) {
             $thumbs = Ad::where('type', '=', $page->virtual_type)->where('category', '=', $page->category)->orderBy('vorder', 'desc')->cacheTags('ads')->remember(1440)->paginate($virtualPerpage);
             foreach ($thumbs as $thumb) {
                 Ads::track($thumb, 3, $page->id);
             }
             // get list of categories
             $category_model = Ad::groupBy('category')->where('type', '=', $page->virtual_type)->cacheTags('ads')->remember(1440)->get(array('category'));
             $categories = array();
             foreach ($category_model as $category_item) {
                 $categories[$category_item->category] = $category_item->category;
             }
             //                $page->dname = 'Category';
         }
         // benchmarking the database access
         $bmEnd = microtime(true);
         $page->elapsed = $bmEnd - $bmStart;
         $page_vars->qstring = '';
         if ($page->pass_query == 'Y') {
             $qry = Input::query();
             $qry['mc_rnm'] = substr(time(), 2);
             if (count($qry)) {
                 $page_vars->qstring = '?' . http_build_query($qry);
             }
         }
         if ($page->randomize) {
             foreach (explode(',', $page->randomize) as $random_tag) {
                 $page_vars->{$random_tag} = mt_rand(10000, 99999);
             }
         }
         foreach (AppConfig::getAll() as $cfi => $cfd) {
             $page_vars->{$cfi} = $cfd;
         }
         $page_vars->nocache = NOCACHE_CODE;
         if (!$page->layout) {
             //                if ($_SERVER['REMOTE_ADDR'] == '108.47.107.194') {
             //                    $page->layout = 'template.layout2';
             //                } else {
             $page->layout = 'template.layout';
             //                }
         }
         // get data on child and parent pages
         $childpages = new Page();
         $P = clone $childpages->getConnection()->getPaginator();
         $P->setPageName('article');
         $childpages->getConnection()->setPaginator($P);
         $childpages = $childpages->join('article_pages', 'pages.id', '=', 'article_pages.page_id');
         $childpages = $childpages->where('article_pages.parent_id', '=', $page->id);
         $childpages = $childpages->whereNull('article_pages.deleted_at');
         $childpages = $childpages->orderBy('pageOrder');
         $childpages = $childpages->cacheTags('pages')->remember(1440);
         $childpages = $childpages->paginate($perpage);
         // pass ALL the data to the view
         return View::make('page.page')->with('dyn_layout', $page->layout)->with('page', $page)->with('childpages', $childpages)->with('categories', $categories)->with('links', $links)->with('link_id', $link_id)->with('thumbs', $thumbs)->with('columns', $columns)->with('top_banner', empty($slug))->with('debug', $debug)->with('parse_body', Display::format($page->body, $page_vars, false, false));
     } else {
         if (substr($slug, -5) == '.html') {
             $new_slug = substr($slug, 0, -5);
             $new_page = Page::where('slug', '=', $new_slug)->cacheTags('pages')->remember(1440)->first();
             if (count($new_page) > 0) {
                 return Redirect::to('/' . $new_slug, 301);
             }
         }
         $missing = new Missing();
         $missing->slug = $slug;
         $missing->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "[none]";
         $missing->save();
         AppLog::alert('Page Not Found', 404, json_encode(array('slug' => $slug)));
         return Response::view('page.notfound', array('slug' => $slug), 404);
     }
 }
 /**
  * __construct
  *
  * @param array $missingRevisions
  * @param array $potentialAncestors
  * @return void
  */
 public function __construct(array $potentialAncestors, array $missingRevisions)
 {
     parent::__construct($missingRevisions);
     $this->possible_ancestors = $potentialAncestors;
 }
Exemple #7
0
 public function getViewMissing($id)
 {
     $data = Missing::find($id);
     return View::make('front.missing_view')->with('data', $data);
 }
 public function getSuccess($id)
 {
     $data = Missing::find($id);
     return View::make('admin.success_view_missing')->with('data', $data);
 }
Exemple #9
0
<?php

// missing.php
require "Missing.class.php";
$missing = new Missing();
$missing->nonExistent("first", ["second"]);
echo "<hr>";
Missing::nonExistent("tuatahi", ["tuarua"]);