Go to file
2022-08-28 14:50:08 +00:00
.gitignore Initial commit 2022-08-12 09:13:25 +02:00
conf.php-sample move some stuff out of the config, DEFINE debug 2022-08-24 13:13:17 +00:00
index.php remove not needed functions 2022-08-28 08:55:14 +00:00
README.md fix formatting 2022-08-28 14:50:08 +00:00

Shortr

Single PHP URL Shorter

Database and table needed, build on MariaDB / MySQL:

CREATE DATABASE IF NOT EXISTS `shortr` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `shortr`;
CREATE TABLE `urls` (
  `id` varchar(255) NOT NULL,
  `url` text DEFAULT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `ip` varchar(255) DEFAULT NULL,
  `count` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Example OpenBSD httpd.conf

server "host.domain.tld" {
	listen on $local_v4 port 80
	tcp { nodelay, sack }
	log style forwarded
	root "/htdocs/host.domain.tld/shortr"
	directory { index "index.php" }
	location match "^/[%l%u%d]+$" {
		request rewrite "/index.php?hash=%1"
	}
	location "/*.php*" {
		fastcgi socket "/run/php-fpm.sock"
	}
}

Configuration file needs to be renamed to conf.php

Configuration options:

define("HASH_LENGTH", 4);
define("SITE_TITLE", "NAME OF SITE");
define("BASE_URL", 'https://host.domain.tld/');
define("DB_HOST", 'localhost');
define("DB_USER", 'shortr');
define("DB_PASS", 'RandomStringOfChars');
define("DB_NAME", 'shortr');
define("DB_TABLE", 'urls');