diff --git a/config.json b/config.json
index 0980c91..bac5848 100644
--- a/config.json
+++ b/config.json
@@ -1,11 +1,11 @@
{
"installed": false,
+ "website_name": "OpenShorte",
"db": {
"host": "127.0.0.1",
"port": 3306,
"username": "",
"password": "",
"name": ""
- },
- "installation_path": ""
+ }
}
\ No newline at end of file
diff --git a/functions.php b/functions.php
index c23b72a..2ff1edb 100644
--- a/functions.php
+++ b/functions.php
@@ -1,24 +1,8 @@
+
+
+
+
+
+ Dashboard Home | =$GLOBALS['config']['website_name']?>
+
+
+ Open Management Console
+
+
+
- BJPHoster URL Shortener | Password Reset
+
+
+ Password Reset | =$GLOBALS['config']['website_name']?>
diff --git a/lib/php/go.php b/lib/php/go.php
index 9caf307..81679b4 100644
--- a/lib/php/go.php
+++ b/lib/php/go.php
@@ -26,8 +26,9 @@
- Redirect in 5 seconds
-
+
+
+ Redirect in 5 seconds | =$GLOBALS['config']['website_name']?>
@@ -37,7 +38,7 @@
window.onload = function() {
var seconds = 5;
function update_timeout (interval) {
- document.getElementById("title").innerHTML = "Redirect in "+seconds+" seconds";
+ document.getElementById("title").innerHTML = "Redirect in " + seconds +" seconds | =$GLOBALS['config']['website_name']?>";
document.getElementById("body-timeout").innerHTML = seconds;
if (seconds == 0) {
window.location.href = "=$row['URL']?>";
diff --git a/lib/php/insert.php b/lib/php/insert.php
index 64d45eb..2515118 100644
--- a/lib/php/insert.php
+++ b/lib/php/insert.php
@@ -1,63 +1,43 @@
connect ( );
- if ( isset ( $_POST [ 'url' ] ) ) {
- $url = $_POST [ 'url' ];
- $database->prepare ( "INSERT INTO `links` ( `ID`, `URL`, `created_by` ) VALUES ( NULL, ?, " . $_SESSION [ 'user_id' ] . " );" );
- $parameters = [
- [ "s" ],
- [ &$url ],
- ];
- $database->bind ( $parameters );
- $database->execute ( );
- $database->prepare ( "SELECT MAX( links.ID ) as `last` FROM links;");
- $database->execute ( );
- $result = $database->get_result ( );
- $row = $result->fetch_assoc ( );
header ( 'Content-Type: application/json' );
+ http_response_code ( 401 );
$response = [
- 'status' => 200,
- 'message' => 'URL inserted correctly.',
- 'last_insert' => $row [ 'last' ],
+ 'status' => 401,
+ 'error_message' => 'You either are not logged in or you do not have permissions to insert new URLs.'
];
echo ( json_encode ( $response ) );
exit;
}
- else {
- $database->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] );
- $database->execute ( );
- $result = $database->get_result ( );
- $row = $result->fetch_assoc ( );
-?>
-
-
-
- BJPHoster URL Shortener | Control Panel
-
-
-
-
-
-" );
- }
- else {
- do {
- echo ( "\t\t\t" . '
' . $row [ 'ID' ] . " | " . $row [ 'URL' ] . "
\n" );
- } while ( $row = $result->fetch_assoc ( ) );
- }
-?>
-
-
-
-
-
-
-
-
- 400,
+ 'error_message' => 'You either did not provide a URL or you provided an invalid one.'
+ ];
+ echo ( json_encode ( $response ) );
+ exit;
}
+ $database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
+ $database->connect ( );
+ $url = $_POST [ 'url' ];
+ $database->prepare ( "INSERT INTO `links` ( `URL`, `created_by` ) VALUES ( ?, " . $_SESSION [ 'user_id' ] . " );" );
+ $parameters = [
+ [ "s" ],
+ [ &$url ],
+ ];
+ $database->bind ( $parameters );
+ $database->execute ( );
+ $database->prepare ( "SELECT MAX( links.ID ) as `last` FROM links;");
+ $database->execute ( );
+ $result = $database->get_result ( );
+ $row = $result->fetch_assoc ( );
+ header ( 'Content-Type: application/json' );
+ $response = [
+ 'status' => 200,
+ 'message' => 'URL inserted correctly.',
+ 'last_insert' => $row [ 'last' ],
+ ];
+ echo ( json_encode ( $response ) );
+ exit;
diff --git a/lib/php/login.php b/lib/php/login.php
index 15ad2ef..984c76f 100644
--- a/lib/php/login.php
+++ b/lib/php/login.php
@@ -1,6 +1,6 @@
- BJPHoster URL Shortener | Login
+ Redirect in 5 seconds | =$GLOBALS['config']['website_name']?>
-
-
+
+
@@ -75,9 +75,9 @@
-
-
-
+
+
+
connect ( );
+ if ( isset ( $_POST [ 'url' ] ) ) {
+ $url = $_POST [ 'url' ];
+ $database->prepare ( "INSERT INTO `links` ( `ID`, `URL`, `created_by` ) VALUES ( NULL, ?, " . $_SESSION [ 'user_id' ] . " );" );
+ $parameters = [
+ [ "s" ],
+ [ &$url ],
+ ];
+ $database->bind ( $parameters );
+ $database->execute ( );
+ $database->prepare ( "SELECT MAX( links.ID ) as `last` FROM links;");
+ $database->execute ( );
+ $result = $database->get_result ( );
+ $row = $result->fetch_assoc ( );
+ header ( 'Content-Type: application/json' );
+ $response = [
+ 'status' => 200,
+ 'message' => 'URL inserted correctly.',
+ 'last_insert' => $row [ 'last' ],
+ ];
+ echo ( json_encode ( $response ) );
+ exit;
+ }
+ else {
+ $database->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] );
+ $database->execute ( );
+ $result = $database->get_result ( );
+ $row = $result->fetch_assoc ( );
+?>
+
+
+
+ BJPHoster URL Shortener | Control Panel
+
+
+
+
+
+" );
+ }
+ else {
+ do {
+ echo ( "\t\t\t" . '
' . $row [ 'ID' ] . " | " . $row [ 'URL' ] . "
\n" );
+ } while ( $row = $result->fetch_assoc ( ) );
+ }
+?>
+
+
+
+
+
+
+
+
+