Version 3.0.5

This commit is contained in:
Neo committed 2025-12-19 00:31:03 -08:00
1 parent 19b38c7c74
commit 1d4720f3e2
3755 files changed
+508378 -664541

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1 @@
<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>␍
@@ -0,0 +1,465 @@
<?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;
}
}
@@ -0,0 +1,456 @@
<?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;
}
}
@@ -0,0 +1,548 @@
<?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;
}
}
@@ -0,0 +1,700 @@
<?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,345 @@
<?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;
}
}
@@ -0,0 +1 @@
<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>␍
@@ -0,0 +1,431 @@
<?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;
}
}
@@ -0,0 +1,370 @@
<?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 );
}
}
}
@@ -0,0 +1 @@
<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>␍
@@ -0,0 +1,558 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Blog plugin
* Last Updated: $LastChangedDate: 2009-11-18 03:40:19 -0500 (Wed, 18 Nov 2009) $
*
* @author $Author: matt $
* @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 IP.Blog
* @link http://www.iinvisionpower.com
* @version $Rev: 5428 $
*/
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 blog_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* Blog dat
*
* @access private
* @var array Data about the blog
*/
public $blog;
/**
* Entry data
*
* @access private
* @var array Data about the entry
*/
public $entry;
/**
* 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;
/* Load the language */
$registry->class_localization->loadLanguageFile( array( 'public_blog' ), 'blog' );
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
return $html->addRow( $this->lang->words['r_supermod'],
sprintf( $this->lang->words['r_supermod_info'], $this->settings['_base_url'] ),
$this->registry->output->formYesNo('report_supermod', (!isset( $plugin_data['report_supermod'] )) ? 1 : $plugin_data['report_supermod'] )
);
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
$save_data_array['report_supermod'] = intval($this->request['report_supermod']);
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if ( ! IPSLib::appIsInstalled('blog') )
{
return false;
}
if( $this->memberData['g_is_supmod'] == 1 && ( ! isset($this->_extra['report_supermod']) || $this->_extra['report_supermod'] == 1 ) )
{
return true;
}
else
{
$this->DB->build( array(
'select' => 'md.moderate_type, md.moderate_mg_id',
'from' => array('blog_moderators' => 'md'),
'add_join' => array(
array(
'select' => 'm.member_id, m.name, m.email, m.member_group_id',
'from' => array( 'members' => 'm' ),
'where' => "(md.moderate_type='member' AND md.moderate_mg_id={$this->memberData['member_id']}) OR (md.moderate_type='group' AND md.moderate_mg_id IN(" . implode( ',', $group_ids ) . "))",
'type' => 'inner'
)
),
) );
$this->DB->execute();
if ( $this->DB->getTotalRows() > 0 )
{
return true;
}
else
{
return false;
}
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$ex_form_data = array(
'blog_id' => intval($this->request['blog_id']),
'comment_id' => intval($this->request['comment_id']),
'entry_id' => intval($this->request['entry_id']),
'st' => intval($this->request['st'])
);
if( $ex_form_data['entry_id'] < 1 || $ex_form_data['blog_id'] < 1 )
{
$this->registry->output->showError( 'reports_blog_entry_id', 10152 );
}
$this->_loadBlog( $ex_form_data['blog_id'] );
$this->_checkAccess( $ex_form_data['entry_id'] );
$this->settings['blog_url'] = $this->registry->getClass('blogFunctions')->getBlogUrl( $ex_form_data['blog_id'] );
$this->registry->output->setTitle( $this->lang->words['report_title'] );
$this->registry->output->addNavigation( $this->lang->words['blog_title'], "app=blog" );
$this->registry->output->addNavigation( $this->blog['blog_name'], $this->settings['blog_url'] );
$this->registry->output->addNavigation( $this->entry['entry_name'], $this->settings['blog_url'] . "showentry={$this->entry['entry_id']}" );
$this->registry->output->addNavigation( $this->lang->words['report_title'], '' );
if ( $this->request['comment_id'] )
{
$url = $this->settings['base_url'] . "app=blog&blogid={$this->entry['blog_id']}&showentry={$ex_form_data['entry_id']}&show=comment&cid={$ex_form_data['comment_id']}";
}
else
{
$url = $this->settings['base_url'] . "app=blog&blogid={$this->entry['blog_id']}&showentry={$ex_form_data['entry_id']}";
}
if ( $this->request['comment_id'] )
{
$this->lang->words['report_title'] .= " (" . $this->lang->words['bg_comment'] . " #" . $this->request['comment_id'] . ')';
}
$this->lang->words['report_basic_title'] = ( $this->request['comment_id'] ) ? $this->lang->words['report_title'] : $this->lang->words['report_entry'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_topic'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_message'];
//-----------------------------------------
// Instead of dull output, lets make it
// blogerishes!
//-----------------------------------------
return $this->registry->getClass('reportLibrary')->showReportForm( $this->entry['entry_name'], $url, $ex_form_data );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
$cache = $this->cache->getCache('report_cache');
return array(
'title' => $cache['blog_titles'][ $report_row['exdat1'] ],
'url' => "/index.php?app=blog&blogid=" . $report_row['exdat1'],
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$blog_id = intval( $this->request['blog_id'] );
$entry_id = intval( $this->request['entry_id'] );
$comment_id = intval( $this->request['comment_id'] );
if( $entry_id < 1 || $blog_id < 1 )
{
$this->registry->output->showError( 'reports_blog_entry_id', 10153 );
}
$this->_loadBlog( $blog_id );
$this->_checkAccess( $entry_id );
if ( $comment_id )
{
$url = "app=blog&blogid={$blog_id}&showentry={$entry_id}&show=comment&cid={$comment_id}";
}
else
{
$url = "app=blog&blogid={$blog_id}&showentry={$entry_id}";
}
$return_data = array();
$a_url = str_replace("&", "&amp;", $url);
$uid = md5( $url . '_' . $com_dat['com_id'] );
$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'];
}
}
if ( $comment_id )
{
$data = $this->DB->buildAndFetch( array(
'select' => 'c.*',
'from' => array( 'blog_comments' => 'c' ),
'where' => 'c.comment_id=' . $comment_id,
'add_join' => array(
array(
'select' => 'e.*',
'from' => array( 'blog_entries' => 'e' ),
'where' => 'e.entry_id=c.entry_id',
'type' => 'left',
),
array(
'select' => 'mem.member_id, mem.members_display_name',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=c.member_id',
'type' => 'left',
),
)
) );
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 0;
IPSText::getTextClass('bbcode')->parsing_section = 'global';
$message = "[quote name='" . IPSText::getTextClass('bbcode')->makeQuoteSafe( $data['members_display_name'] ) . "']";
$message .= "\n[url=" . $this->settings['base_url'] . $url . "]" . $this->lang->words['bg_comment'] . " #{$comment_id}[/url]\n";
$message .= IPSText::getTextClass('bbcode')->preEditParse( $data['comment_text'] );
$message .= "[/quote]\n\n";
$this->entry['entry_name'] .= ' (' . $this->lang->words['bg_comment'] . ' ' . $comment_id . ')';
}
else
{
$data = $this->DB->buildAndFetch( array('select' => 'e.*',
'from' => array( 'blog_entries' => 'e' ),
'where' => 'e.entry_id=' . $entry_id,
'add_join' => array( array( 'select' => 'mem.member_id, mem.members_display_name',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=e.entry_author_id',
'type' => 'left' ) ) ) );
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 0;
IPSText::getTextClass('bbcode')->parsing_section = 'global';
$message = "[quote name='" . IPSText::getTextClass('bbcode')->makeQuoteSafe( $data['members_display_name'] ) . "']";
$message .= IPSText::getTextClass('bbcode')->preEditParse( $data['entry_short'] );
$message .= "\n[url=" . $this->settings['base_url'] . $url . "]" . $this->lang->words['read_more_go_on'] . "[/url]\n";
$message .= "[/quote]\n\n";
}
$message .= $this->request['message'];
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $this->entry['entry_name'],
'status' => $status['new'],
'url' => '/index.php?' . $a_url,
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'exdat1' => $blog_id,
'exdat2' => $entry_id,
'exdat3' => $comment_id
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $message ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$cache = $this->cache->getCache('report_cache');
if( $cache['blog_titles'][ $this->blog['blog_id'] ] != $this->blog['blog_name'] )
{
$cache['blog_titles'][ $this->blog['blog_id'] ] = $this->blog['blog_name'];
$this->cache->setCache( 'report_cache', $cache, array( 'array' => 1, 'donow' => 1 ) );
}
$return_data['REDIRECT_URL'] = $a_url;
$return_data['REPORT_INDEX'] = $rid;
$return_data['SAVED_URL'] = '/index.php?' . $url;
$return_data['REPORT'] = $build_report['report'];
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'] );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
/**
* Load up blog libs
*
* @access private
* @param integer Blog id
* @return void
*/
private function _loadBlog( $blog_id )
{
require_once( IPSLib::getAppDir('blog') . '/app_class_blog.php' );
$blog = new app_class_blog( $this->registry );
$this->blog = $this->registry->getClass('blogFunctions')->loadBlog( $blog_id );
$this->settings['blog_url'] = $this->registry->getClass('blogFunctions')->getBlogUrl( $this->blog['blog_id'] );
}
/**
* Check access
*
* @access private
* @param integer Entry id
* @return void
*/
private function _checkAccess($eid)
{
if ( ! $this->memberData['member_id'] )
{
$this->registry->output->showError( 'reports_must_be_member' );
}
if ( ! $this->blog['blog_name'] )
{
$this->registry->output->showError( 'blog_not_enabled', 10154 );
}
$this->entry = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'blog_entries', 'where' => "entry_id=" . $eid ) );
if ( !$this->entry['entry_id'] )
{
$this->registry->output->showError( 'reports_no_entry', 10155 );
}
//-----------------------------------------
// Are we allowed to see draft entries?
//-----------------------------------------
if ( $this->blog['allow_entry'] )
{
$show_draft = $this->blog['blog_settings']['hidedraft'] ? false : true;
}
elseif ( $this->memberData['g_is_supmod'] or $this->memberData['_blogmod']['moderate_can_view_draft'] )
{
$show_draft = true;
}
else
{
$show_draft = false;
}
if ( $this->entry['entry_status'] == 'draft' and !$show_draft )
{
$this->registry->output->showError( 'reports_cannot_view_entry', 10156, true );
}
}
}
@@ -0,0 +1,412 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Calendar plugin
* Last Updated: $LastChangedDate: 2009-03-04 07:36:56 -0500 (Wed, 04 Mar 2009) $
*
* @author $Author: matt $
* @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: 4135 $
*/
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 calendar_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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;
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
$return = '';
return $return;
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions (only supermods can moderate calendar)
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( $this->_extra['report_bypass'] == 0 || $this->memberData['g_is_supmod'] == 1 )
{
return true;
}
else
{
return false;
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ), 'calendar' );
$eventid = intval($this->request['event_id']);
if( ! $eventid )
{
$this->registry->output->showError( 'reports_no_event', 10177 );
}
/**
* Load event
*/
$event = $this->DB->buildAndFetch( array(
'select' => 'e.*',
'from' => array( 'cal_events' => 'e' ),
'where' => 'e.event_id=' . $eventid,
'add_join' => array(
array(
'select' => 'c.*',
'from' => array( 'cal_calendars' => 'c' ),
'where' => 'c.cal_id=e.event_calendar_id',
'type' => 'left',
)
)
) );
/* Loop through the cache and build calendar jump */
if ( count( $this->caches['calendars'] ) AND is_array( $this->caches['calendars'] ) )
{
foreach( $this->caches['calendars'] as $cal_id => $cal )
{
if( $cal_id == $event['event_calendar_id'] )
{
/* Got a perm */
if( ! $this->registry->permissions->check( 'view', $cal ) )
{
$this->registry->output->showError( 'reports_no_event', 10178 );
}
}
}
}
$ex_form_data = array(
'event_id' => $eventid,
'ctyp' => 'calendar',
'title' => $event['event_title']
);
$this->registry->output->setTitle( $this->lang->words['report_cal_page'] );
$this->registry->output->addNavigation( $this->lang->words['t_welcome'], "app=calendar&amp;module=calendar&amp;cal_id={$event['event_calendar_id']}&amp;do=showevent&amp;event_id={$event['event_id']}" );
$this->registry->output->addNavigation( $this->lang->words['report_cal_page'], '' );
$this->lang->words['report_basic_title'] = $this->lang->words['report_cal_title'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_cal_title'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_cal_msg'];
$url = $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;cal_id={$event['event_calendar_id']}&amp;do=showevent&amp;event_id={$event['event_id']}";
return $this->registry->getClass('reportLibrary')->showReportForm( $event['event_title'], $url, $ex_form_data );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
ipsRegistry::_loadAppCoreVariables( 'calendar' );
$calendarCache = $this->cache->getCache('calendars');
return array(
'title' => $calendarCache[ $report_row['exdat1'] ]['cal_title'],
'url' => "/index.php?app=calendar&amp;module=calendar&amp;cal_id={$report_row['exdat1']}",
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$eventid = intval($this->request['event_id']);
if( ! $eventid )
{
$this->registry->output->showError( 'reports_no_event', 10179 );
}
/**
* Load event
*/
$event = $this->DB->buildAndFetch( array(
'select' => 'e.*',
'from' => array( 'cal_events' => 'e' ),
'where' => 'e.event_id=' . $eventid,
'add_join' => array(
array(
'select' => 'c.*',
'from' => array( 'cal_calendars' => 'c' ),
'where' => 'c.cal_id=e.event_calendar_id',
'type' => 'left',
)
)
) );
/* Loop through the cache and build calendar jump */
if ( count( $this->caches['calendars'] ) AND is_array( $this->caches['calendars'] ) )
{
foreach( $this->caches['calendars'] as $cal_id => $cal )
{
if( $cal_id == $event['event_calendar_id'] )
{
/* Got a perm */
if( ! $this->registry->permissions->check( 'view', $cal ) )
{
$this->registry->output->showError( 'reports_no_event', 10180 );
}
}
}
}
$url = "app=calendar&module=calendar&cal_id={$event['event_calendar_id']}&do=showevent&event_id={$event['event_id']}";
$return_data = array();
$a_url = str_replace("&", "&amp;", $url);
$uid = md5( 'cal_' . $eventid . '_' . $com_dat['com_id'] );
$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'];
}
}
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $this->request['title'],
'status' => $status['new'],
'url' => '/index.php?' . $a_url,
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'exdat1' => $event['event_calendar_id'],
'exdat2' => $event['event_id'],
'exdat3' => 0
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $this->request['message'] ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data = array(
'REDIRECT_URL' => $a_url,
'REPORT_INDEX' => $rid,
'SAVED_URL' => '/index.php?' . $url,
'REPORT' => $build_report['report']
);
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'], true );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
}
@@ -0,0 +1,498 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Default plugin
* Last Updated: $LastChangedDate: 2009-06-08 16:27:31 -0400 (Mon, 08 Jun 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: 4736 $
*/
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 default_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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();
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
$req_input = '';
$return = '';
if( is_array($plugin_data['required_input']) && count($plugin_data['required_input']) > 0 )
{
foreach( $plugin_data['required_input'] as $key => $value )
{
if( $req_input != '' )
{
$req_input .= "\r\n";
}
$req_input .= $key . ' ' . $value;
}
}
$return .= $html->addRow( "Название секции",
"Помогает определить модуль форума из которого была отправлена жалоба.",
$this->registry->output->formInput('section_title', $plugin_data['section_title'])
);
$return .= $html->addRow( "URL секции",
"Ссылка на секцию из которой пришла жалоба.",
$this->registry->output->formInput('section_url', $plugin_data['section_url'])
);
$desc = <<<EOF
Здесь вы можете определить формат заполннения полей при отправке жалобы.
Каждое поле описывается на одной строке. В начале идет id поле,
пробел, регульрное выражение для проверки значения. Если срабатывает регулярное выражение - отправителю жалобы показывается ошибка.<br /><br />Например:<br />
<div style="border: 1px solid #999; padding: 3px; margin-top: 2px;">content_id [^0-9]<br />title [^A-Za-z0-9]</div>
EOF;
$return .= $html->addRow( "Формат полей",
$desc,
$this->registry->output->formTextarea('required_input', $req_input, 50, 9)
);
$return .= $html->addRow( "URL",
"Сслыка на саму публикацию. Если не указан 'http://' будет подставлен базовый URL форума. Можно использовать данные из входных параметров: {input_id}",
$this->registry->output->formInput('string_url', $plugin_data['string_url'])
);
$return .= $html->addRow( "Название",
"Название жалобы. Можно использовать данные из входных параметров: {input_id}. Можно использовать #PAGE_TITLE#",
$this->registry->output->formInput('string_title', $plugin_data['string_title'])
);
return $return;
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
if( ! $_POST['string_url'] )
{
return "Поле 'URL' должно быть заполнено";
}
if( ! $_POST['string_title'] )
{
return "Поле 'Название' должно быть заполнено. Не можете придумать - используйте #PAGE_TITLE#";
}
$req_in_a = array();
if( $_POST['required_input'] )
{
$req_i = explode( "<br />", $this->request['required_input'] );
foreach( $req_i as $line )
{
$line_inp = explode( ' ', $line, 2 );
$req_in_a[ $line_inp[0] ] = $line_inp[1];
}
}
$save_data_array['required_input'] = $req_in_a;
$save_data_array['string_url'] = str_replace("&amp;", "&", $this->request['string_url']);
$save_data_array['string_title'] = $this->request['string_title'];
$save_data_array['section_title'] = $this->request['section_title'];
$save_data_array['section_url'] = $this->request['section_url'];
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( $this->_extra['report_bypass'] == 0 || $this->memberData['g_is_supmod'] == 1 )
{
return true;
}
else
{
return false;
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$this->registry->output->setTitle( $this->lang->words['report_basic_title'] );
$this->registry->output->addNavigation( $this->lang->words['report_basic_title'], '' );
$url = '';
$title = '';
$ex_form_data = array();
$this->processBasicForumData( $com_dat, $url, $title, $ex_form_data );
//-----------------------------------------
// Title, URL Extra Data (Array)
//-----------------------------------------
return $this->registry->getClass('reportLibrary')->showReportForm( $title, $url, $ex_form_data );
}
/**
* Process the basic forum data
*
* @access public
* @param array Application data
* @param string URL
* @param string Title
* @param array Extra form data
* @return mixed Could show page error, or set $url, $title and $ex_form_data
*/
public function processBasicForumData( $com_dat, &$url, &$title, &$ex_form_data )
{
//-----------------------------------------
// Process required input information
//-----------------------------------------
if( is_array($this->_extra['required_input']) && count($this->_extra['required_input']) > 0 )
{
foreach( $this->_extra['required_input'] as $key => $regex )
{
if( ! $this->request[ $key ] || ( trim($regex) != '' && preg_match( "/{$regex}/" , $this->request[ $key ] ) ) )
{
$this->registry->output->showError( 'reports_input_not_match', 10157 );
}
else
{
$ex_form_data[ $key ] = $this->request[ $key ];
}
}
}
//-----------------------------------------
// Format URL String with inputs
//-----------------------------------------
if( ! $this->_extra['string_url'] )
{
$this->registry->output->showError( 'reports_input_not_match', 10158 );
}
else
{
$url = $this->_extra['string_url'];
while( preg_match("/\{([a-z0-9_\-]+)\}/i", $url, $matched) )
{
$url = str_replace( '{' . $matched[1] . '}', $ex_form_data[$matched[1]], $url);
}
}
if( strpos( $url, 'http://' ) !== 0 )
{
$url = $this->settings['base_url'] . $url;
}
//-----------------------------------------
// Format Title String with inputs, etc..
//-----------------------------------------
if( ! $this->_extra['string_title'] )
{
$this->registry->output->showError( 'reports_input_not_match', 10159 );
}
else
{
$title = $this->_extra['string_title'];
while( preg_match("/\{([a-z0-9_\-]+)\}/i", $title, $matched) )
{
$title = str_replace( '{' . $matched[1] . '}', $ex_form_data[$matched[1]], $title);
}
if( strpos( $title, "#PAGE_TITLE#" ) !== false )
{
$page_title = $this->_getPageTitle( $url );
$title = str_replace( "#PAGE_TITLE#", $page_title, $title );
}
}
$this->registry->output->setTitle( $title );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
return array(
'title' => $this->_extra['section_title'],
'url' => $this->_extra['section_url'],
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$this->processBasicForumData( $com_dat, $url, $title, $ex_form_data );
$return_data = array();
$a_url = str_replace( "&", "&amp;", $url );
$uid = md5( $url . '_' . $com_dat['com_id'] );
$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'];
}
}
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $title,
'status' => $status['new'],
'url' => $a_url,
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $this->request['message'] ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data['REDIRECT_URL'] = $a_url;
$return_data['REPORT_INDEX'] = $rid;
$return_data['SAVED_URL'] = $url;
$return_data['REPORT'] = $build_report['report'];
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'] );
}
/**
* Loads an HTML page and grabs its title
*
* @access private
* @param string Web URL
* @return string
*/
private function _getPageTitle( $URL )
{
$html_code = file_get_contents( $URL );
# I just hope the page is html...
if( preg_match("/\<title\>(.+?)\<\/title\>/i", $html_code, $match ) )
{
return htmlentities( $match[1] );
}
else
{
return $this->lang->words['report_page_title_unknown'];
}
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
}
@@ -0,0 +1,425 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Downloads plugin
* Last Updated: $LastChangedDate: 2009-08-18 16:46:02 -0400 (Tue, 18 Aug 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 IP.Downloads
* @link http://www.iinvisionpower.com
* @version $Rev: 5027 $
*/
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 downloads_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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;
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
$return = '';
$return .= $html->addRow( $this->lang->words['r_supermod'],
sprintf( $this->lang->words['r_supermod_info'], $this->settings['_base_url'] ),
$this->registry->output->formYesNo('report_supermod', (!isset( $plugin_data['report_supermod'] )) ? 1 : $plugin_data['report_supermod'] )
);
$return .= $html->addRow( $this->lang->words['r_dlmod'],
"",
$this->registry->output->formYesNo('report_bypass', (!isset( $plugin_data['report_bypass'] )) ? 1 : $plugin_data['report_bypass'] )
);
return $return;
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
$save_data_array['report_supermod'] = intval($this->request['report_supermod']);
$save_data_array['report_bypass'] = intval($this->request['report_bypass']);
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( $this->_extra['report_bypass'] == 0
|| ( $this->memberData['g_is_supmod'] == 1 && ( ! isset($this->_extra['report_supermod']) || $this->_extra['report_supermod'] == 1 ) ) )
{
return true;
}
else
{
$cache = $this->cache->getCache('idm_mods');
/**
* If no idm_mods cache, we have no downloads moderators
*/
if( !count($cache) )
{
return false;
}
else
{
/**
* Loop over the cache
*/
foreach( $cache as $k => $v )
{
/**
* Can we moderate comments?
*/
if( $v['modcancomments'] )
{
/**
* Check against member moderator
*/
if( $v['modtype'] == 2 AND $this->memberData['member_id'] == $v['modgmid'] )
{
return true;
}
/**
* Check against group moderator
*/
else if( $v['modtype'] == 1 )
{
/**
* Take into account secondary groups too
*/
$groups = array( $this->memberData['member_group_id'] );
if( $this->memberData['mgroup_others'] )
{
$groups = array_merge( $groups, explode( ',', IPSText::cleanPermString( $this->memberData['mgroup_others'] ) ) );
}
/**
* Loop over our groups, if one is the modgmid, then we're a group mod
*/
foreach( $groups as $gid )
{
if( $gid == $v['modgmid'] )
{
return true;
}
}
}
}
}
}
}
/**
* If we're still here, return false
*/
return false;
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$this->registry->class_localization->loadLanguageFile( array( 'public_downloads' ), 'downloads' );
$file = intval($this->request['file']);
$comment = intval($this->request['comment']);
$st = intval($this->request['st']);
if( ! $file )
{
$this->registry->output->showError( 'reports_no_file' );
}
$title = $this->DB->buildAndFetch( array( 'select' => 'file_name', 'from' => 'downloads_files', 'where' => 'file_id=' . intval($file) ) );
$ex_form_data = array(
'file' => $file,
'ctyp' => 'comment',
'title' => $title['file_name'],
'comment' => $comment,
'st' => $st,
);
$this->registry->output->setTitle( $this->lang->words['report_file_page'] );
$this->registry->output->addNavigation( $this->lang->words['downloads'], "app=downloads" );
$this->registry->output->addNavigation( $this->lang->words['report_file_page'], '' );
$this->lang->words['report_basic_title'] = $this->lang->words['report_file_title'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_file_title'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_file_msg'];
$url = $this->settings['base_url'] . "app=downloads&amp;showfile=" . $ex_form_data['file'];
return $this->registry->getClass('reportLibrary')->showReportForm( $title['file_name'], $url, $ex_form_data );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
return array(
'title' => $this->lang->words['report_section_title_site_downloads'],
'url' => "/index.php?app=downloads",
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$file = intval($this->request['file']);
$comment = intval($this->request['comment']);
$st = intval($this->request['st']);
$url = 'app=downloads&showfile=' . $file . '&st=' . $st . '&showcomments=1#comment' . $comment;
if( $file < 1 )
{
$this->registry->output->showError( 'reports_no_file', 10161 );
}
$return_data = array();
$a_url = str_replace("&", "&amp;", $url);
$uid = md5( 'idm_' . $con_type . '_' . $img . '_' . $comment . '_' . $com_dat['com_id'] );
$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'];
}
}
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $this->request['title'],
'status' => $status['new'],
'url' => '/index.php?' . $a_url,
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'exdat1' => $file,
'exdat2' => $comment,
'exdat3' => $st
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $this->request['message'] ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data = array(
'REDIRECT_URL' => $a_url,
'REPORT_INDEX' => $rid,
'SAVED_URL' => '/index.php?' . $url,
'REPORT' => $build_report['report']
);
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'] );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
}
@@ -0,0 +1,435 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Gallery plugin
* Last Updated: $LastChangedDate: 2009-03-29 16:35:41 -0400 (Sun, 29 Mar 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 IP.Gallery
* @link http://www.iinvisionpower.com
* @version $Rev: 4342 $
*/
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 gallery_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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;
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
$return = '';
$return .= $html->addRow( $this->lang->words['r_supermod'],
sprintf( $this->lang->words['r_supermod_info'], $this->settings['_base_url'] ),
$this->registry->output->formYesNo('report_supermod', (!isset( $plugin_data['report_supermod'] )) ? 1 : $plugin_data['report_supermod'] )
);
$return .= $html->addRow( $this->lang->words['r_galmod'],
"",
$this->registry->output->formYesNo('report_bypass', (!isset( $plugin_data['report_bypass'] )) ? 1 : $plugin_data['report_bypass'] )
);
return $return;
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
$save_data_array['report_supermod'] = intval($this->request['report_supermod']);
$save_data_array['report_bypass'] = intval($this->request['report_bypass']);
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( $this->_extra['report_bypass'] == 0
|| ( $this->memberData['g_is_supmod'] == 1 && ( ! isset($this->_extra['report_supermod']) || $this->_extra['report_supermod'] == 1 ) ) )
{
return true;
}
else
{
$this->DB->build( array(
'select' => 'g.g_id',
'from' => array( 'groups' => 'g' ),
'where' => "(g.g_mod_albums=1 OR g.g_is_supmod=1) AND m.member_id=" . $this->memberData['member_id'],
'add_join' => array(
array(
'select' => 'm.members_display_name, m.member_id, m.email',
'from' => array( 'members' => 'm' ),
'where' => "m.member_group_id = g.g_id OR m.mgroup_others LIKE " . $this->DB->buildConcat( array( array( '%', 'string' ), array( 'g.g_id' ), array( '%', 'string' ) ) ) ,
)
)
) );
$res = $this->DB->execute();
if( $this->DB->getTotalRows($res) > 0 )
{
return true;
}
else
{
return false;
}
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
define( 'GALLERY_LIBS', IPS_ROOT_PATH . '/applications_addon/ips/gallery/sources/libs/' );
require_once( GALLERY_LIBS . 'lib_gallery.php' );
$this->registry->setClass( 'glib', new lib_gallery( $this->registry ) );
$this->registry->class_localization->loadLanguageFile( array( 'public_gallery' ), 'gallery' );
if( $this->request['ctyp'] == 'comment' )
{
$comment_id = intval($this->request['comment_id']);
$comment = $this->DB->buildAndFetch( array( 'select' => 'img_id', 'from' => 'gallery_comments', 'where' => "pid={$comment_id}" ) );
$data = $this->registry->getClass('glib')->getImageInfo( $comment['img_id'] );
$ex_form_data = array(
'img_id' => $comment['img_id'],
'comment_id' => $comment_id,
'ctyp' => 'comment',
'st' => intval($this->request['st']),
'title' => $data['caption'] . $this->lang->words['report_gallery_comment_suffix'],
);
$this->registry->output->setTitle( $this->lang->words['report_comment_page'] );
$this->registry->output->addNavigation( $this->lang->words['gallery'], "app=gallery" );
$this->registry->output->addNavigation( $this->lang->words['report_comment_page'], '' );
$this->lang->words['report_basic_title'] = $this->lang->words['report_comment_page'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_comment_title'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_comment_msg'];
return $this->registry->getClass('reportLibrary')->showReportForm( '', '', $ex_form_data );
}
elseif( $this->request['ctyp'] == 'image' )
{
if( $this->settings['gallery_disable_report_images'] )
{
$this->registry->output->showError( 'reports_images_disabled', 10162 );
}
$img_id = intval($this->request['img_id']);
if( ! $img_id )
{
$this->registry->output->showError( 'reports_no_imageid', 10163 );
}
$data = $this->registry->getClass('glib')->getImageInfo( $img_id );
$thumb = $this->registry->getClass('glib')->makeImageLink( $data, 1 );
$ex_form_data = array(
'img_id' => $img_id,
'ctyp' => 'image',
//'thumb' => $thumb,
'title' => $data['caption'] . $this->lang->words['report_gallery_image_suffix']
);
$this->registry->output->setTitle( $data['caption'] . $this->lang->words['report_gallery_image_suffix'] );
$this->registry->output->addNavigation( $this->lang->words['gallery'], "app=gallery" );
$this->registry->output->addNavigation( $data['caption'] . $this->lang->words['report_gallery_image_suffix'], '' );
$this->lang->words['report_basic_title'] = $this->lang->words['report_img_page'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_img_title'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_img_msg'];
$url = $this->settings['base_url'] . "app=gallery&amp;module=images&amp;section=viewimage&amp;img=" . $ex_form_data['img_id'];
return $this->registry->getClass('reportLibrary')->showReportForm( $data['caption'], $url, $ex_form_data );
}
else
{
$this->registry->output->showError( 'reports_invalid_gtype', 10164 );
}
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
return array(
'title' => $this->lang->words['report_section_title_site_gallery'],
'url' => "/index.php?app=gallery",
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$con_type = $this->request['ctyp'];
if( $con_type == 'image' )
{
$img = $this->request['img_id'];
$url = 'app=gallery&module=images&section=viewimage&img=' . $img;
}
elseif( $con_type == 'comment' )
{
$img = $this->request['img_id'];
$comment = $this->request['comment_id'];
$st = intval($this->request['st']);
$url = 'app=gallery&module=images&section=viewimage&img=' . $img . '&st=' . $st . '#' . $comment;
}
if( $img < 1 )
{
$this->registry->output->showError( 'reports_no_imageid', 10165 );
}
$return_data = array();
$a_url = str_replace("&", "&amp;", $url);
$uid = md5( 'gallery_' . $con_type . '_' . $img . '_' . $comment . '_' . $com_dat['com_id'] );
$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'];
}
}
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $this->request['title'],
'status' => $status['new'],
'url' => '/index.php?' . $a_url,
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'img_preview' => $this->request['thumb'],
'exdat1' => $img,
'exdat2' => $comment,
'exdat3' => $st
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $this->request['message'] ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data = array(
'REDIRECT_URL' => $a_url,
'REPORT_INDEX' => $rid,
'SAVED_URL' => '/index.php?' . $url,
'REPORT' => $build_report['report']
);
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'] );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
}
@@ -0,0 +1 @@
<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>␍
@@ -0,0 +1,403 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Private Messages plugin
* Last Updated: $LastChangedDate: 2009-06-11 17:00:57 -0400 (Thu, 11 Jun 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: 4764 $
*/
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 messages_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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;
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
$req_input = '';
$return = '';
if( is_array($plugin_data['required_input']) && count($plugin_data['required_input']) > 0 )
{
foreach( $plugin_data['required_input'] as $key => $value )
{
if( $req_input != '' )
{
$req_input .= "\r\n";
}
$req_input .= $key . ' ' . $value;
}
}
foreach( $this->cache->getCache('group_cache') as $g )
{
$groups[] = array( $g['g_id'], $g['g_title'] );
}
$return .= $html->addRow( $this->lang->words['r_messages_enter'],
$this->lang->words['r_menter_desc'],
$this->registry->output->formMultiDropdown('plugi_messages_add[]', $groups, explode( ',', $plugin_data['plugi_messages_add'] ) )
);
return $return;
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
$save_data_array['plugi_messages_add'] = ( is_array($this->request['plugi_messages_add']) AND count($this->request['plugi_messages_add']) ) ? implode( ',', $this->request['plugi_messages_add'] ) : '';
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( $this->_extra['report_bypass'] == 0 || $this->memberData['g_is_supmod'] == 1 )
{
return true;
}
else
{
return false;
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$this->registry->class_localization->loadLanguageFile( array( 'public_messaging' ), 'members' );
$msg = intval($this->request['topicID']);
if( ! $msg )
{
$this->registry->output->showError( 'reports_no_msg', 10166 );
}
$message = $this->DB->buildAndFetch( array(
'select' => 'mt_title',
'from' => 'message_topics',
'where' => 'mt_id=' . intval($msg)
) );
$ex_form_data = array(
'topic' => $msg,
'msg' => intval($this->request['msg']),
'st' => intval($this->request['st']),
'ctyp' => 'message',
'title' => $message['mt_title']
);
$this->registry->output->setTitle( $this->lang->words['report_msg_page'] );
$this->registry->output->addNavigation( $this->lang->words['t_welcome'], "app=members&amp;module=messaging" );
$this->registry->output->addNavigation( $this->lang->words['report_msg_page'], '' );
$this->lang->words['report_basic_title'] = $this->lang->words['report_msg_title'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_msg_title'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_msg_msg'];
$url = $this->settings['base_url'] . "app=members&amp;module=messaging&amp;section=view&amp;do=showConversation&amp;topicID=" . $ex_form_data['topic'] . "&amp;st=" . $ex_form_data['st'] . "#msg" . $ex_form_data['msg'];
return $this->registry->getClass('reportLibrary')->showReportForm( $message['mt_title'], $url, $ex_form_data );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
return array(
'title' => $this->lang->words['report_section_title_msg'],
'url' => "/index.php?app=core&amp;module=reports&amp;section=reports&amp;do=showMessage&amp;topicID={$report_row['exdat1']}&amp;st={$report_row['exdat3']}&amp;msg={$report_row['exdat2']}",
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$topic = $this->request['topic'];
$msg = $this->request['msg'];
$st = $this->request['st'];
$url = 'app=members&module=messaging&section=view&do=showConversation&topicID=' . $topic;
if( $msg < 1 )
{
$this->registry->output->showError( 'reports_no_msg', 10167 );
}
$return_data = array();
$a_url = str_replace("&", "&amp;", $url);
$uid = md5( 'msg_' . $msg . '_' . $com_dat['com_id'] );
$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'];
}
}
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $this->request['title'],
'status' => $status['new'],
'url' => '/index.php?' . $a_url,
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'exdat1' => $topic,
'exdat2' => $msg,
'exdat3' => $st,
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
}
$data = $this->DB->buildAndFetch( array(
'select' => 't.mt_title',
'from' => array( 'message_topics' => 't' ),
'where' => 't.mt_id=' . $topic . ' AND m.msg_id=' . $msg,
'add_join' => array(
array(
'select' => 'm.msg_post',
'from' => array( 'message_posts' => 'm' ),
'where' => 't.mt_id=m.msg_topic_id',
'type' => 'left',
),
array(
'select' => 'mem.member_id, mem.members_display_name',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=m.msg_author_id',
'type' => 'left',
),
)
) );
$message = "[quote name='" . IPSText::getTextClass('bbcode')->makeQuoteSafe( $data['members_display_name'] ) . "']";
$message .= $data['msg_post'];
$message .= "[/quote]\n\n";
$message .= $this->request['message'];
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $message ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data = array(
'REDIRECT_URL' => "app=members&amp;module=messaging&amp;section=view&amp;do=showConversation&amp;topicID=" . $topic . "&amp;st=" . $st . "#msg" . $msg,
'REPORT_INDEX' => $rid,
'SAVED_URL' => '/index.php?' . $url,
'REPORT' => $build_report['report']
);
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'] );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
}
@@ -0,0 +1,555 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Posts plugin
* Last Updated: $LastChangedDate: 2009-07-09 22:20:10 -0400 (Thu, 09 Jul 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: 4864 $
*/
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 post_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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;
require_once( IPSLib::getAppDir( 'forums' ) . '/app_class_forums.php' );
$app_class_forums = new app_class_forums( $this->registry );
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
return $html->addRow( $this->lang->words['r_supermod'],
sprintf( $this->lang->words['r_supermod_info'], $this->settings['_base_url'] ),
$this->registry->output->formYesNo('report_supermod', (!isset( $plugin_data['report_supermod'] )) ? 1 : $plugin_data['report_supermod'] )
);
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
$save_data_array['report_supermod'] = intval($this->request['report_supermod']);
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
$nmc =& $new_members_cache['report_temp']['post_marker'];
foreach( $new_reports as $report )
{
if( $report['is_new'] == 1 || $report['is_active'] == 1 )
{
$nmc['forum'][ $report['exdat1'] ]['info'] = array( 'id' => $report['id'], 'title' => $report['title'], 'com_id' => $report['com_id'] );
$nmc['topic'][ $report['exdat2'] ]['info'] = array( 'id' => $report['id'], 'title' => $report['title'], 'com_id' => $report['com_id'] );
$nmc['post'][ $report['exdat3'] ]['info'] = array( 'id' => $report['id'], 'title' => $report['title'], 'com_id' => $report['com_id'] );
}
if( $report['is_new'] == 1 )
{
$nmc['forum'][ $report['exdat1'] ]['gfx'] = 1;
$nmc['topic'][ $report['exdat2'] ]['gfx'] = 1;
$nmc['post'][ $report['exdat3'] ]['gfx'] = 1;
}
elseif( $report['is_active'] == 1 )
{
$nmc['forum'][ $report['exdat1'] ]['gfx'] = 2;
$nmc['topic'][ $report['exdat2'] ]['gfx'] = 2;
$nmc['post'][ $report['exdat3'] ]['gfx'] = 2;
}
}
}
/**
* Get report permissions
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( ( $this->memberData['g_is_supmod'] == 1 && ( ! isset($this->_extra['report_supermod']) || $this->_extra['report_supermod'] == 1 ) ) )
{
return true;
}
else
{
$forum_ids = array();
foreach( $this->caches['moderators'] as $mod )
{
if( $mod['member_id'] == $this->memberData['member_id'] )
{
$these_forums = explode( ',', IPSText::cleanPermString( $mod['forum_id'] ) );
foreach( $these_forums as $forum_id )
{
$forum_ids['exdat1'][] = $forum_id;
}
}
elseif( $mod['is_group'] == 1 && in_array( $mod['group_id'], $group_ids ) == true )
{
$these_forums = explode( ',', IPSText::cleanPermString( $mod['forum_id'] ) );
foreach( $these_forums as $forum_id )
{
$forum_ids['exdat1'][] = $forum_id;
}
}
}
if( count( $forum_ids ) > 0 )
{
$to_return = $forum_ids;
return true;
}
else
{
return false;
}
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$this->lang->words['report_basic_title'] = $this->lang->words['report_post_title'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_post_url_title'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_post_enter'];
$this->registry->output->setTitle( $this->lang->words['report_basic_title'] );
$this->registry->output->addNavigation( $this->lang->words['report_basic_title'], '' );
$topic_id = intval($this->request['tid']);
$this->_checkAccess( $topic_id );
$extra_data = array(
'topic_id' => intval($topic_id),
'post_id' => intval($this->request['pid']),
'forum_id' => intval($this->topic['forum_id']),
);
$url = $this->registry->output-> buildSEOUrl( "showtopic={$extra_data['topic_id']}&amp;view=findpost&amp;p={$extra_data['post_id']}", 'public', $this->topic['title_seo'], 'showtopic' );
//-----------------------------------------
// Title, URL Extra Data (Array)
//-----------------------------------------
return $this->registry->getClass('reportLibrary')->showReportForm( $this->topic['title'], $url, $extra_data );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
return array(
'title' => $this->registry->class_forums->forum_by_id[ $report_row['exdat1'] ]['name'],
'url' => '/index.php?showforum=' . $report_row['exdat1'],
'seo_title' => $this->registry->class_forums->forum_by_id[ $report_row['exdat1'] ]['name_seo'],
'seo_template' => 'showforum',
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$topic_id = intval($this->request['topic_id']);
$post_id = intval($this->request['post_id']);
$forum_id = intval($this->request['forum_id']);
if( ! $topic_id || ! $post_id )
{
$this->registry->output->showError( 'reports_missing_tidpid', 10168 );
}
$uid = md5( 'topic_' . $topic_id . '_' . $post_id . '_' . $forum_id . '_' . $com_dat['com_id'] );
$url = 'showtopic=' . intval($topic_id) . '&view=findpost&p=' . intval($post_id);
$save_url = str_replace( '&', '&amp;', $url);
$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'];
}
}
$data = $this->DB->buildAndFetch( array(
'select' => 'p.post',
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid=' . $post_id,
'add_join' => array(
array(
'select' => 't.title_seo',
'from' => array( 'topics' => 't' ),
'where' => 't.tid=p.topic_id',
'type' => 'left',
),
array(
'select' => 'mem.member_id, mem.members_display_name',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=p.author_id',
'type' => 'left',
),
)
) );
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 0;
IPSText::getTextClass('bbcode')->parsing_section = 'global';
$message = "[quote name='" . IPSText::getTextClass('bbcode')->makeQuoteSafe( $data['members_display_name'] ) . "']";
$message .= IPSText::getTextClass('bbcode')->preEditParse( $data['post'] );
$message .= "[/quote]\n\n";
$message .= $this->request['message'];
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$this->_checkAccess( $topic_id );
$built_report_main = array(
'uid' => $uid,
'title' => $this->topic['title'],
'status' => $status['new'],
'url' => '/index.php?' . $save_url,
'seoname' => $data['title_seo'],
'seotemplate' => 'showtopic',
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'exdat1' => $forum_id,
'exdat2' => $topic_id,
'exdat3' => $post_id,
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'], 'seoname' => $data['title_seo'], 'seotemplate' => 'showtopic' ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $message ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data = array(
'REDIRECT_URL' => $url,
'FORUM_ID' => $forum_id,
'REPORT_INDEX' => $rid,
'SAVED_URL' => '/index.php?' . $save_url,
'REPORT' => $build_report['report'],
'SEOTITLE' => $data['title_seo'],
'TEMPLATE' => 'showtopic',
);
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'], $report_data['SEOTITLE'], $report_data['TEMPLATE'] );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
//-----------------------------------------
// Build where for secondary member groups
//-----------------------------------------
$secondaryWhere = array();
if( is_array($group_ids) AND count($group_ids) )
{
foreach( $group_ids as $group_id )
{
$secondaryWhere[] = "m.mgroup_others LIKE '%,{$group_id},%'";
}
}
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => "(m.member_group_id IN(" . $group_ids . ") " . ( count($secondaryWhere) ? "OR " . implode( ' OR ', $secondaryWhere ) : '' ) . ") AND moderator.forum_id LIKE '%,{$report_data['FORUM_ID']},%'",
'add_join' => array(
array(
'select' => 'm.member_id, m.members_display_name as name, m.language, m.members_disable_pm, m.email, m.member_group_id',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=noti.mem_id',
),
array(
'select' => 'moderator.member_id, moderator.group_id',
'from' => array( 'moderators' => 'moderator' ),
'where' => 'moderator.member_id=m.member_id OR moderator.group_id=m.member_group_id',
),
)
) );
$this->DB->execute();
$mods = array();
$notify = array();
if ( $this->DB->getTotalRows() )
{
while( $r = $this->DB->fetch() )
{
$r['member_id'] = $r['mem_id'];
$mods[] = $r;
}
}
else
{
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => "(m.member_group_id IN(" . $group_ids . ") " . ( count($secondaryWhere) ? "OR " . implode( ' OR ', $secondaryWhere ) : '' ) . ") AND g.g_is_supmod=1",
'add_join' => array(
array(
'select' => 'm.member_id, m.members_display_name as name, m.language, m.members_disable_pm, m.email, m.member_group_id',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=noti.mem_id',
'type' => 'left',
),
array(
'from' => array( 'groups' => 'g' ),
'where' => 'g.g_id=m.member_group_id',
'type' => 'left',
),
)
) );
$this->DB->execute();
if ( $this->DB->getTotalRows() )
{
while( $r = $this->DB->fetch() )
{
$mods[] = $r;
}
}
else
{
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => "(m.member_group_id IN(" . $group_ids . ") " . ( count($secondaryWhere) ? "OR " . implode( ' OR ', $secondaryWhere ) : '' ) . ") AND g.g_access_cp=1",
'add_join' => array(
array(
'select' => 'm.member_id, m.members_display_name as name, m.language, m.members_disable_pm, m.email, m.member_group_id',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=noti.mem_id',
'type' => 'left',
),
array(
'from' => array( 'groups' => 'g' ),
'where' => 'g.g_id=m.member_group_id',
'type' => 'left',
),
)
) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$mods[] = $r;
}
}
}
foreach( $mods as $row )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
return $notify;
}
/**
* Check access to report the topic
*
* @access private
* @param integer Topic id
* @return void
*/
private function _checkAccess( $tid )
{
if ( ! $this->memberData['member_id'] )
{
$this->registry->output->showError( 'reports_must_be_member', 10169 );
}
//-----------------------------------------
// Needs silly a. alias to keep oracle
// happy
//-----------------------------------------
$this->topic = $this->DB->buildAndFetch( array( 'select' => 'a.*,a.title as topic_title', 'from' => 'topics a', 'where' => "a.tid=" . $tid ) );
if( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php" );
$this->registry->setClass( 'class_forums', new class_forums( $this->registry ) );
$this->registry->getClass( 'class_forums' )->forumsInit();
}
$this->registry->getClass('class_forums')->forumsCheckAccess( $this->topic['forum_id'], 0, 'topic', $this->topic );
}
}
@@ -0,0 +1,361 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Report Center :: Profiles plugin
* Last Updated: $LastChangedDate: 2009-11-12 22:12:49 -0500 (Thu, 12 Nov 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: 5396 $
*/
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 profiles_plugin
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Holds extra data for the plugin
*
* @access private
* @var array Data specific to the plugin
*/
public $_extra;
/**
* 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;
}
/**
* Display the form for extra data in the ACP
*
* @access public
* @param array Plugin data
* @param object HTML object
* @return string HTML to add to the form
*/
public function displayAdminForm( $plugin_data, &$html )
{
$return = '';
return $return;
}
/**
* Process the plugin's form fields for saving
*
* @access public
* @param array Plugin data for save
* @return string Error message
*/
public function processAdminForm( &$save_data_array )
{
return '';
}
/**
* Update timestamp for report
*
* @access public
* @param array New reports
* @param array New members cache
* @return boolean
*/
public function updateReportsTimestamp( $new_reports, &$new_members_cache )
{
return true;
}
/**
* Get report permissions (only supermods can moderate profiles)
*
* @access public
* @param string Type of perms to check
* @param array Permissions data
* @param array group ids
* @param string Special permissions
* @return boolean
*/
public function getReportPermissions( $check, $com_dat, $group_ids, &$to_return )
{
if( $this->_extra['report_bypass'] == 0 || $this->memberData['g_is_supmod'] == 1 )
{
return true;
}
else
{
return false;
}
}
/**
* Show the report form for this module
*
* @access public
* @param array Application data
* @return string HTML form information
*/
public function reportForm( $com_dat )
{
$this->registry->class_localization->loadLanguageFile( array( 'public_profile' ), 'members' );
$mem = intval($this->request['member_id']);
if( ! $mem )
{
$this->registry->output->showError( 'reports_no_member', 10175 );
}
$member = IPSMember::load( $mem );
$ex_form_data = array(
'member_id' => $mem,
'ctyp' => 'profile',
'title' => $member['members_display_name']
);
$this->registry->output->setTitle( $this->lang->words['report_mem_page'] );
$this->registry->output->addNavigation( $member['members_display_name'], "showuser=" . $member['member_id'] );
$this->registry->output->addNavigation( $this->lang->words['report_mem_page'], '' );
$this->lang->words['report_basic_title'] = $this->lang->words['report_mem_page'];
$this->lang->words['report_basic_url_title'] = $this->lang->words['report_mem_page'];
$this->lang->words['report_basic_enter'] = $this->lang->words['report_mem_msg'];
$url = $this->registry->getClass('output')->buildSEOUrl( "showuser=" . $ex_form_data['member_id'], 'public', $member['members_seo_name'], 'showuser' );
return $this->registry->getClass('reportLibrary')->showReportForm( $member['members_display_name'], $url, $ex_form_data );
}
/**
* Get section and link
*
* @access public
* @param array Report data
* @return array Section/link
*/
public function giveSectionLinkTitle( $report_row )
{
return array(
'title' => $this->lang->words['report_section_title_mem'],
'url' => "/index.php?showuser={$report_row['exdat1']}",
'seo_template' => "showuser",
'seo_title' => $report_row['seoname'],
);
}
/**
* Process a report and save the data appropriate
*
* @access public
* @param array Report data
* @return array Data from saving the report
*/
public function processReport( $com_dat )
{
$mem = $this->request['member_id'];
$url = 'showuser=' . $mem;
if( $mem < 1 )
{
$this->registry->output->showError( 'reports_no_member', 10176 );
}
$return_data = array();
$a_url = str_replace("&", "&amp;", $url);
$uid = md5( 'mem_' . $mem . '_' . $com_dat['com_id'] );
$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'];
}
}
$data = IPSMember::load( $this->request['member_id'] );
$this->DB->build( array( 'select' => 'id', 'from' => 'rc_reports_index', 'where' => "uid='{$uid}'" ) );
$this->DB->execute();
if( $this->DB->getTotalRows() == 0 )
{
$built_report_main = array(
'uid' => $uid,
'title' => $this->request['title'],
'status' => $status['new'],
'url' => '/index.php?' . $a_url,
'seoname' => $data['members_seo_name'],
'seotemplate' => 'showuser',
'rc_class' => $com_dat['com_id'],
'updated_by' => $this->memberData['member_id'],
'date_updated' => time(),
'date_created' => time(),
'exdat1' => $mem,
'exdat2' => 0,
'exdat3' => 0
);
$this->DB->insert( 'rc_reports_index', $built_report_main );
$rid = $this->DB->getInsertId();
}
else
{
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
$this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'], 'seoname' => $data['members_seo_name'], 'seotemplate' => 'showuser' ), "id='{$rid}'" );
}
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'reports';
$build_report = array(
'rid' => $rid,
'report' => IPSText::getTextClass('bbcode')->preDbParse( $this->request['message'] ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
$this->DB->insert( 'rc_reports', $build_report );
$reports = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'rc_reports', 'where' => "rid='{$rid}'" ) );
$this->DB->update( 'rc_reports_index', array( 'num_reports' => $reports['total'] ), "id='{$rid}'" );
$return_data = array(
'REDIRECT_URL' => $a_url,
'REPORT_INDEX' => $rid,
'SAVED_URL' => '/index.php?' . $url,
'REPORT' => $build_report['report'],
'TEMPLATE' => 'showuser',
'SEOTITLE' => $data['members_seo_name'],
);
return $return_data;
}
/**
* Where to send user after report is submitted
*
* @access public
* @param array Report data
* @return void
*/
public function reportRedirect( $report_data )
{
if( $report_data['SEOTITLE'] )
{
$name['members_seo_name'] = $report_data['SEOTITLE'];
}
else
{
$name = $this->DB->buildAndFetch( array( 'select' => 'members_seo_name', 'from' => 'members', 'where' => 'member_id=' . intval($this->request['member_id']) ) );
}
$this->registry->output->redirectScreen( $this->lang->words['report_sending'], $this->settings['base_url'] . $report_data['REDIRECT_URL'], $name['members_seo_name'], 'showuser' );
}
/**
* Retrieve list of users to send notifications to
*
* @access public
* @param string Group ids
* @param array Report data
* @return array Array of users to PM/Email
*/
public function getNotificationList( $group_ids, $report_data )
{
$notify = array();
$this->DB->build( array(
'select' => 'noti.*',
'from' => array( 'rc_modpref' => 'noti' ),
'where' => 'mem.member_group_id IN(' . $group_ids . ')',
'add_join' => array(
array(
'select' => 'mem.member_id, mem.members_display_name as name, mem.language, mem.members_disable_pm, mem.email, mem.member_group_id',
'from' => array( 'members' => 'mem' ),
'where' => 'mem.member_id=noti.mem_id',
)
)
) );
$this->DB->execute();
if( $this->DB->getTotalRows() > 0 )
{
while( $row = $this->DB->fetch() )
{
if( $row['by_pm'] == 1 )
{
$notify['PM'][] = $row;
}
if( $row['by_email'] == 1 )
{
$notify['EMAIL'][] = $row;
}
$notify['RSS'][] = $row;
}
}
return $notify;
}
}