Jump to content

help on modifying script


dimebag12

Recommended Posts

hi

sorry if im asking in the wrong section

i have a little problem with a php script

i want to use url shortening service for myself on my own host

so i searched alot and found the php script that is exactly what i want

but there is a problem . the this script have ability to shorten the url and add automatic name or number to the shortened url or the user can define tag for its shortened url

and now the problem while defining tag im not able to use some characters like / or . or _ so i need a help to modify the script so i can use those characters too when chosing tag for my shortened url

i do not know php and have nobody to help me

i searched alot in the script and i think this the line that need to be modified

 

// Find last URL
	$result = mysql_query('SELECT id FROM shrt_urls WHERE custom=0 ORDER BY id DESC') or error('Query failed. '.mysql_error());
	// Get its ID
	if ( mysql_num_rows($result) ) {
		$id = mysql_result($result,0,0)+1;
	} else
		$id = 1;
	// Loop through till we find a free ID (needs improving to reduce potential number of queries)
	while ( mysql_num_rows(mysql_query('SELECT 1 FROM shrt_urls WHERE id='.$id.' LIMIT 1')) )
			$id++;
	$key = id2key($id);
} else {
	$custom = 1;
	$key = clean($_POST['key']);
	// Check for forbidden characters
	if ( ! ctype_alnum($key) ) {
		$_SESSION['msg'] = 'Error: The new URL can only contain alphanumeric characters (a-z,0-9).';
		localRedirect($return);
	}
	// Check chosen key is available
	$id = key2id($key);
	if ( mysql_num_rows(mysql_query('SELECT 1 FROM shrt_urls WHERE id='.$id.' LIMIT 1')) ) {
		$_SESSION['msg'] = 'Error: Sorry, the new URL you chose is already in use.';
		localRedirect($return);

 

hope ive guessed it write

can someone help me remove this restriction ?

thanks so much in advanced

Link to comment
https://forums.phpfreaks.com/topic/145398-help-on-modifying-script/
Share on other sites

Remove or modify this...

 

      if ( ! ctype_alnum($key) ) {
         $_SESSION['msg'] = 'Error: The new URL can only contain alphanumeric characters (a-z,0-9).';
         localRedirect($return);
      }

 

If you don't understand why, see ctype_alnum();

hi

thanks for reply

i tried removing that line

but the problem is not solved

in fact still the whole script is working okay but again when i want to define tag for shortened url with chracters like . or / this time it does not give me the same error as befor :

The new URL can only contain alphanumeric characters (a-z,0-9).

 

but it says :

We could not complete your request. The following error was returned.

Could not find the requested URL.

some kind of undefined error

whats wrong is that code related to some other varaiable ?

is it not better that i modify it somehow rather than deleting it ?

plz help me i really need this script

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.