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

@@ -1,10 +1,11 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Attachments
* Last Updated: $Date: 2009-12-03 17:23:59 -0500 (Thu, 03 Dec 2009) $
* Last Updated: $Date: 2010-11-15 11:39:10 -0500 (Mon, 15 Nov 2010) $
* </pre>
*
* <code>
* Possible Error strings:
@@ -16,13 +17,13 @@
* - no_upload_dir_perms (Upload dir is not writeable)
* </code>
*
* @author $Author: bfarber $
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @version $Rev: 5516 $
* @link http://www.invisionpower.com
* @version $Rev: 7185 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -36,7 +37,6 @@ class class_attach
/**
* Global html class
*
* @access public
* @var object
*/
public $html;
@@ -44,7 +44,6 @@ class class_attach
/**
* Type of attachment
*
* @access public
* @var string
*/
public $type = '';
@@ -52,7 +51,6 @@ class class_attach
/**
* Plugin Class
*
* @access public
* @var object
*/
public $plugin = '';
@@ -60,7 +58,6 @@ class class_attach
/**
* Post key
*
* @access public
* @var string
*/
public $attach_post_key = '';
@@ -68,7 +65,6 @@ class class_attach
/**
* Relationship ID
*
* @access public
* @var integer
*/
public $attach_rel_id = '';
@@ -76,7 +72,6 @@ class class_attach
/**
* Return variables
*
* @access public
* @var array [ 'allow_uploads', 'space_allowed', 'space_allowed_human', 'space_used', 'space_used_human', 'space_left', 'space_left_human' ]
*/
public $attach_stats = array();
@@ -85,7 +80,6 @@ class class_attach
* Lang array
* Internal language array
*
* @access public
* @var array
*/
public $language = array( 'unlimited' => 'Неограничено',
@@ -94,7 +88,6 @@ class class_attach
/**
* Error array
*
* @access public
* @var string
*/
public $error = "";
@@ -102,7 +95,6 @@ class class_attach
/**
* Full upload path
*
* @access public
* @var string
*/
public $upload_path = '';
@@ -110,7 +102,6 @@ class class_attach
/**
* Upload part part (from /uploads)
*
* @access public
* @var string
*/
public $upload_dir = '';
@@ -118,7 +109,6 @@ class class_attach
/**
* Extra upload form url
*
* @access public
* @var string
*/
public $extra_upload_form_url = '';
@@ -126,7 +116,6 @@ class class_attach
/**
* Custom settings
*
* @access public
* @var array
*/
public $attach_settings = array(
@@ -140,7 +129,6 @@ class class_attach
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
@@ -149,12 +137,12 @@ class class_attach
protected $request;
protected $lang;
protected $member;
protected $memberData;
/**#@-*/
/**
* CONSTRUCTOR
*
* @access public
* @param object ipsRegistry reference
* @return void
*/
@@ -173,7 +161,6 @@ class class_attach
/**
* Initiates class
*
* @access public
* @return void
*/
public function init()
@@ -223,14 +210,13 @@ class class_attach
//-----------------------------------------
$this->upload_path = $this->attach_settings['upload_dir'];
$this->_upload_path = $this->upload_path;
}
/**
* Show the attachment (or force download)
*
* @access public
* @param int Attachment ID (The main attach id)
* @return void
*/
@@ -257,13 +243,13 @@ class class_attach
/* Got a reply? */
if( $attach === FALSE OR ! is_array( $attach ) )
{
$this->registry->getClass('output')->showError( 'no_permission_to_download', 10171 );
$this->registry->getClass('output')->showError( 'no_permission_to_download', 10171, null, null, 403 );
}
/* Got a rel id? */
if( ! $attach['attach_rel_id'] AND $attach['attach_member_id'] != $this->memberData['member_id'] )
{
$this->registry->getClass('output')->showError( 'err_attach_not_attached', 10172 );
$this->registry->getClass('output')->showError( 'err_attach_not_attached', 10172, null, null, 403 );
}
//-----------------------------------------
@@ -292,10 +278,10 @@ class class_attach
$this->registry->cache()->updateCacheWithoutSaving( 'attachtypes', $attachtypes );
}
/* Show attachment */
$attach_cache = $this->registry->cache()->getCache('attachtypes');
$this->_upload_path = ( isset( $this->plugin->settings[ 'upload_dir' ] ) ) ? $this->plugin->settings[ 'upload_dir' ] : $this->attach_settings[ 'upload_dir' ];
$this->_upload_path = ( isset( $this->plugin->mysettings[ 'upload_dir' ] ) ) ? $this->plugin->mysettings[ 'upload_dir' ] : $this->attach_settings[ 'upload_dir' ];
$file = $this->_upload_path . "/" . $attach['attach_location'];
@@ -307,31 +293,59 @@ class class_attach
/* Open and display the file.. */
header( "Content-Type: {$attach_cache[ $attach['attach_ext'] ]['atype_mimetype']}" );
if( $attach['attach_is_image'] )
$disposition = $attach['attach_is_image'] ? "inline" : "attachment";
if( in_array( $this->memberData['userAgentKey'], array( 'firefox', 'opera' ) ) )
{
header( "Content-Disposition: inline; filename=\"{$attach['attach_file']}\"" );
@header( 'Content-Disposition: ' . $disposition . "; filename*={$this->settings['gb_char_set']}''" . rawurlencode($attach['attach_file']) );
}
else if( in_array( $this->memberData['userAgentKey'], array( 'explorer' ) ) )
{
@header( 'Content-Disposition: ' . $disposition . '; filename="' . rawurlencode($attach['attach_file']) . '"' );
}
else
{
header( "Content-Disposition: attachment; filename=\"{$attach['attach_file']}\"" );
@header( 'Content-Disposition: ' . $disposition . '; filename="' . $attach['attach_file'] . '"' );
}
if( !ini_get('zlib.output_compression') OR ini_get('zlib.output_compression') == 'off' )
{
header( 'Content-Length: ' . (string) ( filesize( $file ) ) );
}
if( $fh = fopen( $file, 'rb' ) )
/**
* @link http://community.invisionpower.com/tracker/issue-22011-wrong-way-to-handle-attachments-transfer/
*/
if ( function_exists('ob_end_clean') )
{
while( ! feof( $fh ) )
{
echo fread( $fh, 4096 );
flush();
@ob_flush();
}
@fclose( $fh );
}
@ob_end_clean();
}
if( function_exists('readfile') )
{
readfile( $file );
}
else
{
if( $fh = fopen( $file, 'rb' ) )
{
while( ! feof( $fh ) )
{
echo fread( $fh, 4096 );
if ( function_exists('ob_get_length') AND function_exists('ob_flush') AND @ob_get_length() )
{
@ob_flush();
}
else
{
@flush();
}
}
@fclose( $fh );
}
}
exit();
}
@@ -344,14 +358,13 @@ class class_attach
else
{
/* No permission? */
$this->registry->getClass('output')->showError( 'no_permission_to_download', 10174 );
$this->registry->getClass('output')->showError( 'no_permission_to_download', 10174, null, null, 403 );
}
}
/**
* Swaps the HTML for the nice attachments.
*
* @access public
* @param array Array of HTML blocks to convert: [ rel_id => $html ]
* @param array Relationship ids
* @param string Skin group to use
@@ -417,7 +430,7 @@ class class_attach
//-----------------------------------------
$rows = $this->plugin->renderAttachment( $attach_ids, $rel_ids, $this->attach_post_key );
//-----------------------------------------
// Got anything?
//-----------------------------------------
@@ -478,7 +491,7 @@ class class_attach
// Make sure we've not seen this ID
//-----------------------------------------
$row['_attach_id'] = $row['attach_id'] . '-' . str_replace( ".", "-", microtime( true ) );
$row['_attach_id'] = $row['attach_id'] . '-' . str_replace( array( '.', ' ' ), "-", microtime() );
$not_inline = $_seen_rows > 0 ? $_seen_rows%$this->settings['topic_attach_no_per_row'] : 1;
@@ -501,7 +514,7 @@ class class_attach
// Convert HTML
//-----------------------------------------
if ( is_array( $map_attach_id_to_rel_id[ $_attach_id ] ) AND count( $map_attach_id_to_rel_id[ $_attach_id ] ) )
if ( isset($map_attach_id_to_rel_id[ $_attach_id ]) AND is_array( $map_attach_id_to_rel_id[ $_attach_id ] ) AND count( $map_attach_id_to_rel_id[ $_attach_id ] ) )
{
foreach( $map_attach_id_to_rel_id[ $_attach_id ] as $idx => $_rel_id )
{
@@ -607,11 +620,11 @@ class class_attach
$_seen_rows++;
}
//-----------------------------------------
// Anthing to add?
//-----------------------------------------
if ( count( $final_blocks ) )
{
foreach( $final_blocks as $rel_id => $type )
@@ -647,7 +660,6 @@ class class_attach
/**
* Removes attachment(s)
*
* @access public
* @param array $remove_ids Array of attachment ids to remove
* @param string $id_type Column to use when deleting, attach_rel_id by default
* @return bool
@@ -710,7 +722,6 @@ class class_attach
/**
* Removes an attachment.
*
* @access public
* @return void
*/
public function removeAttachment()
@@ -721,7 +732,6 @@ class class_attach
if ( ! $this->attach_id )
{
echo "no this->attachid";
return FALSE;
}
@@ -735,7 +745,6 @@ class class_attach
if ( ! $attachment['attach_id'] )
{
echo "no attach id";
return FALSE;
}
@@ -775,7 +784,6 @@ class class_attach
}
else
{
echo "no perms";
return FALSE;
}
}
@@ -784,7 +792,6 @@ class class_attach
* Converts post-key attachments into rel_id / rel_module attachments
* by adding in the correct ID, etc
*
* @access public
* @param array $args
* @return array
*/
@@ -812,7 +819,6 @@ class class_attach
/**
* Uploads and saves file
*
* @access public
* @return mixed void, or the new insert id
*/
public function processUpload()
@@ -881,7 +887,6 @@ class class_attach
'attach_thumb_location' => "",
'attach_hits' => 0,
'attach_date' => time(),
'attach_temp' => 0,
'attach_post_key' => $this->attach_post_key,
'attach_member_id' => $this->memberData['member_id'],
'attach_rel_id' => $this->attach_rel_id,
@@ -900,7 +905,7 @@ class class_attach
// Set up the variables
//-----------------------------------------
$upload->out_file_name = $this->type . '-' . $this->memberData['member_id'] . '-' . str_replace( '.', '', microtime( true ) );
$upload->out_file_name = $this->type . '-' . $this->memberData['member_id'] . '-' . str_replace( array( '.', ' ' ), '-', microtime() );
$upload->out_file_dir = $this->upload_path;
$upload->max_file_size = $this->attach_stats['max_single_upload'] ? $this->attach_stats['max_single_upload'] : 1000000000;
$upload->make_script_safe = 1;
@@ -997,6 +1002,7 @@ class class_attach
require_once( IPS_KERNEL_PATH."classImage.php" );
require_once( IPS_KERNEL_PATH."classImageGd.php" );
$image = new classImageGd();
$image->force_resize = true;
$image->init( array(
@@ -1036,15 +1042,14 @@ class class_attach
$this->DB->insert( 'attachments', $attach_data );
$newid = $this->DB->getInsertId();
return $newid;
}
}
}
/**
* Uploads and saves file
*
* @access public
* @return mixed void, or an array of new insert ids
*/
public function processMultipleUploads()
@@ -1063,6 +1068,13 @@ class class_attach
}
}
/* Can Upload */
if ( ! $this->attach_stats['allow_uploads'] )
{
$this->error = 'upload_failed';
return;
}
/* Setup Attachment Types */
if( ! ( $this->registry->cache()->getCache('attachtypes') ) OR ! is_array( $this->registry->cache()->getCache('attachtypes') ) )
{
@@ -1082,13 +1094,6 @@ class class_attach
$this->registry->cache()->updateCacheWithoutSaving( 'attachtypes', $attachtypes );
}
/* Can Upload */
if ( ! $this->attach_stats['allow_uploads'] )
{
$this->error = 'upload_failed';
return;
}
/* Attachment Library */
require_once( IPS_KERNEL_PATH.'classUpload.php' );
@@ -1140,7 +1145,6 @@ class class_attach
'attach_thumb_location' => "",
'attach_hits' => 0,
'attach_date' => time(),
'attach_temp' => 0,
'attach_post_key' => $this->attach_post_key,
'attach_member_id' => $this->memberData['member_id'],
'attach_rel_id' => $this->attach_rel_id,
@@ -1240,14 +1244,13 @@ class class_attach
/**
* Gets stuff required for the upload form
*
* @access public
* @return void
*/
public function getUploadFormSettings()
{
/* Collect settings from the plug-in */
$stats = $this->plugin->getSpaceAllowance( $this->attach_post_key );
/* Fix language strings */
if( isset($this->lang->words['attach_unlimited']) )
{
@@ -1258,7 +1261,7 @@ class class_attach
{
$this->language['not_allowed'] = $this->lang->words['attach_notallowed'];
}
/* Format and return... */
$this->attach_stats['space_used'] = $stats['space_used'];
$this->attach_stats['space_used_human'] = IPSLib::sizeFormat( $stats['space_used'] );
@@ -1266,7 +1269,7 @@ class class_attach
$this->attach_stats['max_single_upload'] = $stats['max_single_upload'];
$this->attach_stats['max_single_upload_human'] = $this->attach_stats['max_single_upload'] ? IPSLib::sizeFormat( $stats['max_single_upload'] ) : $this->language[ 'unlimited' ];
$this->attach_stats['total_space_allowed_human'] = $this->attach_stats['total_space_allowed'] ? IPSLib::sizeFormat( $this->attach_stats['total_space_allowed'] ) : $this->language[ 'unlimited' ];
if( $stats['space_allowed'] == 0 )
{
/* Unlimited... */
@@ -1298,7 +1301,6 @@ class class_attach
/**
* Checks the upload dir. See above. It's not rocket science
*
* @access public
* @return bool
*/
public function checkUploadDirectory()
@@ -1364,29 +1366,35 @@ class class_attach
/**
* Loads child extends class.
*
* @access public
* @return void
* @todo Should we add a check here in the foreach to see if the application is enabled?
*/
public function loadAttachmentPlugin()
{
/* INIT */
$this->type = IPSText::alphanumericalClean( $this->type );
/* Load... */
$file = IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/plugin_' . $this->type . '.php';
$class = 'plugin_'.$this->type;
if( ! is_object( $this->plugin ) )
/* No plugin yet? Load it! */
if( ! is_object( $this->plugin ) && $this->type )
{
if ( file_exists( $file ) )
/* Load... */
foreach( ipsRegistry::$applications as $app )
{
require_once( $file );
$this->plugin = new $class( $this->registry );
$this->plugin->getSettings();
if( file_exists( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/attachments/plugin_' . $this->type . '.php' ) )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/attachments/plugin_' . $this->type . '.php', 'plugin_'.$this->type, $app['app_directory'] );
$this->plugin = new $classToLoad( $this->registry );
$this->plugin->getSettings();
/* Found it, stop */
break;
}
}
else
/* Still here? Error out then.. */
if ( ! is_object( $this->plugin ) )
{
print "Could not locate $file";
print "Could not locate plugin {$this->type}";
exit();
}
}
@@ -1395,7 +1403,6 @@ class class_attach
/**
* Swaps the HTML for the nice attachments.
*
* @access private
* @param array Array of matches from preg_replace_callback
* @return string HTML
*/
@@ -1412,7 +1419,7 @@ class class_attach
// Generate random ID
//-----------------------------------------
$row['_attach_id'] = $row['attach_id'] . '-' . preg_replace( "#[\.\s]#", "-", microtime() );
$row['_attach_id'] = $row['attach_id'] . '-' . str_replace( array( '.', ' ' ), "-", microtime() );
//-----------------------------------------
// Build HTML
@@ -1433,5 +1440,4 @@ class class_attach
return $tmp;
}
}
@@ -1 +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.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<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>
@@ -1,465 +0,0 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* IP.Blog attachment parsing
* Last Updated: $Date: 2009-07-21 16:19:42 -0400 (Tue, 21 Jul 2009) $
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage IP.Blog
* @link http://www.iinvisionpower.com
* @since 6/24/2008
* @version $Revision: 4923 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class plugin_blogcblock extends class_attach
{
/**
* Module type
*
* @access public
* @var string
*/
public $module = 'blogcblock';
/**
* Returns an array of settings:
* 'siu_thumb' = Allow thumbnail creation?
* 'siu_height' = Height of the generated thumbnail in pixels
* 'siu_width' = Width of the generated thumbnail in pixels
* 'upload_dir' = Base upload directory (must be a full path)
*
* You can omit any of these settings and IPB will use the default
* settings (which are the ones entered into the ACP for post thumbnails)
*
* @access public
* @return boolean
*/
public function getSettings()
{
$this->mysettings = array( 'siu_thumb' => $this->settings['blog_thumb'],
'siu_width' => $this->settings['blog_thumb_width'],
'siu_height' => $this->settings['blog_thumb_height'],
'upload_dir' => $this->settings['blog_upload_dir'],
);
return true;
}
/**
* Checks the attachment and checks for download / show perms
*
* @access public
* @param integer Attachment id
* @return array Attachment data
*/
public function getAttachmentData( $attach_id )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$_ok = 0;
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => 'a.*',
'from' => array( 'attachments' => 'a' ),
'where' => "a.attach_rel_module='" . $this->module . "' AND a.attach_id=" . $attach_id,
'add_join' => array( 0 => array( 'select' => 'bcc.cbcus_id',
'from' => array( 'blog_custom_cblocks' => 'bcc' ),
'where' => "bcc.cbcus_id=a.attach_rel_id",
'type' => 'left' ),
1 => array( 'select' => 'cb.blog_id',
'from' => array( 'blog_cblocks' => 'cb' ),
'where' => "cb.cblock_ref_id=bcc.cbcus_id AND cb.cblock_type='custom'",
'type' => 'left' ) )
) );
$attach_sql = $this->DB->execute();
$attach = $this->DB->fetch( $attach_sql );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! isset( $attach['blog_id'] ) || ! $attach['blog_id'] )
{
return FALSE;
}
require_once ( IPSLib::getAppDir('blog') . '/sources/lib/lib_blogfunctions.php' );
$blog_std = new blogFunctions( $this->registry );
$blog_std->buildPerms();
$blog = $blog_std->loadBlog( $attach['blog_id'] );
if( !$blog['blog_id'] )
{
return false;
}
return $attach;
}
/**
* Check the attachment and make sure its OK to display
*
* @access public
* @param array Array of ids
* @param array Array of relationship ids
* @return array Attachment data
*/
public function renderAttachment( $attach_ids, $rel_ids=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$rows = array();
$query = '';
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! is_array( $attach_ids ) OR ! count( $attach_ids ) )
{
$attach_ids = array( -2 );
}
if ( is_array( $rel_ids ) and count( $rel_ids ) )
{
$query = " OR attach_rel_id IN (-1," . implode( ",", $rel_ids ) . ")";
}
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'attachments',
'where' => "attach_rel_module='" . $this->module . "' AND ( attach_id IN(-1," . implode( ",", $attach_ids ) . ") " . $query . " )",
) );
$attach_sql = $this->DB->execute();
//-----------------------------------------
// Loop through and filter off naughty ids
//-----------------------------------------
while( $db_row = $this->DB->fetch( $attach_sql ) )
{
$_ok = 1;
//-----------------------------------------
// Ok?
//-----------------------------------------
if ( $_ok )
{
$rows[ $db_row['attach_id'] ] = $db_row;
}
}
//-----------------------------------------
// Return
//-----------------------------------------
return $rows;
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param string Post key
* @param integer Related ID
* @param array Arguments for query
* @return array Returns count of items found
*/
public function postUploadProcess( $post_key, $rel_id, $args=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$cnt = array( 'cnt' => 0 );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! $post_key )
{
return 0;
}
$this->DB->build( array( "select" => 'COUNT(*) as cnt',
'from' => 'attachments',
'where' => "attach_rel_module='".$this->module."' AND attach_post_key='{$post_key}'") );
$this->DB->execute();
$cnt = $this->DB->fetch();
if ( $cnt['cnt'] )
{
$this->DB->buildAndFetch( array( 'update' => 'blog_custom_cblocks',
'set' => "cbcus_has_attach=cbcus_has_attach+" . $cnt['cnt'],
'where' => "cbcus_id=" . intval( $rel_id ) ) );
}
return array( 'count' => $cnt['cnt'] );
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function attachmentRemovalCleanup( $attachment )
{
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
$this->DB->build( array( 'select' => 'e.cbcus_id',
'from' => array( 'blog_custom_cblocks' => 'e' ),
'where' => 'e.cbcus_id='. intval( $attachment['attach_rel_id'] )
) );
$this->DB->execute();
$cbcus = $this->DB->fetch();
if ( isset( $cbcus['cbcus_id'] ) )
{
$this->DB->build( array( "select" => 'count(*) as cnt',
'from' => 'attachments',
'where' => "attach_rel_module='".$this->module."' AND attach_rel_id = ".$cbcus['cbcus_id'] ) );
$this->DB->execute();
$cnt = $this->DB->fetch();
$count = intval( $cnt['cnt'] );
$this->DB->buildAndFetch( array( 'update' => 'blog_custom_cblocks', 'set' => "cbcus_has_attach=". $count , 'where' => "cbcus_id=".$cbcus['cbcus_id'] ) );
}
return TRUE;
}
/**
* Determines if you have permission for bulk attachment removal
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Ids to check against
* @return boolean
*/
public function canBulkRemove( $attach_rel_ids=array() )
{
return $this->memberData['g_is_supmod'] ? true : false;
}
/**
* Determines if you can remove this attachment
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function canRemove( $attachment )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$ok_to_remove = FALSE;
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
//-----------------------------------------
// Allowed to remove?
//-----------------------------------------
if ( $this->memberData['member_id'] == $attachment['attach_member_id'] )
{
if ( $this->settings['blog_allow_cblockchange'] && $this->settings['blog_allow_cblocks'] )
{
$ok_to_remove = TRUE;
}
}
else if ( $this->memberData['g_is_supmod'] )
{
$ok_to_remove = TRUE;
}
elseif ( $this->memberData['_blogmod']['moderate_allow_editcblocks'] )
{
$ok_to_remove = TRUE;
}
return $ok_to_remove;
}
/**
* Returns an array of the allowed upload sizes in bytes.
* Return 'space_allowed' as -1 to not allow uploads.
* Return 'space_allowed' as 0 to allow unlimited uploads
* Return 'max_single_upload' as 0 to not set a limit
*
* @access public
* @param string MD5 post key
* @param id Member ID
* @return array [ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
*/
public function getSpaceAllowance( $post_key='', $member_id='' )
{
$max_php_size = intval( IPSLib::getMaxPostSize() );
$member_id = intval( $member_id ? $member_id : $this->memberData['member_id'] );
$space_left = 0;
$space_used = 0;
$space_allowed = 0;
$max_single_upload = 0;
$space_calculated = 0;
if ( $post_key )
{
//-----------------------------------------
// Check to make sure we're not attempting
// to upload to another's post...
//-----------------------------------------
if ( ! $this->memberData['g_is_supmod'] )
{
$post = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'posts',
'where' => "post_key='".$post_key."'" ) );
if ( $post['post_key'] AND ( $post['author_id'] != $member_id ) )
{
$space_allowed = -1;
$space_calculated = 1;
}
}
}
//-----------------------------------------
// Generate total space allowed
//-----------------------------------------
$total_space_allowed = ( $this->memberData['g_blog_attach_per_entry'] ? $this->memberData['g_blog_attach_per_entry'] : $this->memberData['g_blog_attach_max'] ) * 1024;
//-----------------------------------------
// Allowed to attach?
//-----------------------------------------
if ( ! $member_id )
{
$space_allowed = -1;
}
if ( ! $space_calculated )
{
//-----------------------------------------
// Generate space allowed figure
//-----------------------------------------
if ( $total_space_allowed > 0 )
{
if ( $this->memberData['g_blog_attach_per_entry'] )
{
//-----------------------------------------
// Per post limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => "attach_post_key='".$post_key."'" ) );
$space_used = intval( $_space_used['figure'] );
$space_allowed = intval( ( $this->memberData['g_blog_attach_per_entry'] * 1024 ) - $space_used );
$space_allowed = $space_allowed < 0 ? 0 : $space_allowed;
}
else
{
//-----------------------------------------
// Global limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => 'attach_member_id='.$member_id." AND attach_rel_module in('blogentry','blogcblock')" ) );
$space_used = intval( $_space_used['figure'] );
$space_allowed = intval( ( $this->memberData['g_blog_attach_max'] * 1024 ) - $space_used );
$space_allowed = $space_allowed < 0 ? 0 : $space_allowed;
}
}
else
{
# Unlimited
$space_allowed = 0;
}
//-----------------------------------------
// Generate space left figure
//-----------------------------------------
$space_left = $space_allowed ? $space_allowed : 0;
$space_left = ($space_left < 0) ? 0 : $space_left;
//-----------------------------------------
// Generate max upload size
//-----------------------------------------
if ( ! $max_single_upload )
{
if ( $space_left > 0 AND $space_left < $max_php_size )
{
$max_single_upload = $space_left;
}
else if ( $max_php_size )
{
$max_single_upload = $max_php_size;
}
}
}
$return = array( 'space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed );
return $return;
}
}
@@ -1,456 +0,0 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* IP.Blog attachment parsing
* Last Updated: $Date: 2009-11-09 08:04:23 -0500 (Mon, 09 Nov 2009) $
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage IP.Blog
* @link http://www.iinvisionpower.com
* @since 6/24/2008
* @version $Revision: 5335 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class plugin_blogentry extends class_attach
{
/**
* Module type
*
* @access public
* @var string
*/
public $module = 'blogentry';
/**
* Returns an array of settings:
* 'siu_thumb' = Allow thumbnail creation?
* 'siu_height' = Height of the generated thumbnail in pixels
* 'siu_width' = Width of the generated thumbnail in pixels
* 'upload_dir' = Base upload directory (must be a full path)
*
* You can omit any of these settings and IPB will use the default
* settings (which are the ones entered into the ACP for post thumbnails)
*
* @access public
* @return boolean
*/
public function getSettings()
{
$this->mysettings = array( 'siu_thumb' => $this->settings['blog_thumb'],
'siu_width' => $this->settings['blog_thumb_width'],
'siu_height' => $this->settings['blog_thumb_height'],
'upload_dir' => $this->settings['blog_upload_dir'] ? $this->settings['blog_upload_dir'] : $this->settings['upload_dir'] );
return true;
}
/**
* Checks the attachment and checks for download / show perms
*
* @access public
* @param integer Attachment id
* @return array Attachment data
*/
public function getAttachmentData( $attach_id )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$_ok = 0;
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => 'a.*',
'from' => array( 'attachments' => 'a' ),
'where' => "a.attach_rel_module='".$this->module."' AND a.attach_id=".$attach_id,
'add_join' => array( 0 => array( 'select' => 'e.entry_id, e.blog_id',
'from' => array( 'blog_entries' => 'e' ),
'where' => "e.entry_id=a.attach_rel_id",
'type' => 'left' ) )
) );
$attach_sql = $this->DB->execute();
$attach = $this->DB->fetch( $attach_sql );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! isset( $attach['blog_id'] ) || ! $attach['blog_id'] )
{
return FALSE;
}
require_once ( IPSLib::getAppDir('blog') . '/sources/classes/blogFunctions.php' );
$blog_std = new blogFunctions( $this->registry );
$blog_std->buildPerms();
$blog = $blog_std->loadBlog( $attach['blog_id'] );
if( !$blog['blog_id'] )
{
return false;
}
return $attach;
}
/**
* Check the attachment and make sure its OK to display
*
* @access public
* @param array Array of ids
* @param array Array of relationship ids
* @return array Attachment data
*/
public function renderAttachment( $attach_ids, $rel_ids=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$rows = array();
$query = '';
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! is_array( $attach_ids ) OR ! count( $attach_ids ) )
{
$attach_ids = array( -2 );
}
if ( is_array( $rel_ids ) and count( $rel_ids ) )
{
$query = " OR attach_rel_id IN (-1," . implode( ",", $rel_ids ) . ")";
}
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'attachments',
'where' => "attach_rel_module='".$this->module."' AND ( attach_id IN(-1,". implode( ",", $attach_ids ) . ") " . $query . " )",
) );
$attach_sql = $this->DB->execute();
//-----------------------------------------
// Loop through and filter off naughty ids
//-----------------------------------------
while( $db_row = $this->DB->fetch( $attach_sql ) )
{
$_ok = 1;
//-----------------------------------------
// Ok?
//-----------------------------------------
if ( $_ok )
{
$rows[ $db_row['attach_id'] ] = $db_row;
}
}
//-----------------------------------------
// Return
//-----------------------------------------
return $rows;
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param string Post key
* @param integer Related ID
* @param array Arguments for query
* @return array Returns count of items found
*/
public function postUploadProcess( $post_key, $rel_id, $args=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$cnt = array( 'cnt' => 0 );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! $post_key )
{
return 0;
}
$this->DB->build( array( "select" => 'COUNT(*) as cnt',
'from' => 'attachments',
'where' => "attach_rel_module='".$this->module."' AND attach_post_key='{$post_key}'") );
$this->DB->execute();
$cnt = $this->DB->fetch();
if ( $cnt['cnt'] )
{
$this->DB->buildAndFetch( array( 'update' => 'blog_entries',
'set' => "entry_has_attach=entry_has_attach+" . $cnt['cnt'],
'where' => "entry_id=" . intval( $rel_id ) ) );
}
return array( 'count' => $cnt['cnt'] );
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function attachmentRemovalCleanup( $attachment )
{
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
$this->DB->build( array( 'select' => 'entry_id',
'from' => 'blog_entries',
'where' => 'entry_id='. intval( $attachment['attach_rel_id'] )
) );
$this->DB->execute();
$entry = $this->DB->fetch();
if ( isset( $entry['entry_id'] ) )
{
$this->DB->build( array( "select" => 'count(*) as cnt',
'from' => 'attachments',
'where' => "attach_rel_module='blogentry' AND attach_rel_id = ".$entry['entry_id'] ) );
$this->DB->execute();
$cnt = $this->DB->fetch();
$count = intval( $cnt['cnt'] );
$this->DB->build( array( 'update' => 'blog_entries', 'set' => "entry_has_attach=". $count , 'where' => "entry_id=".$entry['entry_id'] ) );
$this->DB->execute();
}
return TRUE;
}
/**
* Determines if you have permission for bulk attachment removal
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Ids to check against
* @return boolean
*/
public function canBulkRemove( $attach_rel_ids=array() )
{
return $this->memberData['g_is_supmod'] ? true : false;
}
/**
* Determines if you can remove this attachment
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function canRemove( $attachment )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$ok_to_remove = FALSE;
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
//-----------------------------------------
// Allowed to remove?
//-----------------------------------------
if ( $this->memberData['member_id'] == $attachment['attach_member_id'] )
{
$ok_to_remove = TRUE;
}
else if ( $this->memberData['g_is_supmod'] )
{
$ok_to_remove = TRUE;
}
elseif ( $this->memberData['_blogmod']['moderate_edit_comment'] )
{
$ok_to_remove = TRUE;
}
return $ok_to_remove;
}
/**
* Returns an array of the allowed upload sizes in bytes.
* Return 'space_allowed' as -1 to not allow uploads.
* Return 'space_allowed' as 0 to allow unlimited uploads
* Return 'max_single_upload' as 0 to not set a limit
*
* @access public
* @param string MD5 post key
* @param id Member ID
* @return array [ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
*/
public function getSpaceAllowance( $post_key='', $member_id='' )
{
$max_php_size = intval( IPSLib::getMaxPostSize() );
$member_id = intval( $member_id ? $member_id : $this->memberData['member_id'] );
$space_left = 0;
$space_used = 0;
$space_allowed = 0;
$max_single_upload = 0;
$space_calculated = 0;
if ( $post_key )
{
//-----------------------------------------
// Check to make sure we're not attempting
// to upload to another's post...
//-----------------------------------------
if ( ! $this->memberData['g_is_supmod'] )
{
$post = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'posts', 'where' => "post_key='{$post_key}'" ) );
if ( $post['post_key'] AND ( $post['author_id'] != $member_id ) )
{
$space_allowed = -1;
$space_calculated = 1;
}
}
}
//-----------------------------------------
// Generate total space allowed
//-----------------------------------------
$total_space_allowed = ( $this->memberData['g_blog_attach_max'] ? $this->memberData['g_blog_attach_max'] : 0 ) * 1024;
//-----------------------------------------
// Allowed to attach?
//-----------------------------------------
if ( ! $member_id )
{
$space_allowed = -1;
}
if ( ! $space_calculated )
{
//-----------------------------------------
// Generate space allowed figure
//-----------------------------------------
if ( $total_space_allowed > 0 )
{
if ( $this->memberData['g_blog_attach_per_entry'] )
{
//-----------------------------------------
// Per post limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => "attach_post_key='".$post_key."'" ) );
$space_used = intval( $_space_used['figure'] );
$space_allowed = intval( ( $this->memberData['g_blog_attach_per_entry'] * 1024 ) - $space_used );
$space_allowed = $space_allowed < 0 ? 0 : $space_allowed;
}
else
{
//-----------------------------------------
// Global limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => 'attach_member_id='.$member_id." AND attach_rel_module in('blogentry','blogcblock')" ) );
$space_used = intval( $_space_used['figure'] );
$space_allowed = intval( ( $this->memberData['g_blog_attach_max'] * 1024 ) - $space_used );
$space_allowed = $space_allowed < 0 ? 0 : $space_allowed;
}
}
else
{
# Unlimited
$space_allowed = 0;
}
//-----------------------------------------
// Generate space left figure
//-----------------------------------------
$space_left = $space_allowed ? $space_allowed : 0;
$space_left = ($space_left < 0) ? 0 : $space_left;
//-----------------------------------------
// Generate max upload size
//-----------------------------------------
if ( ! $max_single_upload )
{
if ( $space_left > 0 AND $space_left < $max_php_size )
{
$max_single_upload = $space_left;
}
else if ( $max_php_size )
{
$max_single_upload = $max_php_size;
}
}
}
$return = array( 'space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed );
return $return;
}
}
@@ -1,548 +0,0 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* IP.Board messenger attachments plugin
* Last Updated: $Date: 2009-09-24 08:06:26 -0400 (Thu, 24 Sep 2009) $
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @since 6/24/2008
* @version $Revision: 5147 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class plugin_msg extends class_attach
{
/**
* Module type
*
* @access public
* @var string
*/
public $module = 'msg';
/**
* Checks the attachment and checks for download / show perms
*
* @access public
* @param integer Attachment id
* @return array Attachment data
*/
public function getAttachmentData( $attach_id )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$_ok = 0;
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => 'a.*',
'from' => array( 'attachments' => 'a' ),
'where' => "a.attach_rel_module='".$this->module."' AND a.attach_id=".$attach_id,
'add_join' => array( 0 => array( 'select' => 'p.*',
'from' => array( 'message_posts' => 'p' ),
'where' => "p.msg_id=a.attach_rel_id",
'type' => 'left' ),
1 => array( 'select' => 't.*',
'from' => array( 'message_topics' => 't' ),
'where' => "t.mt_id=p.msg_topic_id",
'type' => 'left' ),
2 => array( 'select' => 'u.*',
'from' => array( 'message_topic_user_map' => 'u' ),
'where' => "u.map_topic_id=t.mt_id AND u.map_user_id=" . $this->memberData['member_id'],
'type' => 'left' ) ) ) );
$attach_sql = $this->DB->execute();
$attach = $this->DB->fetch( $attach_sql );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! isset( $attach['msg_id'] ) OR empty( $attach['msg_id'] ) )
{
if( $attach['attach_member_id'] != $this->memberData['member_id'] )
{
return FALSE;
}
}
//-----------------------------------------
// For previews
//-----------------------------------------
if ( $attach['attach_rel_id'] == 0 AND $attach['attach_member_id'] == $this->memberData['member_id'] )
{
$_ok = 1;
}
else if ( $attach['map_user_id'] )
{
$_ok = 1;
}
//-----------------------------------------
// Ok?
//-----------------------------------------
if ( $_ok )
{
return $attach;
}
else
{
return FALSE;
}
}
/**
* Check the attachment and make sure its OK to display
*
* @access public
* @param array Array of ids
* @param array Array of relationship ids
* @return array Attachment data
*/
public function renderAttachment( $attach_ids, $rel_ids=array(), $attach_post_key=0 )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$rows = array();
$query_bits = array();
$query = '';
$match = 0;
//-----------------------------------------
// Check
//-----------------------------------------
if ( is_array( $attach_ids ) AND count( $attach_ids ) )
{
$query_bits[] = "attach_id IN (" . implode( ",", $attach_ids ) .")";
}
if ( is_array( $rel_ids ) and count( $rel_ids ) )
{
// We need to reset the array - this query bit will return everything we need, but
// if we "OR" join the above query bit with this one, it causes bigger mysql loads
$query_bits = array();
$query_bits[] = "attach_rel_id IN (" . implode( ",", $rel_ids ) . ")";
//$query = " OR attach_rel_id IN (-1," . implode( ",", $rel_ids ) . ")";
$match = 1;
}
if ( $attach_post_key )
{
$query_bits[] = "attach_post_key='".$this->DB->addSlashes( $attach_post_key )."'";
//$query .= " OR attach_post_key='".$this->DB->addSlashes( $attach_post_key )."'";
$match = 2;
}
if( !count($query_bits) )
{
$query = "attach_id IN (-1)";
}
else
{
$query = implode( " OR ", $query_bits );
}
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module='{$this->module}' AND ( {$query} )" ) );
$attach_sql = $this->DB->execute();
//-----------------------------------------
// Loop through and filter off naughty ids
//-----------------------------------------
while( $db_row = $this->DB->fetch( $attach_sql ) )
{
$_ok = 1;
if ( $match == 1 )
{
if ( ! in_array( $db_row['attach_rel_id'], $rel_ids ) )
{
$_ok = 0;
}
}
else if ( $match == 2 )
{
if ( $db_row['attach_post_key'] != $attach_post_key )
{
$_ok = 0;
}
}
//-----------------------------------------
// Ok?
//-----------------------------------------
if ( $_ok )
{
$rows[ $db_row['attach_id'] ] = $db_row;
}
}
//-----------------------------------------
// Return
//-----------------------------------------
return $rows;
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param string Post key
* @param integer Related ID
* @param array Arguments for query
* @return array Returns count of items found
*/
public function postUploadProcess( $post_key, $rel_id, $args=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$cnt = array( 'cnt' => 0 );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! $post_key )
{
return 0;
}
$cnt = $this->DB->buildAndFetch( array( "select" => 'COUNT(*) as cnt',
'from' => 'attachments',
'where' => "attach_post_key='{$post_key}'") );
/*if ( $cnt['cnt'] )
{
$this->DB->update( 'message_topics', "mt_hasattach=mt_hasattach+" . $cnt['cnt'], "mt_id=" . intval( $args['mt_id'] ), FALSE, TRUE );
}*/
return array( 'count' => $cnt['cnt'] );
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function attachmentRemovalCleanup( $attachment )
{
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
$message = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'message_posts',
'where' => 'msg_id=' . intval( $attachment['attach_rel_id'] ) ) );
if ( isset( $message['msg_topic_id'] ) )
{
//-----------------------------------------
// GET ALL MSG IDS IN THIS TOPIC
//-----------------------------------------
$pids = array();
$count = 0;
$this->DB->build( array( 'select' => 'msg_id',
'from' => 'message_posts',
'where' => "msg_topic_id=". $message['msg_topic_id'] ) );
$this->DB->execute();
while ( $p = $this->DB->fetch() )
{
$pids[] = $p['msg_id'];
}
//-----------------------------------------
// GET ATTACHMENT COUNT
//-----------------------------------------
if ( count( $pids ) )
{
$this->DB->build( array( "select" => 'count(*) as cnt',
'from' => 'attachments',
'where' => "attach_rel_module='msg' AND attach_rel_id IN(".implode(",",$pids).")") );
$this->DB->execute();
$cnt = $this->DB->fetch();
$count = intval( $cnt['cnt'] );
}
$this->DB->update( 'message_topics', array( 'mt_hasattach' => $count ), "mt_id=" . $message['msg_topic_id'] );
}
return TRUE;
}
/**
* Determines if you have permission for bulk attachment removal
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Ids to check against
* @return boolean
*/
public function canBulkRemove( $attach_rel_ids=array() )
{
return $this->memberData['g_is_supmod'] ? true : false;
}
/**
* Determines if you can remove this attachment
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function canRemove( $attachment )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$ok_to_remove = FALSE;
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
//-----------------------------------------
// Allowed to remove?
//-----------------------------------------
if ( $this->memberData['member_id'] == $attachment['attach_member_id'] )
{
$ok_to_remove = TRUE;
}
else if ( $this->memberData['g_is_supmod'] )
{
$ok_to_remove = TRUE;
}
else
{
$message = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'message_posts',
'where' => 'msg_id=' . intval( $attachment['attach_rel_id'] ) ) );
if ( $this->memberData['member_id'] == $message['msg_author_id'] )
{
$ok_to_remove = TRUE;
}
}
return $ok_to_remove;
}
/**
* Returns an array of the allowed upload sizes in bytes.
* Return 'space_allowed' as -1 to not allow uploads.
* Return 'space_allowed' as 0 to allow unlimited uploads
* Return 'max_single_upload' as 0 to not set a limit
*
* @access public
* @param string MD5 post key
* @param id Member ID
* @return array [ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
*/
public function getSpaceAllowance( $post_key='', $member_id='' )
{
$max_php_size = intval( IPSLib::getMaxPostSize() );
$member_id = intval( $member_id ? $member_id : $this->memberData['member_id'] );
$space_left = 0;
$space_used = 0;
$space_allowed = 0;
$max_single_upload = 0;
//-----------------------------------------
// Allowed to attach?
//-----------------------------------------
if ( ! $member_id )
{
$space_allowed = -1;
}
else
{
//-----------------------------------------
// Generate total space allowed
//-----------------------------------------
$total_space_allowed = ( $this->memberData['g_attach_per_post'] ? $this->memberData['g_attach_per_post'] : $this->memberData['g_attach_max'] ) * 1024;
//-----------------------------------------
// Generate space used figure
//-----------------------------------------
if ( $this->memberData['g_attach_per_post'] )
{
//-----------------------------------------
// Per post limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => "attach_post_key='".$post_key."'" ) );
$space_used = intval( $_space_used['figure'] );
}
else
{
//-----------------------------------------
// Global limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => 'attach_member_id='.$member_id . " AND attach_rel_module IN( 'post', 'msg' )" ) );
$space_used = intval( $_space_used['figure'] );
}
//-----------------------------------------
// Generate space allowed figure
//-----------------------------------------
if ( $this->memberData['g_attach_max'] > 0 )
{
if ( $this->memberData['g_attach_per_post'] )
{
$_g_space_used = $this->DB->buildAndFetch( array( 'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => 'attach_member_id='.$member_id . " AND attach_rel_module IN( 'post', 'msg' )" ) );
$g_space_used = intval( $_g_space_used['figure'] );
if( intval( ( $this->memberData['g_attach_max'] * 1024 ) - $g_space_used ) < 0 )
{
$space_used = $g_space_used;
$total_space_allowed = $this->memberData['g_attach_max'] * 1024;
$space_allowed = ( $this->memberData['g_attach_max'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
else
{
$space_allowed = ( $this->memberData['g_attach_per_post'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
}
else
{
$space_allowed = ( $this->memberData['g_attach_max'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
}
else
{
if ( $this->memberData['g_attach_per_post'] )
{
$space_allowed = ( $this->memberData['g_attach_per_post'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
else
{
# Unlimited
$space_allowed = 0;
}
}
//-----------------------------------------
// Generate space left figure
//-----------------------------------------
$space_left = $space_allowed ? $space_allowed : 0;
$space_left = ($space_left < 0) ? -1 : $space_left;
//-----------------------------------------
// Generate max upload size
//-----------------------------------------
if ( ! $max_single_upload )
{
if ( $space_left > 0 AND $space_left < $max_php_size )
{
$max_single_upload = $space_left;
}
else if ( $max_php_size )
{
$max_single_upload = $max_php_size;
}
}
}
IPSDebug::fireBug( 'info', array( 'Space left: ' . $space_left ) );
IPSDebug::fireBug( 'info', array( 'Max PHP size: ' . $max_php_size ) );
IPSDebug::fireBug( 'info', array( 'Max single file size: ' . $max_single_upload ) );
$return = array( 'space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed );
return $return;
}
/**
* Returns an array of settings:
* 'siu_thumb' = Allow thumbnail creation?
* 'siu_height' = Height of the generated thumbnail in pixels
* 'siu_width' = Width of the generated thumbnail in pixels
* 'upload_dir' = Base upload directory (must be a full path)
*
* You can omit any of these settings and IPB will use the default
* settings (which are the ones entered into the ACP for post thumbnails)
*
* @access public
* @return boolean
*/
public function getSettings()
{
$this->mysettings = array();
return true;
}
}
@@ -1,700 +0,0 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* IP.Board post attachments plugin
* Last Updated: $Date: 2009-09-22 17:31:43 -0400 (Tue, 22 Sep 2009) $
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @since 6/24/2008
* @version $Revision: 5141 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class plugin_post extends class_attach
{
/**
* Module type
*
* @access public
* @var string
*/
public $module = 'post';
/**
* Constructor
*
* @access public
* @param object ipsRegistry reference
* @return void
*/
public function __construct( ipsRegistry $registry )
{
parent::__construct( $registry );
/* Load and init forums */
if( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
try
{
require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php" );
$this->registry->setClass( 'class_forums', new class_forums( $registry ) );
}
catch( Exception $error )
{
IPS_exception_error( $error );
}
$this->registry->getClass('class_forums')->strip_invisible = 1;
$this->registry->getClass('class_forums')->forumsInit();
$this->memberData = $this->registry->getClass('class_forums')->setUpModerator( $this->memberData );
}
}
/**
* Checks the attachment and checks for download / show perms
*
* @access public
* @param integer Attachment id
* @return array Attachment data
*/
public function getAttachmentData( $attach_id )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$_ok = 0;
if( ! $attach_id )
{
return FALSE;
}
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array(
'select' => 'a.*',
'from' => array( 'attachments' => 'a' ),
'where' => "a.attach_rel_module='{$this->module}' AND a.attach_id={$attach_id}",
'add_join' => array(
array(
'select' => 'p.pid, p.topic_id, p.queued',
'from' => array( 'posts' => 'p' ),
'where' => "p.pid=a.attach_rel_id",
'type' => 'left'
),
array(
'select' => 't.forum_id',
'from' => array( 'topics' => 't' ),
'where' => "t.tid=p.topic_id",
'type' => 'left'
)
)
) );
$attach_sql = $this->DB->execute();
$attach = $this->DB->fetch( $attach_sql );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! isset( $attach['pid'] ) OR empty( $attach['pid'] ) )
{
if( $attach['attach_member_id'] != $this->memberData['member_id'] )
{
return FALSE;
}
}
//-----------------------------------------
// Queued post?
//-----------------------------------------
if ( $attach['queued'] )
{
if ( ! ipsRegistry::getClass('class_forums')->canQueuePosts( $attach['forum_id'] ) )
{
return FALSE;
}
}
//-----------------------------------------
// TheWalrus inspired fix for previewing
// the post and clicking the attachment...
//-----------------------------------------
if ( $attach['attach_rel_id'] == 0 AND $attach['attach_member_id'] == $this->memberData['member_id'] )
{
$_ok = 1;
}
else
{
if ( ! ipsRegistry::getClass('class_forums')->forum_by_id[ $attach['forum_id'] ] )
{
//-----------------------------------------
// TheWalrus inspired fix for previewing
// the post and clicking the attachment...
//-----------------------------------------
if ( $attach['attach_rel_id'] == 0 AND $attach['attach_member_id'] == $this->memberData['member_id'] )
{
# We're ok.
}
else
{
return FALSE;
}
}
if ( IPSMember::checkPermissions('read', $attach['forum_id']) === FALSE )
{
return FALSE;
}
if ( IPSMember::checkPermissions('download', $attach['forum_id']) === FALSE )
{
return FALSE;
}
//-----------------------------------------
// Still here?
//-----------------------------------------
$_ok = 1;
}
//-----------------------------------------
// Ok?
//-----------------------------------------
if ( $_ok )
{
return $attach;
}
else
{
return FALSE;
}
}
/**
* Check the attachment and make sure its OK to display
*
* @access public
* @param array Array of ids
* @param array Array of relationship ids
* @return array Attachment data
*/
public function renderAttachment( $attach_ids, $rel_ids=array(), $attach_post_key=0 )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$rows = array();
$query_bits = array();
$query = '';
$match = 0;
//-----------------------------------------
// Check
//-----------------------------------------
if ( is_array( $attach_ids ) AND count( $attach_ids ) )
{
$query_bits[] = "attach_id IN (" . implode( ",", $attach_ids ) .")";
}
if ( is_array( $rel_ids ) and count( $rel_ids ) )
{
// We need to reset the array - this query bit will return everything we need, but
// if we "OR" join the above query bit with this one, it causes bigger mysql loads
$query_bits = array();
$query_bits[] = "attach_rel_id IN (" . implode( ",", $rel_ids ) . ")";
//$query = " OR attach_rel_id IN (-1," . implode( ",", $rel_ids ) . ")";
$match = 1;
}
if ( $attach_post_key )
{
$query_bits[] = "attach_post_key='".$this->DB->addSlashes( $attach_post_key )."'";
//$query .= " OR attach_post_key='".$this->DB->addSlashes( $attach_post_key )."'";
$match = 2;
}
if( !count($query_bits) )
{
$query = "attach_id IN (-1)";
}
else
{
$query = implode( " OR ", $query_bits );
}
//-----------------------------------------
// Grab 'em
//-----------------------------------------
$this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module='{$this->module}' AND ( {$query} )" ) );
$attach_sql = $this->DB->execute();
//-----------------------------------------
// Loop through and filter off naughty ids
//-----------------------------------------
while( $db_row = $this->DB->fetch( $attach_sql ) )
{
$_ok = 1;
if ( $match == 1 )
{
if ( ! in_array( $db_row['attach_rel_id'], $rel_ids ) )
{
$_ok = 0;
}
}
else if ( $match == 2 )
{
if ( $db_row['attach_post_key'] != $attach_post_key )
{
$_ok = 0;
}
}
//-----------------------------------------
// Ok?
//-----------------------------------------
if ( $_ok )
{
$rows[ $db_row['attach_id'] ] = $db_row;
}
}
//-----------------------------------------
// Return
//-----------------------------------------
return $rows;
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param string Post key
* @param integer Related ID
* @param array Arguments for query
* @return array Returns count of items found
*/
public function postUploadProcess( $post_key, $rel_id, $args=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$cnt = array( 'cnt' => 0 );
//-----------------------------------------
// Check..
//-----------------------------------------
if ( ! $post_key )
{
return 0;
}
$this->DB->build( array( "select" => 'COUNT(*) as cnt', 'from' => 'attachments', 'where' => "attach_post_key='{$post_key}'" ) );
$this->DB->execute();
$cnt = $this->DB->fetch();
if ( $cnt['cnt'] )
{
$this->DB->update( 'topics', "topic_hasattach=topic_hasattach+" . $cnt['cnt'], "tid=" . intval( $args['topic_id'] ), false, true );
}
return array( 'count' => $cnt['cnt'] );
}
/**
* Recounts number of attachments for the articles row
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function attachmentRemovalCleanup( $attachment )
{
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
$this->DB->build( array(
'select' => 'p.pid',
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid='. intval( $attachment['attach_rel_id'] ),
'add_join' => array(
array(
'select' => 't.forum_id, t.tid',
'from' => array( 'topics' => 't' ),
'where' => 't.tid=p.topic_id',
'type' => 'inner'
)
)
) );
$this->DB->execute();
$topic = $this->DB->fetch();
if ( isset( $topic['tid'] ) )
{
//-----------------------------------------
// GET PIDS
//-----------------------------------------
$pids = array();
$count = 0;
$this->DB->build( array( 'select' => 'pid', 'from' => 'posts', 'where' => "topic_id={$topic['tid']}" ) );
$this->DB->execute();
while ( $p = $this->DB->fetch() )
{
$pids[] = $p['pid'];
}
//-----------------------------------------
// GET ATTACHMENT COUNT
//-----------------------------------------
if ( count( $pids ) )
{
$this->DB->build( array(
'select' => 'count(*) as cnt',
'from' => 'attachments',
'where' => "attach_rel_module='post' AND attach_rel_id IN(" . implode( ',', $pids ) . ")") );
$this->DB->execute();
$cnt = $this->DB->fetch();
$count = intval( $cnt['cnt'] );
}
$this->DB->update( 'topics', array( 'topic_hasattach' => $count ), "tid=".$topic['tid'] );
}
return TRUE;
}
/**
* Determines if you have permission for bulk attachment removal
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Ids to check against
* @return boolean
*/
public function canBulkRemove( $attach_rel_ids=array() )
{
return $this->memberData['g_is_supmod'] ? true : false;
}
/**
* Determines if you can remove this attachment
* Returns TRUE or FALSE
* IT really does
*
* @access public
* @param array Attachment data
* @return boolean
*/
public function canRemove( $attachment )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$ok_to_remove = FALSE;
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $attachment['attach_id'] )
{
return FALSE;
}
//-----------------------------------------
// Allowed to remove?
//-----------------------------------------
if ( $this->memberData['member_id'] == $attachment['attach_member_id'] )
{
$ok_to_remove = TRUE;
}
else if ( $this->memberData['g_is_supmod'] )
{
$ok_to_remove = TRUE;
}
else
{
//-----------------------------------------
// Moderstor? Get forum ID
//-----------------------------------------
if ( $this->memberData['forumsModeratorData'] )
{
$_moderator = $this->memberData['forumsModeratorData'];
$this->DB->build( array(
'select' => 'p.pid',
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid='. intval( $attachment['attach_rel_id'] ),
'add_join' => array(
array(
'select' => 't.forum_id, t.tid',
'from' => array( 'topics' => 't' ),
'where' => 't.tid=p.topic_id',
'type' => 'inner'
)
)
) );
$this->DB->execute();
$topic = $this->DB->fetch();
if ( isset( $topic['forum_id'] ) )
{
if ( isset($_moderator[ $topic['forum_id'] ]['edit_post']) and $_moderator[ $topic['forum_id'] ]['edit_post'] )
{
$ok_to_remove = TRUE;
}
}
}
}
return $ok_to_remove;
}
/**
* Returns an array of the allowed upload sizes in bytes.
* Return 'space_allowed' as -1 to not allow uploads.
* Return 'space_allowed' as 0 to allow unlimited uploads
* Return 'max_single_upload' as 0 to not set a limit
*
* @access public
* @param string MD5 post key
* @param id Member ID
* @return array [ 'space_used', 'space_left', 'space_allowed', 'max_single_upload' ]
*/
public function getSpaceAllowance( $post_key='', $member_id='' )
{
$max_php_size = intval( IPSLib::getMaxPostSize() );
$member_id = intval( $member_id ? $member_id : $this->memberData['member_id'] );
$forum_id = intval( ipsRegistry::$request['forum_id'] ? ipsRegistry::$request['forum_id'] : ipsRegistry::$request['f'] );
$space_left = 0;
$space_used = 0;
$space_allowed = 0;
$max_single_upload = 0;
$space_calculated = 0;
if ( $post_key )
{
//-----------------------------------------
// Check to make sure we're not attempting
// to upload to another's post...
//-----------------------------------------
if ( ! $this->memberData['g_is_supmod'] AND !$this->memberData['is_mod'] )
{
$post = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'posts', 'where' => "post_key='{$post_key}'" ) );
if ( $post['post_key'] AND ( $post['author_id'] != $member_id ) )
{
$space_allowed = -1;
$space_calculated = 1;
}
}
}
//-----------------------------------------
// Generate total space allowed
//-----------------------------------------
$total_space_allowed = ( $this->memberData['g_attach_per_post'] ? $this->memberData['g_attach_per_post'] : $this->memberData['g_attach_max'] ) * 1024;
//-----------------------------------------
// Allowed to attach?
//-----------------------------------------
if ( ! $member_id OR ! $forum_id )
{
$space_allowed = -1;
}
if ( IPSMember::checkPermissions('upload', $forum_id ) !== TRUE )
{
$space_allowed = -1;
}
else if ( ! $space_calculated )
{
//-----------------------------------------
// Generate space allowed figure
//-----------------------------------------
if ( $this->memberData['g_attach_per_post'] )
{
//-----------------------------------------
// Per post limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array(
'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => "attach_post_key='{$post_key}'"
) );
$space_used = intval( $_space_used['figure'] );
}
else
{
//-----------------------------------------
// Global limit...
//-----------------------------------------
$_space_used = $this->DB->buildAndFetch( array(
'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => "attach_member_id={$member_id} AND attach_rel_module IN( 'post', 'msg' )"
) );
$space_used = intval( $_space_used['figure'] );
}
if ( $this->memberData['g_attach_max'] > 0 )
{
if ( $this->memberData['g_attach_per_post'] )
{
$_g_space_used = $this->DB->buildAndFetch( array(
'select' => 'SUM(attach_filesize) as figure',
'from' => 'attachments',
'where' => "attach_member_id={$member_id} AND attach_rel_module IN( 'post', 'msg' )"
) );
$g_space_used = intval( $_g_space_used['figure'] );
if( intval( ( $this->memberData['g_attach_max'] * 1024 ) - $g_space_used ) < 0 )
{
$space_used = $g_space_used;
$total_space_allowed = $this->memberData['g_attach_max'] * 1024;
$space_allowed = ( $this->memberData['g_attach_max'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
else
{
$space_allowed = ( $this->memberData['g_attach_per_post'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
}
else
{
$space_allowed = ( $this->memberData['g_attach_max'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
}
else
{
if ( $this->memberData['g_attach_per_post'] )
{
$space_allowed = ( $this->memberData['g_attach_per_post'] * 1024 ) - $space_used;
$space_allowed = $space_allowed < 0 ? -1 : $space_allowed;
}
else
{
# Unlimited
$space_allowed = 0;
}
}
//-----------------------------------------
// Generate space left figure
//-----------------------------------------
$space_left = $space_allowed ? $space_allowed : 0;
$space_left = ($space_left < 0) ? -1 : $space_left;
//-----------------------------------------
// Generate max upload size
//-----------------------------------------
if ( ! $max_single_upload )
{
if ( $space_left > 0 AND $space_left < $max_php_size )
{
$max_single_upload = $space_left;
}
else if ( $max_php_size )
{
$max_single_upload = $max_php_size;
}
}
}
IPSDebug::fireBug( 'info', array( 'Space left: ' . $space_left ) );
IPSDebug::fireBug( 'info', array( 'Max PHP size: ' . $max_php_size ) );
IPSDebug::fireBug( 'info', array( 'Max single file size: ' . $max_single_upload ) );
$return = array( 'space_used' => $space_used, 'space_left' => $space_left, 'space_allowed' => $space_allowed, 'max_single_upload' => $max_single_upload, 'total_space_allowed' => $total_space_allowed );
return $return;
}
/**
* Returns an array of settings:
* 'siu_thumb' = Allow thumbnail creation?
* 'siu_height' = Height of the generated thumbnail in pixels
* 'siu_width' = Width of the generated thumbnail in pixels
* 'upload_dir' = Base upload directory (must be a full path)
*
* You can omit any of these settings and IPB will use the default
* settings (which are the ones entered into the ACP for post thumbnails)
*
* @access public
* @return boolean
*/
public function getSettings()
{
$this->mysettings = array();
return true;
}
}
@@ -0,0 +1,185 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Subscriptions Hooks Gateway "Handler"
* Owner: Matt "Oh Lord, why did I get assigned this?" Mecham
* Last Updated: $Date: 2010-01-15 15:18:44 +0000 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @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 9th March 2005 11:03
* @version $Revision: 5713 $
*/
class core_hookGateway
{
/**#@+
* Registry objects
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Method constructor
*
* @param object Registry Object
* @return void
*/
function __construct( ipsRegistry $registry )
{
/* Make registry objects */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Shows board index recent entries
*
*/
public function shareLinks()
{
/* System enabled? */
if ( ! $this->settings['sl_enable'] OR ! $this->settings['sl_publicdata'] OR ! $this->memberData['member_id'] )
{
return '';
}
/* INIT */
$fetchData = array();
$finalData = array();
$noThisIsFinalReally = array();
/* Fetch cached data */
$this->DB->build( array( 'select' => '*',
'from' => 'core_share_links_caches',
'where' => "cache_key IN ('mostitems', 'mostrecent', 'mosttypes')" ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$caches[ $row['cache_key'] ] = ( $row['cache_data'] ) ? unserialize( $row['cache_data'] ) : array();
}
foreach( array( 'mostrecent', 'mostitems' ) as $items )
{
/* Build an array of data up */
if ( is_array( $caches[ $items ] ) AND count( $caches[ $items ] ) )
{
foreach( $caches[ $items ] as $data )
{
if ( $data['log_data_app'] AND $data['log_data_type'] AND $data['log_data_primary_id'] )
{
$key = $data['log_data_app'] . '--' . $data['log_data_type'] . '--' . $data['log_data_primary_id'];
$fetchData[ $data['log_data_app'] ][ $key ] = $data;
}
}
}
}
/* Now go and fetch the data for the grabbed stuff */
if ( is_array( $fetchData ) AND count( $fetchData ) )
{
foreach( $fetchData as $app => $data )
{
$finalData[ $app ] = $this->_fetchAppData( $app, $data );
}
}
/* Now to mash it all back */
if ( is_array( $finalData ) AND count( $finalData ) )
{
foreach( array( 'mostrecent', 'mostitems' ) as $items )
{
/* Build an array of data up */
if ( is_array( $caches[ $items ] ) AND count( $caches[ $items ] ) )
{
foreach( $caches[ $items ] as $data )
{
if ( $data['log_data_app'] AND $data['log_data_type'] AND $data['log_data_primary_id'] )
{
$key = $data['log_data_app'] . '--' . $data['log_data_type'] . '--' . $data['log_data_primary_id'];
if ( is_array( $finalData[ $data['log_data_app'] ][ $key ] ) )
{
$noThisIsFinalReally[ $items ][] = array_merge( $data, $finalData[ $data['log_data_app'] ][ $key ] );
}
}
}
}
}
}
return $this->registry->getClass('output')->getTemplate('boards')->hookBoardIndexShareLinks( $noThisIsFinalReally );
}
/**
* Fetch application data
*
* @param string App
* @param array Array of incoming data
* @return array Array of outgoing data
*/
protected function _fetchAppData( $appKey, $data )
{
if ( $appKey )
{
$app_cache = $this->cache->getCache('app_cache');
$app = $app_cache[ $appKey ];
/* Only if app enabled... */
if ( $app['app_enabled'] )
{
/* Setup */
$_file = IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/coreExtensions.php';
/* Check for the file */
if( file_exists( $_file ) )
{
/* Get the file */
$_class = IPSLib::loadLibrary( $_file, $app['app_directory'] . 'ShareLinks', $app['app_directory'] );
/* Check for the class */
if( class_exists( $_class ) )
{
/* Create an object */
$_obj = new $_class();
/* Check for the module */
if( method_exists( $_obj, 'processData' ) )
{
/* Call it */
return $_obj->processData( $data );
}
}
}
}
}
}
}
@@ -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>
@@ -1,345 +1,359 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Library of shared methods for hooks installation/configuration
* Last Updated: $LastChangedDate: 2009-06-30 12:06:12 -0400 (Tue, 30 Jun 2009) $
*
* @author $Author: josh $
* @author Based on original "Report Center" by Luke Scott
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @version $Rev: 4829 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class hooksFunctions
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @access public
* @param object Registry object
* @return void
*/
public function __construct( ipsRegistry $registry )
{
//-----------------------------------------
// Make object
//-----------------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->lang = $this->registry->class_localization;
$this->lang->loadLanguageFile( array( 'admin_applications' ) );
}
/**
* Get all the available hook ids in a function for a given type
*
* @access public
* @param string Skin Function
* @param string Hook type [foreach|if]
* @return array Settings for dropdown
*/
public function getHookIds( $template='', $type='' )
{
if( !$template )
{
return array();
}
$type = $type ? $type : 'foreach';
$return = array( array( 0, $this->lang->words['h_selectid'] ) );
$seenids = array();
$presort = array();
$this->DB->build( array( 'select' => 'template_content', 'from' => 'skin_templates', 'where' => "template_name='{$template}'" ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
/* Use regex to try to find the ids */
$matches = array();
if( $type == 'foreach' )
{
preg_match_all( "#\<foreach\s+loop=\"(.+?)\:(.+?)\"\>#i", $r['template_content'], $matches );
}
else
{
preg_match_all( "#\<if\s+test=\"(.+?)\:\|\:(.+?)\"\>#i", $r['template_content'], $matches );
}
if( is_array($matches[1]) AND count($matches[1]) )
{
foreach( $matches[1] as $match )
{
$presort[ $match ] = array( $match, $match );
}
}
}
/* Put the ids in alphabetical order, kinda hacky, oh well ;) */
ksort( $presort );
foreach( $presort as $k => $v )
{
$return[$k] = $v;
}
return $return;
}
/**
* Get all the available skin files
*
* @access public
* @return array Settings for dropdown
*/
public function getSkinGroups()
{
$return = array( array( 0, $this->lang->words['h_selectfile'] ) );
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'template_group' ), 'from' => 'skin_templates', 'order' => 'template_group ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['template_group'], $r['template_group'] );
}
return $return;
}
/**
* Get all the available skin templates in a skin group
*
* @access public
* @param string Skin Group
* @return array Settings for dropdown
*/
public function getSkinMethods( $file='' )
{
if( !$file )
{
return array();
}
$return = array( array( 0, $this->lang->words['h_selecttemp'] ) );
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'template_name' ), 'from' => 'skin_templates', 'where' => "template_group='{$file}'", 'order' => 'template_name ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['template_name'], $r['template_name'] );
}
return $return;
}
/**
* Retrieve setting groups for multiselect
*
* @access public
* @return array Settings for multiselect
*/
public function getSettingGroups()
{
$return = array();
$this->DB->build( array( 'select' => 'conf_title_id, conf_title_title', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['conf_title_id'], $r['conf_title_title'] );
}
return $return;
}
/**
* Retrieve settings for multiselect
*
* @access public
* @return array Settings for multiselect
*/
public function getSettings()
{
$return = array();
$this->DB->build( array( 'select' => 'conf_id, conf_title', 'from' => 'core_sys_conf_settings', 'order' => 'conf_title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['conf_id'], $r['conf_title'] );
}
return $return;
}
/**
* Retrieve available modules for export
*
* @access public
* @return array Settings for multiselect
*/
public function getModules()
{
$return = array();
$this->DB->build(
array(
'select' => 'm.sys_module_key, m.sys_module_title, m.sys_module_admin',
'from' => array( 'core_sys_module' => 'm' ),
'order' => 'a.app_title ASC, m.sys_module_title ASC',
'add_join' => array(
array(
'select' => 'a.app_title',
'from' => array( 'core_applications' => 'a' ),
'where' => 'a.app_directory=m.sys_module_application',
'type' => 'left'
)
)
)
);
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$admin = $r['sys_module_admin'] ? $this->lang->words['hook_admin_module'] : $this->lang->words['hook_public_module'];
$return[] = array( $r['sys_module_key'], $r['app_title'] . ':: ' . $r['sys_module_title'] . $admin );
}
return $return;
}
/**
* Retrieve available Help Files for export
*
* @access public
* @return array Settings for multiselect
*/
public function getHelpFiles()
{
$return = array();
$this->DB->build( array( 'select' => 'id, title', 'from' => 'faq', 'order' => 'title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['id'], $r['title'] );
}
return $return;
}
/**
* Retrieve available tasks for export
*
* @access public
* @return array Settings for multiselect
*/
public function getTasks()
{
$return = array();
$this->DB->build( array( 'select' => 'task_id, task_title', 'from' => 'task_manager', 'order' => 'task_title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['task_id'], $r['task_title'] );
}
return $return;
}
/**
* Get all the available language files
*
* @access public
* @return array Settings for dropdown
*/
public function getLanguageFiles()
{
$return = array( array( 0, 'Select a File' ) );
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'word_pack' ), 'from' => 'core_sys_lang_words', 'order' => 'word_pack ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['word_pack'], $r['word_pack'] );
}
return $return;
}
/**
* Get all the available language strings in a given file
*
* @access public
* @param string Language file
* @return array Settings for multiselect
*/
public function getStrings( $file='' )
{
if( !$file )
{
return array();
}
$return = array();
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'word_key' ), 'from' => 'core_sys_lang_words', 'where' => "word_pack='{$file}'", 'order' => 'word_key ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['word_key'], $r['word_key'] );
}
return $return;
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Library of shared methods for hooks installation/configuration
* Last Updated: $LastChangedDate: 2010-10-14 13:15:13 -0400 (Thu, 14 Oct 2010) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 6980 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class hooksFunctions
{
/**#@+
* Registry objects
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @param object Registry object
* @return void
*/
public function __construct( ipsRegistry $registry )
{
//-----------------------------------------
// Make object
//-----------------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->lang = $this->registry->class_localization;
$this->lang->loadLanguageFile( array( 'admin_applications' ) );
}
/**
* Get all the available hook ids in a function for a given type
*
* @param string Skin Function
* @param string Hook type [foreach|if]
* @return array Settings for dropdown
*/
public function getHookIds( $template='', $type='' )
{
if( !$template )
{
return array();
}
$type = $type ? $type : 'foreach';
$return = array( array( 0, $this->lang->words['h_selectid'] ) );
$seenids = array();
$presort = array();
$this->DB->build( array( 'select' => 'template_content', 'from' => 'skin_templates', 'where' => "template_set_id=0 AND template_master_key='root' AND template_name='{$template}'" ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
/* Use regex to try to find the ids */
$matches = array();
if( $type == 'foreach' )
{
preg_match_all( "#\<foreach\s+loop=\"(.+?)\:(.+?)\"\>#i", $r['template_content'], $matches );
}
else
{
preg_match_all( "#\<if\s+test=\"(.+?)\:\|\:(.+?)\"\>#i", $r['template_content'], $matches );
}
if( is_array($matches[1]) AND count($matches[1]) )
{
foreach( $matches[1] as $match )
{
$presort[ $match ] = array( $match, $match );
}
}
}
/* Put the ids in alphabetical order, kinda hacky, oh well ;) */
ksort( $presort );
foreach( $presort as $k => $v )
{
$return[$k] = $v;
}
return $return;
}
/**
* Get all the available skin files
*
* @return array Settings for dropdown
*/
public function getSkinGroups()
{
$return = array( array( 0, $this->lang->words['h_selectfile'] ) );
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'template_group' ), 'from' => 'skin_templates', 'order' => 'template_group ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['template_group'], $r['template_group'] );
}
return $return;
}
/**
* Get all the available skin templates in a skin group
*
* @param string Skin Group
* @return array Settings for dropdown
*/
public function getSkinMethods( $file='' )
{
if( !$file )
{
return array();
}
$return = array( array( 0, $this->lang->words['h_selecttemp'] ) );
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'template_name' ), 'from' => 'skin_templates', 'where' => "template_group='{$file}'", 'order' => 'template_name ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['template_name'], $r['template_name'] );
}
return $return;
}
/**
* Retrieve css files for multiselect
*
* @return array Settings for multiselect
*/
public function getCSSFiles()
{
/* Query CSS Files */
$this->DB->build( array( 'select' => '*', 'from' => 'skin_css', 'order' => 'css_set_id ASC' ) );
$this->DB->execute();
/* Loop through CSS Files and add to array */
$cssFiles = array();
while( $r = $this->DB->fetch() )
{
$cssFiles[] = array( $r['css_id'], $r['css_set_id'] . ': ' . $r['css_group'] );
}
return $cssFiles;
}
/**
* Retrieve setting groups for multiselect
*
* @return array Settings for multiselect
*/
public function getSettingGroups()
{
$return = array();
$this->DB->build( array( 'select' => 'conf_title_id, conf_title_title', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['conf_title_id'], $r['conf_title_title'] );
}
return $return;
}
/**
* Retrieve settings for multiselect
*
* @return array Settings for multiselect
*/
public function getSettings()
{
$return = array();
$this->DB->build( array( 'select' => 'conf_id, conf_title', 'from' => 'core_sys_conf_settings', 'order' => 'conf_title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['conf_id'], $r['conf_title'] );
}
return $return;
}
/**
* Retrieve available modules for export
*
* @return array Settings for multiselect
*/
public function getModules()
{
$return = array();
$this->DB->build(
array(
'select' => 'm.sys_module_application, m.sys_module_key, m.sys_module_title, m.sys_module_admin',
'from' => array( 'core_sys_module' => 'm' ),
'order' => 'a.app_title ASC, m.sys_module_title ASC',
'add_join' => array(
array(
'select' => 'a.app_title',
'from' => array( 'core_applications' => 'a' ),
'where' => 'a.app_directory=m.sys_module_application',
'type' => 'left'
)
)
)
);
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$admin = $r['sys_module_admin'] ? $this->lang->words['hook_admin_module'] : $this->lang->words['hook_public_module'];
$prefix = $r['sys_module_admin'] ? mb_strtolower( $this->lang->words['a_admin'] ) : mb_strtolower( $this->lang->words['a_public'] );
$return[] = array( $prefix.'-'.$r['sys_module_application'].'-'.$r['sys_module_key'], $r['app_title'] . ':: ' . $r['sys_module_title'] . $admin );
}
return $return;
}
/**
* Retrieve available Help Files for export
*
* @return array Settings for multiselect
*/
public function getHelpFiles()
{
$return = array();
$this->DB->build( array( 'select' => 'id, title', 'from' => 'faq', 'order' => 'title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['id'], $r['title'] );
}
return $return;
}
/**
* Retrieve available tasks for export
*
* @return array Settings for multiselect
*/
public function getTasks()
{
$return = array();
$this->DB->build( array( 'select' => 'task_id, task_title', 'from' => 'task_manager', 'order' => 'task_title ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['task_id'], $r['task_title'] );
}
return $return;
}
/**
* Get all the available language files
*
* @return array Settings for dropdown
*/
public function getLanguageFiles()
{
$return = array( array( 0, $this->lang->words['selectafile'] ) );
$this->DB->build( array( 'select' => 'word_app, word_pack', 'from' => 'core_sys_lang_words', 'group' => 'word_app, word_pack', 'order' => 'word_app, word_pack' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['word_app'].'_'.$r['word_pack'], $r['word_app'].'_'.$r['word_pack'] );
}
return $return;
}
/**
* Get all the available language strings in a given file
*
* @param string Language file
* @return array Settings for multiselect
*/
public function getStrings( $file='' )
{
if( !$file )
{
return array();
}
$bits = explode( '_', $file );
$app = $bits[0];
$pack = str_replace( $app.'_', '', $file );
$return = array();
$this->DB->build( array( 'select' => $this->DB->buildDistinct( 'word_key' ), 'from' => 'core_sys_lang_words', 'where' => "word_app='{$app}' AND word_pack='{$pack}'", 'order' => 'word_key ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['word_key'], $r['word_key'] );
}
return $return;
}
}
@@ -1 +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.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<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>
@@ -1,431 +1,426 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Library for reported content
* Last Updated: $LastChangedDate: 2009-10-01 10:02:08 -0400 (Thu, 01 Oct 2009) $
*
* @author $Author: bfarber $
* @author Based on original "Report Center" by Luke Scott
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @version $Rev: 5190 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class reportLibrary
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Group Ids
*
* @access protected
* @var array
*/
protected $member_group_ids;
/**
* Array of plugin objects
*
* @access public
* @var array
*/
public $plugins;
/**
* Status for new reports
*
* @access public
* @var integer
*/
public $report_is_new = 0;
/**
* Status for complete reports
*
* @access public
* @var integer
*/
public $report_is_complete = 0;
/**
* Cache of status/flag images
*
* @access public
* @var array
*/
public $flag_cache = array();
/**
* Cache of HTML status dropdown
*
* @access public
* @var string
*/
public $flag_body = '';
/**
* Constructor
*
* @access public
* @param object Registry object
* @return void
*/
public function __construct( ipsRegistry $registry )
{
//-----------------------------------------
// Make object
//-----------------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->member_group_ids = array( $this->memberData['member_group_id'] );
$this->member_group_ids = array_diff( array_merge( $this->member_group_ids, explode( ',', $this->memberData['mgroup_others'] ) ), array('') );
}
/**
* Rebuild the member cache array if it is outdated
*
* @access public
* @return integer New 'total reports' count
*/
public function rebuildMemberCacheArray()
{
$this->DB->loadCacheFile( IPSLib::getAppDir('core') . '/sql/' . ips_DBRegistry::getDriverType() . '_report_queries.php', 'report_sql_queries' );
$class_perm = $this->buildQueryPermissions();
$total = $this->DB->buildAndFetch( array(
'select' => 'COUNT(*) as reports',
'from' => array( 'rc_reports_index' => 'rep' ),
'where' => $class_perm . " AND stat.is_active=1",
'add_join' => array(
array(
'from' => array( 'rc_classes' => 'rcl' ),
'where' => 'rcl.com_id=rep.rc_class'
),
array(
'from' => array( 'rc_status' => 'stat' ),
'where' => 'stat.status=rep.status'
),
)
) );
$reports_by_plugin = array();
$this->DB->build( array(
'select' => 'rep.id, rep.title, rep.num_reports, rep.exdat1, rep.exdat2, rep.exdat3',
'from' => array( 'rc_reports_index' => 'rep' ),
'where' => $class_perm . " AND (stat.is_active=1 OR stat.is_new=1) AND rcl.onoff=1",
'order' => 'stat.is_new ASC',
'add_join' => array(
array(
'select' => 'stat.is_active, stat.is_new',
'from' => array( 'rc_status' => 'stat' ),
'where' => 'stat.status=rep.status'
),
array(
'select' => 'rcl.com_id, rcl.com_id, rcl.my_class, rcl.extra_data',
'from' => array( 'rc_classes' => 'rcl' ),
'where' => 'rcl.com_id=rep.rc_class'
),
)
) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if( $row['my_class'] != '' )
{
$reports_by_plugin[ $row['my_class'] ][] = $row;
}
}
$build_member_cache_array['report_temp'] = array();
foreach( $reports_by_plugin as $plugin_name => $reports_array )
{
$this->loadPlugin( $plugin_name );
$this->plugins[ $plugin_name ]->updateReportsTimestamp( $reports_array, $build_member_cache_array );
}
$build_member_cache_array['report_last_updated'] = time();
$build_member_cache_array['report_num'] = $total['reports'];
if( count($build_member_cache_array) > 0 )
{
IPSMember::packMemberCache( $this->memberData['member_id'], $build_member_cache_array );
}
return $total['reports'];
}
/**
* Builds permissions for several sql queries for various functions
*
* @access public
* @param string based on mods or users
* @return string
*/
public function buildQueryPermissions( $check='mod' )
{
//-----------------------------------------
// Are we checking user or mod permissions?
//-----------------------------------------
if( $check == 'mod' )
{
$col = 'mod_group_perm';
}
else
{
$col = 'group_can_report';
}
//-----------------------------------------
// Get components we have access to...
//-----------------------------------------
$this->DB->buildFromCache( 'get_class_permissions', array( 'COL' => $col, 'GROUP_IDS' => $this->member_group_ids ), 'report_sql_queries' );
$res = $this->DB->execute();
while( $row = $this->DB->fetch( $res ) )
{
if( $row['my_class'] != '' )
{
$spec_perm = '';
$this->loadPlugin( $row['my_class'] );
if( $row['extra_data'] && $row['extra_data'] != 'N;' )
{
$this->plugins[ $row['my_class'] ]->_extra = unserialize( $row['extra_data'] );
}
else
{
$this->plugins[ $row['my_class'] ]->_extra = array();
}
if( $this->plugins[ $row['my_class'] ]->getReportPermissions( $check, $row, $this->member_group_ids, $spec_perm ) )
{
$cids[ $row['com_id'] ] = $spec_perm;
}
}
}
return $this->DB->fetchLoadedClass('report_sql_queries')->join_com_permissions( array( 'NOTCACHE' => 1, 'COMS' => $cids ) );
}
/**
* Loads plugins into $this->plugins object for later use
*
* @access public
* @param string plugin name (>name<.php)
* @return void
*/
public function loadPlugin( $plugin_name )
{
if( ! $this->plugins[ $plugin_name ] )
{
require_once( IPSLib::getAppDir('core') . '/sources/reportPlugins/' . $plugin_name . '.php' );
$class_name = $plugin_name . '_plugin';
$this->plugins[ $plugin_name ] = new $class_name( $this->registry );
}
}
/**
* Process a URL
*
* @access public
* @param string URL
* @param string FURL Title
* @param string FURL Template
* @return string Full URL if existing URL was short
*/
public function processUrl( $url, $friendlyTitle='', $friendlyTemplate='' )
{
if( $url && ! preg_match( "/(http|https)\:\/\//", $url ) )
{
$returnUrl = str_replace( '/index.php?', '', $url );
$returnUrl = $this->registry->output->buildSEOUrl( $returnUrl, 'public', $friendlyTitle, $friendlyTemplate );
return $returnUrl;
}
else
{
return $url;
}
}
/**
* Fixes the member's RSS Key if none set
*
* @access public
* @return void
*/
public function checkMemberRSSKey()
{
if( ! $this->memberData['_cache']['rc_rss_key'] )
{
$new_rss_key = md5( uniqid( microtime(), true ) );
$this->DB->build( array( 'select' => '*', 'from' => 'rc_modpref', 'where' => "mem_id=" . $this->memberData['member_id'] ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 1 )
{
$this->DB->update( 'rc_modpref', array( 'rss_key' => $new_rss_key ), "mem_id=" . $this->memberData['member_id'] );
}
else
{
$this->DB->insert( 'rc_modpref', array( 'rss_key' => $new_rss_key, 'mem_id' => $this->memberData['member_id'], 'rss_cache' => '' ) );
}
$memberCache = $this->memberData['_cache'];
$memberCache['rc_rss_key'] = $new_rss_key;
$this->member->setProperty( '_cache', $memberCache );
IPSMember::packMemberCache( $this->memberData['member_id'], array( 'rc_rss_key' => $new_rss_key ) );
}
}
/**
* Generates report form HTML
*
* @access public
* @param string Title - What is being reported
* @param string URL - what the user can click on (title)
* @param array Extra data passed on to the form for processing
* @return string
*/
public function showReportForm( $name, $url, $ex_data=array() )
{
$extra_input = '';
if( is_array( $ex_data ) && count( $ex_data ) > 0 )
{
foreach( $ex_data as $bname => $value )
{
$extra_input .= "<input type='hidden' name='{$bname}' value='{$value}' />";
}
}
return $this->registry->getClass('output')->getTemplate('reports')->basicReportForm( $name, $url, $extra_input );
}
/**
* Updates global 'cache time' which forces 'mod caches' to re-cache
*
* @access public
* @return void
*/
public function updateCacheTime()
{
$cache = $this->cache->getCache('report_cache');
$cache['last_updated'] = time();
$this->cache->setCache( 'report_cache', $cache, array( 'array' => 1, 'donow' => 1 ) );
}
/**
* Builds the status information (and maybe drop down html)
*
* @access public
* @param boolean Do we need the drop down?
* @return string HTML body
*/
public function buildStatuses( $ignore_html = false )
{
if( !$this->flag_cache )
{
$stat_set = array();
$this->body = '';
$this->DB->build( array(
'select' => 'stat.status, stat.title, stat.is_new, stat.is_complete',
'from' => array( 'rc_status' => 'stat' ),
'order' => 'stat.rorder ASC, star.points ASC',
'add_join' => array(
array(
'select' => 'star.img, star.width, star.height, star.points, star.is_png',
'from' => array( 'rc_status_sev' => 'star' ),
'where' => 'stat.status=star.status'
)
)
) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if( ! $stat_set[ $row['status'] ] )
{
$this->body .= "<option value='{$row['status']}'>{$row['title']}</option>";
if( $row['is_new'] == 1 )
{
$this->report_is_new = $row['status'];
}
elseif( $row['is_complete'] == 1 )
{
$this->report_is_complete = $row['status'];
}
}
$stat_set[ $row['status'] ] = true;
$this->flag_cache[ $row['status'] ][ $row['points'] ] = array(
'img' => $row['img'],
'width' => $row['width'],
'height' => $row['height'],
'is_png' => $row['is_png'],
'title' => $row['title'],
);
if( $row['points'] == 0 )
{
$this->flag_cache[ $row['status'] ][ NULL ] = array(
'img' => $row['img'],
'width' => $row['width'],
'height' => $row['height'],
'is_png' => $row['is_png'],
'title' => $row['title'],
);
}
}
}
return $ignore_html ? '' : $this->body;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Library for reported content
* Last Updated: $LastChangedDate: 2010-10-19 11:56:25 -0400 (Tue, 19 Oct 2010) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author Based on original "Report Center" by Luke Scott
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 6997 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class reportLibrary
{
/**#@+
* Registry objects
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Group Ids
*
* @var array
*/
protected $member_group_ids;
/**
* Array of plugin objects
*
* @var array
*/
public $plugins;
/**
* Status for new reports
*
* @var integer
*/
public $report_is_new = 0;
/**
* Status for complete reports
*
* @var integer
*/
public $report_is_complete = 0;
/**
* Cache of status/flag images
*
* @var array
*/
public $flag_cache = array();
/**
* Cache of HTML status dropdown
*
* @var string
*/
public $flag_body = '';
/**
* Constructor
*
* @param object Registry object
* @return void
*/
public function __construct( ipsRegistry $registry )
{
//-----------------------------------------
// Make object
//-----------------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->member_group_ids = array( $this->memberData['member_group_id'] );
$this->member_group_ids = array_diff( array_merge( $this->member_group_ids, explode( ',', $this->memberData['mgroup_others'] ) ), array('') );
}
/**
* Rebuild the member cache array if it is outdated
*
* @return integer New 'total reports' count
*/
public function rebuildMemberCacheArray()
{
$this->DB->loadCacheFile( IPSLib::getAppDir('core') . '/sql/' . ips_DBRegistry::getDriverType() . '_report_queries.php', 'report_sql_queries' );
$class_perm = $this->buildQueryPermissions();
$total = $this->DB->buildAndFetch( array(
'select' => 'COUNT(*) as reports',
'from' => array( 'rc_reports_index' => 'rep' ),
'where' => $class_perm . " AND stat.is_active=1",
'add_join' => array(
array(
'from' => array( 'rc_classes' => 'rcl' ),
'where' => 'rcl.com_id=rep.rc_class'
),
array(
'from' => array( 'rc_status' => 'stat' ),
'where' => 'stat.status=rep.status'
),
)
) );
$reports_by_plugin = array();
$this->DB->build( array(
'select' => 'rep.id, rep.title, rep.num_reports, rep.exdat1, rep.exdat2, rep.exdat3',
'from' => array( 'rc_reports_index' => 'rep' ),
'where' => $class_perm . " AND (stat.is_active=1 OR stat.is_new=1) AND rcl.onoff=1",
'order' => 'stat.is_new ASC',
'add_join' => array(
array(
'select' => 'stat.is_active, stat.is_new',
'from' => array( 'rc_status' => 'stat' ),
'where' => 'stat.status=rep.status'
),
array(
'select' => 'rcl.com_id, rcl.com_id, rcl.my_class, rcl.extra_data',
'from' => array( 'rc_classes' => 'rcl' ),
'where' => 'rcl.com_id=rep.rc_class'
),
)
) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if( $row['my_class'] != '' )
{
$reports_by_plugin[ $row['app'] ][ $row['my_class'] ][] = $row;
}
}
$build_member_cache_array['report_temp'] = array();
foreach( $reports_by_plugin as $app => $plugins )
{
foreach( $plugins as $plugin_name => $reports_array )
{
$this->loadPlugin( $plugin_name, $app );
$this->plugins[ $plugin_name ]->updateReportsTimestamp( $reports_array, $build_member_cache_array );
}
}
$build_member_cache_array['report_last_updated'] = time();
$build_member_cache_array['report_num'] = $total['reports'];
if( count($build_member_cache_array) > 0 )
{
IPSMember::packMemberCache( $this->memberData['member_id'], $build_member_cache_array );
}
return $total['reports'];
}
/**
* Builds permissions for several sql queries for various functions
*
* @param string based on mods or users
* @return string
*/
public function buildQueryPermissions( $check='mod' )
{
//-----------------------------------------
// Are we checking user or mod permissions?
//-----------------------------------------
if( $check == 'mod' )
{
$col = 'mod_group_perm';
}
else
{
$col = 'group_can_report';
}
//-----------------------------------------
// Get components we have access to...
//-----------------------------------------
$this->DB->buildFromCache( 'get_class_permissions', array( 'COL' => $col, 'GROUP_IDS' => $this->member_group_ids ), 'report_sql_queries' );
$res = $this->DB->execute();
while( $row = $this->DB->fetch( $res ) )
{
if( $row['my_class'] != '' )
{
$spec_perm = '';
$this->loadPlugin( $row['my_class'], $row['app'] );
if( !$this->plugins[ $row['my_class'] ] )
{
continue;
}
if( $row['extra_data'] && $row['extra_data'] != 'N;' )
{
$this->plugins[ $row['my_class'] ]->_extra = unserialize( $row['extra_data'] );
}
else
{
$this->plugins[ $row['my_class'] ]->_extra = array();
}
if( $this->plugins[ $row['my_class'] ]->getReportPermissions( $check, $row, $this->member_group_ids, $spec_perm ) )
{
$cids[ $row['com_id'] ] = $spec_perm;
}
}
}
return $this->DB->fetchLoadedClass('report_sql_queries')->join_com_permissions( array( 'NOTCACHE' => 1, 'COMS' => $cids ) );
}
/**
* Loads plugins into $this->plugins object for later use
*
* @param string plugin name (>name<.php)
* @return void
*/
public function loadPlugin( $plugin_name, $app )
{
if( ! $this->plugins[ $plugin_name ] )
{
if( file_exists( IPSLib::getAppDir( $app ) . '/extensions/reportPlugins/' . $plugin_name . '.php' ) )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/reportPlugins/' . $plugin_name . '.php', $plugin_name . '_plugin', $app );
$this->plugins[ $plugin_name ] = new $classToLoad( $this->registry );
}
}
}
/**
* Process a URL
*
* @param string URL
* @param string FURL Title
* @param string FURL Template
* @return string Full URL if existing URL was short
*/
public function processUrl( $url, $friendlyTitle='', $friendlyTemplate='' )
{
if( $url && ! preg_match( "/(http|https)\:\/\//", $url ) )
{
$returnUrl = str_replace( '/index.php?', '', $url );
$returnUrl = $this->registry->output->buildSEOUrl( $returnUrl, 'public', $friendlyTitle, $friendlyTemplate );
return $returnUrl;
}
else
{
return $url;
}
}
/**
* Fixes the member's RSS Key if none set
*
* @return void
*/
public function checkMemberRSSKey()
{
if( ! $this->memberData['_cache']['rc_rss_key'] )
{
$new_rss_key = md5( uniqid( microtime(), true ) );
$this->DB->build( array( 'select' => '*', 'from' => 'rc_modpref', 'where' => "mem_id=" . $this->memberData['member_id'] ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 1 )
{
$this->DB->update( 'rc_modpref', array( 'rss_key' => $new_rss_key ), "mem_id=" . $this->memberData['member_id'] );
}
else
{
$this->DB->insert( 'rc_modpref', array( 'rss_key' => $new_rss_key, 'mem_id' => $this->memberData['member_id'], 'rss_cache' => '' ) );
}
$memberCache = $this->memberData['_cache'];
$memberCache['rc_rss_key'] = $new_rss_key;
$this->member->setProperty( '_cache', $memberCache );
IPSMember::packMemberCache( $this->memberData['member_id'], array( 'rc_rss_key' => $new_rss_key ) );
}
}
/**
* Generates report form HTML
*
* @param string Title - What is being reported
* @param string URL - what the user can click on (title)
* @param array Extra data passed on to the form for processing
* @return string
*/
public function showReportForm( $name, $url, $ex_data=array() )
{
$extra_input = '';
if( is_array( $ex_data ) && count( $ex_data ) > 0 )
{
foreach( $ex_data as $bname => $value )
{
$extra_input .= "<input type='hidden' name='{$bname}' value='{$value}' />";
}
}
return $this->registry->getClass('output')->getTemplate('reports')->basicReportForm( $name, $url, $extra_input );
}
/**
* Updates global 'cache time' which forces 'mod caches' to re-cache
*
* @return void
*/
public function updateCacheTime()
{
$cache = $this->cache->getCache('report_cache');
$cache['last_updated'] = time();
$this->cache->setCache( 'report_cache', $cache, array( 'array' => 1, 'donow' => 1 ) );
}
/**
* Builds the status information (and maybe drop down html)
*
* @param boolean Do we need the drop down?
* @return string HTML body
*/
public function buildStatuses( $ignore_html = false )
{
if( !$this->flag_cache )
{
$stat_set = array();
$this->body = '';
$this->DB->build( array(
'select' => 'stat.status, stat.title, stat.is_new, stat.is_complete',
'from' => array( 'rc_status' => 'stat' ),
'order' => 'stat.rorder ASC, star.points ASC',
'add_join' => array(
array(
'select' => 'star.img, star.width, star.height, star.points, star.is_png',
'from' => array( 'rc_status_sev' => 'star' ),
'where' => 'stat.status=star.status'
)
)
) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if( ! $stat_set[ $row['status'] ] )
{
$this->body .= "<option value='{$row['status']}'>{$row['title']}</option>";
if( $row['is_new'] == 1 )
{
$this->report_is_new = $row['status'];
}
elseif( $row['is_complete'] == 1 )
{
$this->report_is_complete = $row['status'];
}
}
$stat_set[ $row['status'] ] = true;
$this->flag_cache[ $row['status'] ][ $row['points'] ] = array(
'img' => $row['img'],
'width' => $row['width'],
'height' => $row['height'],
'is_png' => $row['is_png'],
'title' => $row['title'],
);
if( $row['points'] == 0 )
{
$this->flag_cache[ $row['status'] ][ NULL ] = array(
'img' => $row['img'],
'width' => $row['width'],
'height' => $row['height'],
'is_png' => $row['is_png'],
'title' => $row['title'],
);
}
}
}
return $ignore_html ? '' : $this->body;
}
}
@@ -1,370 +1,323 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Notifications class for reported content
* Last Updated: $LastChangedDate: 2009-09-24 08:06:26 -0400 (Thu, 24 Sep 2009) $
*
* @author $Author: josh $
* @author Based on original "Report Center" by Luke Scott
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @version $Rev: 5147 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class reportNotifications
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Messenger object
*
* @access protected
* @var object
*/
protected $messenger;
/**
* Data for the members
*
* @access public
* @var array
*/
public $my_data;
/**
* Data for the reported content
*
* @access public
* @var array
*/
public $my_report_data;
/**
* Constructor
*
* @access public
* @param object Registry object
* @return void
*/
public function __construct( ipsRegistry $registry )
{
//-----------------------------------------
// Make object
//-----------------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->lang = $this->registry->getClass('class_localization');
require_once( IPSLib::getAppDir( 'members' ) . '/sources/classes/messaging/messengerFunctions.php' );
$this->messenger = new messengerFunctions( $this->registry );
}
/**
* Initialize library
*
* @access public
* @param array Member data
* @param array Reported content
* @return void
*/
public function initNotify( $data, $report_data )
{
$this->my_data = $data;
$this->my_report_data = $report_data;
}
/**
* Send the notifications
*
* @access public
* @return void
*/
public function sendNotifications()
{
if( $this->my_data['PM'] && $this->settings['report_pm_enabled'] == 1 )
{
$this->_sendPMNotifications( $this->my_data['PM'], $this->my_report_data );
}
if( $this->my_data['EMAIL'] && $this->settings['report_nemail_enabled'] == 1 )
{
$this->_sendEmailNotifications( $this->my_data['EMAIL'], $this->my_report_data );
}
$this->_buildRSSFeed( $this->my_data['RSS'], $this->my_report_data );
}
/**
* Send the PM Notifications
*
* @access private
* @return void
*/
private function _sendPMNotifications( $data, $report_data )
{
foreach( $data as $user )
{
IPSText::getTextClass( 'email' )->getTemplate("report_emailpm");
IPSText::getTextClass( 'email' )->buildMessage( array(
'MOD_NAME' => $user['name'],
'USERNAME' => $this->memberData['members_display_name'],
'LINK' => $this->registry->getClass('reportLibrary')->processUrl( $report_data['SAVED_URL'], $report_data['SEOTITLE'], $report_data['TEMPLATE'] ),
'REPORTLINK'=> $this->settings['base_url'] . 'app=core&module=reports&do=show_report&rid=' . $report_data['REPORT_INDEX'],
'REPORT' => $report_data['REPORT'],
)
);
try
{
$this->messenger = new messengerFunctions( $this->registry );
$this->messenger->sendNewPersonalTopic( $user['member_id'],
$this->memberData['member_id'],
array(),
$this->lang->words['subject_report'] . ' ' . $this->memberData['members_display_name'],
IPSText::getTextClass( 'editor' )->method == 'rte' ? nl2br(IPSText::getTextClass( 'email' )->message) : IPSText::getTextClass( 'email' )->message,
array( 'origMsgID' => 0,
'fromMsgID' => 0,
'postKey' => md5(microtime()),
'trackMsg' => 0,
'addToSentFolder' => 0,
'hideCCUser' => 0,
'forcePm' => 1,
'isSystem' => TRUE
)
);
}
catch( Exception $error )
{
$msg = $error->getMessage();
if( $msg != 'CANT_SEND_TO_SELF' )
{
$toMember = IPSMember::load( $user['member_id'], 'core' );
if ( strstr( $msg, 'BBCODE_' ) )
{
$msg = str_replace( 'BBCODE_', '', $msg );
$this->registry->output->showError( $msg, 10149 );
}
else if ( isset($this->lang->words[ 'err_' . $msg ]) )
{
$this->lang->words[ 'err_' . $msg ] = $this->lang->words[ 'err_' . $msg ];
$this->lang->words[ 'err_' . $msg ] = str_replace( '#NAMES#' , implode( ",", $this->messenger->exceptionData ), $this->lang->words[ 'err_' . $msg ] );
$this->lang->words[ 'err_' . $msg ] = str_replace( '#TONAME#' , $toMember['members_display_name'] , $this->lang->words[ 'err_' . $msg ] );
$this->lang->words[ 'err_' . $msg ] = str_replace( '#FROMNAME#', $this->memberData['members_display_name'], $this->lang->words[ 'err_' . $msg ] );
$this->registry->output->showError( 'err_' . $msg, 10150 );
}
else
{
$_msgString = $this->lang->words['err_UNKNOWN'] . ' ' . $msg;
$this->registry->output->showError( 'err_UNKNOWN', 10151 );
}
}
}
}
}
/**
* Send the PM Notifications
*
* @access private
* @return void
*/
private function _sendEmailNotifications( $data, $report_data )
{
foreach( $data as $user )
{
IPSText::getTextClass( 'email' )->getTemplate( "report_emailpm", $user['language'] );
IPSText::getTextClass( 'email' )->buildMessage( array(
'MOD_NAME' => $user['name'],
'USERNAME' => $this->memberData['members_display_name'],
'LINK' => $this->registry->getClass('reportLibrary')->processUrl($report_data['SAVED_URL'], $report_data['SEOTITLE'], $report_data['TEMPLATE'] ),
'REPORTLINK'=> $this->settings['base_url'] . 'app=core&module=reports&do=show_report&rid=' . $report_data['REPORT_INDEX'],
'REPORT' => $report_data['REPORT'],
)
);
IPSText::getTextClass( 'email' )->subject = $this->lang->words['subject_report'] . ' ' . $this->memberData['members_display_name'];
IPSText::getTextClass( 'email' )->to = $user['email'];
IPSText::getTextClass( 'email' )->sendMail();
}
}
/**
* Build a private RSS feed for the member to monitor reports
*
* @access private
* @return void
*/
private function _buildRSSFeed( $data=array(), $report_data )
{
$ids = array();
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_reports' ), 'core' );
if( is_array($data) AND count($data) )
{
foreach( $data as $user )
{
$ids[] = $user['member_id'];
}
}
if( count( $ids ) == 0 )
{
return;
}
require_once( IPS_KERNEL_PATH . 'classRss.php' );
$status = array();
$this->DB->build( array( 'select' => 'status, is_new, is_complete',
'from' => 'rc_status',
'where' => "is_new=1 OR is_complete=1",
) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if( $row['is_new'] == 1 )
{
$status['new'] = $row['status'];
}
elseif( $row['is_complete'] == 1 )
{
$status['complete'] = $row['status'];
}
}
//-----------------------------------------
// Now, we loop over each of the member ids
//-----------------------------------------
foreach( $ids as $id )
{
//-----------------------------------------
// Clear out for new RSS doc and add channel
//-----------------------------------------
$rss = new classRss();
$channel_id = $rss->createNewChannel( array( 'title' => $this->lang->words['rss_feed_title'],
'link' => $this->settings['board_url'],
'description' => $this->lang->words['reports_rss_desc'],
'pubDate' => $rss->formatDate( time() )
) );
//-----------------------------------------
// Now we need to find all open reports for
// this member
//-----------------------------------------
$this->DB->build( array(
'select' => 'i.*',
'from' => array( 'rc_reports_index' => 'i' ),
'where' => 's.is_active=1',
'add_join' => array(
array(
'from' => array( 'rc_status' => 's' ),
'where' => 's.status=i.status',
'type' => 'left',
),
array(
'select' => 'c.my_class, c.mod_group_perm',
'from' => array( 'rc_classes' => 'c' ),
'where' => 'c.com_id=i.rc_class',
'type' => 'left',
),
)
) );
$outer = $this->DB->execute();
while( $r = $this->DB->fetch($outer) )
{
//-----------------------------------------
// Fix stuff....this is hackish :(
//-----------------------------------------
if( $r['my_class'] == 'post' )
{
$r['FORUM_ID'] = $r['exdat1'];
}
//-----------------------------------------
// Found all open reports, can we access?
//-----------------------------------------
require_once( IPSLib::getAppdir('core') . '/sources/reportPlugins/' . $r['my_class'] . '.php' );
$class = $r['my_class'] . '_plugin';
$object = new $class( $this->registry );
$notify = $object->getNotificationList( IPSText::cleanPermString( $r['mod_group_perm'] ), $r );
$pass = false;
if( is_array($notify['RSS']) AND count($notify['RSS']) )
{
foreach( $notify['RSS'] as $memberAccount )
{
if( $memberAccount['mem_id'] == $id )
{
$pass = true;
break;
}
}
}
if( $pass )
{
$url = $this->registry->getClass('reportLibrary')->processUrl( str_replace( '&amp;', '&', $r['url'] ) );
$rss->addItemToChannel( $channel_id, array( 'title' => $url,
'link' => $url,
'description' => $r['title'],
'content' => $r['title'],
'pubDate' => $rss->formatDate( $r['date_updated'] )
) );
}
}
$rss->createRssDocument();
$this->DB->update( 'rc_modpref', array( 'rss_cache' => $rss->rss_document ), "mem_id=" . $id );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Notifications class for reported content
* Last Updated: $LastChangedDate: 2010-10-19 11:56:25 -0400 (Tue, 19 Oct 2010) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author Based on original "Report Center" by Luke Scott
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 6997 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class reportNotifications
{
/**#@+
* Registry objects
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Messenger object
*
* @var object
*/
protected $messenger;
/**
* Data for the members
*
* @var array
*/
public $my_data;
/**
* Data for the reported content
*
* @var array
*/
public $my_report_data;
/**
* Constructor
*
* @param object Registry object
* @return void
*/
public function __construct( ipsRegistry $registry )
{
//-----------------------------------------
// Make object
//-----------------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->lang = $this->registry->getClass('class_localization');
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'members' ) . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members' );
$this->messenger = new $classToLoad( $this->registry );
}
/**
* Initialize library
*
* @param array Member data
* @param array Reported content
* @return void
*/
public function initNotify( $data, $report_data )
{
$this->my_data = $data;
$this->my_report_data = $report_data;
}
/**
* Send the notifications
*
* @return void
*/
public function sendNotifications()
{
//-----------------------------------------
// Notifications library
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
$notifyLibrary = new $classToLoad( $this->registry );
$_memberIds = array();
foreach( $this->my_data as $_data )
{
$_memberIds[] = $_data['member_id'];
}
$_memberData = IPSMember::load( $_memberIds );
foreach( $this->my_data as $user )
{
//-----------------------------------------
// Don't send notification to self
//-----------------------------------------
if( $user['member_id'] == $this->memberData['member_id'] )
{
continue;
}
$user = array_merge( $user, $_memberData[ $user['member_id'] ] );
IPSText::getTextClass( 'email' )->getTemplate( "report_emailpm", $user['language'] );
IPSText::getTextClass( 'email' )->buildMessage( array(
'MOD_NAME' => $user['members_display_name'],
'USERNAME' => $this->memberData['members_display_name'],
'LINK' => $this->registry->getClass('reportLibrary')->processUrl( $this->my_report_data['SAVED_URL'], $this->my_report_data['SEOTITLE'], $this->my_report_data['TEMPLATE'] ),
'REPORTLINK'=> $this->settings['base_url'] . 'app=core&module=reports&do=show_report&rid=' . $this->my_report_data['REPORT_INDEX'],
'REPORT' => $this->my_report_data['REPORT'],
)
);
$_subject = sprintf(
$this->lang->words['subject_report'],
$this->registry->output->buildSEOUrl( 'showuser=' . $this->memberData['member_id'], 'public', $this->memberData['members_seo_name'], 'showuser' ),
$this->memberData['members_display_name'],
$this->settings['base_url'] . 'app=core&module=reports&do=show_report&rid=' . $this->my_report_data['REPORT_INDEX'],
$this->registry->getClass('reportLibrary')->processUrl( $this->my_report_data['SAVED_URL'], $this->my_report_data['SEOTITLE'], $this->my_report_data['TEMPLATE'] )
);
$notifyLibrary->setMember( $user );
$notifyLibrary->setFrom( $this->memberData );
$notifyLibrary->setNotificationKey( 'report_center' );
$notifyLibrary->setNotificationUrl( $this->settings['base_url'] . 'app=core&module=reports&do=show_report&rid=' . $this->my_report_data['REPORT_INDEX'] );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
$notifyLibrary->setNotificationTitle( $_subject );
try
{
$notifyLibrary->sendNotification();
}
catch( Exception $e ){}
}
$this->_buildRSSFeed( $this->my_data, $this->my_report_data );
}
/**
* Build a private RSS feed for the member to monitor reports
*
* @return void
*/
private function _buildRSSFeed( $data=array(), $report_data )
{
$ids = array();
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_reports' ), 'core' );
if( is_array($data) AND count($data) )
{
foreach( $data as $user )
{
$ids[] = intval($user['member_id']);
}
}
if( count( $ids ) == 0 )
{
return;
}
$rssClassToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classRss.php', 'classRss' );
$status = array();
$this->DB->build( array( 'select' => 'status, is_new, is_complete',
'from' => 'rc_status',
'where' => "is_new=1 OR is_complete=1",
) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if( $row['is_new'] == 1 )
{
$status['new'] = $row['status'];
}
elseif( $row['is_complete'] == 1 )
{
$status['complete'] = $row['status'];
}
}
//-----------------------------------------
// Now, we loop over each of the member ids
//-----------------------------------------
foreach( $ids as $id )
{
if( !$id )
{
continue;
}
//-----------------------------------------
// Clear out for new RSS doc and add channel
//-----------------------------------------
$rss = new $rssClassToLoad();
$channel_id = $rss->createNewChannel( array( 'title' => $this->lang->words['rss_feed_title'],
'link' => $this->settings['board_url'],
'description' => $this->lang->words['reports_rss_desc'],
'pubDate' => $rss->formatDate( time() )
) );
//-----------------------------------------
// Now we need to find all open reports for
// this member
//-----------------------------------------
$this->DB->build( array(
'select' => 'i.*',
'from' => array( 'rc_reports_index' => 'i' ),
'where' => 's.is_active=1',
'add_join' => array(
array(
'from' => array( 'rc_status' => 's' ),
'where' => 's.status=i.status',
'type' => 'left',
),
array(
'select' => 'c.my_class, c.mod_group_perm, c.app',
'from' => array( 'rc_classes' => 'c' ),
'where' => 'c.com_id=i.rc_class',
'type' => 'left',
),
)
) );
$outer = $this->DB->execute();
while( $r = $this->DB->fetch($outer) )
{
/* Deleted report plugin, skip */
if( $r['my_class'] == '' )
{
continue;
}
//-----------------------------------------
// Fix stuff....this is hackish :(
//-----------------------------------------
if( $r['my_class'] == 'post' )
{
$r['FORUM_ID'] = $r['exdat1'];
}
//-----------------------------------------
// Found all open reports, can we access?
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $r['app'] ) . '/extensions/reportPlugins/' . $r['my_class'] . '.php', $r['my_class'] . '_plugin', $r['app'] );
$object = new $classToLoad( $this->registry );
$notify = $object->getNotificationList( IPSText::cleanPermString( $r['mod_group_perm'] ), $r );
$pass = false;
if( is_array($notify['RSS']) AND count($notify['RSS']) )
{
foreach( $notify['RSS'] as $memberAccount )
{
if( $memberAccount['mem_id'] == $id )
{
$pass = true;
break;
}
}
}
if( $pass )
{
$url = $this->registry->getClass('reportLibrary')->processUrl( str_replace( '&amp;', '&', $r['url'] ) );
$rss->addItemToChannel( $channel_id, array( 'title' => $url,
'link' => $url,
'description' => $r['title'],
'content' => $r['title'],
'pubDate' => $rss->formatDate( $r['date_updated'] )
) );
}
}
$rss->createRssDocument();
$this->DB->update( 'rc_modpref', array( 'rss_cache' => $rss->rss_document ), "mem_id=" . $id );
}
}
}