vimarsana; $googledb = $db->google; $ratingdb =$db->googleratingdb; $like = ""; $dislike = ""; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip_address = $_SERVER['HTTP_CLIENT_IP']; } //whether ip is from proxy elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } //whether ip is from remote address else { $ip_address = $_SERVER['REMOTE_ADDR']; } //var_dump($_GET); $slug = ""; if (isset($_GET['like'])) { $dislike = $_GET['like']; $slug = $_GET['like']; } if (isset($_GET['dislike'])) { $like = $_GET['dislike']; if ($slug == "") { $slug = $_GET['dislike']; } } //$like = "amigo-night-club-others-yerevan"; $input = array("ip"=>$ip_address,"slug"=>$slug); $checkdups = $ratingdb->findOne($input); $url = "https://vimarsana.com/review/" . $slug ; $name = str_replace("-"," " ,$slug); $facebooktitle = "I have reviewed " . ucwords($name) . ". Share your Comments too !!"; $facebookurl = 'https://www.facebook.com/sharer/sharer.php?u=' . urlencode($url) . '&hashtag=%23vimarsana"e=' . $facebooktitle ; $facebookurl = $url; //$checkdups = array(); if (isset($checkdups['ip'])) { // echo $slug . " ," . $like . "," . $dislike; // echo "In loop 1 - " . $url; header('Location: ' . $facebookurl); } else { $input = array("ip"=>$ip_address,"slug"=>$slug,"datefull"=>date("Ymdhis"),"date"=>date("Ymd")); $ratingdb->insertOne($input); if (isset($_GET['like'])) { $input = array("slug"=>$slug); // var_dump($input); $result = $googledb->findOne($input,array('id'=>1,'likecount'=>1)); if (isset($result['id'])) { $likecount = 1; $dlikecount = 1; $total = 0; if (isset($result['likecount'])) { $likecount = $result['likecount'] + 1; } if (isset($result['dlikecount'])) { $dlikecount = $result['dlikecount'] + 1; } $total = $likecount + $dlikecount; $output = array('$set'=>array('likecount'=>$likecount,'total'=>$total)); // var_dump($input); // var_dump($output); $googledb->updateOne($input,$output); } $url = "https://vimarsana.com/review/" . $slug . "&rating=true"; // echo "In loop 2 - " . $url; header('Location: ' . $facebookurl); } if (isset($_GET['dislike'])) { $input = array("slug"=>$slug); // var_dump($input); $result = $googledb->findOne($input,array('id'=>1,'dlikecount'=>1)); if (isset($result['id'])) { $likecount = 1; $dlikecount = 1; $total = 0; if (isset($result['likecount'])) { $likecount = $result['likecount'] + 1; } if (isset($result['dlikecount'])) { $dlikecount = $result['dlikecount'] + 1; } $total = $likecount + $dlikecount; $output = array('$set'=>array('dlikecount'=>$dlikecount,'total'=>$total)); // var_dump($input); // var_dump($output); $googledb->updateOne($input,$output); } $url = "https://vimarsana.com/review/" . $slug . "&rating=true"; // echo "In loop 3 - " . $url; header('Location: ' . $facebookurl); } } ?>