Skip to content

Conversation

@MasterOfTheTiger
Copy link
Contributor

This changes the URL shortener to use GET (and rudimentary support for POST) to process user input.

This also resolves #9 by adding support for custom slugs through the new slug GET parameter.

Known issues:

  • There is not a workaround for URLs containing & in their URL (I will finish this in future commits to this pull request)
  • If using POST and password protection, note that the password is passed along via GET when clicking the link to view a specific slug's stats

I am sure I took too much liberty and changing some things, so many things probably need to be changed before this is merged.

@MasterOfTheTiger
Copy link
Contributor Author

Sorry about not working on this. My computer broke and I was unable to do PHP development. I will get back onto it now.

@tylerhall
Copy link
Owner

👍

@MasterOfTheTiger
Copy link
Contributor Author

I need to get a development environment set up. I don't know how to do mod_rewrite for PHP development, and I can't find the router script I used for it before.

@tylerhall
Copy link
Owner


$url = ltrim($_SERVER['REQUEST_URI'], '/');
$url = isset($_POST['url']) ? '' : $_GET['url'];
$custom_slug = isset($_POST['slug']) ? '' : $_GET['slug'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$custom_slug should be escaped before it's used in mysql_query on lines 84 and 97.

Suggested change
$custom_slug = isset($_POST['slug']) ? '' : $_GET['slug'];
$custom_slug = mysqli_real_escape_string($db, isset($_POST['slug']) ? '' : $_GET['slug']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow choosing custom slugs when shortening a new URL

3 participants