Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+44 -54
View File
@@ -3,70 +3,66 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* URL Shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* Last Updated: $Date: 2011-03-11 12:41:48 -0500 (Fri, 11 Mar 2011) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @link http://www.invisionpower.com
* @link http://hatynka.in
* @since 24th November 2009
* @version $Revision: 5713 $
* @version $Revision: 8042 $
*/
/*
Example: Shorten URL
require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );
$shorten = new urlShorten();
$data = $shorten->shorten( 'http://www.invisionpower.com', 'bitly' );
print $data['url'];
Example: List available shorteners
require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );
$shorten = new urlShorten();
print_r( $shorten->fetchAvailableApis() );
*/
# Example: Shorten URL
# require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );/*noLibHook*/
# $shorten = new urlShorten();
# $data = $shorten->shorten( 'http://www.invisionpower.com', 'bitly' );
#
# print $data['url'];
#
# Example: List available shorteners
# require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );/*noLibHook*/
# $shorten = new urlShorten();
#
# print_r( $shorten->fetchAvailableApis() );
#
class urlShorten
{
/**
* Main API classes directory
*
* @access public
* @var object
* @var $_mainDir
*/
private $_mainDir;
protected $_mainDir;
/**
* API class
* API object
*
* @access public
* @var object
* @var $_api
*/
private $_api;
protected $_api;
/**
* Additional error messages
* Array of additional error messages
*
* @access public
* @var array
* @var $errors
*/
public $errors = array();
/**
* Method constructor
*
* @access public
* @return void
* @return @e void
*
* EXCEPTION MESSAGES
* NO_METHOD API class could not be found
* @throws Exception
* @li NO_METHOD (API class could not be found)
*/
public function __construct()
{
@@ -76,15 +72,14 @@ class urlShorten
/**
* Shorten URL
*
* @access public
* @param string URL to shorten
* @param string Method key to use (If left blank, we'll just grab the first one)
* @return array
* @param string $url URL to shorten
* @param string $apiKey Method key to use (If left blank, we'll just grab the first one)
* @return @e array Shortened url data
*
* EXCEPTION MESSAGES
* NO_METHOD API class could not be found
* BAD_FORMAT URL is not in the correct format
* FAILED URL shorten failed
* @throws Exception
* @li NO_METHOD (API class could not be found)
* @li BAD_FORMAT (URL is not in the correct format)
* @li FAILED (URL shorten failed)
*/
public function shorten( $url, $apiKey )
{
@@ -98,7 +93,7 @@ class urlShorten
{
$_thisDir = $this->_mainDir . '/' . $apiKey;
if ( @file_exists( $_thisDir . '/api.php' ) )
if ( @is_file( $_thisDir . '/api.php' ) )
{
$this->_setMethod( $apiKey );
}
@@ -142,28 +137,26 @@ class urlShorten
* Set method
* Assumes that the folder and files exist
*
* @access private
* @param string
* @param string $apiKey API key
* @return @e void
*/
private function _setMethod( $apiKey )
protected function _setMethod( $apiKey )
{
$config = array();
if ( file_exists( $this->_mainDir . '/' . $apiKey . '/conf.php' ) )
if ( is_file( $this->_mainDir . '/' . $apiKey . '/conf.php' ) )
{
require( $this->_mainDir . '/' . $apiKey . '/conf.php' );
require( $this->_mainDir . '/' . $apiKey . '/conf.php' );/*noLibHook*/
}
require_once( $this->_mainDir . '/' . $apiKey . '/api.php' );
$this->_api = new $apiKey( $config );
$classToLoad = IPSLib::loadLibrary( $this->_mainDir . '/' . $apiKey . '/api.php', $apiKey );
$this->_api = new $classToLoad( $config );
}
/**
* Fetch all available APIs
*
* @access public
* @return array
* @return @e array Available APIs
*/
public function fetchAvailableApis()
{
@@ -187,7 +180,4 @@ class urlShorten
return $apis;
}
}