GithubHelp home page GithubHelp logo

shortener's Introduction

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.

shortener's People

Contributors

guacam-ole avatar

Stargazers

cardi avatar Mehmet Akif DERE avatar

Watchers

 avatar

shortener's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.