-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding login, signin, config file.....
- Loading branch information
Showing
19 changed files
with
462 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,54 @@ | ||
# simple-shortener | ||
# simple-shortener by Azlux | ||
|
||
<p>Simple shortener working with MySQL or SQLite database in php and small javascript functions.<br /><br /> | ||
This shortener create a ID for every user to have a list of short url create by user (working with cookie). The user can add comments for the link to find it faster into its history.<br /> | ||
<br/> | ||
Nice shortcut added. The shortcut will create a new short url of your current page when you click on it.<br /><br /> | ||
Simple shortener working with MySQL or SQLite database in PHP. | ||
The goal is to create a simple and KISS shortener without dependencies. | ||
The user can add comments for the link to find it faster into its history. | ||
|
||
|
||
Nice shortcut added. The shortcut will create a new short url of your current page when you click on it. | ||
Writed to work into subfolder. (don't need to be at the root) | ||
</p> | ||
|
||
======= | ||
<p> | ||
File installation.php to execute at first access. This php file need the +w mode on the folder (only the first time, you can remove the writing after the install) is you choose the SQlite database<br /> | ||
</p> | ||
|
||
============= | ||
#####Nginx configuration : | ||
## Installation : | ||
- | ||
- Copy `config.example.php` to `config.php` | ||
- Set you config file | ||
- Call `installation.php` to setup the database | ||
- delete `installation.php` | ||
- Create a user, the first one will be an admin (allow you to see no connected shorted links) | ||
|
||
|
||
### Nginx configuration : | ||
|
||
```NGINX | ||
if (!-e $request_filename) { | ||
rewrite ^/([^/]*)$ /index.php?site=$1 last; | ||
location / { | ||
rewrite ^/(.*)$ /index.php?site=$1 last; | ||
try_files $uri $uri/ /index.php; | ||
} | ||
location /assets { | ||
try_files $uri =404; | ||
} | ||
location /favicon.ico { | ||
try_files $uri =404; | ||
} | ||
location ~ \.php$ { | ||
try_files $uri =404; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_index index.php; | ||
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
``` | ||
Think about remove access to the sqlite file (and .htaccess) with : | ||
```NGINX | ||
location ~* \.(sqlite3|ht)$ { | ||
deny all; | ||
deny all; | ||
} | ||
``` | ||
#####Apache configuration (.htaccess) : | ||
tested and approved :) (delete the file if you are on nginx) | ||
### Apache configuration (.htaccess) : | ||
(delete the file if you are on nginx) | ||
|
||
|
||
<br/> | ||
####Credit :<p> | ||
### Credit :<p> | ||
Based on code provided by [SilouFR](https://github.com/SilouFr) | ||
</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
body { | ||
background-color: #23232f; | ||
} | ||
#content { | ||
background: rgba(255, 255, 255, 0.08); | ||
border-color: #e1e1e1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
body { | ||
background-color: #dddddd; | ||
} | ||
#content { | ||
background: rgba(255, 255, 255, 0.40); | ||
border-color: #2a85b3; | ||
} |
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function bookmark() { | ||
document.getElementById("bookmark").setAttribute('href', "javascript:(function () {var d = document;var w = window;var enc = encodeURIComponent;var f = '" + window.location.href + "index.php';var l = d.location;var p = '?shorten=' + enc(l.href) + '&comment=' + enc(d.title) + '&userID="+getID()+"';var u = f + p;var a = function () {if (!w.open(u))l.href = u;};if (/Firefox/.test(navigator.userAgent))setTimeout(a, 0); else a();void(0);})();"); | ||
} | ||
bookmark(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
require 'config.php'; | ||
|
||
|
||
if (DATABASE_TYPE == "mysql") { | ||
try { | ||
$connexion = new PDO('mysql:host='.MYSQL_HOST.';dbname='.MYSQL_DATABASE.';charset=utf8', MYSQL_USER, MYSQL_PASSWORD); | ||
$connexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
} catch (PDOException $e) { | ||
echo $e->getMessage(); | ||
} | ||
} | ||
elseif (DATABASE_TYPE == "sqlite3") { | ||
try { | ||
$connexion = new PDO("sqlite:".SQLITE3_FILE); | ||
$connexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
} catch (PDOException $e) { | ||
echo $e->getMessage(); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
define('DATABASE_TYPE', 'mysql'); //mysql or sqlite3 | ||
|
||
// useless if sqlite3 is selected | ||
define('MYSQL_HOST', 'localhost'); | ||
define('MYSQL_DATABASE', 'url'); | ||
define('MYSQL_USER', 'url'); | ||
define('MYSQL_PASSWORD', '******'); | ||
|
||
//useless if mysql is selected | ||
define('SQLITE3_FILE', './database.sqlite3'); | ||
|
||
define('DEFAULT_URL', 'https://azlux.fr'); // omit the trailing slash! | ||
define('URL_SIZE', 5); // The lenght of your short created links | ||
define('WEB_THEME', 'white'); // dark or white | ||
define('PUBLIC_INSTANCE', 'false'); // true to allow no connected people to create short url. The admin can see no connected short URL created. | ||
define('ALLOW_SIGNIN', 'false'); // true to allow people to signin on there own | ||
|
||
?> |
Binary file not shown.
Oops, something went wrong.