Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

@@ -0,0 +1,73 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* URL shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-22 10:10:04 -0500 (Fri, 22 Jan 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 5742 $
*/
/* Class name must match shortener directory name */
class bitly extends urlShorten
{
private $_config = array();
private $_cfm;
/**
* Method constructor
*
* If you pass false as the key, it will not save out the imported GUIDs
* @access public
* @return 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;
}
/**
* Shorten URL
*
* @access public
* @param string URL to shorten
* @return array ( 'status' => [ok/failed], 'url' => [shortened url], 'method' => [api used], 'raw' => [any raw data] )
* Exception codes:
*/
public function apiShorten( $url )
{
/* Query the service */
$response = $this->_cfm->getFileContents( "http://api.bit.ly/shorten?version=2.0.1&longUrl=" . urlencode( $url ) . "&login={$this->_config['login']}&apiKey={$this->_config['apiKey']}" );
if ( ! $response )
{
return array( 'status' => 'failed' );
}
$obj = json_decode( $response, TRUE );
return array( 'status' => 'ok',
'url' => $obj['results'][$url]['shortUrl'],
'method' => 'bitly',
'raw' => $obj['results'] );
}
}
@@ -0,0 +1,28 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* URL shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 5713 $
*/
$config = array();
/* Login... */
$config['login'] = 'invisionps';
/* API KEY - You can find your apiKey at http://bit.ly/account/your_api_key : */
$config['apiKey'] = 'R_eee8c282b147b0aed1bce4370ac81744';
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; 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.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; 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.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; 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.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,193 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* URL Shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 5713 $
*/
/*
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() );
*/
class urlShorten
{
/**
* Main API classes directory
*
* @access public
* @var object
*/
private $_mainDir;
/**
* API class
*
* @access public
* @var object
*/
private $_api;
/**
* Additional error messages
*
* @access public
* @var array
*/
public $errors = array();
/**
* Method constructor
*
* @access public
* @return void
*
* EXCEPTION MESSAGES
* NO_METHOD API class could not be found
*/
public function __construct()
{
$this->_mainDir = IPS_ROOT_PATH . 'sources/classes/url/apis';
}
/**
* 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
*
* EXCEPTION MESSAGES
* NO_METHOD API class could not be found
* BAD_FORMAT URL is not in the correct format
* FAILED URL shorten failed
*/
public function shorten( $url, $apiKey )
{
/* Check URL */
if ( ! strstr( $url, 'http://' ) AND ! strstr( $url, 'https://' ) )
{
throw new Exception( 'BAD_FORMAT' );
}
if ( $apiKey )
{
$_thisDir = $this->_mainDir . '/' . $apiKey;
if ( @file_exists( $_thisDir . '/api.php' ) )
{
$this->_setMethod( $apiKey );
}
}
else
{
/* We don't care */
$apis = $this->fetchAvailableApis();
if ( is_array( $apis ) AND count( $apis ) )
{
$apiKey = array_shift( $apis );
if ( $apiKey )
{
$this->_setMethod( $apiKey );
}
}
}
if ( ! is_object( $this->_api ) )
{
throw new Exception( 'NO_METHOD' );
}
/* still here? */
$data = $this->_api->apiShorten( $url );
if ( $data['status'] == 'ok' )
{
return $data;
}
else
{
/* could do something more useful here */
throw new Exception( 'FAILED' );
}
}
/**
* Set method
* Assumes that the folder and files exist
*
* @access private
* @param string
*/
private function _setMethod( $apiKey )
{
$config = array();
if ( file_exists( $this->_mainDir . '/' . $apiKey . '/conf.php' ) )
{
require( $this->_mainDir . '/' . $apiKey . '/conf.php' );
}
require_once( $this->_mainDir . '/' . $apiKey . '/api.php' );
$this->_api = new $apiKey( $config );
}
/**
* Fetch all available APIs
*
* @access public
* @return array
*/
public function fetchAvailableApis()
{
$apis = array();
try
{
foreach( new DirectoryIterator( $this->_mainDir ) as $file )
{
if ( ! $file->isDot() AND $file->isDir() )
{
$_name = $file->getFileName();
if ( substr( $_name, 0, 1 ) != '.' )
{
$apis[] = $_name;
}
}
}
} catch ( Exception $e ) {}
return $apis;
}
}