Removed database initialization code and instead used the function defined in db.inc.php
This commit is contained in:
15
checkloc.php
15
checkloc.php
@@ -1,5 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db.inc.php';
|
||||||
|
if (isset($_SESSION['glink']) && !empty($_SESSION['glink'])) {
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
} else {
|
||||||
|
http_response_code(403);
|
||||||
|
die('Forbidden.');
|
||||||
|
}
|
||||||
// FUNCTION TO CALCULATE HAVERSINE DISTANCE GIVEN COORDINATES OF
|
// FUNCTION TO CALCULATE HAVERSINE DISTANCE GIVEN COORDINATES OF
|
||||||
// TWO POINTS, AND RADIUS (IN KM)
|
// TWO POINTS, AND RADIUS (IN KM)
|
||||||
function haversine_distance($lat1, $long1, $lat2, $long2, $radius) {
|
function haversine_distance($lat1, $long1, $lat2, $long2, $radius) {
|
||||||
@@ -36,9 +44,8 @@
|
|||||||
$user_long = $user_long * (M_PI / 180);
|
$user_long = $user_long * (M_PI / 180);
|
||||||
$glink = $_GET["glink"];
|
$glink = $_GET["glink"];
|
||||||
|
|
||||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
$session = init_cass_db();
|
||||||
$keyspace = 'glink';
|
|
||||||
$session = $cluster->connect($keyspace);
|
|
||||||
$statement = $session->prepare('SELECT latitude,longitude,radius,url FROM data WHERE shortlink=? ALLOW FILTERING;');
|
$statement = $session->prepare('SELECT latitude,longitude,radius,url FROM data WHERE shortlink=? ALLOW FILTERING;');
|
||||||
$result = $session->execute($statement,array('arguments' => array($glink)));
|
$result = $session->execute($statement,array('arguments' => array($glink)));
|
||||||
|
|
||||||
|
10
redirect.php
10
redirect.php
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once 'db.inc.php';
|
||||||
|
ini_set("session.cookie_secure",1);
|
||||||
|
session_start();
|
||||||
use Cassandra;
|
use Cassandra;
|
||||||
|
|
||||||
$uri = $_SERVER['REQUEST_URI'];
|
$uri = $_SERVER['REQUEST_URI'];
|
||||||
@@ -7,13 +10,11 @@
|
|||||||
$matches_uri = preg_match('/^[a-zA-Z]+$/',$uri);
|
$matches_uri = preg_match('/^[a-zA-Z]+$/',$uri);
|
||||||
|
|
||||||
if (($matches_uri == 0) || ($matches_uri == false)) {
|
if (($matches_uri == 0) || ($matches_uri == false)) {
|
||||||
header("Location: http://glink.zip/");
|
header("Location: https://glink.zip/");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
$session = init_cass_db();
|
||||||
$keyspace = 'glink';
|
|
||||||
$session = $cluster->connect($keyspace);
|
|
||||||
|
|
||||||
$statement = $session->prepare('SELECT url,is_geo FROM data WHERE shortlink=? ALLOW FILTERING;');
|
$statement = $session->prepare('SELECT url,is_geo FROM data WHERE shortlink=? ALLOW FILTERING;');
|
||||||
$result = $session->execute($statement,array('arguments' => array($uri)));
|
$result = $session->execute($statement,array('arguments' => array($uri)));
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
if ($row['is_geo'] == true) {
|
if ($row['is_geo'] == true) {
|
||||||
|
$_SESSION['glink'] = $uri;
|
||||||
header("Location: https://glink.zip/reqloc.html?glink=" . $uri);
|
header("Location: https://glink.zip/reqloc.html?glink=" . $uri);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once 'db.inc.php';
|
||||||
|
|
||||||
function gen_base62_rand_shortlink($len) {
|
function gen_base62_rand_shortlink($len) {
|
||||||
$rand_bytes = random_bytes(intval(($len * 2) / 3));
|
$rand_bytes = random_bytes(intval(($len * 2) / 3));
|
||||||
@@ -29,9 +30,7 @@ function gen_rand_shortlink($len) {
|
|||||||
|
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
$session = init_cass_db();
|
||||||
$keyspace = 'glink';
|
|
||||||
$session = $cluster->connect($keyspace);
|
|
||||||
|
|
||||||
$url = $_GET["url"];
|
$url = $_GET["url"];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user