public function onAddView() { $id = post('id'); $temp = DB::table('fotis_external_articles')->where('id', '=', $id)->increment('total_views'); $data['result'] = 'ok'; $temp2 = Article::where('id', '=', $id)->first(); $data['views'] = $temp2->total_views; $data['url'] = $temp2->article_url; return $data; }
public function checkifexists() { if (isset(Auth::getUser()->email)) { } else { trigger_error('login'); } $email = Auth::getUser()->email; $articles = Article::where('user_email', '=', $email)->get(); $bool = 1; $image = trim(post('image')); $title = trim(post('title')); $url = trim(post('articleurl')); $url2 = trim($url, '/'); // $url2 = strtok($url2, '?'); // $url2 = strtok($url2, '#'); $url2 = preg_replace('/([^:])(\\/{2,})/', '$1/', $url2); $url2 = trim($url2, '/'); // $url = preg_replace('/&?return=[^&]*/', '', $url); // $url = parse_url($url, PHP_URL_PATH); // echo $url; // $url = filter_var(post('articleurl'), FILTER_SANITIZE_URL); // trigger_error($url2); foreach ($articles as $article) { if ($url2 == $article->article_url) { $bool = 0; } if ($title == $article->article_title && $image == $article->article_image) { $bool = 0; // trigger_error($title . $article->article_title . $image . $article->article_image); } } // trigger_error($bool); return $bool; }