function shurly_next_url in ShURLy 7
Same name and namespace in other branches
- 8 shurly.module \shurly_next_url()
- 6 shurly.module \shurly_next_url()
Return next available short URL
2 calls to shurly_next_url()
- shurly_create_form_validate in ./
shurly.module - Validation of the main form
- shurly_shorten in ./
shurly.module - API function to shorten a URL @arg $long_url - the long URL to shorten @arg $custom - optional custom short URL
File
- ./
shurly.module, line 1017 - description http://www.youtube.com/watch?v=Qo7qoonzTCE
Code
function shurly_next_url() {
$count = variable_get('shurly_counter', 3249);
// starts the URLs with 3 characters
do {
$count++;
// counter is stored as base 10
// $index is a-z, A-Z, 0-9, sorted randomly, with confusing characters (01lIO) removed - 57 characters
// a custom index can be created as a variable override in settings.php
$index = variable_get('shurly_index', 'kZ4oJ3Uwi5STqcpGNxfYgMQAdPWmsenh78XB26uLbEaRDzKrHVj9CyFtv');
$str = shurly_dec2any($count, NULL, $index);
// check that this string hasn't been used already
// check that the string is a valid (available) path
} while (shurly_url_exists($str) !== FALSE || shurly_path_available($str) === FALSE);
variable_set('shurly_counter', $count);
return $str;
}