Removed database initialization code and instead used the function defined in db.inc.php

This commit is contained in:
2023-06-25 14:09:30 -05:00
parent df131d2fb5
commit 1c74b82f6e
3 changed files with 19 additions and 11 deletions

View File

@@ -1,4 +1,7 @@
<?php
require_once 'db.inc.php';
ini_set("session.cookie_secure",1);
session_start();
use Cassandra;
$uri = $_SERVER['REQUEST_URI'];
@@ -7,13 +10,11 @@
$matches_uri = preg_match('/^[a-zA-Z]+$/',$uri);
if (($matches_uri == 0) || ($matches_uri == false)) {
header("Location: http://glink.zip/");
header("Location: https://glink.zip/");
exit;
} else {
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
$keyspace = 'glink';
$session = $cluster->connect($keyspace);
$session = init_cass_db();
$statement = $session->prepare('SELECT url,is_geo FROM data WHERE shortlink=? ALLOW FILTERING;');
$result = $session->execute($statement,array('arguments' => array($uri)));
@@ -29,6 +30,7 @@
exit;
} else {
if ($row['is_geo'] == true) {
$_SESSION['glink'] = $uri;
header("Location: https://glink.zip/reqloc.html?glink=" . $uri);
exit;
} else {