Version 3.2.3

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

No files matched your search

@@ -2,9 +2,9 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Attachments
* Last Updated: $Date: 2010-11-15 11:39:10 -0500 (Mon, 15 Nov 2010) $
* Last Updated: $Date: 2011-09-09 19:44:48 -0400 (Fri, 09 Sep 2011) $
* </pre>
*
* <code>
@@ -17,13 +17,13 @@
* - no_upload_dir_perms (Upload dir is not writeable)
* </code>
*
* @author $Author: ips_terabyte $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 7185 $
* @link http://hatynka.in
* @version $Rev: 9476 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -60,14 +60,21 @@ class class_attach
*
* @var string
*/
public $attach_post_key = '';
public $attach_post_key = '';
/**
* Relationship ID
*
* @var integer
*/
public $attach_rel_id = '';
public $attach_rel_id = 0;
/**
* Relationship parent ID
*
* @var int
*/
public $attach_parent_id = 0;
/**
* Return variables
@@ -144,7 +151,7 @@ class class_attach
* CONSTRUCTOR
*
* @param object ipsRegistry reference
* @return void
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
@@ -161,7 +168,7 @@ class class_attach
/**
* Initiates class
*
* @return void
* @return @e void
*/
public function init()
{
@@ -218,7 +225,7 @@ class class_attach
* Show the attachment (or force download)
*
* @param int Attachment ID (The main attach id)
* @return void
* @return @e void
*/
public function showAttachment( $attach_id )
{
@@ -285,7 +292,7 @@ class class_attach
$file = $this->_upload_path . "/" . $attach['attach_location'];
if( file_exists( $file ) and ( $attach_cache[ $attach['attach_ext'] ]['atype_mimetype'] != "" ) )
if( is_file( $file ) and ( $attach_cache[ $attach['attach_ext'] ]['atype_mimetype'] != "" ) )
{
/* Update the "hits".. */
$this->DB->buildAndFetch( array( 'update' => 'attachments', 'set' => "attach_hits=attach_hits+1", 'where' => "attach_id={$attach_id}" ) );
@@ -360,8 +367,164 @@ class class_attach
/* No permission? */
$this->registry->getClass('output')->showError( 'no_permission_to_download', 10174, null, null, 403 );
}
}
}
/**
* Retrieve the HTML for a single attachment
*
* @param mixed Array of attachment data, or an attachment ID
* @param string Skin group to use
* @param bool Whether to wrap with the attachment block wrapper or not
* @return string Attachment HTML
*/
public function renderSingleAttachment( $attachment, $skin_name='topic', $use_wrapper=false )
{
if( is_int($attachment) )
{
$row = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'attachments', 'where' => 'attach_id=' . intval($attachment) ) );
}
else
{
$row = $attachment;
}
if( !$row['attach_id'] )
{
return '';
}
$attachtypes = $this->getAttachTypes();
$type = '';
//-----------------------------------------
// Is it an image, and are we viewing the image in the post?
//-----------------------------------------
if ( $this->settings['show_img_upload'] and $row['attach_is_image'] )
{
if ( $this->attach_settings['siu_thumb'] AND $row['attach_thumb_location'] AND $row['attach_thumb_width'] )
{
//-----------------------------------------
// Make sure we've not seen this ID
//-----------------------------------------
$row['_attach_id'] = $row['attach_id'] . '-' . str_replace( array( '.', ' ' ), "-", microtime() );
$type = 'thumb';
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->Show_attachments_img_thumb( array(
't_location' => $row['attach_thumb_location'],
't_width' => $row['attach_thumb_width'],
't_height' => $row['attach_thumb_height'],
'o_width' => $row['attach_img_width'],
'o_height' => $row['attach_img_height'],
'attach_id' => $row['attach_id'],
'_attach_id' => $row['_attach_id'],
'file_size' => IPSLib::sizeFormat( $row['attach_filesize'] ),
'attach_hits' => $row['attach_hits'],
'location' => $row['attach_file'],
'type' => $this->type,
'notinline' => 1,
'attach_rel_id' => $row['attach_rel_id']
) );
}
else
{
//-----------------------------------------
// Standard size..
//-----------------------------------------
$type = 'image';
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->Show_attachments_img( array(
'o_location' => $row['attach_location'],
'o_width' => $row['attach_img_width'],
'o_height' => $row['attach_img_height'],
'attach_id' => $row['attach_id'],
'_attach_id' => $row['_attach_id'],
'file_size' => IPSLib::sizeFormat( $row['attach_filesize'] ),
'attach_hits' => $row['attach_hits'],
'location' => $row['attach_file'],
'type' => $this->type,
'notinline' => 1,
'attach_rel_id' => $row['attach_rel_id']
) );
}
}
else
{
//-----------------------------------------
// Full attachment thingy
//-----------------------------------------
$type = 'attach';
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->Show_attachments( array (
'attach_hits' => $row['attach_hits'],
'mime_image' => $attachtypes[ $row['attach_ext'] ]['atype_img'],
'attach_file' => $row['attach_file'],
'attach_id' => $row['attach_id'],
'type' => $this->type,
'file_size' => IPSLib::sizeFormat( $row['attach_filesize'] ),
) );
}
//-----------------------------------------
// Wrap?
//-----------------------------------------
if ( $use_wrapper )
{
switch( $type )
{
case 'thumb':
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->show_attachment_title( $this->lang->words['attach_thumbs'], $tmp, 'thumb' );
break;
case 'image':
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->show_attachment_title( $this->lang->words['attach_images'], $tmp, 'image' );
break;
default:
case 'attach':
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->show_attachment_title( $this->lang->words['attach_normal'], $tmp, 'attach' );
break;
}
}
return $tmp;
}
/**
* Retrieve attachment types from cache
*
* @return @e array
*/
protected function getAttachTypes()
{
//-----------------------------------------
// Got attachment types?
//-----------------------------------------
if ( ! is_array( $this->registry->cache()->getCache('attachtypes') ) )
{
$attachtypes = array();
$this->DB->build( array( 'select' => 'atype_extension,atype_mimetype,atype_img', 'from' => 'attachments_type' ) );
$outer = $this->DB->execute();
while ( $r = $this->DB->fetch( $outer ) )
{
$attachtypes[ $r['atype_extension'] ] = $r;
}
$this->registry->cache()->updateCacheWithoutSaving( 'attachtypes', $attachtypes );
}
else
{
$attachtypes = $this->registry->cache()->getCache('attachtypes');
}
return $attachtypes;
}
/**
* Swaps the HTML for the nice attachments.
*
@@ -410,7 +573,7 @@ class class_attach
{
$returnArray[ $id ] = array( 'html' => $html, 'attachmentHtml' => '' );
preg_match_all( "#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is", $html, $match );
preg_match_all( '#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is', $html, $match );
if ( is_array( $match[0] ) and count( $match[0] ) )
{
@@ -437,27 +600,8 @@ class class_attach
if ( is_array( $rows ) AND count( $rows ) )
{
//-----------------------------------------
// Got attachment types?
//-----------------------------------------
$attachtypes = $this->getAttachTypes();
if ( ! is_array( $this->registry->cache()->getCache('attachtypes') ) )
{
$attachtypes = array();
$this->DB->build( array( 'select' => 'atype_extension,atype_mimetype,atype_img', 'from' => 'attachments_type' ) );
$outer = $this->DB->execute();
while ( $r = $this->DB->fetch( $outer ) )
{
$attachtypes[ $r['atype_extension'] ] = $r;
}
$this->registry->cache()->updateCacheWithoutSaving( 'attachtypes', $attachtypes );
}
$_seen_rows = 0;
foreach( $rows as $_attach_id => $row )
{
//-----------------------------------------
@@ -465,12 +609,6 @@ class class_attach
//-----------------------------------------
$row = $rows[ $_attach_id ];
if( $this->attach_rel_id != $row['attach_rel_id'] )
{
// Reset if we are onto a new post..
$_seen_rows = 0;
}
$this->attach_rel_id = $row['attach_rel_id'];
@@ -492,9 +630,7 @@ class class_attach
//-----------------------------------------
$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;
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->Show_attachments_img_thumb( array( 't_location' => $row['attach_thumb_location'],
't_width' => $row['attach_thumb_width'],
't_height' => $row['attach_thumb_height'],
@@ -506,7 +642,6 @@ class class_attach
'attach_hits' => $row['attach_hits'],
'location' => $row['attach_file'],
'type' => $this->type,
'notinline' => $not_inline,
'attach_rel_id' => $row['attach_rel_id']
) );
@@ -527,24 +662,15 @@ class class_attach
'row' => $row,
'skin_name' => $skin_name );
$returnArray[ $_rel_id ]['html'] = preg_replace_callback( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", array( &$this, '_parseThumbnailInline' ), $returnArray[ $_rel_id ]['html'] );
$returnArray[ $_rel_id ]['html'] = preg_replace_callback( '#\[attachment='.$row['attach_id'].'\:(?:[^\]]+?)[\n|\]]#is', array( &$this, '_parseThumbnailInline' ), $returnArray[ $_rel_id ]['html'] );
}
else if ( $_count )
{
# Just the one, then?
$returnArray[ $_rel_id ]['html'] = preg_replace( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", $tmp, $returnArray[ $_rel_id ]['html'] );
$returnArray[ $_rel_id ]['html'] = preg_replace( '#\[attachment='.$row['attach_id'].'\:(?:[^\]]+?)[\n|\]]#is', $tmp, $returnArray[ $_rel_id ]['html'] );
}
else
{
# None. :(
$_seen++;
if ( $_seen == $this->settings['topic_attach_no_per_row'] )
{
$tmp .= "\n<br />\n";
$_seen = 0;
}
$final_blocks[ $_rel_id ]['thumb'][] = $tmp;
}
}
@@ -560,7 +686,19 @@ class class_attach
// Standard size..
//-----------------------------------------
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->Show_attachments_img( $row['attach_location'] );
$tmp = $this->registry->getClass('output')->getTemplate( $skin_name )->Show_attachments_img( array(
'o_location' => $row['attach_location'],
'o_width' => $row['attach_img_width'],
'o_height' => $row['attach_img_height'],
'attach_id' => $row['attach_id'],
'_attach_id' => $row['_attach_id'],
'file_size' => IPSLib::sizeFormat( $row['attach_filesize'] ),
'attach_hits' => $row['attach_hits'],
'location' => $row['attach_file'],
'type' => $this->type,
'notinline' => 1,
'attach_rel_id' => $row['attach_rel_id']
) );
if ( is_array( $map_attach_id_to_rel_id[ $_attach_id ] ) AND count( $map_attach_id_to_rel_id[ $_attach_id ] ) )
{
@@ -568,7 +706,7 @@ class class_attach
{
if ( strstr( $htmlArray[ $_rel_id ], '[attachment='.$row['attach_id'].':' ) )
{
$returnArray[ $_rel_id ]['html'] = preg_replace( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", $tmp, $returnArray[ $_rel_id ]['html'] );
$returnArray[ $_rel_id ]['html'] = preg_replace( '#\[attachment='.$row['attach_id'].'\:(?:[^\]]+?)[\n|\]]#is', $tmp, $returnArray[ $_rel_id ]['html'] );
}
else
{
@@ -604,7 +742,7 @@ class class_attach
{
if ( strstr( $htmlArray[ $_rel_id ], '[attachment='.$row['attach_id'].':' ) )
{
$returnArray[ $_rel_id ]['html'] = preg_replace( "#\[attachment=".$row['attach_id']."\:(?:[^\]]+?)[\n|\]]#is", $tmp, $returnArray[ $_rel_id ]['html'] );
$returnArray[ $_rel_id ]['html'] = preg_replace( '#\[attachment='.$row['attach_id'].'\:(?:[^\]]+?)[\n|\]]#is', $tmp, $returnArray[ $_rel_id ]['html'] );
}
else
{
@@ -722,7 +860,7 @@ class class_attach
/**
* Removes an attachment.
*
* @return void
* @return @e void
*/
public function removeAttachment()
{
@@ -758,8 +896,7 @@ class class_attach
// Remove from the DB
//-----------------------------------------
$this->DB->buildAndFetch( array( 'delete' => 'attachments',
'where' => 'attach_id='.$attachment['attach_id'] ) );
$this->DB->delete( 'attachments', 'attach_id='.$attachment['attach_id'] );
//-----------------------------------------
// Remove from the filesystem
@@ -806,8 +943,9 @@ class class_attach
// Got any to update?
//-----------------------------------------
$this->DB->update( 'attachments', array( 'attach_rel_id' => $this->attach_rel_id,
'attach_rel_module' => $this->type ), "attach_post_key='{$this->attach_post_key}'" );
$this->DB->update( 'attachments', array( 'attach_rel_id' => $this->attach_rel_id,
'attach_parent_id' => intval($this->attach_parent_id),
'attach_rel_module' => $this->type ), "attach_post_key='{$this->attach_post_key}'" );
//-----------------------------------------
// Update module specific?
@@ -843,6 +981,16 @@ class class_attach
}
}
//-----------------------------------------
// Can upload?
//-----------------------------------------
if ( ! $this->attach_stats['allow_uploads'] )
{
$this->error = 'upload_failed';
return;
}
//-----------------------------------------
// Got attachment types?
//-----------------------------------------
@@ -852,9 +1000,9 @@ class class_attach
$attachtypes = array();
$this->DB->build( array(
'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img',
'from' => 'attachments_type',
'where' => "atype_photo=1 OR atype_post=1"
'select' => 'atype_extension,atype_mimetype,atype_post,atype_img',
'from' => 'attachments_type',
'where' => "atype_post=1"
) );
$this->DB->execute();
@@ -865,16 +1013,6 @@ class class_attach
$this->registry->cache()->updateCacheWithoutSaving( 'attachtypes', $attachtypes );
}
//-----------------------------------------
// Can upload?
//-----------------------------------------
if ( ! $this->attach_stats['allow_uploads'] )
{
$this->error = 'upload_failed';
return;
}
//-----------------------------------------
// Set up array
@@ -898,7 +1036,7 @@ class class_attach
// Load the library
//-----------------------------------------
require_once( IPS_KERNEL_PATH.'classUpload.php' );
require_once( IPS_KERNEL_PATH.'classUpload.php' );/*noLibHook*/
$upload = new classUpload();
//-----------------------------------------
@@ -974,7 +1112,7 @@ class class_attach
// Still here?
//-----------------------------------------
if ( $upload->saved_upload_name and @file_exists( $upload->saved_upload_name ) )
if ( $upload->saved_upload_name and @is_file( $upload->saved_upload_name ) )
{
//-----------------------------------------
// Strip off { } and [ ]
@@ -999,30 +1137,66 @@ class class_attach
if ( $attach_data['attach_is_image'] == 1 )
{
require_once( IPS_KERNEL_PATH."classImage.php" );
require_once( IPS_KERNEL_PATH."classImageGd.php" );
require_once( IPS_KERNEL_PATH . 'classImage.php' );/*noLibHook*/
require_once( IPS_KERNEL_PATH . 'classImageGd.php' );/*noLibHook*/
/* Main attachment */
if ( ! empty( $this->settings['attach_img_max_w'] ) AND ! empty( $this->settings['attach_img_max_h'] ) )
{
$image = new classImageGd();
$image->init( array( 'image_path' => $this->upload_path,
'image_file' => $upload->parsed_file_name ) );
$image->force_resize = false;
if ( $imgData = $image->resizeImage( $this->settings['attach_img_max_w'], $this->settings['attach_img_max_h'], false, true ) )
{
if( !$imgData['noResize'] )
{
$image->writeImage( $this->upload_path . '/' . $upload->parsed_file_name );
}
if ( is_array( $imgData ) )
{
$attach_data['attach_img_width'] = $imgData['newWidth'];
$attach_data['attach_img_height'] = $imgData['newHeight'];
}
}
}
/* Thumb nail */
$image = new classImageGd();
$image->force_resize = true;
$image->init( array(
'image_path' => $this->upload_path,
'image_file' => $upload->parsed_file_name,
) );
$image->init( array( 'image_path' => $this->upload_path,
'image_file' => $upload->parsed_file_name ) );
if ( $this->attach_settings['siu_thumb'] )
{
$_thumbName = preg_replace( "#^(.*)\.(\w+?)$#", "\\1_thumb.\\2", $upload->parsed_file_name );
if( $thumb_data = $image->resizeImage( $this->attach_settings['siu_width'], $this->attach_settings['siu_height'] ) )
if( $this->attach_settings['siu_width'] < $attach_data['attach_img_width'] OR $this->attach_settings['siu_height'] < $attach_data['attach_img_height'] )
{
$image->writeImage( $this->upload_path . '/' . $_thumbName );
$_thumbName = preg_replace( '#^(.*)\.(\w+?)$#', "\\1_thumb.\\2", $upload->parsed_file_name );
if ( is_array( $thumb_data ) )
if( $thumb_data = $image->resizeImage( $this->attach_settings['siu_width'], $this->attach_settings['siu_height'] ) )
{
$thumb_data['thumb_location'] = $_thumbName;
$image->writeImage( $this->upload_path . '/' . $_thumbName );
if ( is_array( $thumb_data ) )
{
$thumb_data['thumb_location'] = $_thumbName;
}
}
}
else
{
/* Instead of building a thumb the same size as the main image, just copy the details */
$thumb_data = array(
'thumb_location' => $upload->parsed_file_name,
'newWidth' => $attach_data['attach_img_width'],
'newHeight' => $attach_data['attach_img_height'],
);
}
}
if ( $thumb_data['thumb_location'] )
@@ -1032,9 +1206,19 @@ class class_attach
$attach_data['attach_thumb_width'] = $thumb_data['newWidth'];
$attach_data['attach_thumb_height'] = $thumb_data['newHeight'];
$attach_data['attach_thumb_location'] = $this->upload_dir . $thumb_data['thumb_location'];
}
}
}
//-----------------------------------------
// Make sure we send integers
// @link http://community.invisionpower.com/tracker/issue-32511-attachments-mysql-strict-mode
//-----------------------------------------
$attach_data['attach_img_width'] = intval( $attach_data['attach_img_width'] );
$attach_data['attach_img_height'] = intval( $attach_data['attach_img_height'] );
$attach_data['attach_thumb_width'] = intval( $attach_data['attach_thumb_width'] );
$attach_data['attach_thumb_height'] = intval( $attach_data['attach_thumb_height'] );
//-----------------------------------------
// Add into Database
//-----------------------------------------
@@ -1080,10 +1264,9 @@ class class_attach
{
$attachtypes = array();
$this->DB->build( array(
'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img',
'from' => 'attachments_type',
'where' => "atype_photo=1 OR atype_post=1"
$this->DB->build( array('select' => 'atype_extension,atype_mimetype,atype_post,atype_img',
'from' => 'attachments_type',
'where' => "atype_post=1"
) );
$this->DB->execute();
@@ -1096,7 +1279,7 @@ class class_attach
}
/* Attachment Library */
require_once( IPS_KERNEL_PATH.'classUpload.php' );
require_once( IPS_KERNEL_PATH . 'classUpload.php' );/*noLibHook*/
$upload = new classUpload();
/* Set up the library */
@@ -1188,7 +1371,7 @@ class class_attach
}
/* Still Here */
if( $upload->saved_upload_name and @file_exists( $upload->saved_upload_name ) )
if( $upload->saved_upload_name and @is_file( $upload->saved_upload_name ) )
{
/* Strip off { } and [ ] */
$upload->original_file_name = str_replace( array( '[', ']', '{', '}' ), "", $upload->original_file_name );
@@ -1199,24 +1382,50 @@ class class_attach
$attach_data['attach_is_image'] = $upload->is_image;
$attach_data['attach_ext'] = $upload->real_file_extension;
if( $attach_data['attach_is_image'] == 1 )
if ( $attach_data['attach_is_image'] == 1 )
{
require_once( IPS_KERNEL_PATH."classImage.php" );
require_once( IPS_KERNEL_PATH."classImageGd.php" );
require_once( IPS_KERNEL_PATH . 'classImage.php' );/*noLibHook*/
require_once( IPS_KERNEL_PATH . 'classImageGd.php' );/*noLibHook*/
/* Main attachment */
if ( ! empty( $this->settings['attach_img_max_w'] ) AND ! empty( $this->settings['attach_img_max_h'] ) )
{
$image = new classImageGd();
$image->init( array( 'image_path' => $this->upload_path,
'image_file' => $upload->parsed_file_name ) );
if ( $imgData = $image->resizeImage( $this->settings['attach_img_max_w'], $this->settings['attach_img_max_h'] ) )
{
$image->writeImage( $this->upload_path . '/' . $upload->parsed_file_name );
if ( is_array( $imgData ) )
{
$attach_data['attach_img_width'] = $imgData['newWidth'];
$attach_data['attach_img_height'] = $imgData['newHeight'];
}
}
}
/* Thumb nail */
$image = new classImageGd();
$image->force_resize = true;
$image->init( array( 'image_path' => $this->upload_path, 'image_file' => $upload->parsed_file_name ) );
$image->init( array( 'image_path' => $this->upload_path,
'image_file' => $upload->parsed_file_name ) );
if ( $this->attach_settings['siu_thumb'] )
{
$_thumbName = preg_replace( "#^(.*)\.(\w+?)$#", "\\1_thumb.\\2", $upload->parsed_file_name );
$thumb_data = $image->resizeImage( $this->attach_settings['siu_width'], $this->attach_settings['siu_height'] );
$image->writeImage( $this->upload_path . '/' . $_thumbName );
$_thumbName = preg_replace( '#^(.*)\.(\w+?)$#', "\\1_thumb.\\2", $upload->parsed_file_name );
if ( is_array( $thumb_data ) )
if( $thumb_data = $image->resizeImage( $this->attach_settings['siu_width'], $this->attach_settings['siu_height'] ) )
{
$thumb_data['thumb_location'] = $_thumbName;
$image->writeImage( $this->upload_path . '/' . $_thumbName );
if ( is_array( $thumb_data ) )
{
$thumb_data['thumb_location'] = $_thumbName;
}
}
}
@@ -1229,7 +1438,7 @@ class class_attach
$attach_data['attach_thumb_location'] = $this->upload_dir . $thumb_data['thumb_location'];
}
}
/* Add into Database */
$this->DB->insert( 'attachments', $attach_data );
@@ -1244,7 +1453,7 @@ class class_attach
/**
* Gets stuff required for the upload form
*
* @return void
* @return @e void
*/
public function getUploadFormSettings()
{
@@ -1275,19 +1484,19 @@ class class_attach
/* Unlimited... */
$this->attach_stats['allow_uploads'] = 1;
$this->attach_stats['space_allowed'] = 'unlimited';
$this->attach_stats['space_allowed_human'] = $this->language[ 'unlimited' ];
$this->attach_stats['space_allowed_human'] = $this->language['unlimited'];
$this->attach_stats['space_left'] = 'unlimited';
$this->attach_stats['space_left_human'] = $this->language[ 'unlimited' ];
$this->attach_stats['total_space_allowed_human'] = $this->language[ 'unlimited' ];
$this->attach_stats['space_left_human'] = $this->language['unlimited'];
$this->attach_stats['total_space_allowed_human'] = $this->language['unlimited'];
}
else if ( $stats['space_allowed'] == -1 )
{
/* None */
$this->attach_stats['allow_uploads'] = 0;
$this->attach_stats['space_allowed'] = 'not_allowed';
$this->attach_stats['space_allowed_human'] = $this->language[ 'not_allowed' ];
$this->attach_stats['space_allowed_human'] = $this->language['not_allowed'];
$this->attach_stats['space_left'] = 'not_allowed';
$this->attach_stats['space_left_human'] = $this->language[ 'not_allowed' ];
$this->attach_stats['space_left_human'] = $this->language['not_allowed'];
}
else
{
@@ -1308,10 +1517,10 @@ class class_attach
/* Check dir exists... */
if( ! file_exists( $this->upload_path ) )
{
if( @mkdir( $this->upload_path, 0777 ) )
if( @mkdir( $this->upload_path, IPS_FOLDER_PERMISSION ) )
{
@file_put_contents( $this->upload_path . '/index.html', '' );
@chmod( $this->upload_path, 0777 );
@chmod( $this->upload_path, IPS_FOLDER_PERMISSION );
}
else
{
@@ -1335,10 +1544,10 @@ class class_attach
if( ! file_exists( $path ) )
{
if( @mkdir( $path, 0777 ) )
if( @mkdir( $path, IPS_FOLDER_PERMISSION ) )
{
@file_put_contents( $path . '/index.html', '' );
@chmod( $path, 0777 );
@chmod( $path, IPS_FOLDER_PERMISSION );
# Set path and dir correct
$this->upload_path .= '/' . $this_month;
@@ -1366,8 +1575,7 @@ class class_attach
/**
* Loads child extends class.
*
* @return void
* @todo Should we add a check here in the foreach to see if the application is enabled?
* @return @e void
*/
public function loadAttachmentPlugin()
{
@@ -1378,9 +1586,9 @@ class class_attach
if( ! is_object( $this->plugin ) && $this->type )
{
/* Load... */
foreach( ipsRegistry::$applications as $app )
foreach( IPSLIb::getEnabledApplications() as $app )
{
if( file_exists( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/attachments/plugin_' . $this->type . '.php' ) )
if( is_file( 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 );
@@ -1406,7 +1614,7 @@ class class_attach
* @param array Array of matches from preg_replace_callback
* @return string HTML
*/
private function _parseThumbnailInline( $matches )
protected function _parseThumbnailInline( $matches )
{
//-----------------------------------------
// INIT
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -2,28 +2,36 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* 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) $
* Last Updated: $Date: 2011-06-10 13:49:21 -0400 (Fri, 10 Jun 2011) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @link http://www.invisionpower.com
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 5713 $
* @version $Revision: 9029 $
*/
class core_hookGateway
{
/**#@+
* Registry objects
/**
* Registry Object Shortcuts
*
* @var object
*/
* @var $registry
* @var $DB
* @var $settings
* @var $request
* @var $lang
* @var $member
* @var $memberData
* @var $cache
* @var $caches
*/
protected $registry;
protected $DB;
protected $settings;
@@ -33,13 +41,12 @@ class core_hookGateway
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Method constructor
*
* @param object Registry Object
* @return void
* @return @e void
*/
function __construct( ipsRegistry $registry )
{
@@ -55,131 +62,4 @@ class core_hookGateway
$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 );
}
}
}
}
}
}
}
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -2,18 +2,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Library of shared methods for hooks installation/configuration
* Last Updated: $LastChangedDate: 2010-10-14 13:15:13 -0400 (Thu, 14 Oct 2010) $
* Last Updated: $LastChangedDate: 2011-07-22 06:21:22 -0400 (Fri, 22 Jul 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 6980 $
* @link http://hatynka.in
* @version $Rev: 9303 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -24,11 +24,19 @@ if ( ! defined( 'IN_IPB' ) )
class hooksFunctions
{
/**#@+
* Registry objects
/**
* Registry Object Shortcuts
*
* @var object
*/
* @var $registry
* @var $DB
* @var $settings
* @var $request
* @var $lang
* @var $member
* @var $memberData
* @var $cache
* @var $caches
*/
protected $registry;
protected $DB;
protected $settings;
@@ -38,13 +46,12 @@ class hooksFunctions
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @param object Registry object
* @return void
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
@@ -62,7 +69,7 @@ class hooksFunctions
$this->caches =& $this->registry->cache()->fetchCaches();
$this->lang = $this->registry->class_localization;
$this->lang->loadLanguageFile( array( 'admin_applications' ) );
$this->lang->loadLanguageFile( array( 'admin_applications' ), 'core' );
}
/**
@@ -79,20 +86,17 @@ class hooksFunctions
return array();
}
$type = $type ? $type : 'foreach';
$return = array( array( 0, $this->lang->words['h_selectid'] ) );
$seenids = array();
$presort = array();
$type = $type ? $type : 'foreach';
$return = 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->build( array( 'select' => 'template_content', 'from' => 'skin_templates', 'where' => "template_set_id=0 AND template_name='{$template}'" ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
/* Use regex to try to find the ids */
$matches = array();
$matches = array();
if( $type == 'foreach' )
{
@@ -100,25 +104,23 @@ class hooksFunctions
}
else
{
preg_match_all( "#\<if\s+test=\"(.+?)\:\|\:(.+?)\"\>#i", $r['template_content'], $matches );
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 );
$return[ $match ] = array( $match, $match );
}
}
}
/* Put the ids in alphabetical order, kinda hacky, oh well ;) */
ksort( $presort );
foreach( $presort as $k => $v )
{
$return[$k] = $v;
}
ksort( $return );
array_unshift( $return, array( 0, $this->lang->words['h_selectid'] ) );
return $return;
}
@@ -176,7 +178,7 @@ class hooksFunctions
public function getCSSFiles()
{
/* Query CSS Files */
$this->DB->build( array( 'select' => '*', 'from' => 'skin_css', 'order' => 'css_set_id ASC' ) );
$this->DB->build( array( 'select' => $this->DB->buildDistinct('css_group'), 'from' => 'skin_css', 'order' => 'css_group ASC' ) );
$this->DB->execute();
/* Loop through CSS Files and add to array */
@@ -184,7 +186,7 @@ class hooksFunctions
while( $r = $this->DB->fetch() )
{
$cssFiles[] = array( $r['css_id'], $r['css_set_id'] . ': ' . $r['css_group'] );
$cssFiles[] = array( $r['css_group'], $r['css_group'] );
}
return $cssFiles;
@@ -199,12 +201,12 @@ class hooksFunctions
{
$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->build( array( 'select' => 'conf_title_keyword, 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[] = array( $r['conf_title_keyword'], $r['conf_title_title'] );
}
return $return;
@@ -219,12 +221,12 @@ class hooksFunctions
{
$return = array();
$this->DB->build( array( 'select' => 'conf_id, conf_title', 'from' => 'core_sys_conf_settings', 'order' => 'conf_title ASC' ) );
$this->DB->build( array( 'select' => 'conf_key, 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[] = array( $r['conf_key'], $r['conf_title'] );
}
return $return;
@@ -259,7 +261,7 @@ class hooksFunctions
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'] );
$prefix = $r['sys_module_admin'] ? 'admin' : 'public';
$return[] = array( $prefix.'-'.$r['sys_module_application'].'-'.$r['sys_module_key'], $r['app_title'] . ':: ' . $r['sys_module_title'] . $admin );
}
@@ -281,7 +283,7 @@ class hooksFunctions
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['id'], $r['title'] );
$return[] = array( $r['title'], $r['title'] );
}
return $return;
@@ -296,12 +298,12 @@ class hooksFunctions
{
$return = array();
$this->DB->build( array( 'select' => 'task_id, task_title', 'from' => 'task_manager', 'order' => 'task_title ASC' ) );
$this->DB->build( array( 'select' => 'task_key, 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[] = array( $r['task_key'], $r['task_title'] );
}
return $return;
@@ -321,7 +323,7 @@ class hooksFunctions
while( $r = $this->DB->fetch() )
{
$return[] = array( $r['word_app'].'_'.$r['word_pack'], $r['word_app'].'_'.$r['word_pack'] );
$return[] = array( $r['word_app'] . '_' . $r['word_pack'], $r['word_app'] . '_' . $r['word_pack'] );
}
return $return;
@@ -340,11 +342,10 @@ class hooksFunctions
return array();
}
$bits = explode( '_', $file );
$app = $bits[0];
$pack = str_replace( $app.'_', '', $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();
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -2,19 +2,19 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Library for reported content
* Last Updated: $LastChangedDate: 2010-10-19 11:56:25 -0400 (Tue, 19 Oct 2010) $
* Last Updated: $LastChangedDate: 2011-08-19 20:27:50 -0400 (Fri, 19 Aug 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: bfarber $
* @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
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 6997 $
* @link http://hatynka.in
* @version $Rev: 9401 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -25,19 +25,28 @@ if ( ! defined( 'IN_IPB' ) )
class reportLibrary
{
/**#@+
* Registry objects
/**
* Registry Object Shortcuts
*
* @var object
*/
* @var $registry
* @var $DB
* @var $settings
* @var $request
* @var $lang
* @var $member
* @var $memberData
* @var $cache
* @var $caches
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
/**#@-*/
protected $caches;
/**
* Group Ids
@@ -84,8 +93,8 @@ class reportLibrary
/**
* Constructor
*
* @param object Registry object
* @return void
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
@@ -105,6 +114,62 @@ class reportLibrary
$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('') );
}
/**
* Recache report center plugins
*
* @return @e void
*/
public function rebuildReportCache()
{
$_classes = array();
$this->DB->build( array( 'select' => '*', 'from' => 'rc_classes', 'where' => 'onoff=1' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
if( IPSLib::appIsInstalled( $r['app'] ) )
{
$_classes[ $r['my_class'] ] = $r;
}
}
$this->cache->setCache( 'report_plugins' , $_classes, array( 'array' => 1 ) );
}
/**
* Returns the correct status icon / flag to display for a report row
*
* @param array Report Row
* @return string
*/
public function buildStatusIcon( $row )
{
$this->buildStatuses( true );
//-----------------------------------------
// Pick the right flag.. or else!
//-----------------------------------------
$row['img'] = str_replace( '<#IMG_DIR#>', $this->registry->output->skin['set_image_dir'], $this->flag_cache[ $row['status'] ][ $row['points'] ]['img'] );
$row['width'] = $this->flag_cache[ $row['status'] ][ $row['points'] ]['width'];
$row['height'] = $this->flag_cache[ $row['status'] ][ $row['points'] ]['height'];
$row['is_png'] = $this->flag_cache[ $row['status'] ][ $row['points'] ]['is_png'];
//-----------------------------------------
// Image? PNG? Using 'Is-Evil' machine?
//-----------------------------------------
if( $row['img'] != '' )
{
return $this->registry->getClass('output')->getTemplate('reports')->statusIcon( $row['img'], $row['width'], $row['height'] );
}
else
{
return '&nbsp;';
}
}
/**
* Rebuild the member cache array if it is outdated
@@ -147,7 +212,7 @@ class reportLibrary
'where' => 'stat.status=rep.status'
),
array(
'select' => 'rcl.com_id, rcl.com_id, rcl.my_class, rcl.extra_data',
'select' => 'rcl.com_id, rcl.com_id, rcl.my_class, rcl.extra_data, rcl.app',
'from' => array( 'rc_classes' => 'rcl' ),
'where' => 'rcl.com_id=rep.rc_class'
),
@@ -168,10 +233,13 @@ class reportLibrary
foreach( $reports_by_plugin as $app => $plugins )
{
foreach( $plugins as $plugin_name => $reports_array )
if( IPSLib::appIsInstalled( $app ) )
{
$this->loadPlugin( $plugin_name, $app );
$this->plugins[ $plugin_name ]->updateReportsTimestamp( $reports_array, $build_member_cache_array );
foreach( $plugins as $plugin_name => $reports_array )
{
$this->loadPlugin( $plugin_name, $app );
$this->plugins[ $plugin_name ]->updateReportsTimestamp( $reports_array, $build_member_cache_array );
}
}
}
@@ -182,7 +250,7 @@ class reportLibrary
{
IPSMember::packMemberCache( $this->memberData['member_id'], $build_member_cache_array );
}
return $total['reports'];
}
@@ -211,52 +279,73 @@ class reportLibrary
// 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 ) )
foreach( $this->cache->getCache('report_plugins') as $_className => $row )
{
if( $row['my_class'] != '' )
if( !IPSMember::isInGroup( $this->memberData, explode( ',', IPSText::cleanPermString( $row[ $col ] ) ) ) )
{
$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();
}
continue;
}
if( $this->plugins[ $row['my_class'] ]->getReportPermissions( $check, $row, $this->member_group_ids, $spec_perm ) )
{
$cids[ $row['com_id'] ] = $spec_perm;
}
$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 ) );
}
/**
* Check permissions for "can report"
*
* @param string $className Report center class name
* @return @e bool
*/
public function canReport( $className )
{
if( !$this->caches['report_plugins'][ $className ]['com_id'] )
{
return false;
}
if( IPSMember::isInGroup( $this->memberData, explode( ',', IPSText::cleanPermString( $this->caches['report_plugins'][ $className ]['group_can_report'] ) ) ) )
{
return true;
}
return false;
}
/**
* Loads plugins into $this->plugins object for later use
*
* @param string plugin name (>name<.php)
* @return void
* @param string $plugin_name plugin name (>name<.php)
* @param string $app App name
* @return @e void
*/
public function loadPlugin( $plugin_name, $app )
{
if( ! $this->plugins[ $plugin_name ] )
{
if( file_exists( IPSLib::getAppDir( $app ) . '/extensions/reportPlugins/' . $plugin_name . '.php' ) )
if( IPSLib::appIsInstalled( $app ) AND is_file( IPSLib::getAppDir( $app ) . '/extensions/reportPlugins/' . $plugin_name . '.php' ) )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/reportPlugins/' . $plugin_name . '.php', $plugin_name . '_plugin', $app );
@@ -291,7 +380,7 @@ class reportLibrary
/**
* Fixes the member's RSS Key if none set
*
* @return void
* @return @e void
*/
public function checkMemberRSSKey()
{
@@ -345,7 +434,7 @@ class reportLibrary
/**
* Updates global 'cache time' which forces 'mod caches' to re-cache
*
* @return void
* @return @e void
*/
public function updateCacheTime()
{
@@ -2,19 +2,19 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Notifications class for reported content
* Last Updated: $LastChangedDate: 2010-10-19 11:56:25 -0400 (Tue, 19 Oct 2010) $
* Last Updated: $LastChangedDate: 2011-09-30 05:21:05 -0400 (Fri, 30 Sep 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: mmecham $
* @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
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 6997 $
* @link http://hatynka.in
* @version $Rev: 9571 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -25,19 +25,28 @@ if ( ! defined( 'IN_IPB' ) )
class reportNotifications
{
/**#@+
* Registry objects
/**
* Registry Object Shortcuts
*
* @var object
*/
* @var $registry
* @var $DB
* @var $settings
* @var $request
* @var $lang
* @var $member
* @var $memberData
* @var $cache
* @var $caches
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
/**#@-*/
protected $caches;
/**
* Messenger object
@@ -63,8 +72,8 @@ class reportNotifications
/**
* Constructor
*
* @param object Registry object
* @return void
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
@@ -91,7 +100,7 @@ class reportNotifications
*
* @param array Member data
* @param array Reported content
* @return void
* @return @e void
*/
public function initNotify( $data, $report_data )
{
@@ -99,10 +108,82 @@ class reportNotifications
$this->my_report_data = $report_data;
}
/**
* Send the notifications for comments/replies to a report
*
* @param string $comment Comment string
* @return @e void
*/
public function sendReplyNotifications( $postContent )
{
//-----------------------------------------
// 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_reply", $user['language'] );
IPSText::getTextClass( 'email' )->buildMessage( array(
'MOD_NAME' => $user['members_display_name'],
'COMMENTER' => $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'],
'COMMENT' => $postContent,
)
);
$_subject = sprintf(
$this->lang->words['subject_reportreply'],
$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 );
}
/**
* Send the notifications
*
* @return void
* @return @e void
*/
public function sendNotifications()
{
@@ -173,13 +254,15 @@ class reportNotifications
/**
* Build a private RSS feed for the member to monitor reports
*
* @return void
* @return @e void
*/
private function _buildRSSFeed( $data=array(), $report_data )
protected function _buildRSSFeed( $data=array(), $report_data )
{
$ids = array();
//-----------------------------------------
// Check member ids
//-----------------------------------------
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_reports' ), 'core' );
$ids = array();
if( is_array($data) AND count($data) )
{
@@ -194,13 +277,24 @@ class reportNotifications
return;
}
//-----------------------------------------
// Init
//-----------------------------------------
$rssClassToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classRss.php', 'classRss' );
$status = array();
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_reports' ), 'core' );
//-----------------------------------------
// Get status data
//-----------------------------------------
$status = array();
$active = array( 0 );
$this->DB->build( array( 'select' => 'status, is_new, is_complete',
'from' => 'rc_status',
'where' => "is_new=1 OR is_complete=1",
'from' => 'rc_status',
'where' => "is_new=1 OR is_complete=1 OR is_active=1",
) );
$this->DB->execute();
@@ -214,6 +308,69 @@ class reportNotifications
{
$status['complete'] = $row['status'];
}
if( $row['is_active'] )
{
$active[] = $row['status'];
}
}
//-----------------------------------------
// Now we need to find all open reports
//-----------------------------------------
$_reports = array();
$this->DB->build( array(
'select' => 'i.*',
'from' => array( 'rc_reports_index' => 'i' ),
'where' => 'i.status IN(' . implode( ',', $active ) . ')',
'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) )
{
//-----------------------------------------
// Skip deleted plugins
//-----------------------------------------
if( $r['my_class'] == '' )
{
continue;
}
//-----------------------------------------
// Fix stuff....this is hackish :(
//-----------------------------------------
if( $r['my_class'] == 'post' )
{
$r['FORUM_ID'] = $r['exdat1'];
}
//-----------------------------------------
// Get notify list
//-----------------------------------------
$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 );
$_reports[] = array( 'data' => $r, 'notify' => $notify );
}
//-----------------------------------------
@@ -231,93 +388,52 @@ class reportNotifications
// Clear out for new RSS doc and add channel
//-----------------------------------------
$rss = new $rssClassToLoad();
$channel_id = $rss->createNewChannel( array( 'title' => $this->lang->words['rss_feed_title'],
$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
// What reports can we access?
//-----------------------------------------
$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) )
if( count($_reports) )
{
/* Deleted report plugin, skip */
if( $r['my_class'] == '' )
foreach( $_reports as $_report )
{
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 )
$pass = false;
if( is_array($_report['notify']) AND count($_report['notify']) )
{
if( $memberAccount['mem_id'] == $id )
foreach( $_report['notify'] as $memberAccount )
{
$pass = true;
break;
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'] )
) );
if( $pass )
{
$url = $this->registry->getClass('reportLibrary')->processUrl( str_replace( '&amp;', '&', $_report['data']['url'] ) );
$rss->addItemToChannel( $channel_id, array( 'title' => $url,
'link' => $url,
'description' => $_report['data']['title'],
'content' => $_report['data']['title'],
'pubDate' => $rss->formatDate( $_report['data']['date_updated'] )
) );
}
}
}
$rss->createRssDocument();
$this->DB->update( 'rc_modpref', array( 'rss_cache' => $rss->rss_document ), "mem_id=" . $id );
$this->DB->replace( 'rc_modpref', array( 'rss_cache' => $rss->rss_document ), "mem_id=" . $id, array( 'mem_id' ) );
}
}
}