Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -3,45 +3,44 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* URL shortener
|
||||
* Owner: Matt Mecham
|
||||
* Last Updated: $Date: 2010-01-22 10:10:04 -0500 (Fri, 22 Jan 2010) $
|
||||
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 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: 5742 $
|
||||
* @version $Revision: 8644 $
|
||||
*/
|
||||
|
||||
|
||||
/* Class name must match shortener directory name */
|
||||
class bitly extends urlShorten
|
||||
{
|
||||
private $_config = array();
|
||||
protected $_config = array();
|
||||
|
||||
private $_cfm;
|
||||
protected $_cfm;
|
||||
|
||||
/**
|
||||
* Method constructor
|
||||
*
|
||||
* If you pass false as the key, it will not save out the imported GUIDs
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*
|
||||
*/
|
||||
public function __construct( $config=array() )
|
||||
{
|
||||
$this->_config = $config;
|
||||
|
||||
require_once( IPS_KERNEL_PATH . 'classFileManagement.php' );
|
||||
$this->_cfm = new classFileManagement();
|
||||
$this->_cfm->use_sockets = 1;
|
||||
$this->_cfm->timeout = 30;
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
|
||||
$this->_cfm = new $classToLoad();
|
||||
$this->_cfm->timeout = 30;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <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: 2010-12-17 08:01:38 -0500 (Fri, 17 Dec 2010) $
|
||||
* </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: 7445 $
|
||||
*/
|
||||
|
||||
$config = array();
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,6 @@
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.2.3
|
||||
* URL shortener
|
||||
* Owner: Matt Mecham
|
||||
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author Matt Mecham
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://hatynka.in
|
||||
* @since 24th November 2009
|
||||
* @version $Revision: 8644 $
|
||||
*/
|
||||
|
||||
|
||||
/* Class name must match shortener directory name */
|
||||
class topic extends urlShorten
|
||||
{
|
||||
protected $_config = array();
|
||||
|
||||
protected $_cfm;
|
||||
|
||||
/**
|
||||
* Method constructor
|
||||
*
|
||||
* If you pass false as the key, it will not save out the imported GUIDs
|
||||
*
|
||||
* @return @e void
|
||||
*
|
||||
*/
|
||||
public function __construct( $config=array() )
|
||||
{
|
||||
$this->_config = $config;
|
||||
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
|
||||
$this->_cfm = new $classToLoad();
|
||||
$this->_cfm->timeout = 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorten URL
|
||||
*
|
||||
* @param string URL to shorten
|
||||
* @return array ( 'status' => [ok/failed], 'url' => [shortened url], 'method' => [api used], 'raw' => [any raw data] )
|
||||
*/
|
||||
public function apiShorten( $url )
|
||||
{
|
||||
/* Query the service */
|
||||
$response = $this->_cfm->getFileContents( "http://topic.to/api.php?action=shorturl&url=" . urlencode( $url ) . "&format=json" );
|
||||
|
||||
if ( ! $response )
|
||||
{
|
||||
return array( 'status' => 'failed' );
|
||||
}
|
||||
|
||||
$obj = json_decode( $response, TRUE );
|
||||
|
||||
if ( $obj['statusCode'] != 200 )
|
||||
{
|
||||
return array( 'status' => 'failed' );
|
||||
}
|
||||
|
||||
return array( 'status' => 'ok',
|
||||
'url' => $obj['shorturl'],
|
||||
'method' => 'topic',
|
||||
'raw' => $obj['url'] );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.2.3
|
||||
* URL shortener
|
||||
* Owner: Matt Mecham
|
||||
* Last Updated: $Date: 2010-12-17 08:01:38 -0500 (Fri, 17 Dec 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author Matt Mecham
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://hatynka.in
|
||||
* @since 24th November 2009
|
||||
* @version $Revision: 7445 $
|
||||
*/
|
||||
|
||||
$config = array();
|
||||
|
||||
/* Login... */
|
||||
$config['login'] = '';
|
||||
|
||||
/* API KEY - Not needed : */
|
||||
$config['apiKey'] = '';
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,6 @@
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user