mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-12 21:22:28 +01:00
clean out branch
This commit is contained in:
parent
b6e6b28590
commit
ea53117961
@ -1,8 +0,0 @@
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /(index\.php)?\?id=([0-9]+)([^\ ]*)
|
||||
RewriteRule ^ /%3?%4 [L,R=301]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^([a-zA-Z0-9]+)/?$ /r.php?u=$1 [L,QSA]
|
27
404.php
27
404.php
@ -1,27 +0,0 @@
|
||||
<!-- polr 404 --><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>404</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="bootstrap.css"/>
|
||||
<link rel="stylesheet" href="main.css"/>
|
||||
</head>
|
||||
<body style="padding-top:60px">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<a class="navbar-brand" href="<?php require_once('req.php');echo 'http://'.$wsa;?>"><?php echo $wsn;?></a>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="//github.com/Cydrobolt/polr">Polr Github</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="jumbotron" style="text-align:center; padding-top:80px; background-color: rgba(0,0,0,0);">
|
||||
<h1>404</h1><br><h2>You step in the stream</h2><h2>But the water has moved on.</h2><h2>This page is not here</h2></div>
|
||||
</div>
|
||||
<footer>
|
||||
<p><?php echo $footer;?></p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
25
README.md
25
README.md
@ -1,25 +0,0 @@
|
||||
polr information
|
||||
==================
|
||||
|
||||
####Current State: Under development, merging in updates from PaaS. Latest version: 0.15 RC1 Beta, with known issues. (https://github.com/Cydrobolt/polr/releases/tag/v0.15-RC2-KI)
|
||||
|
||||
Welcome to Polr, the self-hosted version. Read up on some documentation through our github wiki (https://github.com/Cydrobolt/polr/wiki)
|
||||
|
||||
Would like to contribute? Submit pull requests through our Github page. Found an issue? Create an issue here: (https://github.com/Cydrobolt/polr/issues)
|
||||
|
||||
|
||||
|
||||
Copyright (C) 2014 Polr
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
93
api.php
93
api.php
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
//API CONFIGURATION BELOW
|
||||
|
||||
//POLR API - by http://github.com/cydrobolt/polr
|
||||
|
||||
require_once('req.php'); //Fetch Config
|
||||
if(is_string($_REQUEST['apikey']) && is_string($_REQUEST['action']) && is_string($_REQUEST['url'])) {
|
||||
$apikey = $mysqli->real_escape_string($_REQUEST['apikey']); //Sanitize input
|
||||
$action = $mysqli->real_escape_string($_REQUEST['action']);
|
||||
$url_api = $mysqli->real_escape_string($_REQUEST['url']);
|
||||
}
|
||||
else {
|
||||
die("Error: Values not strings");
|
||||
}
|
||||
|
||||
//checking API key:
|
||||
$query = "SELECT valid FROM api WHERE apikey='$apikey'";
|
||||
$result = $mysqli->query($query) or showerror();
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
//check if valid
|
||||
if(!$row['valid']) {
|
||||
$api_key_valid = 0;
|
||||
}
|
||||
else {
|
||||
$api_key_valid = 1;
|
||||
}
|
||||
|
||||
if(!$api_key_valid) {
|
||||
header("HTTP/1.0 401 Forbidden"); //Access denied - fake key
|
||||
die('<h1>401 Forbidden</h1>');
|
||||
}
|
||||
|
||||
if(!filter_var($url_api, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) && $action!="lookup") {
|
||||
echo "Error: URL is not valid"; //URL not well formatted, but allow if action is lookup
|
||||
die();
|
||||
}
|
||||
|
||||
function lookup ($urltl) {
|
||||
global $mysqli;
|
||||
$val = $mysqli->real_escape_string($urltl);
|
||||
$query = "SELECT rurl FROM redirinfo WHERE baseval='{$val}'";
|
||||
$result = $mysqli->query($query) or die("QUERY ERROR");
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
return $row['rurl'];
|
||||
}
|
||||
|
||||
function shorten ($urlr) {
|
||||
global $mysqli;
|
||||
global $wsa;
|
||||
$query1 = "SELECT rid FROM redirinfo WHERE rurl='{$urlr}'";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$existing = $row['rid'];
|
||||
if(!$existing) {
|
||||
$query1 = "SELECT MAX(rid) AS rid FROM redirinfo;";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$ridr = $row['rid'];
|
||||
$baseval = base_convert($ridr+1,10,36);
|
||||
$query2 = "INSERT INTO redirinfo (baseval,rurl) VALUES ('{$baseval}','{$urlr}');";
|
||||
$result2r = $mysqli->query($query2) or showerror();
|
||||
return "http://{$wsa}/{$baseval}";
|
||||
}
|
||||
else {
|
||||
$query1 = "SELECT baseval FROM redirinfo WHERE rurl='{$urlr}'";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$baseval = $row['baseval'];
|
||||
return "http://{$wsa}/{$baseval}";
|
||||
}
|
||||
}
|
||||
|
||||
//api action start
|
||||
|
||||
if($action=="shorten") {
|
||||
echo shorten($url_api);
|
||||
die();
|
||||
}
|
||||
else if($action=="lookup") {
|
||||
$looked_up_url = lookup($url_api);
|
||||
if(!$looked_up_url) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
die("<h1>404 Not Found</h1>");
|
||||
}
|
||||
else {
|
||||
echo $looked_up_url;
|
||||
}
|
||||
die();
|
||||
}
|
||||
else {
|
||||
die("Invalid Action");
|
||||
}
|
||||
|
61
appcalls.php
61
appcalls.php
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/*Polr ver 0.1.
|
||||
* http://github.com/cydrobolt/polr
|
||||
*/
|
||||
//To use this, put this in your app
|
||||
// --> include('appcalls.php'); if appcalls.php is in the same directory as the script calling it
|
||||
// --> include('/path/to/appcalls.php'); if appcalls.php is in another dir
|
||||
|
||||
/* This script does not sanitize any input. It also doesn't check whether
|
||||
* the person calling it has an API key or not. Please only use this
|
||||
* for shortening urls from your other scripts.
|
||||
*/
|
||||
|
||||
//How to use:
|
||||
/*
|
||||
* Simply include this script, then use the functions
|
||||
* lookup($url); to lookup the baseval (the letters following the slash, e.g polr.cf/<baseval>)
|
||||
* of an url to find the longurl.
|
||||
*
|
||||
* shorten($url); shortens a url, returns the shortened url.
|
||||
*
|
||||
* The shortened url will be in a http://domain/baseval form. You will need the
|
||||
* .htaccess file provided in order to accomplish this. r.php must be in your
|
||||
* domain root.
|
||||
*
|
||||
*/
|
||||
|
||||
function lookup ($urltl) {
|
||||
global $mysqli;
|
||||
$val = $mysqli->real_escape_string($urltl);
|
||||
$query = "SELECT rurl FROM redirinfo WHERE baseval='{$val}'";
|
||||
$result = $mysqli->query($query) or die("QUERY ERROR");
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
return $row['rurl'];
|
||||
}
|
||||
|
||||
function shorten ($urlr) {
|
||||
global $mysqli;
|
||||
global $wsa;
|
||||
$query1 = "SELECT rid FROM redirinfo WHERE rurl='{$urlr}'";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$existing = $row['rid'];
|
||||
if(!$existing) {
|
||||
$query1 = "SELECT MAX(rid) AS rid FROM redirinfo;";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$ridr = $row['rid'];
|
||||
$baseval = base_convert($ridr+1,10,36);
|
||||
$query2 = "INSERT INTO redirinfo (baseval,rurl) VALUES ('{$baseval}','{$urlr}');";
|
||||
$result2r = $mysqli->query($query2) or showerror();
|
||||
return "http://{$wsa}/{$baseval}";
|
||||
}
|
||||
else {
|
||||
$query1 = "SELECT baseval FROM redirinfo WHERE rurl='{$urlr}'";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$baseval = $row['baseval'];
|
||||
return "http://{$wsa}/{$baseval}";
|
||||
}
|
||||
}
|
1
bootstrap.css
vendored
1
bootstrap.css
vendored
File diff suppressed because one or more lines are too long
@ -1,78 +0,0 @@
|
||||
<!-- polr -->
|
||||
<?php require_once("req.php");?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $wsn;?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="bootstrap.css"/>
|
||||
<link rel="stylesheet" href="main.css"/>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body style="padding-top:60px">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<a class="navbar-brand" href="index.php"><?php echo $wsn;?></a>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="//github.com/Cydrobolt/polr">Polr Github</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="jumbotron" style="text-align:center; padding-top:80px; background-color: rgba(0,0,0,0);">
|
||||
|
||||
|
||||
<?php
|
||||
if(!filterurl($_POST['urlr'])) {
|
||||
echo "You entered an invalid url<br>";
|
||||
echo "<a href='index.php'>Back</a>";
|
||||
die();
|
||||
}
|
||||
$urlr = $_POST['urlr'];
|
||||
$urlr = $mysqli->real_escape_string($urlr);
|
||||
//Other URL Shorteners List Array
|
||||
|
||||
$isshort = array('polr.cf','bit.ly','is.gd','tiny.cc','adf.ly','ur1.ca','goo.gl','ow.ly','j.mp');
|
||||
|
||||
foreach ($isshort as $url_shorteners) {
|
||||
if(strstr($urlr, $url_shorteners)) {
|
||||
echo "You entered an already shortened URL.<br>";
|
||||
echo "<a href='index.php'>Back</a>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
$query1 = "SELECT rid FROM redirinfo WHERE rurl='{$urlr}'";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$existing = $row['rid'];
|
||||
$decodescript = "<script src='durl.js'></script>";
|
||||
$ip = $mysqli->real_escape_string($ip);
|
||||
|
||||
if(!$existing) {
|
||||
$query1 = "SELECT MAX(rid) AS rid FROM redirinfo;";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$ridr = $row['rid'];
|
||||
$baseval = base_convert($ridr+1,10,36);
|
||||
$query2 = "INSERT INTO redirinfo (baseval,rurl,ip) VALUES ('{$baseval}','{$urlr}','{$ip}');";
|
||||
$result2r = $mysqli->query($query2) or showerror();
|
||||
$basevaltd = "http://".$wsa."/".$baseval;
|
||||
echo "<div style='text-align:center'>URL:<input type='text' id='i' class='form-control' value=\"$basevaltd\" />";
|
||||
|
||||
}
|
||||
else {
|
||||
$query1 = "SELECT baseval FROM redirinfo WHERE rurl='{$urlr}'";
|
||||
$result = $mysqli->query($query1);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
$baseval = $row['baseval'];
|
||||
$basevaltd = "http://".$wsa."/".$baseval;
|
||||
echo "<div style='text-align:center'>URL:<input type='text' id='i' class='form-control' value=\"$basevaltd\" />";
|
||||
}
|
||||
echo "<a href='index.php'>Back</a>";
|
||||
echo "</div>";
|
||||
?>
|
||||
<footer>
|
||||
<p id="footer-pad"><?php echo $footer;?></p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
58
index.php
58
index.php
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
@(include('config.php')) or header('Location:setup.php');
|
||||
include('req.php');
|
||||
if($ppfrontend==true && !isset($_POST['pw'])) {
|
||||
echo "<h2>Enter password to proceed:</h2>";
|
||||
echo "<form action='index.php' method='post'><br><input type='password' name='pw' /><br><input type='submit' value='Log in' /></form>";
|
||||
die();
|
||||
}
|
||||
else if(md5(sha1($_POST['pw']."523422da3a33")+sha1($version.$reldate))==$ppass) {
|
||||
echo "<!--logged in-->";
|
||||
}
|
||||
else if($ppfrontend!=true) {
|
||||
echo "<!--PP disabled-->";
|
||||
}
|
||||
else {
|
||||
echo "<b>Wrong Password, try again.</b>";
|
||||
echo "<form action='index.php' method='post'><br><input type='password' name='pw' /><br><input type='submit' value='Log in' /></form>";
|
||||
die();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Polr Status</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="bootstrap.css"/>
|
||||
<link rel="stylesheet" href="main.css"/>
|
||||
</head>
|
||||
<body style="padding-top:60px">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<a class="navbar-brand" href="<?php require_once('req.php');echo 'http://'.$wsa;?>"><?php echo $wsn;?></a>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="//github.com/Cydrobolt/polr">Polr Github</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="jumbotron" style="padding-top:80px; background-color: rgba(0,0,0,0);">
|
||||
<h1>Welcome to your Polr Instance</h1>
|
||||
<?php
|
||||
if ($wp==1) {
|
||||
echo "<p style='color: red'>Your Polr instance is improperly configured. Delete config.php and reinstall.</p>";
|
||||
}
|
||||
else {
|
||||
echo "<p style='color: green'>Your Polr instance is properly configured.</p>";
|
||||
}
|
||||
?>
|
||||
<br>
|
||||
<h2>Shorten a link:</h2>
|
||||
<br><form method="POST" action="createurl.php" role="form"><input type="text" class="form-control" placeholder="URL" id="url" value="http://" name="urlr" /><br> <input type="submit" class="btn btn-info btn-large" value="Shorten it!"/></form><br>
|
||||
<br>If you need help, click <a href="http://webchat.freenode.net/?channels=#polr">here</a> to contact a developer<br>
|
||||
<b>Clueless? Read the docs. <a href='https://github.com/Cydrobolt/polr/wiki'>https://github.com/Cydrobolt/polr/wiki</a></b></div>
|
||||
</div>
|
||||
<div class='footer-pad'>
|
||||
<p><?php echo $footer;?></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
10
main.css
10
main.css
@ -1,10 +0,0 @@
|
||||
footer {
|
||||
padding-left:5%;
|
||||
bottom:0px;
|
||||
position:absolute;
|
||||
font-size:75%;
|
||||
}
|
||||
.footer-pad {
|
||||
padding-left:11%;
|
||||
font-size: 75%;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
footer {
|
||||
padding-left:5%;
|
||||
font-size:75%;
|
||||
}
|
14
ovr.php
14
ovr.php
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
//THIS CONFIG OVERRIDES THE REQ.PHP CONFIG - DO NOT USE IN PRODUCTION, DEV ONLY
|
||||
//ERRORS COULD OCCUR IF YOU DO NOT CONFIGURE POLR'S REQ.PHP CONFIG CORRECTLY IN PRODUCTION
|
||||
//Polr CONFIGURATION
|
||||
|
||||
/*
|
||||
$host = "localhost"; //Enter Mysql host address
|
||||
$user = "root"; //Mysql user
|
||||
$passwd = ""; //Mysql user password
|
||||
$db = "polr"; //Mysql DB name
|
||||
$wsa = "localhost/polr/php"; //Address of website : e.g polr.cf - do not include http://
|
||||
$ip = $_SERVER['REMOTE_ADDR']; //How Polr should fetch the user's ip - some hosts require you to use getenv()
|
||||
$ovr = 1;
|
||||
*/
|
26
r.php
26
r.php
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
//POLR Redirector
|
||||
require_once('req.php');
|
||||
if(is_string($_GET['u'])) {
|
||||
$val = $mysqli->real_escape_string($_GET['u']);
|
||||
}
|
||||
else {
|
||||
echo "Sorry. You didn't enter a string.";
|
||||
die();
|
||||
}
|
||||
$query = "SELECT rurl FROM redirinfo WHERE baseval='{$val}'";
|
||||
$result = $mysqli->query($query) or showerror();
|
||||
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
|
||||
if(!$row['rurl']) {
|
||||
header("Location: 404.php",true,301);
|
||||
}
|
||||
else {
|
||||
header("Location: {$row['rurl']}",true,301);
|
||||
$oldclicks = sqlfetch("redirinfo","clicks","baseval",$val);
|
||||
$newclicks = $oldclicks+1;
|
||||
sqlrun("UPDATE redirinfo SET clicks='{$newclicks}' WHERE baseval='{$val}'");
|
||||
}
|
||||
|
||||
|
66
req.php
66
req.php
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
//POLR CONFIGURATION LOADING
|
||||
|
||||
|
||||
@(require_once('config.php'));
|
||||
include('version.php');
|
||||
$footer = "© Copyright 2014 $wsn. Powered by <a href='http://github.com/cydrobolt/polr'>Polr</a> ver $version build $reldate";
|
||||
|
||||
//connect to mysql with $mysqli variable
|
||||
$mysqli = new mysqli($host,$user,$passwd,$db) or $wp=1; //If cannot connect, then set var $wp to 1
|
||||
|
||||
//SQL Functions
|
||||
|
||||
//Sanitize input when using sqlrun!
|
||||
function sqlrun ($query) {
|
||||
global $mysqli;
|
||||
$queryrs = $query;
|
||||
$resultrs = $mysqli->query($queryrs) or $mysqli->error;
|
||||
return true;
|
||||
}
|
||||
|
||||
function sqlex ($table,$rowf,$where,$wval) {
|
||||
global $mysqli; //Import var into function
|
||||
//Sanitize strings
|
||||
$rowfs = $mysqli->real_escape_string($rowf);
|
||||
$tables = $mysqli->real_escape_string($table);
|
||||
$wheres = $mysqli->real_escape_string($where);
|
||||
$wvals = $mysqli->real_escape_string($wval);
|
||||
|
||||
$query = "SELECT $rowfs FROM $tables WHERE $wheres='$wvals'";
|
||||
$result = $mysqli->query($query) or showerror();
|
||||
$numrows = $mysqli->affected_rows;
|
||||
if(!numrows) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function sqlfetch ($table,$rowf,$where,$wval) {
|
||||
global $mysqli;
|
||||
|
||||
$rowfs = $mysqli->real_escape_string($rowf);
|
||||
$tables = $mysqli->real_escape_string($table);
|
||||
$wheres = $mysqli->real_escape_string($where);
|
||||
$wvals = $mysqli->real_escape_string($wval);
|
||||
|
||||
$query = "SELECT $rowfs FROM $tables WHERE $wheres='$wvals'";
|
||||
$result = $mysqli->query($query) or showerror();
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
return $row[$rowf];
|
||||
}
|
||||
function showerror (){
|
||||
echo "There seems to be a problem :'( *sniff* . Click > <a href='http://webchat.freenode.net/?channels=polr'>here</a> contact an administrator.";
|
||||
die();
|
||||
}
|
||||
|
||||
function filterurl ($url) {
|
||||
if(!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
107
setup.php
107
setup.php
@ -1,107 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Polr Setup</title>
|
||||
<link rel="stylesheet" href="bootstrap.css"/>
|
||||
<link rel="stylesheet" href="main.css"/>
|
||||
</head>
|
||||
<body style="padding-top:60px">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<a class="navbar-brand" href="//github.com/Cydrobolt/polr">Polr</a>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="//github.com/Cydrobolt/polr">Github</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class='container-fluid' style="text-align: center">
|
||||
<span><h1>Polr setup</h1></span><br>
|
||||
<?php
|
||||
@(include('config.php'));
|
||||
include ('version.php');
|
||||
if (isset($ppass)) {
|
||||
if(!isset($_POST['pw'])) {
|
||||
echo "<h2>Enter password to proceed:</h2>";
|
||||
echo "<form action='setup.php' method='post'><br><input type='password' name='pw' /><br><input type='submit' value='Log in' /></form>";
|
||||
die();
|
||||
}
|
||||
else if(md5(sha1($_POST['pw']."523422da3a33")+sha1($version.$reldate))==$ppass) {
|
||||
echo "";
|
||||
}
|
||||
else {
|
||||
echo "Wrong password";
|
||||
echo "<h2>Enter password to proceed:</h2>";
|
||||
echo "<form action='setup.php' method='post'><br><input type='password' name='pw' /><br><input type='submit' value='Log in' /></form>";
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
if (isset($_POST['dbserver'])) {
|
||||
$data = '<?php
|
||||
$host="'.$_POST['dbserver'].'";'.
|
||||
'$user="'.$_POST['dbuser'].'";'.
|
||||
'$passwd="'.$_POST['dbpass'].'";'.
|
||||
'$db="'.$_POST['dbname'].'";'.
|
||||
'$wsa = "'.$_POST['appurl'].'";'.
|
||||
'$wsn = "'.$_POST['appname'].'";'.
|
||||
'$ppass = "'.md5(sha1($_POST['protpass']."523422da3a33")+sha1($version.$reldate)).'";'.
|
||||
'$ppfrontend = "'.$_POST['pp'].'";'.
|
||||
'$ip = $_SERVER[\'REMOTE_ADDR\'];
|
||||
?>';
|
||||
$file = "config.php";
|
||||
|
||||
$handle = fopen($file, 'a');
|
||||
if (fwrite($handle, $data) === FALSE) { echo "Can not write to (".$file.")"; }
|
||||
echo "Succesfully created config. ";
|
||||
fclose($handle);
|
||||
require_once('req.php');
|
||||
|
||||
//Create Tables
|
||||
sqlrun("CREATE TABLE redirinfo"
|
||||
. "("
|
||||
. "rid INT NOT NULL AUTO_INCREMENT,"
|
||||
. "PRIMARY KEY(rid),"
|
||||
. "rurl CHAR(80),"
|
||||
. "baseval CHAR(40),"
|
||||
. "ip CHAR(90)"
|
||||
. ")");
|
||||
sqlrun("CREATE TABLE api"
|
||||
. "("
|
||||
. "apikey CHAR(100) NOT NULL,"
|
||||
. "PRIMARY KEY(apikey),"
|
||||
. "email CHAR(80),"
|
||||
. "valid TINYINT(1)"
|
||||
. ")");
|
||||
sqlrun("CREATE INDEX index ON redirinfo (rurl, baseval, ip)");
|
||||
sqlrun("CREATE INDEX aindex ON api (valid,email)");
|
||||
echo "You are now finished Polr Setup. You can now close this window or click <a href='index.php'>here</a> to check the status of the installation. <br><br>If you need help, click <a href=\"http://webchat.freenode.net/?channels=#polr\">here</a><br>"
|
||||
. "<br><br><b>Clueless? Read the docs. <a href='https://github.com/Cydrobolt/polr/tree/master/docs'>https://github.com/Cydrobolt/polr/tree/master/docs</a></b>";
|
||||
}
|
||||
else {
|
||||
include('version.php');
|
||||
echo "<form name=\"Config Creation\" method=\"post\" action=\"".'setup.php'."\">";
|
||||
echo "Database Host: <input type=\"text\" name=\"dbserver\" value=\"localhost\"><br>";
|
||||
echo "Database User: <input type=\"text\" name=\"dbuser\" value=\"root\"><br>";
|
||||
echo "Database Pass: <input type=\"password\" name=\"dbpass\" value=\"password\"><br>";
|
||||
echo "Database Name: <input type=\"text\" name=\"dbname\" value=\"polr\"><br>";
|
||||
echo "Application Name: <input type=\"text\" name=\"appname\" value=\"polr\"><br>";
|
||||
echo "Application URL (path to Polr, no http:// or www.) : <input type=\"text\" name=\"appurl\" value=\"yoursite.com\"><br>";
|
||||
echo "App Access Password: <input type=\"text\" name=\"protpass\" value=\"password123\"><br>";
|
||||
if(isset($_POST['pw'])) {
|
||||
echo "<input type='hidden' value='{$_POST['pw']}' name='pw' />";
|
||||
}
|
||||
echo "<input type=\"checkbox\" name=\"pp\" value=\"Password-Protect\">Password Protect the Frontend (shortener)<br><br>";
|
||||
echo "<input type=\"submit\" value=\"Create/Update config\"><input type=\"reset\" value=\"Clear Fields\">";
|
||||
echo "</form>";
|
||||
echo "<br><br></div><div class='container'><b>Make sure the databse you specify is already created. The database user needs to"
|
||||
. "already have been created. If you enter the wrong information, go in the installation "
|
||||
. "directory and delete config.php.<br>Please grant the mysql user all privileges"
|
||||
. "during the setup, and then restrict the user to only CREATE, UPDATE, INSERT, DELETE, and SELECT.</b>";
|
||||
echo "<br><br>Polr is <a href='http://en.wikipedia.org/wiki/Open-source_software'>Open-Source software</a> licensed under the <a href='https://www.gnu.org/copyleft/gpl.html'>GPL</a>. By continuing to use Polr, you agree to the terms of the GPL.";
|
||||
echo "<footer>Polr Version $version released $reldate - <a href='//github.com/cydrobolt/polr'>Github</a></footer>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('req.php');
|
||||
|
||||
echo var_dump($mysqli);
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
$version = "0.15 RC2";
|
||||
$reldate = "3/10/2014";
|
Loading…
Reference in New Issue
Block a user