Created
January 11, 2015 21:19
-
-
Save ScruffyRules/afc81e89e51bed741748 to your computer and use it in GitHub Desktop.
ShareX URL Shortener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteRule ^(?!.*\.php)(.*)$ go.php?jam=$1 [NC,L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_GET['jam'])) { | |
header("HTTP/1.0 400 Bad Request"); | |
die("HTTP/1.0 400 Bad Request"); | |
} | |
if (!file_exists($_GET['jam'])) { | |
header("HTTP/1.0 400 Bad Request"); | |
die("HTTP/1.0 400 Bad Request"); | |
} | |
header("Location: ".file_get_contents($_GET['jam'])); | |
die(); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Number of characters to be shown when a random file name is generated | |
$url_length = 6; | |
//URL which will be displayed after upload (URL will have the file name appended) | |
$url = "http://scruffyrules.com/s/"; | |
if(!isset($_POST['url'])) { | |
header("HTTP/1.0 400 Bad Request"); | |
die("HTTP/1.0 400 Bad Request"); | |
} | |
$name = generateRandomString(); | |
file_put_contents($name, $_POST['url']); | |
echo $url.$name; | |
function generateRandomString() { | |
global $url_length; | |
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$randomString = ''; | |
for ($i = 0; $i < $url_length; $i++) { | |
$randomString .= $characters[rand(0, strlen($characters) - 1)]; | |
} | |
return $randomString; | |
} | |
?> |
I can't believe this thing is 5 years old
What do you want in it's own directory?
I want the links to be in there own directory like example.com/s/uYLsKi I've tried to figure it out but I can't.
Also I'd probably not use this since it creates a file per URL which is pretty bad.
Well this is the only one I could find so I was ok with what ever. Have you thought about making a more up to date one that works better?
Not really, never really used it.
Guess my search continues thanks for at least making something that works
How do I use the PHP files(new.php, go.php) in ShareX?
you upload those files to your site.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got this to work but I would like it to be in its own directory I can't figure that out. Mind adding more wording or making a video?