Simple Url Shortener

Ahoi - Don't fork
This is my personal server. I try to maintain it and keep it running, but I cannot guarantee it.
So if you want to fork - especially if the idea is to have a backup - do not use the "Fork" button here.
Instead use

git clone --mirror
and push it to your preferred service like Codeberg

  • HTML 37.8%
  • PHP 29.4%
  • JavaScript 17.2%
  • CSS 15.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-03-31 13:42:18 +02:00
.gitea ci: add FUNDING.yml for sponsor links 2026-03-31 13:42:18 +02:00
bower_components Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
css Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
docs Update faq.de.md 2022-05-23 11:05:35 +02:00
js Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
php Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
.gitignore Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
.htaccess Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
404.html Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
bower.json Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
index.html Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00
LICENSE Update LICENSE 2016-10-18 15:31:58 +02:00
README.md Update README.md 2018-08-31 13:12:55 +02:00
stats.html Initial Commit (copy from private Repo; Removed Images, FAQ & Imprint) 2016-10-18 17:01:39 +02:00

Simple Angular / PHP - Url Shortener

License:

CC-BY-NC 3.0 (the "NC" isn't very strict here. Just look into the license-document or contact me if you are unsure)

Before you begin

Origin

This is the public copy of the url shortener used for Hurz.Me / Fade.At Because of license Issues (I don't own the rights to copy the artwork used) and security issues some things have been removed:

Missing Contents

All Images have been removed. So you have to create your own Artwork if you want to have this fancy.

Database

Before you can begin, you have to create a Database and four Tables to store the data. The following Snippet creates those tables: Important If you decide to create the tables manually, make sure to use a collation for the "token" columns that are Case-Sensitive.

SQL-Creation-Script


CREATE TABLE `calculated` (
  `id` bigint(11) NOT NULL AUTO_INCREMENT,
  `target` varchar(1024) NOT NULL,
  `expire` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `expire` (`expire`)
);

CREATE TABLE `calculatedaccess` (
  `id` bigint(20) NOT NULL,
  `accessdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  KEY `idx_calc` (`id`)
);

CREATE TABLE `custom` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `token` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `target` varchar(1024) NOT NULL,
  `expire` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`),
  KEY `expire` (`expire`),
  KEY `token_2` (`token`)
) ;

CREATE TABLE `customaccess` (
  `token` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `accessdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  KEY `idx_custom` (`token`)
) ;


ALTER TABLE `calculatedaccess`
  ADD CONSTRAINT `rts_calculated` FOREIGN KEY (`id`) REFERENCES `calculated` (`id`) ON DELETE CASCADE;

ALTER TABLE `customaccess`
  ADD CONSTRAINT `idx_custom` FOREIGN KEY (`token`) REFERENCES `custom` (`token`) ON DELETE CASCADE;

Some Explanation: In [custom] all custom tokens (5 characters or more) are saved, [calculated] stores all calculated redirects. The [*access] - tables store all external access to the url.

Configuration

Just add a "connect.php" into the php-folder containing the following contents:

<?php
function Connect() {
        $dbHost="localhost";
        $dbName="myDatabase";
        $dbUser="username";
        $dbPass="p@ssw0rd";

        return new PDO('mysql:host='.$dbHost.';dbname='.$dbName, $dbUser, $dbPass);
    }
?>

Watch the Project in Action

You can see what this project does on "http://fade.at",

Additional Stats

As you can see statistics for any address by adding "/stats" to it, you can also see statistics about all custom or all calculated redirects.

To see those just enter [yourdomain]/calculated/stats or [yourdomain]/custom/stats (It would possibly be a good idea to "block" those two custom domains by putting them into the "custom"-table without an expiry-date)

Spam protection

This project uses a very simple JavaScript-Based Spam-protection. It is based on the thoughts of [David Walsh] (https://davidwalsh.name/wordpress-comment-spam) (yes a popular journalist who does JavaScript. How awesome is that?) ;)

I used nearly the same technique on my wordpress-blogs and successfully blocked all spam. But be aware that while this is great to trick any Spam-bot, it can easily fail if someone decides to write a spam-mechanism especially for your site.