Polr Setup
Error: You don't seem to have the MySQL native driver.
You should install it and restart your server in order to use Polr properly.
On Ubuntu-based distros: sudo apt-get install php5-mysqlnd
On Fedora-based distros: sudo yum install php-mysqlnd
, or if you get errors, sudo yum remove php-mysql && yum install php-mysqlnd
For most Windows computers, the native driver should come by default for PHP >= 5.4.
For more information, click here
";
die();
}
function rstr($length = 34) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
if (isset($ppass)) {
if (!isset($_POST['pw'])) {
require_once 'layout-headerlg.php';
echo "
Enter setup password to proceed:
";
echo "
";
require_once 'layout-footerlg.php';
die();
} else if ($pwf = password_verify($_POST['pw'], $ppass)) {
echo "";
} else {
require_once 'layout-headerlg.php';
echo "Wrong password
";
echo "
Enter setup password to proceed:
";
echo "
";
require_once 'layout-footerlg.php';
die();
}
}
if (isset($_POST['dbserver'])) {
$rstr = rstr(50);
function hashpass($pass, $salt = "") {
if (!$salt) {
$salt = rstr(60);
}
$opts = array(
'cost' => 10,
'salt' => $salt
);
$hashed = password_hash($pass, PASSWORD_BCRYPT, $opts);
return $hashed;
}
$nowdate = date('F d Y');
$data = '1) {
$smtpSection = '
$smtpCfg = array(
"servers" => \''.$_POST['smtp-servers'].'\',
"from" => \''.$_POST['smtp-from'].'\',
"username" => \''.$_POST['smtp-username'].'\',
"password" => \''.$_POST['smtp-password'].'\',
);
';
$data .= $smtpSection;
}
$data .= '?>';
$file = "config.php";
$handle = fopen($file, 'a');
if (fwrite($handle, $data) === FALSE) {
echo "Can not write to (" . $file . "). Please make sure your file permissions are correct.
Your webserver's user should have write permissions for the folder. Try looking up
chown
,
chgrp
and
chmod
.
Helpful link";
die();
}
echo "Successfully created config. ";
fclose($handle);
require_once('lib-core.php');
$path = $_POST['path'];
if (strlen($path) > 2) {
$data = "
RewriteEngine On
RewriteBase $path
RewriteRule ^api$ api.php [L]
RewriteRule ^api/$ api.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)\?([a-zA-Z0-9]+)$ r.php?u=$1&lkey=$2 [L,QSA]
RewriteRule ^([a-zA-Z0-9]+)/?$ r.php?u=$1 [L,QSA]
RewriteRule ^t-([a-zA-Z0-9]+)/?$ r.php?u=t-$1 [L,QSA]
RewriteRule ^/?\+([a-zA-Z0-9]+)$ stats.php?bv=$1 [L,QSA]
";
$handle = fopen('.htaccess', 'w');
if (fwrite($handle, $data) === FALSE) {
echo "Can not write to (" . $file . ")";
}
$data = "# Polr **experimental** nginx configuration. Append this to your nginx config for effect.
# If you use Apache, ignore this file.
# Try `/etc/nginx/config.d/` if you have trouble finding the configuration
server {
listen 80;
server_name %SERVER_NAME%;
index index.php
location = $path/api {
rewrite ^(.*)$ $path/api.php;
}
location $path/ {
if (!-e \$request_filename){
rewrite ^$path/([a-zA-Z0-9]+)\?([a-zA-Z0-9]+)$ $path/r.php?u=$1&lkey=$2;
}
rewrite ^$path/([a-zA-Z0-9]+)/?$ $path/r.php?u=$1;
rewrite ^$path/?\+([a-zA-Z0-9]+)$ $path/stats.php?bv=$1;
}
location $path/t {
rewrite ^$path/t-([a-zA-Z0-9]+)/?$ $path/r.php?u=t-$1;
}
}";
$handle = fopen('.nginx-config', 'w');
if (fwrite($handle, $data) === FALSE) {
echo "Can not write to (" . $file . ")";
}
echo "Succesfully created htaccess (custom path)
. ";
fclose($handle);
}
sqlrun('
CREATE TABLE `api` (
`valid` tinyint(1) NOT NULL,
`email` varchar(50) NOT NULL,
`apikey` varchar(70) NOT NULL,
`quota` int(11) NOT NULL,
PRIMARY KEY (`apikey`),
UNIQUE KEY `email` (`email`),
KEY `email_2` (`email`),
KEY `valid` (`valid`),
KEY `aindex` (`valid`,`email`)
);');
sqlrun('
CREATE TABLE `auth` (
`username` varchar(50) NOT NULL,
`password` text NOT NULL,
`email` varchar(65) NOT NULL,
`rkey` varchar(65) NOT NULL,
`role` varchar(37) NOT NULL,
`valid` tinyint(1) NOT NULL DEFAULT "0",
`uid` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`theme` varchar(65) NOT NULL,
`ip` tinytext NOT NULL,
KEY `valid` (`valid`),
KEY `email3` (`email`),
KEY `username2` (`username`)
);');
sqlrun('
CREATE TABLE `redirinfo` (
`rurl` tinytext NOT NULL,
`rid` smallint(200) NOT NULL AUTO_INCREMENT,
`baseval` varchar(30) NOT NULL,
`ip` varchar(90) NOT NULL,
`iscustom` varchar(4) NOT NULL,
`user` tinytext NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`country` varchar(10) NOT NULL,
`lkey` tinytext NOT NULL,
`clicks` int(11) NOT NULL,
`pw` int(120) NOT NULL,
`etc` text,
`etc2` text,
PRIMARY KEY (`rid`),
KEY `baseval` (`baseval`),
KEY `baseval_2` (`baseval`),
KEY `ip` (`ip`),
KEY `iscustom` (`iscustom`)
);');
sqlrun('
CREATE TABLE `redirinfo-temp` (
`rurl` tinytext NOT NULL,
`rid` smallint(200) NOT NULL AUTO_INCREMENT,
`baseval` varchar(30) NOT NULL,
`ip` varchar(90) NOT NULL,
`iscustom` varchar(4) NOT NULL,
`user` tinytext NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`country` tinytext NOT NULL,
`theme` varchar(65) NOT NULL,
`clicks` int(11) NOT NULL,
`pw` int(120) NOT NULL,
`etc` text,
`etc2` text,
PRIMARY KEY (`rid`),
KEY `baseval` (`baseval`),
KEY `ip` (`ip`),
KEY `iscustom` (`iscustom`)
);');
$acctpass = hashpass($_POST['acctpass']);
$nr = sha1(rstr(50));
sqlrun("INSERT INTO auth (username,email,password,rkey,valid,role) VALUES ('{$_POST['acct']}','{$_POST['acctemail']}','{$acctpass}','{$nr}','1','adm') ");
echo "You are now finished Polr Setup. You can now close this window, and login to your account
here (login form @ top right).
If you need help, click
here"
. "
Clueless? Read the docs. https://github.com/Cydrobolt/polr/blob/master/README.md";
} else {
include('version.php');
echo "
";
echo "