shortr/README.md

48 lines
1.1 KiB
Markdown

## 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
) 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');