static function set_url_shortener($class) { self::$instance = new $class(); if (!self::$instance instanceof URLShortenerService) { user_error("Invalid URL shortener supplied: {$class}", E_USER_ERROR); } }
<?php require_once __DIR__ . '/lib/URLShortener/URLShortener.php'; // Set up the URL shortener. $URLShortener = new URLShortener(); if (!$URLShortener->needs_password_set) { // If we've gotten here, and there's a password set, we haven't found a short URL // Do the default redirect $URLShortener->redirect_default(); } else { // Present the set password form ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title><?php echo ucfirst($_SERVER['SERVER_NAME']); ?> </title> </head> <body> <form action="." method="post" accept-charset="utf-8"> <label for="password">Set a password</label> <input type="password" name="newpassword" value="" id="password"> <input type="submit" value="Continue →"> </form> </body> </html> <?php }
<?php /** * URL Shortener Module Configuration * * @package urlshortener * @author Hamish Campbell <*****@*****.**> * @copyright copyright (c) 2010, Hamish Campbell */ // By default, uses a URL Segment of the current site to provide short urls. // Change the default URL Segment ('-') with: // SSURLShortener::set_url_segment('short'); // Use alternative URL shortening services by setting the shortener class: // URLShortener::set_url_shortener(BitlyURLShortener) // URLShortener::init();