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

+204 -222
View File
@@ -2,32 +2,33 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Mobile API
* Last Updated: $Date: 2010-08-11 11:54:57 -0400 (Wed, 11 Aug 2010) $
* Last Updated: $Date: 2011-07-07 16:40:12 -0400 (Thu, 07 Jul 2011) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mat $
* @copyright (c) 2001 - 2008 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
* @version $Rev: 6743 $
* @link http://hatynka.in
* @version $Rev: 9182 $
*
*/
define( 'IPS_IS_MOBILE_APP', true );
define( 'IPB_THIS_SCRIPT', 'public' );
require_once( '../../initdata.php' );
require_once( '../../initdata.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );/*noLibHook*/
class mobileApiRequest
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
@@ -43,9 +44,8 @@ class mobileApiRequest
/**
* Make the registry shortcuts
*
* @access public
* @param object ipsRegistry reference
* @return void
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
@@ -64,8 +64,7 @@ class mobileApiRequest
/**
* Figure out what api is being called
*
* @access public
* @return void
* @return @e void
*/
public function dispatch()
{
@@ -103,6 +102,14 @@ class mobileApiRequest
$this->_handlePostStatus();
break;
case 'postTopic':
$this->_handlePostTopic();
break;
case 'postReply':
$this->_handlePostReply();
break;
default:
$this->_invalidApi();
break;
@@ -140,7 +147,7 @@ class mobileApiRequest
$_data = $notifyLibrary->fetchUnreadNotifications( 10, 'notify_sent', 'DESC', $unreadOnly, true );
/* XML Parser */
require_once( IPS_KERNEL_PATH . 'classXML.php' );
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
$xml = new classXML( 'utf-8' );
$xml->newXMLDocument();
@@ -192,7 +199,7 @@ class mobileApiRequest
$notifyLibrary->setMember( $this->memberData );
/* Notifications Data */
$_notifyConfig = $notifyLibrary->getMemberNotificationConfig();
$_notifyConfig = $notifyLibrary->getMemberNotificationConfig( $this->memberData );
if( $notifyStatus )
{
@@ -241,7 +248,7 @@ class mobileApiRequest
}
/* Check to see if notifications are enabled */
if( ! IPSLib::canReceiveMobileNotifications() )
if( ! IPSMember::canReceiveMobileNotifications() )
{
$this->_returnError( "You are not authorized to receive mobile notifications" );
}
@@ -261,7 +268,7 @@ class mobileApiRequest
protected function _handleNotificationTypes()
{
/* Check to see if notifications are enabled */
if( ! IPSLib::canReceiveMobileNotifications() )
if( ! IPSMember::canReceiveMobileNotifications() )
{
$this->_returnError( "You are not authorized to receive mobile notifications" );
}
@@ -277,7 +284,7 @@ class mobileApiRequest
/* Options */
$_basicOptions = array( array( 'email', $this->lang->words['notopt__email'] ), array( 'pm', $this->lang->words['notopt__pm'] ), array( 'inline', $this->lang->words['notopt__inline'] ), array( 'mobile', $this->lang->words['notopt__mobile'] ) );
$_configOptions = $notifyLibrary->getNotificationData( TRUE );
$_notifyConfig = $notifyLibrary->getMemberNotificationConfig();
$_notifyConfig = $notifyLibrary->getMemberNotificationConfig( $this->memberData );
$_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
$_formOptions = array();
@@ -326,7 +333,7 @@ class mobileApiRequest
//$_formOptions[ $option['key'] ]['options'] = $_available;
$_formOptions[ $option['key'] ]['defaults'] = $_thisConfig['selected'];
$_formOptions[ $option['key'] ]['defaults'] = is_array($_thisConfig['selected']) ? $_thisConfig['selected'] : array();
$_formOptions[ $option['key'] ]['disabled'] = 0;
//-----------------------------------------
@@ -337,7 +344,7 @@ class mobileApiRequest
if( $_defaultConfig[ $option['key'] ]['disable_override'] )
{
$_formOptions[ $option['key'] ]['disabled'] = 1;
$_formOptions[ $option['key'] ]['defaults'] = $_defaultConfig[ $option['key'] ]['selected'];
$_formOptions[ $option['key'] ]['defaults'] = is_array($_defaultConfig[ $option['key'] ]['selected']) ? $_defaultConfig[ $option['key'] ]['selected'] : array();
}
}
@@ -350,7 +357,7 @@ class mobileApiRequest
);
/* XML Parser */
require_once( IPS_KERNEL_PATH . 'classXML.php' );
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
$xml = new classXML( 'utf-8' );
$xml->newXMLDocument();
@@ -423,6 +430,12 @@ class mobileApiRequest
*/
protected function _handleLogin()
{
/* 3.2 upwards renames these fields, but since we do this prior to getting capabilities, we don't know version yet */
$this->request['ips_username'] = ipsRegistry::$request['ips_username'] = $this->request['username'];
$_REQUEST['ips_username'] = $_REQUEST['username'];
$this->request['ips_password'] = ipsRegistry::$request['ips_password'] = $this->request['password'];
$_REQUEST['ips_password'] = $_REQUEST['password'];
/* Load the login handler */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
$this->han_login = new $classToLoad( $this->registry );
@@ -447,6 +460,8 @@ class mobileApiRequest
'facebook' => IPSLib::fbc_enabled() && $this->han_login->member_data['fb_uid'] ? '1' : '0',
'twitter' => IPSLib::twitter_enabled() && $this->han_login->member_data['twitter_id'] ? '1' : '0',
'albums' => $this->_userAlbums( $this->han_login->member_data ),
'version_id' => ipsRegistry::$vn_full,
'version_text' => ipsRegistry::$version,
'form_hash' => md5( $this->han_login->member_data['email'].'&'.$this->han_login->member_data['member_login_key'].'&'.$this->han_login->member_data['joined'] )
) );
}
@@ -460,7 +475,7 @@ class mobileApiRequest
protected function _userEnabledNotifications( $memberData )
{
/* Check to see if notifications are enabled */
if( ! IPSLib::canReceiveMobileNotifications( $memberData ) )
if( ! IPSMember::canReceiveMobileNotifications( $memberData ) )
{
return 0;
}
@@ -507,8 +522,8 @@ class mobileApiRequest
/* Load status class */
if ( ! $this->registry->isClassLoaded( 'memberStatus' ) )
{
require_once( IPS_ROOT_PATH . 'sources/classes/member/status.php' );
$this->registry->setClass( 'memberStatus', new memberStatus( ipsRegistry::instance() ) );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus' );
$this->registry->setClass( 'memberStatus', new $classToLoad( ipsRegistry::instance() ) );
}
return $this->registry->getClass('memberStatus')->canCreate( $memberData ) ? '1' : '0';
@@ -522,41 +537,25 @@ class mobileApiRequest
*/
protected function _userAlbums( $memberData )
{
$albums = array();
/* Make sure we have gallery */
if( ! IPSLib::appIsInstalled( 'gallery' ) )
{
return array();
}
/* Libs */
define( 'GALLERY_LIBS', IPS_ROOT_PATH . '/applications_addon/ips/gallery/sources/libs/' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('gallery') . '/sources/classes/gallery.php', 'ipsGallery', 'gallery' );
$this->registry->setClass( 'gallery', new $classToLoad( $this->registry ) );
/* Gallery Object */
require_once( GALLERY_LIBS . 'lib_gallery.php' );
$this->registry->setClass( 'glib', new lib_gallery( $this->registry ) );
/* Fetch albums */
$_albums = $this->registry->gallery->helper('albums')->fetchAlbumsByOwner( $memberData['member_id'] );
/* Load the category object */
require_once( GALLERY_LIBS . 'lib_categories.php' );
$this->registry->setClass( 'category', new lib_categories( $this->registry ) );
$this->registry->category->normalInit();
$this->registry->glib->category = $this->registry->category;
/* Album Library */
require_once( GALLERY_LIBS . 'lib_albums.php' );
$this->albums = new lib_albums( $this->registry );
/* Get a list of user albums */
$this->albums->fetchAlbumsByOwner( $memberData['member_id'] );
/* Build Albums */
$albums = array();
foreach( $this->albums->album_lookup as $r )
foreach( $_albums as $id => $data )
{
$albums[] = array( 'id' => $r['id'], 'name' => $r['name'] );
$albums[] = array( 'id' => $id, 'name' => $data['album_name'] );
}
return $albums;
}
@@ -585,129 +584,26 @@ class mobileApiRequest
$this->_returnError( "Gallery has been disabled" );
}
/* Libs */
define( 'GALLERY_LIBS', IPS_ROOT_PATH . '/applications_addon/ips/gallery/sources/libs/' );
/* Gallery Object */
require_once( GALLERY_LIBS . 'lib_gallery.php' );
$this->registry->setClass( 'glib', new lib_gallery( $this->registry ) );
/* Load the category object */
require_once( GALLERY_LIBS . 'lib_categories.php' );
$this->registry->setClass( 'category', new lib_categories( $this->registry ) );
$this->registry->category->normalInit();
$this->registry->glib->category = $this->registry->category;
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('gallery') . '/sources/classes/gallery.php', 'ipsGallery', 'gallery' );
$this->registry->setClass( 'gallery', new $classToLoad( $this->registry ) );
/* Get the album */
$albumId = intval( $this->request['album'] );
$this->album = $this->registry->glib->fetchAlbumInfo( $albumId );
$album = $this->registry->gallery->helper('albums')->fetchAlbumsById( $albumId );
/* Check the album owner */
if( $this->album['member_id'] != $this->memberData['member_id'] )
if ( ! $this->registry->gallery->helper('albums')->isUploadable( $album ) )
{
$this->_returnError( "You are not allowed to upload images to that album" );
}
/* Check album limits */
if( $this->memberData['g_img_album_limit'] )
{
$count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) AS total', 'from' => 'gallery_images', 'where' => "album_id={$albumId}" ) );
if( $count['total'] >= $this->memberData['g_img_album_limit'] )
{
$this->_returnError( "You can not upload any more images to that album" );
}
}
if( empty( $this->request['caption'] ) )
{
$this->request['caption'] = IPSText::parseCleanValue( $_FILES['image']['name'] );
}
/* Get upload settings */
$settings = $this->getUploadSettings();
$settings = $this->getUploadSettings( $album );
/* Process the file */
$new_file_info = $this->registry->glib->processUploadedFile( 'image', $settings['thumb'], $settings['watermark'], $settings['container'], $settings['allow_media'], $settings['allow_images'] );
//-------------------------------------------------------------
// Insert information into the database
//-------------------------------------------------------------
$insert = array( 'member_id' => $this->memberData['member_id'],
'category_id' => 0,
'album_id' => $albumId,
'caption' => $this->request['caption'],
'description' => $this->request['description'],
'approved' => $settings['approve'],
'thumbnail' => $settings['thumbnail'],
'views' => 0,
'comments' => 0,
'idate' => time(),
'ratings_total' => 0,
'ratings_count' => 0,
'caption_seo' => IPSText::makeSeoTitle( $this->request['caption'] ),
'image_notes' => '',
);
$insert = array_merge( $insert, $new_file_info );
//-------------------------------------------------------------
// Check copyright data
//-------------------------------------------------------------
if( $this->settings['gallery_allow_usercopyright'] != 'disabled' )
{
$insert['copyright'] = $this->settings['gallery_allow_usercopyright'] == '1' ? ( $this->request['copyright'] ? $this->request['copyright'] : $this->settings['gallery_copyright_default'] ) : $this->settings['gallery_copyright_default'];
}
//-------------------------------------------------------
// Do the insert
//-------------------------------------------------------
$this->DB->insert( 'gallery_images', $insert );
if( ! $this->memberData['has_gallery'] )
{
$this->DB->update( 'members', array( 'has_gallery' => 1 ), "member_id={$this->memberData['member_id']}" );
}
$pid = $this->DB->getInsertId();
if( $this->request['notify'] )
{
$this->DB->insert( 'gallery_subscriptions', array(
'sub_mid' => $this->memberData['member_id'],
'sub_type' => 'image',
'sub_toid' => $pid,
'sub_added' => time()
)
);
}
//------------------------------------------------------------
// Need to update the parents, if they exist and this is a category
//------------------------------------------------------------
$this->registry->glib->reSyncEverything( $insert['category_id'], $insert['album_id'] );
if( $insert['approved'] )
{
require_once( GALLERY_LIBS . 'lib_notifications.php' );
$notify = new lib_notifications( $this->registry );
$notify->category = $this->category;
if( $insert['album_id'] )
{
$notify->sendAlbumNotifications( $insert['album_id'] );
}
else
{
$notify->sendCatNotifications( $insert['category_id'] );
}
}
/* Upload it */
$this->registry->gallery->helper('upload')->addImage( 'image', $albumId, array( 'title' => $this->request['caption'],
'description' => $this->request['description'],
'approved' => $settings['approved'] ) );
exit();
}
@@ -733,12 +629,12 @@ class mobileApiRequest
/* Load status class */
if ( ! $this->registry->isClassLoaded( 'memberStatus' ) )
{
require_once( IPS_ROOT_PATH . 'sources/classes/member/status.php' );
$this->registry->setClass( 'memberStatus', new memberStatus( ipsRegistry::instance() ) );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus' );
$this->registry->setClass( 'memberStatus', new $classToLoad( ipsRegistry::instance() ) );
}
require_once( IPS_KERNEL_PATH . 'classAjax.php' );
$this->ajax = new classAjax();
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
$this->ajax = new $classToLoad();
/* Got content? */
if( !trim( $this->ajax->convertAndMakeSafe( $_POST['content'] ) ) )
@@ -772,6 +668,129 @@ class mobileApiRequest
exit;
}
/**
* Handle posting a new topic
*
* @return string XML
*/
protected function _handlePostTopic()
{
/* Check the form hash */
if( $this->member->form_hash != $this->request['form_hash'] )
{
$this->_returnError( "Invalid Request" );
}
$topic_forum = intval( $this->request['f'] );
ipsRegistry::getAppClass( 'forums' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php', 'classPost' );
$this->registry->setClass( 'classPost', new $classToLoad( ipsRegistry::instance() ) );
$this->registry->getClass('class_forums')->strip_invisible = true;
$this->registry->getClass('class_forums')->forumsInit();
$this->registry->classPost->setIsPreview( false );
$this->registry->classPost->setForumData( $this->registry->getClass('class_forums')->forum_by_id[ $topic_forum ] );
$this->registry->classPost->setForumID( $topic_forum );
$this->registry->classPost->setTopicTitle( $_POST['title'] );
$this->registry->classPost->setPostContent( $_POST['body'] );
$this->registry->classPost->setAuthor( $this->memberData['member_id'] );
$this->registry->classPost->setPublished( true );
$this->registry->classPost->setSettings( array( 'enableSignature' => 1,
'enableEmoticons' => 1,
'post_htmlstatus' => 0,
'enableTracker' => 0 ) );
try {
if ( $this->registry->classPost->addTopic() === FALSE ) {
$this->_returnError( "Topic could not be posted: " . $this->registry->classPost->getPostError() );
} else {
$topic_id = $this->registry->classPost->getTopicData( 'tid' );
}
} catch ( Exception $ex ) {
$this->_returnError( "Error posting topic: " . $ex->getMessage() );
}
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
$xml = new classXML( 'utf-8' );
$xml->newXMLDocument();
$xml->addElement( 'topic' );
$xml->addElementAsRecord( 'topic', 'info', array( 'topic_id' => $topic_id ) );
echo $xml->fetchDocument();
exit();
}
/**
* Handle posting a new reply
*
* @return string XML
*/
protected function _handlePostReply()
{
/* Check the form hash */
if( $this->member->form_hash != $this->request['form_hash'] )
{
$this->_returnError( "Invalid Request" );
}
$topic_forum = intval( $this->request['f'] );
$topic_topic = intval( $this->request['t'] );
ipsRegistry::getAppClass( 'forums' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php', 'classPost' );
$this->registry->setClass( 'classPost', new $classToLoad( ipsRegistry::instance() ) );
$this->registry->getClass('class_forums')->strip_invisible = true;
$this->registry->getClass('class_forums')->forumsInit();
//-----------------------------------------
// Need the topic...
//-----------------------------------------
$topic = $this->registry->DB()->buildAndFetch( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid=' . $topic_topic ) );
$this->registry->classPost->setIsPreview( false );
$this->registry->classPost->setForumData( $this->registry->getClass('class_forums')->forum_by_id[ $topic_forum ] );
$this->registry->classPost->setForumID( $topic_forum );
$this->registry->classPost->setTopicID( $topic_topic );
$this->registry->classPost->setTopicData( $topic );
$this->registry->classPost->setTopicTitle( $_POST['title'] );
$this->registry->classPost->setPostContent( $_POST['body'] );
$this->registry->classPost->setAuthor( $this->memberData['member_id'] );
$this->registry->classPost->setPublished( true );
$this->registry->classPost->setSettings( array( 'enableSignature' => 1,
'enableEmoticons' => 1,
'post_htmlstatus' => 0,
'enableTracker' => 0 ) );
try {
if ( $this->registry->classPost->addReply() === FALSE ) {
$this->_returnError( "Reply could not be posted: " . $this->registry->classPost->getPostError() );
} else {
$topic_id = $this->registry->classPost->getTopicData( 'tid' );
$post_id = $this->registry->classPost->getPostData( 'pid' );
}
} catch ( Exception $ex ) {
$this->_returnError( "Error posting reply: " . $ex->getMessage() );
}
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
$xml = new classXML( 'utf-8' );
$xml->newXMLDocument();
$xml->addElement( 'topic' );
$xml->addElementAsRecord( 'topic', 'info', array( 'topic_id' => $topic_id ) );
$xml->addElementAsRecord( 'topic', 'info', array( 'post_id' => $post_id ) );
echo $xml->fetchDocument();
exit();
}
/**
* Send an error about the selected api
*
@@ -786,12 +805,12 @@ class mobileApiRequest
* Sends an error message in xml
*
* @param string $msg
* @return void
* @return @e void
*/
protected function _returnError( $msg )
{
/* XML Parser */
require_once( IPS_KERNEL_PATH . 'classXML.php' );
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
$xml = new classXML( 'utf-8' );
$xml->newXMLDocument();
@@ -808,12 +827,12 @@ class mobileApiRequest
* Sends forum data in xml format
*
* @param array $dataArray
* @return void
* @return @e void
*/
protected function _returnXml( $dataArray )
{
/* XML Parser */
require_once( IPS_KERNEL_PATH . 'classXML.php' );
require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
$xml = new classXML( 'utf-8' );
$xml->newXMLDocument();
@@ -837,6 +856,9 @@ class mobileApiRequest
}
}
$xml->addElementAsRecord( 'forum', 'version', array( 'version_id' => $dataArray['version_id'] ) );
$xml->addElementAsRecord( 'forum', 'version', array( 'version_text' => $dataArray['version_text'] ) );
/* Output */
echo $xml->fetchDocument();
exit();
@@ -845,62 +867,22 @@ class mobileApiRequest
/**
* Returns settings used for uploading images
*
* @access protected
* @param array Album array
* @return array
*/
protected function getUploadSettings()
protected function getUploadSettings( $album=array() )
{
//-----------------------------------
// Category Settings
//-----------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('gallery') . '/sources/classes/gallery.php', 'ipsGallery', 'gallery' );
$this->registry->setClass( 'gallery', new $classToLoad( $this->registry ) );
if( $this->cat )
{
$thumb = ( $this->cat['thumbnail'] && $this->settings['gallery_create_thumbs'] ) ? 1 : 0;
$watermark = $this->cat['watermark_images'];
if ( !$this->memberData['g_movies'] OR !$this->cat['allow_movies'] )
{
$allow_media = 0;
}
else
{
$allow_media = 1;
}
$container = $this->cat['id'];
$html = ( $this->cat['allow_html'] AND $this->memberData['g_dohtml'] ) ? 1 : 0 ;
$approve_images = $this->cat['approve_images'] ? 0 : 1;
$code = $this->cat['allow_ibfcode'];
$allow_images = $this->cat['allow_images'];
}
//-----------------------------------
// Album Settings
//-----------------------------------
else
{
$cat = $this->registry->category->cat_lookup[ $this->album['category_id'] ];
$thumb = ( $cat['thumbnail'] && $this->settings['gallery_create_thumbs'] ) ? 1 : 0;
$watermark = ( $cat['watermark_images'] && $this->settings['gallery_watermark_path'] ) ? 1 : 0;
$allow_media = ( $cat['allow_movies'] && $this->memberData['g_movies'] ) ? 1 : 0;
$container = $this->album['id'];
$html = ( $cat['allow_html'] && $this->memberData['g_dohtml'] ) ? 1 : 0 ;
$approve_images = ( $cat['approve_images'] ) ? 0 : 1;
$code = ( $cat['allow_ibfcode'] ) ? 1 : 0;
$allow_images = $cat['allow_images'] ? 1 : 0;
}
return array( 'thumb' => $thumb,
'watermark' => $watermark,
'html' => $html,
'code' => $code,
'allow_media' => $allow_media,
'approve' => $approve_images,
'container' => $container,
'allow_images' => $allow_images,
return array( 'thumb' => 1,
'watermark' => ( $this->settings['gallery_watermark_path'] ) ? 1 : 0,
'html' => 0,
'code' => 1,
'allow_media' => $this->registry->gallery->helper('media')->allow( $this->memberData['member_id'] ),
'approve' => ( $this->registry->gallery->helper('albums')->isGlobal( $album ) && $album['album_g_approve_img'] ) ? 1 : 0,
'container' => $album['album_id'],
'allow_images' => 1,
);
}
}