Short URL V3
User Manual
 
 

[home]

Index

[home]
General   Control Panel
 
Entire manual in one web page.

Fast Paste 'n Click

The Fast Paste 'n Click feature is a way to provide easy access to the URL shortening mechanism without going through the control panel.

The interface is similar to tinyurl and other URL shortening services. Paste the long URL and click. You get a short URL back.

Fast Paste 'n Click can optionally also accept a custom alias. If an alias is requested that already exists, the shortening is aborted and a message to that effect is presented to the user.

The Fast Paste 'n Click feature is a separate web page you set up. A .php web page.

To keep the public from accessing the page and using your implementation to create their own short URLs, put the .php web page into a password protected directory. Once logged into the directory, the page is accessible by you from any bookmark or by clicking a link on your personal portal page.

Providing a Public URL Shortening Service

The easy access page could be used to provide a public URL shortening service. Put the page into a public directory instead of in a password protected directory.

Before providing a public URL shortening service, consult with experienced people you trust to determine what advantages and disadvantages there might be, what gotcha's and oops' to consider.

One thing bound to happen is spammers using your service to obfuscate URLs sent in spam emails. The URL with your domain name is then in the spam emails and your domain may be black listed on blocking services.

Consult with your hosting company before implementing such a service for public use. They may have terms prohibiting it or require special authorization or fees.

Security

When the software was installed, an opportunity to provide a Fast Paste 'n Click key was provided. See the "Implementing Fast Paste 'n Click" section below for instructions on how to obtain the key or how to specify a key if not yet done.

That key will be specified in the PHP code of the Fast Paste 'n Click page. A missing key or incorrect key causes the software to reject the URL shortening request.

Implementing Fast Paste 'n Click

The file easyaccess.php that came with the ZIP file software download is an example web page with the Fast Paste 'n Click feature implemented.

Your own easy access page can be created. Or, easyaccess.php may be modified.

Before anything else is done, determine the Fast Paste 'n Click key.

If the key was specified during the installation process, the key is now in the ShortURL_config.php file on the server. Download the file and open it to find the key. It will be on a line something like this:

$FastPasteClickKey = "MyKey";

The key is between the quotation marks.

If nothing is between the quotation marks or if you wish to change it, type a key in now, save the file, and upload it.

The key is best like a strong password, a series of letters, numbers, and other characters. If a quotation mark as part of the key, the quotation mark must be escaped with a preceding backward slash: \"

The easy access, Fast Paste 'n Click web page has one PHP section and two forms.

The PHP section

Here is the PHP code for the easy access page. The code is 20+ lines and has verbose comments. The comments may be removed later, if you wish. Copy the code and paste it somewhere in the web page HEAD area or above the HTML tag.

<?php
/* Here, specify the same Fast Paste 'n Click key as 
   was specified when you installed shortened URL Pro 
   (or as since modified). The current Fast Paste 'n 
   Click key is in the file ShortURL_config.php on 
   your server. It must be identical. Case sensitive. */

$FastPasteClickKeyChecker = "___________";

/* Here, specify the http://... URL of file ShortURL_fast.php */

$FastProcessorURL = "___________";

/* No other edits required. See the manual for other 
   implementation information.                       */
$ShortURLorMessage = $URLtoShorten = $RequestedAlias = '';
$FastProcessorURL = trim($FastProcessorURL);
$FastProcessorURL = preg_replace('/^http:\/\/[^\/]+/i','',$FastProcessorURL);
$ThisDir = $_SERVER['DOCUMENT_ROOT'].preg_replace('/[^\/]*$/','',$FastProcessorURL);
$ThisDirectoryURL = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/[^\/]*$/','',$FastProcessorURL);
if( isset($_POST['URLtoShorten']) ) { include($_SERVER['DOCUMENT_ROOT'].$FastProcessorURL); }
?>

Two edits —

Edit 1:
Note the underscore between the quotation marks following the $FastPasteClickKeyChecker variable. Replace the underscore with the Fast Paste 'n Click key. If a quotation mark as part of the key, the quotation mark must be escaped with a preceding backward slash: \"

Edit 2:
Note the underscore between the quotation marks following the $FastProcessorURL variable. Replace the underscore with the URL of the Fast Paste 'n Click URL shortening software file:

http://example.com/go/ShortURL_fast.php

No other edits need to be done to the PHP code.

The Two Forms —

Form 1:

The first form is the Fast Short URL Maker form. Users type in the URL to shorten. Optionally, they type in a custom alias. And click the button.

Here is the form. Put it in the BODY section where you want the form to appear.

<!-- The form.
     Form field with URL to shorten must be name="URLtoShorten".
     Form field for alias request is optional but, if used, must 
        be name="RequestedAlias".
-->
<form method="post" action="<?php echo($_SERVER['PHP_SELF']) ?>">
<input type="hidden" name="redirectcode" value="301">
<p>
URL to shorten:<br />
<input type="text" name="URLtoShorten" size="55" value="<?php echo($URLtoShorten) ?>">
</p>
<p>
Alias request (optional):<br />
<input type="text" name="RequestedAlias" size="55" maxlength="32" value="<?php echo($RequestedAlias) ?>">
</p>
<p>
<input type="submit" class="submitbutton" name="submitbutton" value="Shorten URL for me" />
</p>
</form>

Form field name="URLtoShorten" is required.

Form field name="RequestedAlias" is optional. It may be removed from the form.

Form hidden field name="redirectcode" is optional. If used, it may specify the redirect code to use when redirecting a browser. Specify "301" or "302" for the value.

The PHP codes need to remain with the form as they are.

Form 2:

The second form contains a form field where the shortened URL is published, ready for copying.

The form prints only when a URL has been shortened. Put it in the location where you want the shortened URLs to be published for copying.

The above is fairly involved. It puts the short URL into a textarea field without borders that self-selects when clicked on.

If you prefer a simple implementation that merely prints the short URL, the form is not even necessary. It can be done with these 3 lines.

<?php if( ! empty($ShortURLorMessage) ): ?>
<?php echo($ShortURLorMessage) ?>
<?php endif; ?>

Wherever you put <?php echo($ShortURLorMessage) ?> (the second line of the above 3-line code) is where the short URL prints. The first and third lines tell the PHP code to print it only when a short URL is available.

Using Fast Paste 'n Click

Once implemented, bookmark the Fast Paste 'n Click URL or link to it on your personal portal page.

The first time you access the page, because it is in a password-protected directory, you will need to provide the directory's username and password.

Thereafter, until you close the browser, you can access the page immediately whenever you quickly want another short URL.

[home]

Short URL V3 version
Short URL V3 version 3.0
Copyright 2009, 2011 Bontrager Connection, LLC
Copyright 2012, 2015, 2016 Will Bontrager Software LLC