Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
@@ -1 +1,10 @@
|
||||
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Extended Member Functions. Disparate functions that are not required
|
||||
* on every page view.
|
||||
* Last Updated: $Date: 2009-09-22 17:31:43 -0400 (Tue, 22 Sep 2009) $
|
||||
* Last Updated: $Date: 2010-08-05 19:11:01 -0400 (Thu, 05 Aug 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: josh $ (Original: MattMecham)
|
||||
* @author $Author: bfarber $ (Original: MattMecham)
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Tuesday 1st March 2005 (11:52)
|
||||
* @version $Revision: 5141 $
|
||||
* @version $Revision: 6731 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -147,7 +149,7 @@ class memberFunctions
|
||||
// So, lets do the converteroo
|
||||
//-----------------------------------------
|
||||
|
||||
IPSMember::save( $member['member_id'], array( 'core' => array( 'name' => $name, 'members_l_username' => mb_strtolower( $name ), 'members_seo_name' => $_seoName ) ) );
|
||||
IPSMember::save( $member['member_id'], array( 'core' => array( 'name' => $name, 'members_l_username' => mb_strtolower( $name ) ) ) );
|
||||
|
||||
$this->DB->force_data_type = array( 'member_name' => 'string' );
|
||||
$this->DB->update( 'moderators', array( 'member_name' => $name ), "member_id=" . $member['member_id'] );
|
||||
@@ -253,11 +255,11 @@ class memberFunctions
|
||||
{
|
||||
if( $field == 'members_display_name' )
|
||||
{
|
||||
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_username_taken'] ) );
|
||||
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => 'reg_error_username_taken' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_username_taken'] ) );
|
||||
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => 'reg_error_username_taken' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,11 +274,11 @@ class memberFunctions
|
||||
switch( $e->getMessage() )
|
||||
{
|
||||
case 'NO_NAME':
|
||||
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_no_name'] ) );
|
||||
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => 'reg_error_no_name' ) );
|
||||
break;
|
||||
|
||||
case 'ILLEGAL_CHARS':
|
||||
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_chars'] ) );
|
||||
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => 'reg_error_chars' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -285,11 +287,11 @@ class memberFunctions
|
||||
switch( $e->getMessage() )
|
||||
{
|
||||
case 'NO_NAME':
|
||||
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_username_none'] ) );
|
||||
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => 'reg_error_username_none' ) );
|
||||
break;
|
||||
|
||||
case 'ILLEGAL_CHARS':
|
||||
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_chars'] ) );
|
||||
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => 'reg_error_chars' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -332,7 +334,7 @@ class memberFunctions
|
||||
$error = "";
|
||||
$banFilters = array();
|
||||
$_timeCheck = time() - 86400 * $this->memberData['g_dname_date'];
|
||||
$member = ( isset( $member['member_id'] ) ) ? $member : $this->memberData;
|
||||
$member = is_array($member) ? $member : array();
|
||||
$checkField = ( $field == 'members_display_name' ) ? 'members_l_display_name' : 'members_l_username';
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -373,14 +375,17 @@ class memberFunctions
|
||||
// Grab # changes > 24 hours
|
||||
//-----------------------------------------
|
||||
|
||||
$name_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MIN(dname_date) as min_date', 'from' => 'dnames_change', 'where' => "dname_member_id=" . $member['member_id'] . " AND dname_date > $_timeCheck" ) );
|
||||
|
||||
$name_count['count'] = intval( $name_count['count'] );
|
||||
$name_count['min_date'] = intval( $name_count['min_date'] ) ? intval( $name_count['min_date'] ) : $_timeCheck;
|
||||
|
||||
if ( intval( $name_count['count'] ) >= $member['g_dname_changes'] )
|
||||
if( $member['member_id'] )
|
||||
{
|
||||
throw new Exception( "NO_MORE_CHANGES" );
|
||||
$name_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MIN(dname_date) as min_date', 'from' => 'dnames_change', 'where' => "dname_member_id=" . $member['member_id'] . " AND dname_date > $_timeCheck" ) );
|
||||
|
||||
$name_count['count'] = intval( $name_count['count'] );
|
||||
$name_count['min_date'] = intval( $name_count['min_date'] ) ? intval( $name_count['min_date'] ) : $_timeCheck;
|
||||
|
||||
if ( intval( $name_count['count'] ) >= $member['g_dname_changes'] )
|
||||
{
|
||||
throw new Exception( "NO_MORE_CHANGES" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,12 +431,30 @@ class memberFunctions
|
||||
// Check for existing name.
|
||||
//-----------------------------------------
|
||||
|
||||
/* Load the handler if it's not present */
|
||||
if( ! $this->han_login )
|
||||
{
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
|
||||
$this->han_login = new $classToLoad( $this->registry );
|
||||
$this->han_login->init();
|
||||
}
|
||||
|
||||
if( $member['member_id'] )
|
||||
{
|
||||
$this->han_login->nameExistsCheck( $name, $member, $checkField );
|
||||
|
||||
if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'NAME_NOT_IN_USE' )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => "{$field}, member_id",
|
||||
'from' => 'members',
|
||||
'where' => $checkField . "='". $this->DB->addSlashes( mb_strtolower($name) )."' AND member_id != ".$member['member_id'],
|
||||
'where' => $checkField . "='" . $this->DB->addSlashes( mb_strtolower($name) ) . "'" . ( $member['member_id'] ? " AND member_id != " . $member['member_id'] : '' ),
|
||||
'limit' => array( 0,1 ) ) );
|
||||
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -446,7 +469,7 @@ class memberFunctions
|
||||
//-----------------------------------------
|
||||
// Not allowed to select another's log in name
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ( $field == 'members_display_name' AND $this->settings['auth_dnames_nologinname'] )
|
||||
{
|
||||
$check_name = $this->DB->buildAndFetch( array( 'select' => "{$field}, member_id",
|
||||
@@ -456,7 +479,7 @@ class memberFunctions
|
||||
|
||||
if ( $this->DB->getTotalRows() )
|
||||
{
|
||||
if ( $member['member_id'] AND $check_name['member_id'] != $member['member_id'] )
|
||||
if ( !$member['member_id'] OR $check_name['member_id'] != $member['member_id'] )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -464,7 +487,7 @@ class memberFunctions
|
||||
}
|
||||
|
||||
if ( $field == 'name' AND $this->settings['auth_dnames_nologinname'] )
|
||||
{
|
||||
{
|
||||
$check_name = $this->DB->buildAndFetch( array( 'select' => "{$field}, member_id",
|
||||
'from' => 'members',
|
||||
'where' => "members_l_display_name='" . $this->DB->addSlashes( mb_strtolower($name) ) . "'",
|
||||
@@ -472,20 +495,20 @@ class memberFunctions
|
||||
|
||||
if ( $this->DB->getTotalRows() )
|
||||
{
|
||||
if ( $member['member_id'] AND $check_name['member_id'] != $member['member_id'] )
|
||||
if ( !$member['member_id'] OR $check_name['member_id'] != $member['member_id'] )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Test for unicode name
|
||||
//-----------------------------------------
|
||||
|
||||
$unicodeName = $this->_getUnicodeName( $name );
|
||||
|
||||
if ( $unicodeName != $name )
|
||||
//-----------------------------------------
|
||||
// Test for unicode name
|
||||
//-----------------------------------------
|
||||
|
||||
$unicodeName = $this->_getUnicodeName( $name );
|
||||
|
||||
if ( $unicodeName != $name )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Check for existing name.
|
||||
@@ -493,7 +516,7 @@ class memberFunctions
|
||||
|
||||
$this->DB->build( array( 'select' => "members_display_name, member_id, email",
|
||||
'from' => 'members',
|
||||
'where' => $checkField . "='". $this->DB->addSlashes( mb_strtolower($unicodeName) )."' AND member_id != ".$member['member_id'],
|
||||
'where' => $checkField . "='". $this->DB->addSlashes( mb_strtolower($unicodeName) ) . "'" . ( $member['member_id'] ? " AND member_id != " . $member['member_id'] : '' ),
|
||||
'limit' => array( 0,1 ) ) );
|
||||
|
||||
$this->DB->execute();
|
||||
@@ -600,13 +623,14 @@ class memberFunctions
|
||||
if( ipsRegistry::$settings['username_characters'] )
|
||||
{
|
||||
$check_against = preg_quote( ipsRegistry::$settings['username_characters'], "/" );
|
||||
|
||||
if( !preg_match( "/^[" . $check_against . "]+$/i", $name ) )
|
||||
$check_against = str_replace( '\-', '-', $check_against ); // Fix for bug #20998
|
||||
|
||||
if( !preg_match( "/^[" . $check_against . "]+$/iu", $name ) )
|
||||
{
|
||||
return array( 'name' => $original, 'errors' => array( str_replace( '{chars}', ipsRegistry::$settings['username_characters'], ipsRegistry::$settings['username_errormsg'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Manually check against bad chars
|
||||
//-----------------------------------------
|
||||
@@ -794,7 +818,7 @@ class memberFunctions
|
||||
|
||||
$upload->out_file_name = 'photo-'.$member_id;
|
||||
$upload->out_file_dir = $upload_path;
|
||||
$upload->max_file_size = ($p_max * 1024) * 8; // Allow xtra for compression
|
||||
$upload->max_file_size = $p_max * 1024;
|
||||
$upload->upload_form_field = 'upload_photo';
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -876,60 +900,71 @@ class memberFunctions
|
||||
{
|
||||
$imageDimensions = getimagesize( $upload_path . '/' . $real_name );
|
||||
|
||||
//-----------------------------------------
|
||||
// Main photo
|
||||
//-----------------------------------------
|
||||
|
||||
if( $imageDimensions[0] > $p_width OR $imageDimensions[1] > $p_height )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Main photo
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH."classImage.php" );
|
||||
require_once( IPS_KERNEL_PATH."classImageGd.php" );
|
||||
$image = new classImageGd();
|
||||
|
||||
$image->init( array(
|
||||
'image_path' => $upload_path,
|
||||
'image_file' => $real_name,
|
||||
) );
|
||||
|
||||
'image_path' => $upload_path,
|
||||
'image_file' => $real_name,
|
||||
) );
|
||||
|
||||
$return = $image->resizeImage( $p_width, $p_height );
|
||||
$image->writeImage( $upload_path . '/' . 'photo-'.$member_id . '.' . $upload->file_extension );
|
||||
|
||||
|
||||
$t_real_name = $return['thumb_location'] ? $return['thumb_location'] : $real_name;
|
||||
|
||||
|
||||
$im['img_width'] = $return['newWidth'] ? $return['newWidth'] : $image->cur_dimensions['width'];
|
||||
$im['img_height'] = $return['newHeight'] ? $return['newHeight'] : $image->cur_dimensions['height'];
|
||||
|
||||
//-----------------------------------------
|
||||
// MINI photo
|
||||
//-----------------------------------------
|
||||
|
||||
$image->init( array(
|
||||
'image_path' => $upload_path,
|
||||
'image_file' => $t_real_name,
|
||||
) );
|
||||
|
||||
$return = $image->resizeImage( $t_width, $t_height );
|
||||
$image->writeImage( $upload_path . '/' . 'photo-thumb-'.$member_id . '.' . $upload->file_extension );
|
||||
|
||||
$t_im['img_width'] = $return['newWidth'];
|
||||
$t_im['img_height'] = $return['newHeight'];
|
||||
$t_im['img_location'] = count($return) ? 'photo-thumb-'.$member_id . '.' . $upload->file_extension : $real_name;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$im['img_width'] = $imageDimensions[0];
|
||||
$im['img_height'] = $imageDimensions[1];
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// MINI photo
|
||||
//-----------------------------------------
|
||||
|
||||
if( $imageDimensions[0] > $t_width OR $imageDimensions[1] > $t_height )
|
||||
{
|
||||
|
||||
require_once( IPS_KERNEL_PATH . "classImage.php" );
|
||||
require_once( IPS_KERNEL_PATH . "classImageGd.php" );
|
||||
|
||||
$image = new classImageGd();
|
||||
|
||||
//-----------------------------------------
|
||||
// Mini photo
|
||||
//-----------------------------------------
|
||||
$image->init( array(
|
||||
'image_path' => $upload_path,
|
||||
'image_file' => $t_real_name,
|
||||
) );
|
||||
|
||||
$return = $image->resizeImage( $t_width, $t_height );
|
||||
$image->writeImage( $upload_path . '/' . 'photo-thumb-'.$member_id . '.' . $upload->file_extension );
|
||||
|
||||
$t_im['img_width'] = $return['newWidth'];
|
||||
$t_im['img_height'] = $return['newHeight'];
|
||||
$t_im['img_location'] = count($return) ? 'photo-thumb-'.$member_id . '.' . $upload->file_extension : $real_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_data = IPSLib::scaleImage( array(
|
||||
'max_height' => $t_height,
|
||||
'max_width' => $t_width,
|
||||
'cur_width' => $im['img_width'],
|
||||
'cur_height' => $im['img_height']
|
||||
) );
|
||||
|
||||
$_data = IPSLib::scaleImage( array( 'max_height' => $t_height,
|
||||
'max_width' => $t_width,
|
||||
'cur_width' => $im['img_width'],
|
||||
'cur_height' => $im['img_height'] ) );
|
||||
|
||||
$t_im['img_width'] = $_data['img_width'];
|
||||
$t_im['img_width'] = $_data['img_width'];
|
||||
$t_im['img_height'] = $_data['img_height'];
|
||||
$t_im['img_location'] = $real_name;
|
||||
}
|
||||
@@ -1011,6 +1046,222 @@ class memberFunctions
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload background image
|
||||
* Assumes all security checks have been performed by this point
|
||||
*
|
||||
* @access public
|
||||
* @param integer [Optional] member id instead of current member
|
||||
* @return array [ error (error message), status (status message [ok/fail] ) ]
|
||||
*/
|
||||
public function uploadBackgroundImage( $member_id = 0 )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$return = array( 'error' => '',
|
||||
'status' => '',
|
||||
'final_location' => '' );
|
||||
|
||||
$member_id = $member_id ? intval($member_id) : intval( $this->memberData['member_id'] );
|
||||
$p_max = $this->memberData['g_max_bgimg_upload'] ? intval( $this->memberData['g_max_bgimg_upload'] ) : 999999999;
|
||||
$real_name = '';
|
||||
$upload_dir = '';
|
||||
$final_location = '';
|
||||
|
||||
if( ! $member_id )
|
||||
{
|
||||
return array( 'status' => 'cannot_find_member' );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out upload dir
|
||||
//-----------------------------------------
|
||||
|
||||
/* Fix for bug 5075 */
|
||||
$this->settings['upload_dir'] = str_replace( '.', '.', $this->settings['upload_dir'] );
|
||||
|
||||
$upload_path = $this->settings['upload_dir'];
|
||||
|
||||
# Preserve original path
|
||||
$_upload_path = $this->settings['upload_dir'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Already a dir?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists( $upload_path . "/bgimages" ) )
|
||||
{
|
||||
if ( @mkdir( $upload_path . "/bgimages", 0777 ) )
|
||||
{
|
||||
@file_put_contents( $upload_path . '/bgimages/index.html', '' );
|
||||
@chmod( $upload_path . "/bgimages", 0777 );
|
||||
|
||||
# Set path and dir correct
|
||||
$upload_path .= "/bgimages";
|
||||
$upload_dir = "bgimages/";
|
||||
}
|
||||
else
|
||||
{
|
||||
# Set path and dir correct
|
||||
$upload_dir = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Set path and dir correct
|
||||
$upload_path .= "/bgimages";
|
||||
$upload_dir = "bgimages/";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Lets check for an uploaded photo..
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $_FILES['bg_upload']['name'] != "" and ($_FILES['bg_upload']['name'] != "none" ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Are we allowed to upload this photo?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $p_max < 0 )
|
||||
{
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'no_bgimg_upload_permission';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove any uploaded photos...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->removeUploadedBackgroundImages( $member_id );
|
||||
|
||||
$real_name = 'bgimg-'.$member_id;
|
||||
|
||||
//-----------------------------------------
|
||||
// Load the library
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classUpload.php' );
|
||||
$upload = new classUpload();
|
||||
|
||||
//-----------------------------------------
|
||||
// Set up the variables
|
||||
//-----------------------------------------
|
||||
|
||||
$upload->out_file_name = 'bgimg-'.$member_id;
|
||||
$upload->out_file_dir = $upload_path;
|
||||
$upload->max_file_size = $p_max * 1024;
|
||||
$upload->upload_form_field = 'bg_upload';
|
||||
|
||||
//-----------------------------------------
|
||||
// Populate allowed extensions
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $this->cache->getCache('attachtypes') ) and count( $this->cache->getCache('attachtypes') ) )
|
||||
{
|
||||
foreach( $this->cache->getCache('attachtypes') as $data )
|
||||
{
|
||||
if ( $data['atype_photo'] )
|
||||
{
|
||||
if( $data['atype_extension'] == 'swf' AND $this->settings['disable_flash'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$upload->allowed_file_ext[] = $data['atype_extension'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Upload...
|
||||
//-----------------------------------------
|
||||
|
||||
$upload->process();
|
||||
|
||||
//-----------------------------------------
|
||||
// Error?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $upload->error_no )
|
||||
{
|
||||
switch( $upload->error_no )
|
||||
{
|
||||
case 1:
|
||||
// No upload
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'upload_failed';
|
||||
break;
|
||||
case 2:
|
||||
// Invalid file ext
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'invalid_file_extension';
|
||||
break;
|
||||
case 3:
|
||||
// Too big...
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'upload_to_big';
|
||||
break;
|
||||
case 4:
|
||||
// Cannot move uploaded file
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'upload_failed';
|
||||
break;
|
||||
case 5:
|
||||
// Possible XSS attack (image isn't an image)
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'upload_failed';
|
||||
break;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Still here?
|
||||
//-----------------------------------------
|
||||
|
||||
$real_name = $upload->parsed_file_name;
|
||||
$t_real_name = $upload->parsed_file_name;
|
||||
|
||||
//-----------------------------------------
|
||||
// Check the file size (after compression)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( filesize( $upload_path . "/" . $real_name ) > ( $p_max * 1024 ) )
|
||||
{
|
||||
@unlink( $upload_path . "/" . $real_name );
|
||||
|
||||
// Too big...
|
||||
$return['status'] = 'fail';
|
||||
$return['error'] = 'upload_to_big';
|
||||
return $return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------
|
||||
|
||||
$final_location = $upload_dir . $real_name;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['status'] = 'ok';
|
||||
return $return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Return...
|
||||
//-----------------------------------------
|
||||
|
||||
$return['final_location'] = $final_location;
|
||||
$return['status'] = 'ok';
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove member uploaded photos
|
||||
@@ -1027,10 +1278,7 @@ class memberFunctions
|
||||
//-----------------------------------------
|
||||
|
||||
$upload_path = $upload_path ? $upload_path : $this->settings['upload_dir'];
|
||||
|
||||
# Preserve original path
|
||||
$_upload_path = $this->settings['upload_dir'];
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Already a dir?
|
||||
//-----------------------------------------
|
||||
@@ -1044,35 +1292,79 @@ class memberFunctions
|
||||
|
||||
# Set path and dir correct
|
||||
$upload_path .= "/profile";
|
||||
$upload_dir = "profile/";
|
||||
}
|
||||
else
|
||||
{
|
||||
# Set path and dir correct
|
||||
$upload_dir = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Set path and dir correct
|
||||
$upload_path .= "/profile";
|
||||
$upload_dir = "profile/";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Go...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
|
||||
{
|
||||
if ( @file_exists( $upload_path."/photo-".$id.".".$ext ) )
|
||||
{
|
||||
@unlink( $upload_path."/photo-".$id.".".$ext );
|
||||
}
|
||||
|
||||
if ( @file_exists( $upload_path."/photo-thumb-".$id.".".$ext ) )
|
||||
//-----------------------------------------
|
||||
// Only try to delete if we didn't just create dir
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
|
||||
{
|
||||
@unlink( $upload_path."/photo-thumb-".$id.".".$ext );
|
||||
if ( @file_exists( $upload_path."/photo-".$id.".".$ext ) )
|
||||
{
|
||||
@unlink( $upload_path."/photo-".$id.".".$ext );
|
||||
}
|
||||
|
||||
if ( @file_exists( $upload_path."/photo-thumb-".$id.".".$ext ) )
|
||||
{
|
||||
@unlink( $upload_path."/photo-thumb-".$id.".".$ext );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove member uploaded background images
|
||||
*
|
||||
* @access public
|
||||
* @param integer Member ID
|
||||
* @param string [Optional] Directory to check
|
||||
* @return array [ error (error message), status (status message [ok/fail] ) ]
|
||||
*/
|
||||
public function removeUploadedBackgroundImages( $id, $upload_path='' )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$upload_path = $upload_path ? $upload_path : $this->settings['upload_dir'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Already a dir?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists( $upload_path . "/bgimages" ) )
|
||||
{
|
||||
if ( @mkdir( $upload_path . "/bgimages", 0777 ) )
|
||||
{
|
||||
@file_put_contents( $upload_path . '/index.html', '' );
|
||||
@chmod( $upload_path . "/bgimages", 0777 );
|
||||
|
||||
# Set path and dir correct
|
||||
$upload_path .= "/bgimages";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Set path and dir correct
|
||||
$upload_path .= "/bgimages";
|
||||
|
||||
//-----------------------------------------
|
||||
// Only should bother trying to delete if we didn't
|
||||
// just create the folder
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
|
||||
{
|
||||
if ( @file_exists( $upload_path."/bgimg-".$id.".".$ext ) )
|
||||
{
|
||||
@unlink( $upload_path."/bgimg-".$id.".".$ext );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1207,7 +1499,7 @@ class memberFunctions
|
||||
|
||||
$upload->out_file_name = $real_name;
|
||||
$upload->out_file_dir = $this->settings['upload_dir'];
|
||||
$upload->max_file_size = ($this->settings['avup_size_max'] * 1024) * 8; // Allow xtra for compression
|
||||
$upload->max_file_size = $this->settings['avup_size_max'] * 1024;
|
||||
$upload->upload_form_field = $uploadFieldName;
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1388,8 +1680,16 @@ class memberFunctions
|
||||
$directory .= '/';
|
||||
}
|
||||
}
|
||||
|
||||
$filename = preg_replace( "/[^\s\w\._\-\[\]\(\)]/", "", urldecode( $this->request[$avatarGalleryImage] ) );
|
||||
|
||||
// BUG #20822
|
||||
if( function_exists( 'mb_ereg_replace' ) )
|
||||
{
|
||||
$filename = mb_ereg_replace( "/[^\s\w\._\-\[\]\(\)]/", "", urldecode( $this->request[$avatarGalleryImage] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename = preg_replace( "/[^\s\w\._\-\[\]\(\)]/", "", urldecode( $this->request[$avatarGalleryImage] ) );
|
||||
}
|
||||
|
||||
if( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_avatars/' . $directory . $filename ) )
|
||||
{
|
||||
@@ -1447,7 +1747,7 @@ class memberFunctions
|
||||
*/
|
||||
public function getHostedAvatarsFromCategory( $catName )
|
||||
{
|
||||
//$catName = IPSText::alphanumericalClean( $catName ); // Commented out because alphanumericalClean removes spaces
|
||||
$catName = IPSText::alphanumericalClean( $catName, ' ' ); // Commented out because alphanumericalClean removes spaces
|
||||
$images = array();
|
||||
$path = '';
|
||||
|
||||
@@ -1540,8 +1840,8 @@ class memberFunctions
|
||||
*/
|
||||
private function _sortAvatars( $a, $b )
|
||||
{
|
||||
$aa = strtolower($a[1]);
|
||||
$bb = strtolower($b[1]);
|
||||
$aa = mb_strtolower($a[1]);
|
||||
$bb = mb_strtolower($b[1]);
|
||||
|
||||
if ( $aa == $bb ) return 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,847 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* Notification library
|
||||
* Last Updated: $Date: 2010-10-08 10:15:14 -0400 (Fri, 08 Oct 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mark $ (Original: bfarber)
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Thursday Jan 7, 2010
|
||||
* @version $Revision: 6956 $
|
||||
*
|
||||
* @todo Need to push Downloads, Blog and Gallery into new system
|
||||
*/
|
||||
|
||||
/**
|
||||
* Notifications class.
|
||||
* Sends notifications to member(s) based on their configured notification options.
|
||||
*/
|
||||
class notifications
|
||||
{
|
||||
/**#@+
|
||||
* Registry objects
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Member data
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $_member = array();
|
||||
|
||||
/**
|
||||
* From member data (usually $this->memberData)
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $_from = array();
|
||||
|
||||
/**
|
||||
* Notification definitions
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $_notificationData = array();
|
||||
|
||||
/**
|
||||
* Notification key
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_notificationKey = '';
|
||||
|
||||
/**
|
||||
* Notification text
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_notificationText = '';
|
||||
|
||||
/**
|
||||
* Notification title
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_notificationTitle = '';
|
||||
|
||||
/**
|
||||
* Notification URL
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_notificationUrl = '';
|
||||
|
||||
/**
|
||||
* CONSTRUCTOR
|
||||
*
|
||||
* @param blog_show $class
|
||||
* @return void
|
||||
**/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
/* Make registry objects */
|
||||
$this->registry = $registry;
|
||||
$this->DB = $this->registry->DB();
|
||||
$this->settings =& $this->registry->fetchSettings();
|
||||
$this->request =& $this->registry->fetchRequest();
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
$this->member = $this->registry->member();
|
||||
$this->memberData =& $this->registry->member()->fetchMemberData();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->caches =& $this->registry->cache()->fetchCaches();
|
||||
|
||||
//-----------------------------------------
|
||||
// Set default
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_from = $this->memberData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for board index hook
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getBoardIndexHook()
|
||||
{
|
||||
$_notifications = $this->fetchUnreadNotifications(10, 'notify_sent', 'DESC');
|
||||
|
||||
//-----------------------------------------
|
||||
// If none are unread, no HTML
|
||||
//-----------------------------------------
|
||||
|
||||
if( !count($_notifications) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->registry->output->getTemplate('boards')->hookUnreadNotifications( $_notifications );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Member
|
||||
*
|
||||
* @access public
|
||||
* @param mixed Member id (int) or member data (array)
|
||||
* @return void
|
||||
*/
|
||||
public function setMember( $member )
|
||||
{
|
||||
if( is_int($member) )
|
||||
{
|
||||
$member = IPSMember::load( $member );
|
||||
}
|
||||
|
||||
$this->_member = $member;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set member message should come 'from'
|
||||
*
|
||||
* @access public
|
||||
* @param mixed Member id (int) or member data (array)
|
||||
* @return void
|
||||
*/
|
||||
public function setFrom( $member )
|
||||
{
|
||||
if( is_int($member) )
|
||||
{
|
||||
$member = IPSMember::load( $member );
|
||||
}
|
||||
|
||||
$this->_from = $member;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notification type key
|
||||
*
|
||||
* @access public
|
||||
* @param string Notification type key
|
||||
* @return void
|
||||
*/
|
||||
public function setNotificationKey( $key )
|
||||
{
|
||||
$this->_notificationKey = $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notification URL
|
||||
*
|
||||
* @access public
|
||||
* @param string Notification URL
|
||||
* @return void
|
||||
*/
|
||||
public function setNotificationUrl( $url )
|
||||
{
|
||||
$this->_notificationUrl = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notification text
|
||||
*
|
||||
* @access public
|
||||
* @param string Text
|
||||
* @return void
|
||||
*/
|
||||
public function setNotificationText( $text )
|
||||
{
|
||||
$this->_notificationText = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notification title
|
||||
*
|
||||
* @access public
|
||||
* @param string Title
|
||||
* @return void
|
||||
*/
|
||||
public function setNotificationTitle( $title )
|
||||
{
|
||||
$this->_notificationTitle = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all notification types
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getNotificationKeys()
|
||||
{
|
||||
$data = $this->getNotificationData();
|
||||
|
||||
return array_keys( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification config file data
|
||||
*
|
||||
* @access public
|
||||
* @param bool If true, will check show_callback to see if user has permission
|
||||
* @return array
|
||||
*/
|
||||
public function getNotificationData( $checkCallbacks=FALSE )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Already stored the data?
|
||||
//-----------------------------------------
|
||||
|
||||
if( count($this->_notificationData) )
|
||||
{
|
||||
return $this->_notificationData;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get for each application
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( ipsRegistry::$applications as $app_dir => $application )
|
||||
{
|
||||
if( IPSLib::appIsInstalled( $app_dir) )
|
||||
{
|
||||
if( file_exists( IPSLib::getAppDir( $app_dir ) . '/extensions/notifications.php' ) )
|
||||
{
|
||||
require_once( IPSLib::getAppDir( $app_dir ) . '/extensions/notifications.php' );
|
||||
|
||||
$className = $app_dir . '_notifications';
|
||||
|
||||
if ( class_exists( $className ) )
|
||||
{
|
||||
$class = new $className();
|
||||
$class->memberData = ipsRegistry::member()->fetchMemberData();
|
||||
|
||||
$_NOTIFY = $class->getConfiguration();
|
||||
|
||||
if ( $checkCallbacks )
|
||||
{
|
||||
foreach ( $_NOTIFY as $n )
|
||||
{
|
||||
if ( $n['show_callback'] and method_exists( $class, $n['key'] ) )
|
||||
{
|
||||
if ( $class->$n['key']() )
|
||||
{
|
||||
$this->_notificationData[] = $n;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_notificationData[] = $n;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_notificationData = ( is_array( $this->_notificationData ) ) ? $this->_notificationData : array();
|
||||
$this->_notificationData = array_merge( $this->_notificationData, $_NOTIFY );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_notificationData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the notification data as if it were configured
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function formatNotificationData()
|
||||
{
|
||||
$_data = $this->getNotificationData();
|
||||
$_return = array();
|
||||
|
||||
foreach( $_data as $data )
|
||||
{
|
||||
$_return[ $data['key'] ] = array();
|
||||
$_return[ $data['key'] ]['selected'] = $data['default'];
|
||||
$_return[ $data['key'] ]['disabled'] = $data['disabled'];
|
||||
$_return[ $data['key'] ]['disable_override'] = 0;
|
||||
}
|
||||
|
||||
return $_return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ACP-set notification configuration
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultNotificationConfig()
|
||||
{
|
||||
return $this->cache->getCache('notifications') ? $this->cache->getCache('notifications') : $this->formatNotificationData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the ACP-set notification configuration
|
||||
*
|
||||
* @access public
|
||||
* @param array Notification configuration
|
||||
* @return void
|
||||
*/
|
||||
public function saveNotificationConfig( $config )
|
||||
{
|
||||
$this->cache->setCache( 'notifications', $config, array( 'array' => 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild notifications cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildNotificationsCache()
|
||||
{
|
||||
$this->saveNotificationConfig( $this->formatNotificationData() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member's notification configuration
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
* @link http://community.invisionpower.com/tracker/issue-23529-notification-defaults-dont-apply/
|
||||
* @link http://community.invisionpower.com/tracker/issue-23663-notification-issues/
|
||||
*/
|
||||
public function getMemberNotificationConfig()
|
||||
{
|
||||
$_cache = IPSMember::unpackMemberCache( $this->_member['members_cache'] );
|
||||
|
||||
if( $_cache['notifications'] )
|
||||
{
|
||||
$savedTypes = array_keys( $_cache['notifications'] );
|
||||
$_default = $this->getDefaultNotificationConfig();
|
||||
$defaultTypes = array_keys( $_default );
|
||||
$missingTypes = array_diff( $savedTypes, $defaultTypes );
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab any missing types
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $missingTypes as $_type )
|
||||
{
|
||||
$_cache['notifications'][ $_type ] = $_default[ $_type ]['selected'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Make changes if admin has disallowed override
|
||||
// since we saved our config
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $_default as $k => $sub )
|
||||
{
|
||||
if( $sub['disable_override'] )
|
||||
{
|
||||
$_cache['notifications'][ $k ]['selected'] = $sub['selected'];
|
||||
}
|
||||
else if( $sub['disabled'] )
|
||||
{
|
||||
$_newSelection = array();
|
||||
|
||||
if( is_array($_cache['notifications'][ $k ]['selected']) AND count($_cache['notifications'][ $k ]['selected']) )
|
||||
{
|
||||
foreach( $_cache['notifications'][ $k ]['selected'] as $_thisType )
|
||||
{
|
||||
if( !in_array( $_thisType, $sub['disabled'] ) )
|
||||
{
|
||||
$_newSelection[] = $_thisType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_cache['notifications'][ $k ]['selected'] = $_newSelection;
|
||||
}
|
||||
}
|
||||
|
||||
return $_cache['notifications'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->getDefaultNotificationConfig();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
* @throws NO_MEMBER_ID, NO_NOTIFY_KEY, BAD_NOTIFY_KEY
|
||||
*/
|
||||
public function sendNotification()
|
||||
{
|
||||
if( !$this->_member['member_id'] )
|
||||
{
|
||||
throw new Exception( 'NO_MEMBER_ID' );
|
||||
}
|
||||
|
||||
if( !$this->_notificationKey )
|
||||
{
|
||||
throw new Exception( 'NO_NOTIFY_KEY' );
|
||||
}
|
||||
|
||||
$_config = $this->getMemberNotificationConfig();
|
||||
|
||||
if( !$_config[ $this->_notificationKey ] )
|
||||
{
|
||||
throw new Exception( 'BAD_NOTIFY_KEY' );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Send appropriate notifications.
|
||||
// We can have more than one notification method for each
|
||||
// notification type.
|
||||
//-----------------------------------------
|
||||
|
||||
if( is_array($_config[ $this->_notificationKey ]) AND count($_config[ $this->_notificationKey ]) )
|
||||
{
|
||||
foreach( $_config[ $this->_notificationKey ]['selected'] as $_type )
|
||||
{
|
||||
switch( $_type )
|
||||
{
|
||||
case 'pm':
|
||||
$this->_sendPMNotification();
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
$this->_sendEmailNotification();
|
||||
break;
|
||||
|
||||
case 'inline':
|
||||
$this->_sendInlineNotification();
|
||||
break;
|
||||
|
||||
case 'mobile':
|
||||
$this->_sendMobileNotification();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification via mobile device
|
||||
*
|
||||
* @access protected
|
||||
* @return mixed True, or can output an error
|
||||
*/
|
||||
protected function _sendMobileNotification()
|
||||
{
|
||||
/* Just save the notification, a task will handle it later */
|
||||
if( IPSLib::canReceiveMobileNotifications( $this->_member ) && $this->_member['ips_mobile_token'] )
|
||||
{
|
||||
$this->DB->insert( 'mobile_notifications', array(
|
||||
'notify_title' => strip_tags( $this->_notificationTitle ),
|
||||
'notify_date' => time(),
|
||||
'member_id' => $this->_member['member_id']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification via private conversation
|
||||
*
|
||||
* @access protected
|
||||
* @return mixed True, or can output an error
|
||||
*/
|
||||
protected function _sendPMNotification()
|
||||
{
|
||||
/* Have they disabled their messenger? */
|
||||
if ( $this->_member['members_disable_pm'] )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* No? Okay, carry on */
|
||||
try
|
||||
{
|
||||
$_classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'members' ) . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members' );
|
||||
|
||||
$_messenger = new $_classToLoad( $this->registry );
|
||||
$_messenger->sendNewPersonalTopic( intval( $this->_member['member_id'] ),
|
||||
intval( $this->_from['member_id'] ),
|
||||
array(),
|
||||
strip_tags($this->_notificationTitle),
|
||||
IPSText::getTextClass('editor')->method == 'rte' ? nl2br( $this->_notificationText ) : $this->_notificationText,
|
||||
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' )
|
||||
{
|
||||
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( ",", $_messenger->exceptionData ) , $this->lang->words[ 'err_' . $msg ] );
|
||||
$this->lang->words[ 'err_' . $msg ] = str_replace( '#TONAME#' , $this->_member['members_display_name'] , $this->lang->words[ 'err_' . $msg ] );
|
||||
$this->lang->words[ 'err_' . $msg ] = str_replace( '#FROMNAME#' , $this->_from['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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification via email
|
||||
*
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
protected function _sendEmailNotification()
|
||||
{
|
||||
IPSText::getTextClass( 'email' )->message = $this->_notificationText;
|
||||
IPSText::getTextClass( 'email' )->subject = strip_tags( $this->_notificationTitle );
|
||||
IPSText::getTextClass( 'email' )->to = $this->_member['email'];
|
||||
IPSText::getTextClass( 'email' )->from = $this->settings['email_out'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Send immediately
|
||||
//-----------------------------------------
|
||||
|
||||
//IPSText::getTextClass( 'email' )->sendMail();
|
||||
|
||||
//-----------------------------------------
|
||||
// Send delayed
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->insert( 'mail_queue', array( 'mail_to' => IPSText::getTextClass( 'email' )->to, 'mail_from' => IPSText::getTextClass( 'email' )->from, 'mail_date' => time(), 'mail_subject' => IPSText::getTextClass('email')->subject, 'mail_content' => IPSText::getTextClass('email')->message ) );
|
||||
|
||||
$cache = $this->cache->getCache('systemvars');
|
||||
$cache['mail_queue'] += 1;
|
||||
$this->cache->setCache( 'systemvars', $cache, array( 'array' => 1, 'donow' => 1 ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an inline notification
|
||||
*
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
protected function _sendInlineNotification()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// First, make sure member doesn't have too many
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_truncateInlineNotifications();
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert new notification
|
||||
//-----------------------------------------
|
||||
|
||||
$_insert = array(
|
||||
'notify_to_id' => $this->_member['member_id'],
|
||||
'notify_from_id' => intval($this->_from['member_id']),
|
||||
'notify_sent' => time(),
|
||||
'notify_read' => 0,
|
||||
'notify_title' => $this->_notificationTitle,
|
||||
'notify_text' => $this->_notificationText,
|
||||
'notify_type_key' => $this->_notificationKey,
|
||||
'notify_url' => $this->_notificationUrl,
|
||||
);
|
||||
|
||||
$this->DB->insert( 'inline_notifications', $_insert );
|
||||
|
||||
//-----------------------------------------
|
||||
// Update member record
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->update( 'members', 'notification_cnt=notification_cnt+1, msg_show_notification=1', 'member_id=' . $this->_member['member_id'], true, true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear out old notifications if there's a limit to how many member can have
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function _truncateInlineNotifications()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Determine member's limit first
|
||||
//-----------------------------------------
|
||||
|
||||
$groups = array( $this->_member['member_group_id'] );
|
||||
|
||||
if( $this->_member['mgroup_others'] )
|
||||
{
|
||||
$_others = IPSText::cleanPermString( $this->_member['mgroup_others'] );
|
||||
$groups = ( is_array( $groups ) AND is_array( $_others ) ) ? array_merge( $_others, $groups ) : array();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// 0 is best, otherwise higher is better
|
||||
//-----------------------------------------
|
||||
|
||||
$_limit = 0;
|
||||
|
||||
foreach( $groups as $_group )
|
||||
{
|
||||
$_thisLimit = $this->caches['group_cache'][ $_group ]['g_max_notifications'];
|
||||
|
||||
if( !$_thisLimit )
|
||||
{
|
||||
$_limit = 0;
|
||||
break;
|
||||
}
|
||||
else if( $_thisLimit > $_limit )
|
||||
{
|
||||
$_limit = $_thisLimit;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// We have a limit
|
||||
//-----------------------------------------
|
||||
|
||||
if( $_limit )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get current count
|
||||
//-----------------------------------------
|
||||
|
||||
$_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->_member['member_id'] ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// At limit?
|
||||
// We use >= because this is run immediately before
|
||||
// we add a new notification, so if we are at limit
|
||||
// we still need to remove 1
|
||||
//-----------------------------------------
|
||||
|
||||
if( $_count['total'] >= $_limit )
|
||||
{
|
||||
$_toDelete = ( $_count['total'] + 1 ) - $_limit;
|
||||
|
||||
//-----------------------------------------
|
||||
// Yes, delete method supports order by and limit
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->delete( 'inline_notifications', 'notify_to_id=' . $this->_member['member_id'], 'notify_sent ASC', array( $_toDelete ) );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild a member's unread notification count
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildUnreadCount()
|
||||
{
|
||||
$count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->_member['member_id'] . ' AND notify_read=0' ) );
|
||||
|
||||
$this->DB->update( 'members', array( 'notification_cnt' => $count['total'] ), 'member_id=' . $this->_member['member_id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch new PM notification
|
||||
*
|
||||
* @access public
|
||||
* @param int Number if items to limit
|
||||
* @param string Sort column
|
||||
* @param string Sort order
|
||||
* @param bool Only get unread notifications
|
||||
* @param bool Run text through preDisplayParse
|
||||
* @return array Unread notifications
|
||||
*/
|
||||
public function fetchUnreadNotifications( $limit=0, $sortKey='notify_sent', $sortOrder='desc', $unread=true, $parseText=false )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$return = array();
|
||||
$limit = ( $limit ) ? array( 0, intval( $limit ) ) : array( 0, 500 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Fetch unread notifications
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'inline_notifications',
|
||||
'where' => 'notify_to_id=' . $this->_member['member_id'] . ( $unread ? ' AND notify_read=0' : '' ),
|
||||
'order' => $sortKey . ' ' . $sortOrder,
|
||||
'limit' => $limit ) );
|
||||
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch($outer) )
|
||||
{
|
||||
/* As the email template parser makes an attempt to reparse 'safe' HTML, we need to make it safe here */
|
||||
$row['notify_text'] = IPSText::htmlspecialchars( $row['notify_text'] );
|
||||
|
||||
IPSText::getTextClass('bbcode')->parse_smilies = 1;
|
||||
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
|
||||
IPSText::getTextClass('bbcode')->parse_html = 0;
|
||||
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
|
||||
IPSText::getTextClass('bbcode')->parsing_section = 'global';
|
||||
|
||||
if( $parseText )
|
||||
{
|
||||
$row['notify_text'] = IPSText::getTextClass('bbcode')->preDisplayParse( nl2br( $row['notify_text'] ) );
|
||||
}
|
||||
|
||||
$row['notify_icon'] = $this->getNotificationIcon( $row['notify_type_key'] );
|
||||
|
||||
$return[ $row['notify_sent'] . '.' . $row['notify_id'] ] = $row;
|
||||
}
|
||||
|
||||
/* Got anything? */
|
||||
if ( ! count( $return ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/* Reverse sort it (latest first) */
|
||||
// Removed (bfarber) - this negates the ability to custom sort the returned notifications by passing in 2nd/3rd function
|
||||
// params, so I'm commenting out for now
|
||||
//krsort( $return );
|
||||
|
||||
/* Return 'em */
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification icon
|
||||
*
|
||||
* @access public
|
||||
* @param string Notification key
|
||||
* @return string Notification icon
|
||||
*/
|
||||
public function getNotificationIcon( $key )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Init
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$key )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get data
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_notificationData = $this->getNotificationData();
|
||||
|
||||
//-----------------------------------------
|
||||
// Now look for key and return icon
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $this->_notificationData as $data )
|
||||
{
|
||||
if( $data['key'] == $key )
|
||||
{
|
||||
return $data['icon'];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user