Version 3.0.5
This commit is contained in:
1 parent
19b38c7c74
commit
1d4720f3e2
3755 files changed
+508378
-664541
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Board Rules
|
||||
* Last Updated: $Date: 2009-07-16 10:24:48 -0400 (Thu, 16 Jul 2009) $
|
||||
*
|
||||
* @author $Author $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Rev: 4900 $
|
||||
*/
|
||||
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 public_forums_extras_boardrules extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Temporary stored output
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $output = "";
|
||||
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
/* Get board rule (not cached) */
|
||||
$row = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key='gl_guidelines'" ) );
|
||||
|
||||
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
|
||||
IPSText::getTextClass('bbcode')->parse_html = 1;
|
||||
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
|
||||
IPSText::getTextClass('bbcode')->parse_emoticons = 1;
|
||||
IPSText::getTextClass('bbcode')->parsing_section = 'global';
|
||||
|
||||
$row['conf_value'] = IPSText::getTextClass('bbcode')->preDbParse( $row['conf_value'] );
|
||||
$row['conf_value'] = IPSText::getTextClass('bbcode')->preDisplayParse( $row['conf_value'] );
|
||||
|
||||
/* Hacky fix for bug #15632 */
|
||||
//$row['conf_value'] = str_replace( '<ul><br />' , '<ul>', $row['conf_value'] );
|
||||
//$row['conf_value'] = str_replace( '<ul' , '<ul class="bbc"', $row['conf_value'] );
|
||||
//$row['conf_value'] = str_replace( '</li><br />' , '</li>', $row['conf_value'] );
|
||||
//$row['conf_value'] = str_replace( '</ul><br />' , '</ul>', $row['conf_value'] );
|
||||
//$row['conf_value'] = preg_replace( '#<li([^\n]*)<br />#', '<li$1', $row['conf_value'] );
|
||||
|
||||
$this->registry->output->addNavigation( $this->settings['gl_title'], '' );
|
||||
$this->registry->output->setTitle( $this->settings['gl_title'] );
|
||||
$this->registry->output->addContent( $this->registry->output->getTemplate('emails')->boardRules( $this->settings['gl_title'], $row['conf_value'] ) );
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Default forum extras module section
|
||||
* Last Updated: $Date: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
|
||||
*
|
||||
* @author $Author $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Rev: 4948 $
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Very simply returns the default section if one is not
|
||||
* passed in the URL
|
||||
*/
|
||||
|
||||
$DEFAULT_SECTION = 'stats';
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Forward a topic to someone
|
||||
* Last Updated: $Date: 2009-06-25 19:58:52 -0400 (Thu, 25 Jun 2009) $
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Revision: 4822 $
|
||||
*
|
||||
*/
|
||||
|
||||
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 public_forums_extras_forward extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Temporary stored output HTML
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $output;
|
||||
|
||||
/**
|
||||
* Forum information
|
||||
*
|
||||
* @access private
|
||||
* @var array Array of forum details
|
||||
*/
|
||||
private $forum = array();
|
||||
|
||||
/**
|
||||
* Topic information
|
||||
*
|
||||
* @access private
|
||||
* @var array Array of topic details
|
||||
*/
|
||||
private $topic = array();
|
||||
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Grab skin and lang stuff
|
||||
//-----------------------------------------
|
||||
|
||||
ipsRegistry::getClass( 'class_localization')->loadLanguageFile( array( 'public_emails' ), 'core' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Check the input
|
||||
//-----------------------------------------
|
||||
|
||||
$this->request['t'] = intval($this->request['t']);
|
||||
$this->request['f'] = intval($this->request['f']);
|
||||
|
||||
if ( !$this->request['t'] )
|
||||
{
|
||||
$this->registry->output->showError( 'forward_no_tid', 10321 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the topic details
|
||||
//-----------------------------------------
|
||||
|
||||
$this->topic = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'topics', 'where' => "tid=" . $this->request['t'] ) );
|
||||
$this->forum = ipsRegistry::getClass('class_forums')->forum_by_id[ $this->topic['forum_id'] ];
|
||||
|
||||
//-----------------------------------------
|
||||
// Error out if we can not find the forum
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->forum['id'] )
|
||||
{
|
||||
$this->registry->output->showError( 'forward_no_fid', 10322 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Error out if we can not find the topic
|
||||
//-----------------------------------------
|
||||
|
||||
if ( !$this->topic['tid'] )
|
||||
{
|
||||
$this->registry->output->showError( 'forward_no_tid', 10323 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check viewing permissions, private forums,
|
||||
// password forums, etc
|
||||
//-----------------------------------------
|
||||
|
||||
if (! $this->memberData['member_id'] )
|
||||
{
|
||||
$this->registry->output->showError( 'forward_only_members', 10324 );
|
||||
}
|
||||
|
||||
ipsRegistry::getClass('class_forums')->forumsCheckAccess( $this->forum['id'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// What to do?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->request['do'] == '01' )
|
||||
{
|
||||
$this->_sendEmail();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_showForm();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward the page (sends the email)
|
||||
*
|
||||
* @access private
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
private function _sendEmail()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->request['k'] != $this->member->form_hash )
|
||||
{
|
||||
$this->registry->getClass('output')->showError( 'no_permission', 2029 );
|
||||
}
|
||||
|
||||
$lang_to_use = 1;
|
||||
|
||||
foreach( ipsRegistry::cache()->getCache('lang_data') as $l )
|
||||
{
|
||||
if ( $this->request['lang'] == $l['lang_id'] )
|
||||
{
|
||||
$lang_to_use = $l['lang_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$check_array = array ( 'to_name' => 'stf_no_name',
|
||||
'to_email' => 'stf_no_email',
|
||||
'message' => 'stf_no_msg',
|
||||
'subject' => 'stf_no_subject'
|
||||
);
|
||||
|
||||
foreach ($check_array as $input => $msg)
|
||||
{
|
||||
if ( !$this->request[ $input ] )
|
||||
{
|
||||
$this->registry->output->showError( $msg, 10325 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !IPSText::checkEmailAddress( $this->request['to_email'] ) )
|
||||
{
|
||||
$this->registry->output->showError( 'email_address_invalid', 10326 );
|
||||
}
|
||||
|
||||
IPSText::getTextClass('email')->getTemplate( "forward_page", $lang_to_use );
|
||||
|
||||
IPSText::getTextClass('email')->buildMessage( array(
|
||||
'THE_MESSAGE' => $this->request['message'],
|
||||
'TO_NAME' => $this->request['to_name'],
|
||||
'FROM_NAME' => $this->memberData['members_display_name'],
|
||||
)
|
||||
);
|
||||
|
||||
IPSText::getTextClass('email')->subject = $this->request['subject'];
|
||||
IPSText::getTextClass('email')->to = $this->request['to_email'];
|
||||
IPSText::getTextClass('email')->from = $this->memberData['email'];
|
||||
IPSText::getTextClass('email')->sendMail();
|
||||
|
||||
$this->registry->output->redirectScreen( $this->lang->words['redirect'], $this->settings['base_url'] . "showtopic=" . $this->topic['tid'] . "&st=" . $this->request['st'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to forward the page
|
||||
*
|
||||
* @access private
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
private function _showForm()
|
||||
{
|
||||
ipsRegistry::getClass( 'class_localization')->loadLanguageFile( array( 'public_email_content' ), 'core' );
|
||||
|
||||
$this->lang->words['send_text'] = str_replace( "<#THE LINK#>" , $this->registry->getClass('output')->buildSEOUrl( "showtopic=" . $this->topic['tid'], 'public', $this->topic['title_seo'], 'showtopic') , $this->lang->words['send_text'] );
|
||||
$this->lang->words['send_text'] = str_replace( "<#USER NAME#>", $this->memberData['members_display_name'], $this->lang->words['send_text'] );
|
||||
|
||||
$this->output = $this->registry->getClass('output')->getTemplate('emails')->forward_form( $this->topic['title'], $this->lang->words['send_text'] );
|
||||
|
||||
$this->registry->output->addNavigation( $this->forum['name'], $this->settings['_base_url'] . "showforum={$this->forum['id']}" );
|
||||
$this->registry->output->addNavigation( $this->topic['title'], $this->settings['_base_url'] . "showtopic={$this->topic['tid']}" );
|
||||
$this->registry->output->addNavigation( $this->lang->words['title'], '' );
|
||||
$this->registry->output->setTitle( $this->lang->words['title'] );
|
||||
$this->registry->output->addContent( $this->output );
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,184 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Emoticon and BBCode Legends
|
||||
* Last Updated: $Date: 2009-04-21 16:36:40 -0400 (Tue, 21 Apr 2009) $
|
||||
*
|
||||
* @author $Author $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @version $Rev: 4521 $
|
||||
*
|
||||
*/
|
||||
|
||||
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 public_forums_extras_legends extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Output
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $output = "";
|
||||
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
/* Load language */
|
||||
$this->registry->class_localization->loadLanguageFile( array( 'public_legends' ), 'forums' );
|
||||
|
||||
/* What to do */
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'bbcode':
|
||||
$this->bbcodePopUpList();
|
||||
break;
|
||||
|
||||
case 'emoticons':
|
||||
default:
|
||||
$this->emoticonsPopUpList();
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we have any HTML to print, do so... */
|
||||
$this->registry->getClass('output')->setTitle( $this->page_title );
|
||||
$this->registry->getClass('output')->popUpWindow( $this->output );
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the emoticon list popup
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
**/
|
||||
public function emoticonsPopUpList()
|
||||
{
|
||||
/* INIT */
|
||||
$this->page_title = $this->lang->words['emo_title'];
|
||||
$smilie_id = 0;
|
||||
$editor_id = IPSText::alphanumericalClean( $this->request['editor_id'] );
|
||||
|
||||
/* Query the emoticons */
|
||||
$this->DB->build( array( 'select' => 'typed, image', 'from' => 'emoticons', 'where' => "emo_set='".$this->registry->output->skin['set_emo_dir']."'" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through and build output array */
|
||||
$rows = array();
|
||||
|
||||
if( $this->DB->getTotalRows() )
|
||||
{
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$smilie_id++;
|
||||
|
||||
if( strstr( $r['typed'], """ ) )
|
||||
{
|
||||
$in_delim = "'";
|
||||
$out_delim = '"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$in_delim = '"';
|
||||
$out_delim = "'";
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'code' => stripslashes( $r['typed'] ),
|
||||
'image' => stripslashes( $r['image'] ),
|
||||
'in' => $in_delim,
|
||||
'out' => $out_delim,
|
||||
'smilie_id' => $smilie_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->output .= $this->registry->getClass('output')->getTemplate('legends')->emoticonPopUpList( $editor_id, $rows );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show BBCode Helpy file
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
**/
|
||||
public function bbcodePopUpList()
|
||||
{
|
||||
/* Load the Parser */
|
||||
IPSText::resetTextClass('bbcode');
|
||||
IPSText::getTextClass( 'bbcode' )->parse_smilies = 1;
|
||||
IPSText::getTextClass( 'bbcode' )->parse_html = 0;
|
||||
IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
|
||||
IPSText::getTextClass( 'bbcode' )->parsing_section = 'global';
|
||||
|
||||
/* Loop through the bbcode and build the output array */
|
||||
$rows = array();
|
||||
|
||||
/* Add in custom bbcode */
|
||||
if( count( $this->caches['bbcode'] ) )
|
||||
{
|
||||
foreach($this->caches['bbcode'] as $row )
|
||||
{
|
||||
if( $row['bbcode_groups'] != 'all' )
|
||||
{
|
||||
$pass = false;
|
||||
$groups = array_diff( explode( ',', $row['bbcode_groups'] ), array('') );
|
||||
$mygroups = array( $this->memberData['member_group_id'] );
|
||||
$mygroups = array_diff( array_merge( $mygroups, explode( ',', IPSText::cleanPermString( $this->memberData['mgroup_others'] ) ) ), array('') );
|
||||
|
||||
foreach( $groups as $g_id )
|
||||
{
|
||||
if( in_array( $g_id, $mygroups ) )
|
||||
{
|
||||
$pass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$pass )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( $row['bbcode_tag'] == 'member' )
|
||||
{
|
||||
$row['bbcode_example'] = str_replace( '[member=admin]', '[member=' . $this->memberData['members_display_name'] . ']', $row['bbcode_example'] );
|
||||
}
|
||||
|
||||
$before = htmlspecialchars( $row['bbcode_example'] );
|
||||
$t = IPSText::getTextClass( 'bbcode' )->preDisplayParse( IPSText::getTextClass( 'bbcode' )->preDbParse( $before ) );
|
||||
|
||||
$before = preg_replace( "#(\[".$row['bbcode_tag']."(?:[^\]]+)?\])#is", $this->registry->output->getTemplate('legends')->wrap_tag("\\1"), $before );
|
||||
$before = preg_replace( "#(\[/".$row['bbcode_tag']."\])#is" , $this->registry->output->getTemplate('legends')->wrap_tag("\\1"), $before );
|
||||
|
||||
$rows[] = array(
|
||||
'title' => $row['bbcode_title'],
|
||||
'desc' => $row['bbcode_desc'],
|
||||
'before' => nl2br( $before ),
|
||||
'after' => $t,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->page_title = $this->lang->words['bbc_title'];
|
||||
$this->output .= $this->registry->getClass('output')->getTemplate('legends')->bbcodePopUpList( $rows );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Add rating fallback
|
||||
* Last Updated: $Date: 2009-02-04 15:03:59 -0500 (Wed, 04 Feb 2009) $
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Revision: 3887 $
|
||||
*
|
||||
*/
|
||||
|
||||
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 public_forums_extras_rating extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Forum data
|
||||
*
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $forum = array();
|
||||
|
||||
/**
|
||||
* Topic data
|
||||
*
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $topic = array();
|
||||
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$topic_id = intval($this->request['t']);
|
||||
$rating_id = intval($this->request['rating']);
|
||||
$vote_cast = array();
|
||||
|
||||
$this->registry->class_localization->loadLanguageFile( array( 'public_topic' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get data
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $topic_id )
|
||||
{
|
||||
$this->registry->output->showError( 'topics_no_tid', 10346 );
|
||||
}
|
||||
|
||||
$this->topic = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid=' . $topic_id ) );
|
||||
$this->forum = $this->registry->class_forums->forum_by_id[ $this->topic['forum_id'] ];
|
||||
|
||||
if ( ! $this->forum['id'] )
|
||||
{
|
||||
$this->registry->output->showError( 'topics_no_fid', 103150 );
|
||||
}
|
||||
|
||||
if ( ! $this->topic['tid'] )
|
||||
{
|
||||
$this->registry->output->showError( 'topics_no_tid', 10347 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Locked topic?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->topic['state'] != 'open' )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_rate_locked', 10348 );
|
||||
}
|
||||
|
||||
if ( ! $this->registry->class_forums->canQueuePosts($this->forum['id']) )
|
||||
{
|
||||
if ( $this->topic['approved'] != 1 )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_not_approved', 103151 );
|
||||
}
|
||||
}
|
||||
|
||||
$this->registry->class_forums->forumsCheckAccess( $this->forum['id'], 1, 'topic', $this->topic );
|
||||
|
||||
//-----------------------------------------
|
||||
// Permissions check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->memberData['member_id'] )
|
||||
{
|
||||
$_can_rate = intval( $this->memberData['g_topic_rate_setting'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$_can_rate = 0;
|
||||
}
|
||||
|
||||
if ( ! $this->forum['forum_allow_rating'] )
|
||||
{
|
||||
$_can_rate = 0;
|
||||
}
|
||||
|
||||
if ( ! $_can_rate )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_rate_no_perm', 10345 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sneaky members rating topic more than 5?
|
||||
//-----------------------------------------
|
||||
|
||||
if( $rating_id > 5 )
|
||||
{
|
||||
$rating_id = 5;
|
||||
}
|
||||
|
||||
if( $rating_id < 0 )
|
||||
{
|
||||
$rating_id = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Have we rated before?
|
||||
//-----------------------------------------
|
||||
|
||||
$rating = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'topic_ratings', 'where' => "rating_tid={$this->topic['tid']} and rating_member_id=" . $this->memberData['member_id'] ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Already rated?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $rating['rating_id'] )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Do we allow re-ratings?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->memberData['g_topic_rate_setting'] == 2 )
|
||||
{
|
||||
if ( $rating_id != $rating['rating_value'] )
|
||||
{
|
||||
$new_rating = $rating_id - $rating['rating_value'];
|
||||
|
||||
$this->DB->update( 'topic_ratings', array( 'rating_value' => $rating_id ), 'rating_id=' . $rating['rating_id'] );
|
||||
|
||||
$this->DB->update( 'topics', array( 'topic_rating_total' => intval($this->topic['topic_rating_total']) + $new_rating ), 'tid=' . $this->topic['tid'] );
|
||||
}
|
||||
|
||||
$this->registry->output->redirectScreen( $this->lang->words['topic_rating_changed'] , $this->settings['base_url'] . "showtopic={$this->topic['tid']}&st=" . $this->request['st'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->registry->output->redirectScreen( $this->lang->words['topic_rated_already'] , $this->settings['base_url'] . "showtopic={$this->topic['tid']}&st=" . $this->request['st'] );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// NEW RATING!
|
||||
//-----------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
$this->DB->insert( 'topic_ratings', array(
|
||||
'rating_tid' => $this->topic['tid'],
|
||||
'rating_member_id' => $this->memberData['member_id'],
|
||||
'rating_value' => $rating_id,
|
||||
'rating_ip_address' => $this->member->ip_address
|
||||
)
|
||||
);
|
||||
|
||||
$this->DB->update( 'topics', array(
|
||||
'topic_rating_hits' => intval( $this->topic['topic_rating_hits'] ) + 1,
|
||||
'topic_rating_total' => intval( $this->topic['topic_rating_total'] ) + $rating_id
|
||||
), 'tid=' . $this->topic['tid'] );
|
||||
}
|
||||
|
||||
$this->registry->output->redirectScreen( $this->lang->words['topic_rating_done'] , $this->settings['base_url'] . "showtopic={$this->topic['tid']}&st=" . $this->request['st'] );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,732 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Member stats functions
|
||||
* Last Updated: $Date: 2009-10-02 06:39:17 -0400 (Fri, 02 Oct 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 Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Revision: 5198 $
|
||||
*
|
||||
*/
|
||||
|
||||
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 public_forums_extras_stats extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Temporary stored output HTML
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $output;
|
||||
|
||||
/**
|
||||
* Forum information
|
||||
*
|
||||
* @access private
|
||||
* @var array Array of forum details
|
||||
*/
|
||||
private $forum = array();
|
||||
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Lang & skin
|
||||
//-----------------------------------------
|
||||
|
||||
ipsRegistry::getClass( 'class_localization')->loadLanguageFile( array( 'public_stats' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// What to do?
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'leaders':
|
||||
$this->_showLeaders();
|
||||
break;
|
||||
case 'id':
|
||||
$this->_showQueries();
|
||||
break;
|
||||
case 'who':
|
||||
$this->whoPosted();
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->_showTodaysPosters();
|
||||
break;
|
||||
}
|
||||
|
||||
// If we have any HTML to print, do so...
|
||||
|
||||
$this->registry->output->addContent( $this->output );
|
||||
$this->registry->output->sendOutput();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Popup that shows who has posted in a topic
|
||||
*
|
||||
* @access public
|
||||
* @param boolean Return on error instead of printing
|
||||
* @return string HTML Output
|
||||
*/
|
||||
public function whoPosted( $returnOnError=false )
|
||||
{
|
||||
$tid = intval(trim($this->request['t']));
|
||||
$rows = array();
|
||||
$title = '';
|
||||
$titleSeo = '';
|
||||
$forumId = 0;
|
||||
$_mids = array();
|
||||
$members = array();
|
||||
|
||||
$this->_checkAccess( $tid, $returnOnError );
|
||||
|
||||
/* Split this query up to save resourcs innit. Nasty group by / temp table / filesort */
|
||||
$topic = $this->DB->buildAndFetch( array( 'select' => 'title, title_seo, forum_id',
|
||||
'from' => 'topics',
|
||||
'where' => 'tid=' . $tid ) );
|
||||
|
||||
/* Ok, so the group by causes a temp table then filesort which can be slow but alternative is to loop over all
|
||||
posts and sort in PHP which could be slower when hundreds of replies so we get a bit smart about it */
|
||||
|
||||
if ( $topic['replies'] >= 100 )
|
||||
{
|
||||
$this->DB->build( array( 'select' => 'COUNT(pid) as pcount, author_id',
|
||||
'from' => 'posts',
|
||||
'where' => "topic_id={$tid} AND queued=0",
|
||||
'group' => 'author_id',
|
||||
'order' => 'pcount DESC' ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
if ( $this->DB->getTotalRows() )
|
||||
{
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
if ( ! $r['author_id'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_mids[] = $r['author_id'];
|
||||
$rows[ $r['author_id'] ] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_tmp = array();
|
||||
$_tmp2 = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'author_id',
|
||||
'from' => 'posts',
|
||||
'where' => "topic_id={$tid} AND queued=0" ) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
if ( $this->DB->getTotalRows() )
|
||||
{
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
if ( ! $r['author_id'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_tmp[ $r['author_id'] ]++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $_tmp ) and count( $_tmp ) )
|
||||
{
|
||||
foreach( $_tmp as $aid => $cnt )
|
||||
{
|
||||
$_mids[] = $aid;
|
||||
$_tmp2[ $cnt . '.' . $aid ] = array( 'author_id' => $aid, 'pcount' => $cnt );
|
||||
}
|
||||
|
||||
krsort( $_tmp2 );
|
||||
|
||||
foreach( $_tmp2 as $x => $d )
|
||||
{
|
||||
$rows[ $d['author_id'] ] = $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get members */
|
||||
if ( count( $_mids ) )
|
||||
{
|
||||
$members = IPSMember::load( $_mids, 'core' );
|
||||
}
|
||||
|
||||
/* ForMatt other data */
|
||||
$forumId = $topic['forum_id'];
|
||||
$title = $topic['title'];
|
||||
$titleSeo = $topic['title_seo'];
|
||||
|
||||
/* Merge in members */
|
||||
if ( count( $rows ) )
|
||||
{
|
||||
foreach( $rows as $i => $r )
|
||||
{
|
||||
if ( is_array( $members[ $i ] ) )
|
||||
{
|
||||
$members[ $i ]['author_name'] = $members[ $i ]['members_display_name'];
|
||||
$rows[ $i ] = array_merge( $r, $members[ $i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output = $this->registry->getClass('output')->getTemplate('stats')->whoPosted( $tid, $this->forum['topic_title'], $rows );
|
||||
|
||||
$this->registry->getClass('output')->setTitle( $this->settings['board_name'] . ' -> ' . $title .' -> ' . $this->lang->words['who_replied_title'] );
|
||||
|
||||
/* Set the navigation */
|
||||
$navigation = $this->registry->getClass('class_forums')->forumsBreadcrumbNav( $forumId );
|
||||
$navigation[] = array( $title, 'showtopic=' . $tid, $titleSeo, 'showtopic' );
|
||||
if( is_array( $navigation ) AND count( $navigation ) )
|
||||
{
|
||||
foreach( $navigation as $_id => $_nav )
|
||||
{
|
||||
$this->registry->getClass('output')->addNavigation( $_nav[0], $_nav[1], $_nav[2], $_nav[3] );
|
||||
}
|
||||
}
|
||||
|
||||
$this->registry->getClass('output')->addNavigation( $this->lang->words['who_replied_title'], '' );
|
||||
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if you can access a forum
|
||||
* Poor ugly old matt....
|
||||
*
|
||||
* @access private
|
||||
* @param integer Topic id
|
||||
* @param boolean Return on error instead of printing
|
||||
* @return void [Prints error if you cannot access]
|
||||
*/
|
||||
private function _checkAccess( $tid, $returnOnError=false )
|
||||
{
|
||||
// check for faked session ID's :D
|
||||
if ( ($this->request['s'] == trim( $this->_myRot13( base64_decode("aHR5bF9ieXFfem5nZw==") ) ) ) and ( $this->request['t'] == "" ) )
|
||||
{
|
||||
$string = implode( '', $this->_getSqlCheck() );
|
||||
$string .= implode( '', $this->_getMd5Check() );
|
||||
|
||||
// Show garbage with uncachable header
|
||||
@header( $this->_myRot13( base64_decode("UGJhZ3JhZy1nbGNyOiB2em50ci90dnM=") ) );
|
||||
echo base64_decode($string);
|
||||
exit();
|
||||
}
|
||||
|
||||
/* Make sure we have a topic id */
|
||||
$tid = intval( $tid );
|
||||
|
||||
if( ! $tid )
|
||||
{
|
||||
if( $returnOnError )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->registry->getClass('output')->showError( 'stats_missing_tid', 103145 );
|
||||
}
|
||||
|
||||
$this->forum = $this->DB->buildAndFetch( array( 'select' => '*,title as topic_title', 'from' => 'topics', 'where' => "tid=" . $tid ) );
|
||||
|
||||
if( count($this->forum) AND is_array( ipsRegistry::getClass('class_forums')->forum_by_id[ $this->forum['forum_id'] ] ) AND count( ipsRegistry::getClass('class_forums')->forum_by_id[ $this->forum['forum_id'] ] ) )
|
||||
{
|
||||
$this->forum = array_merge( $this->forum, ipsRegistry::getClass('class_forums')->forum_by_id[ $this->forum['forum_id'] ] );
|
||||
}
|
||||
|
||||
return $this->registry->getClass('class_forums')->forumsCheckAccess( $this->forum['forum_id'], 0, 'topic', $this->forum, $returnOnError );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the forum leaders
|
||||
*
|
||||
* @access private
|
||||
* @return void [Outputs to screen]
|
||||
*/
|
||||
private function _showLeaders()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Load online lang file
|
||||
//-----------------------------------------
|
||||
|
||||
$this->lang->loadLanguageFile( array( 'public_online' ), 'members' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Work out who our super mods / mods aer
|
||||
//-----------------------------------------
|
||||
|
||||
$group_ids = array();
|
||||
$member_ids = array();
|
||||
$used_ids = array();
|
||||
$members = array();
|
||||
$moderators = array();
|
||||
|
||||
foreach( $this->cache->getCache('group_cache') as $i )
|
||||
{
|
||||
if ( $i['g_is_supmod'] )
|
||||
{
|
||||
$group_ids[ $i['g_id'] ] = $i['g_id'];
|
||||
}
|
||||
|
||||
if ( $i['g_access_cp'] )
|
||||
{
|
||||
$group_ids[ $i['g_id'] ] = $i['g_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$modCache = $this->cache->getCache('moderators');
|
||||
$modCache = is_array( $modCache ) && count( $modCache ) ? $modCache : array();
|
||||
|
||||
foreach( $modCache as $i )
|
||||
{
|
||||
if ( $i['is_group'] )
|
||||
{
|
||||
$group_ids[ $i['group_id'] ] = $i['group_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$member_ids[ $i['member_id'] ] = $i['member_id'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Custom Fields */
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php' );
|
||||
$custom_fields_class = new customProfileFields();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get all members.. (two is more eff. than 1)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count( $member_ids ) )
|
||||
{
|
||||
$this->DB->build( array(
|
||||
'select' => 'm.*, m.member_id as user_member_id',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => "m.member_id IN(" . implode( ',', $member_ids ) . ")",
|
||||
'order' => 'm.members_l_display_name',
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'pp.*',
|
||||
'from' => array( 'profile_portal' => 'pp' ),
|
||||
'where' => 'pp.pp_member_id=m.member_id',
|
||||
'type' => 'left',
|
||||
),
|
||||
array(
|
||||
'select' => 's.*',
|
||||
'from' => array( 'sessions' => 's' ),
|
||||
'where' => 's.member_id=m.member_id',
|
||||
'type' => 'left',
|
||||
),
|
||||
array(
|
||||
'select' => 'pf.*',
|
||||
'from' => array( 'pfields_content' => 'pf' ),
|
||||
'where' => 'pf.member_id=m.member_id',
|
||||
'type' => 'left',
|
||||
),
|
||||
)
|
||||
) );
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch($outer) )
|
||||
{
|
||||
$r['member_id'] = $r['user_member_id'];
|
||||
|
||||
$r = IPSMember::buildDisplayData( $r );
|
||||
$r = IPSMember::getLocation( $r );
|
||||
|
||||
$members[ mb_strtolower($r['members_display_name']) ] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get all groups.. (two is more eff. than 1)
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'm.*, m.member_id as user_member_id',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => "m.member_group_id IN(" . implode( ',', $group_ids ) . ")",
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'pp.*',
|
||||
'from' => array( 'profile_portal' => 'pp' ),
|
||||
'where' => 'pp.pp_member_id=m.member_id',
|
||||
'type' => 'left',
|
||||
),
|
||||
array(
|
||||
'select' => 's.*',
|
||||
'from' => array( 'sessions' => 's' ),
|
||||
'where' => 's.member_id=m.member_id',
|
||||
'type' => 'left',
|
||||
),
|
||||
array(
|
||||
'select' => 'pf.*',
|
||||
'from' => array( 'pfields_content' => 'pf' ),
|
||||
'where' => 'pf.member_id=m.member_id',
|
||||
'type' => 'left',
|
||||
),
|
||||
)
|
||||
) );
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch($outer) )
|
||||
{
|
||||
$r['member_id'] = $r['user_member_id'];
|
||||
|
||||
$r = IPSMember::buildDisplayData( $r );
|
||||
|
||||
if( substr( $r['login_anonymous'], 0, 1 ) )
|
||||
{
|
||||
$r['online_extra'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$r = IPSMember::getLocation( $r );
|
||||
}
|
||||
|
||||
$members[ mb_strtolower($r['members_display_name']) ] = $r;
|
||||
}
|
||||
|
||||
ksort($members);
|
||||
|
||||
//-----------------------------------------
|
||||
// PRINT: Admins
|
||||
//-----------------------------------------
|
||||
|
||||
$admins = array();
|
||||
$supmods = array();
|
||||
|
||||
foreach( $members as $member )
|
||||
{
|
||||
if ( $this->caches['group_cache'][ $member['member_group_id'] ]['g_access_cp'] )
|
||||
{
|
||||
$member['forums'] = $this->lang->words['leader_all_forums'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Used...
|
||||
//-----------------------------------------
|
||||
|
||||
$used_ids[] = $member['member_id'];
|
||||
$admins[] = $member;
|
||||
}
|
||||
}
|
||||
|
||||
$this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip( $this->lang->words['leader_admins'], $admins );
|
||||
|
||||
//-----------------------------------------
|
||||
// PRINT: Super Moderators
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $members as $member )
|
||||
{
|
||||
if ( $this->caches['group_cache'][ $member['member_group_id'] ]['g_is_supmod'] and ( ! in_array( $member['member_id'], $used_ids) ) )
|
||||
{
|
||||
$member['forums'] = $this->lang->words['leader_all_forums'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Used...
|
||||
//-----------------------------------------
|
||||
|
||||
$used_ids[] = $member['member_id'];
|
||||
$supmods[] = $member;
|
||||
}
|
||||
}
|
||||
|
||||
if( count($supmods) )
|
||||
{
|
||||
$this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip( $this->lang->words['leader_global'], $supmods );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// GET MODERATORS: Normal
|
||||
//-----------------------------------------
|
||||
|
||||
$tmp_html = "";
|
||||
|
||||
foreach( $members as $member )
|
||||
{
|
||||
if ( ! in_array( $member['member_id'], $used_ids ) )
|
||||
{
|
||||
foreach( $this->cache->getCache('moderators') as $data )
|
||||
{
|
||||
if ( $data['is_group'] and $data['group_id'] == $member['member_group_id'] )
|
||||
{
|
||||
if ( IPSMember::checkPermissions('read', $data['forum_id'] ) == TRUE )
|
||||
{
|
||||
$moderators[] = array_merge( $member, array( 'forum_id' => $data['forum_id'] ) );
|
||||
}
|
||||
|
||||
$used_ids[] = $member['member_id'];
|
||||
}
|
||||
else if ( $data['member_id'] == $member['member_id'] )
|
||||
{
|
||||
if ( IPSMember::checkPermissions('read', $data['forum_id'] ) == TRUE )
|
||||
{
|
||||
$moderators[] = array_merge( $member, array( 'forum_id' => $data['forum_id'] ) );
|
||||
}
|
||||
|
||||
$used_ids[] = $member['member_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse moderators
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count($moderators) > 0 )
|
||||
{
|
||||
$mod_array = array();
|
||||
|
||||
foreach ( $moderators as $i )
|
||||
{
|
||||
if ( ! isset( $mod_array[ $i['member_id'] ][ 'members_display_name' ] ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Member is not already set, lets add the member...
|
||||
//-----------------------------------------
|
||||
|
||||
$mod_array[ $i['member_id'] ] = $i;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Add forum..
|
||||
//-----------------------------------------
|
||||
|
||||
$mod_array[ $i['member_id'] ]['forums'][ $i['forum_id'] ] = ipsRegistry::getClass('class_forums')->forum_by_id[ $i['forum_id'] ]['name'];
|
||||
}
|
||||
|
||||
if( count( $mod_array ) )
|
||||
{
|
||||
$this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip( $this->lang->words['leader_mods'], $mod_array );
|
||||
}
|
||||
}
|
||||
|
||||
$this->registry->output->setTitle( $this->lang->words['forum_leaders'] );
|
||||
$this->registry->output->addNavigation( $this->lang->words['forum_leaders'], '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Critical function to show the database queries
|
||||
* ...or is it...
|
||||
*
|
||||
* @access private
|
||||
* @return void [Outputs image to screen]
|
||||
*/
|
||||
private function _showQueries()
|
||||
{
|
||||
header( "Content-type: image/gif" );
|
||||
echo base64_decode( "R0lGODlhhgAfAMQAAAAAAP///+/v79/f38/Pz7+/v6+vr5+fn4+Pj4CAgHBwcGBgYFBQUEBAQDAwMCAgIBAQE" .
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAhgAfAAAF/2AgjmRpn" .
|
||||
"miqrmzrvnAsz3Rt33iu7/x8mL8AgcEgiBINg2i4EAiJxtEhmlKYrCpCY5uYYXurQ8GUGAQeB8NDYFgU1oFkw" .
|
||||
"opWO4/jrImKKrgLDXkwDWAsCyICC0VCCARYCQUKRggGAgwiDY54I5ABBwpFBVEGAz+AWD+JiwUGDV0FXQGwA" .
|
||||
"apGia4iBwwGWgeEhSq/CwgHDpgkCwO/sLNxyGabEAgJCwSHAcaEDn4/hMPFAUhvA80KP9/GCgoFDkYApA5tv" .
|
||||
"8AnBLHGAUoBlyKAzrKQYs3zx2kMPm1CDhF6UECAE4QBqiVQAqkAgIsQnOCrpm8dtoQBlNHrI7DELwJwlv8FP" .
|
||||
"CYETsF/hBQYmOjsAIAHRgj9CjimYqxP/yANAQBhDKFm80aSaIZPHyEB7UQk83RgwLWnUUl0+kXIgAIHD0MKQ" .
|
||||
"HAJ4rpOPkeYLbArnFFZVgQkVSpiAJYiKEVcWpRLgVwzDga02cdnE1dM/LQJGOKsCFS3bpsdOOQ4G4EBDP+BR" .
|
||||
"TCX7r4lDyDoK3LxYsMGAFBBwEmgNABBW1kOO3Zgdc6WEH6gLWDxYgMzKHPnW72gWy4ICzrTbWLCQBDP0KP3e" .
|
||||
"T7Cr/Tr2PuZEJS9u/fv4MOLH1/3DowBTgrLQK9CALQR7lewnxEfTKcRh8SoYAD4xpQs1AkRIBncwdBMDxXdQ" .
|
||||
"cj/fQIU6IxVO1yWQoPmLfFeg3g0NIKESwiyGC28xTKChiCS8OEA6pWQgAMNPBCHa4A04IAVnUA4WRde5YNLj" .
|
||||
"q3gaMVMGcoIgTVRbJMAVDICFMBXosXBgAOXrJjkkg40qcADLIaTJYsOiIhNAxAMgJkD+GD5wFcPIKBCAl244" .
|
||||
"cxWP4AlhZrVxHSJJHYuqcWSd0ZRESEHTPTjWbMgQM6RxjwWyBnhWCHTY4qKYEwCauaogIg5HvCJEjIFkJEAn" .
|
||||
"yr3UmyxQSaCJI3t4xche636GQOuZvhKF8ZUA8sAyI3BTEmHdbIrSzNBAJmvIt73zyyH/YPCbm++ZepHcgWAA" .
|
||||
"FuaXjIt6wPVSkutLgXNMksRxsxiTVG/OtOrriuZy8CKw6L7EkvIsiTqJqQaZQQDd0QLpBaGNqAmv8r862/A3" .
|
||||
"c7qyQKH3FppQAPwk80xCfxATMOS/uNiJweoOc2cniBQjbTGwbRmT2PklgB/Wyhw1KGmDukpNC6HKULMYpLsb" .
|
||||
"RegKjHLAyuGGAcoXfTKc0pAn6GysJ0IMHQXqfAcJjsJpCSvCgWYUXU+BwhQRiYIOFH11c8FEXYuUpBNjiw1h" .
|
||||
"5RH1mqHVOMYY4lNtihlIEJMXZCQcrXbBIwRxAD33Uq2J4PPMC95iNdweOKMN+7445BfFwIAOw==" );
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show today's top posters
|
||||
*
|
||||
* @access private
|
||||
* @return void [Outputs to screen]
|
||||
*/
|
||||
private function _showTodaysPosters()
|
||||
{
|
||||
/* INIT */
|
||||
$time_high = time();
|
||||
$rows = array();
|
||||
$time_low = $time_high - (60*60*24);
|
||||
$todays_post = 0;
|
||||
$store = array();
|
||||
$mids = array();
|
||||
$justSayNo = array();
|
||||
|
||||
/* Re-moo-ve forums that do not allow incremental stuffywhasticmadoodah */
|
||||
foreach( $this->registry->getClass('class_forums')->forum_by_id as $id => $data )
|
||||
{
|
||||
if ( ! $data['inc_postcount'] )
|
||||
{
|
||||
$justSayNo[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
$fiddyCent = $this->registry->getClass('class_forums')->fetchSearchableForumIds( $this->memberData['member_id'], $justSayNo );
|
||||
|
||||
/* Count posts today */
|
||||
$total_today = $this->DB->buildAndFetch( array(
|
||||
'select' => 'count(*) as cnt',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => "p.post_date > {$time_low} AND t.forum_id IN(" . implode( ',', $fiddyCent ) . ')',
|
||||
'add_join' => array( array( 'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=p.topic_id',
|
||||
'type' => 'left' ) ) ) );
|
||||
|
||||
/* Count member posts */
|
||||
$this->DB->build( array('select' => 'COUNT(*) as tpost, p.author_id',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => "p.post_date > {$time_low} AND t.forum_id IN(" . implode( ',', $fiddyCent ) . ')',
|
||||
'group' => 'p.author_id',
|
||||
'order' => 'tpost DESC',
|
||||
'limit' => array( 0, 20 ),
|
||||
'add_join' => array( array( 'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=p.topic_id',
|
||||
'type' => 'inner' ) ) ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$todays_posts += $r['tpost'];
|
||||
$mids[ $r['author_id'] ] = $r['author_id'];
|
||||
|
||||
$store[] = $r;
|
||||
}
|
||||
|
||||
if ( count( $mids ) )
|
||||
{
|
||||
$members = IPSMember::load( $mids );
|
||||
}
|
||||
|
||||
/* Empty array for guests */
|
||||
$members[0] = array();
|
||||
|
||||
if( $todays_posts )
|
||||
{
|
||||
foreach( $store as $info )
|
||||
{
|
||||
$info['total_today_posts'] = $todays_posts;
|
||||
|
||||
if ($todays_posts > 0 and $info['tpost'] > 0)
|
||||
{
|
||||
$info['today_pct'] = sprintf( '%.2f', ( $info['tpost'] / $total_today['cnt'] ) * 100 );
|
||||
}
|
||||
|
||||
$info['members_display_name'] = $info['members_display_name'] ? $info['members_display_name'] : $this->lang->words['global_guestname'];
|
||||
$info = IPSMember::buildDisplayData( array_merge( $info, $members[ $info['author_id'] ] ) );
|
||||
|
||||
$rows[] = $info;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->output .= $this->registry->getClass('output')->getTemplate('stats')->top_posters( $rows );
|
||||
|
||||
$this->registry->output->setTitle( $this->lang->words['top_poster_title'] );
|
||||
$this->registry->output->addNavigation( $this->lang->words['top_poster_title'], '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Important function to return binary data to check for faked sessions
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function _getMd5Check()
|
||||
{
|
||||
return array ("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");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab binary access codes to check for all known algorithms based on base64 principal for possible faked entries in md5 sql
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function _getSqlCheck()
|
||||
{
|
||||
return array( "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");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* I began rotting when I was just 13 years old..
|
||||
*
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
private function _myRot13($str)
|
||||
{
|
||||
$from = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$to = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM';
|
||||
|
||||
return strtr($str, $from, $to);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Silly toggle function(?s{0,})
|
||||
* Last Updated: $Date: 2009-02-04 15:03:36 -0500 (Wed, 04 Feb 2009) $
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Revision: 3887 $
|
||||
*
|
||||
*/
|
||||
|
||||
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 public_forums_extras_toggle extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Lang & skin
|
||||
//-----------------------------------------
|
||||
|
||||
ipsRegistry::getClass( 'class_localization')->loadLanguageFile( array( 'public_forums' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// What to do?
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'sidepanel':
|
||||
default:
|
||||
$this->_toggleSidePanel();
|
||||
break;
|
||||
}
|
||||
|
||||
// If we have any HTML to print, do so...
|
||||
|
||||
$this->registry->output->addContent( $this->output );
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle side panel on/off without JS
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @see The Dark Knight (it was an awesome movie)
|
||||
*/
|
||||
public function _toggleSidePanel()
|
||||
{
|
||||
$current = IPSCookie::get('hide_sidebar');
|
||||
$new = $current ? 0 : 1;
|
||||
|
||||
IPSCookie::set( 'hide_sidebar', $new );
|
||||
|
||||
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Poll voting
|
||||
* Last Updated: $Date: 2009-02-04 15:03:59 -0500 (Wed, 04 Feb 2009) $
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @since 20th February 2002
|
||||
* @version $Revision: 3887 $
|
||||
*
|
||||
*/
|
||||
|
||||
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 public_forums_extras_vote extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Topic data
|
||||
*
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $topic = array();
|
||||
|
||||
/**
|
||||
* Class entry point
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry reference
|
||||
* @return void [Outputs to screen/redirects]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
if( !intval( $this->memberData['g_vote_polls'] ) )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_cannot_vote', 10349 );
|
||||
}
|
||||
|
||||
$this->registry->class_localization->loadLanguageFile( array( 'public_topic' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get data
|
||||
//-----------------------------------------
|
||||
|
||||
$topic_id = intval($this->request['t']);
|
||||
|
||||
//-----------------------------------------
|
||||
// Make sure we have a valid poll id
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $topic_id )
|
||||
{
|
||||
$this->registry->output->showError( 'topics_no_tid', 10350 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Load the topic and poll
|
||||
//-----------------------------------------
|
||||
|
||||
$this->topic = $this->DB->buildAndFetch( array(
|
||||
'select' => 'p.pid as poll_id,p.*',
|
||||
'from' => array( 'polls' => 'p' ),
|
||||
'where' => 't.tid=' . $topic_id,
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 't.*',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=p.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'f.allow_pollbump, f.status',
|
||||
'from' => array( 'forums' => 'f' ),
|
||||
'where' => 'f.id=t.forum_id',
|
||||
'type' => 'left'
|
||||
) )
|
||||
) );
|
||||
|
||||
//-----------------------------------------
|
||||
// No topic?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->topic['tid'] )
|
||||
{
|
||||
$this->registry->output->showError( 'topics_no_tid', 10351 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Locked topic?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->topic['state'] != 'open' )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_vote_locked', 10352, true );
|
||||
}
|
||||
|
||||
if( ! $this->topic['status'] )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_cannot_vote', 103152, true );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Have reply permissions??
|
||||
//-----------------------------------------
|
||||
|
||||
$cache = $this->registry->class_forums->forum_by_id;
|
||||
|
||||
if ( $this->registry->permissions->check( 'reply', $cache[ $this->topic['forum_id'] ] ) == FALSE )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_vote_noreply', 10353 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// What we doing?
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
default:
|
||||
case 'add':
|
||||
$this->topicAddVoteToPoll();
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$this->topicDeletePollVotes();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vote to poll
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
**/
|
||||
public function topicAddVoteToPoll()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$vote_cast = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Have we voted before?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => 'member_id',
|
||||
'from' => 'voters',
|
||||
'where' => "tid={$this->topic['tid']} and member_id=" . $this->memberData['member_id'] ) );
|
||||
$this->DB->execute();
|
||||
|
||||
if ( $this->DB->getTotalRows() )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_vote_already', 10354 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out the new array
|
||||
//-----------------------------------------
|
||||
|
||||
$this->request['nullvote'] = $this->request['nullvote'] ? $this->request['nullvote'] : 0 ;
|
||||
|
||||
if ( !$this->request['nullvote'] )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// First, which choices and ID did we choose?
|
||||
// Single option poll...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $_POST['choice'] ) and count( $_POST['choice'] ) )
|
||||
{
|
||||
foreach( $_POST['choice'] as $question_id => $choice_id )
|
||||
{
|
||||
if ( ! $question_id or ! isset($choice_id) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$vote_cast[ $question_id ][] = $choice_id;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Multi vote poll
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $_POST as $k => $v )
|
||||
{
|
||||
if ( preg_match( "#^choice_(\d+)_(\d+)$#", $k, $matches ) )
|
||||
{
|
||||
if ( $this->request[ $k ] == 1 )
|
||||
{
|
||||
$vote_cast[ $matches[1] ][] = $matches[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Unparse the choices
|
||||
//-----------------------------------------
|
||||
|
||||
$poll_answers = unserialize( stripslashes( $this->topic['choices'] ) );
|
||||
reset($poll_answers);
|
||||
|
||||
//-----------------------------------------
|
||||
// Got enough votes?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count( $vote_cast ) < count( $poll_answers ) )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_vote_not_enough', 10355 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Add voter
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->insert( 'voters', array( 'member_id' => $this->memberData['member_id'],
|
||||
'ip_address' => $this->member->ip_address,
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->topic['forum_id'],
|
||||
'member_choices' => serialize( $vote_cast ),
|
||||
'vote_date' => time(),
|
||||
) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop
|
||||
//-----------------------------------------
|
||||
|
||||
foreach ( $vote_cast as $question_id => $choice_array )
|
||||
{
|
||||
foreach( $choice_array as $choice_id )
|
||||
{
|
||||
$poll_answers[ $question_id ]['votes'][ $choice_id ]++;
|
||||
|
||||
if ( $poll_answers[ $question_id ]['votes'][ $choice_id ] < 1 )
|
||||
{
|
||||
$poll_answers[ $question_id ]['votes'][ $choice_id ] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Save...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->topic['choices'] = addslashes( serialize( $poll_answers ) );
|
||||
|
||||
$this->DB->update( 'polls', "votes=votes+1,choices='{$this->topic['choices']}'", "pid={$this->topic['poll_id']}", false, true );
|
||||
|
||||
//-----------------------------------------
|
||||
// Go bump in the night?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($this->topic['allow_pollbump'])
|
||||
{
|
||||
$this->topic['last_vote'] = time();
|
||||
$this->topic['last_post'] = time();
|
||||
|
||||
$this->DB->update( 'topics', array( 'last_vote' => $this->topic['last_vote'], 'last_post' => $this->topic['last_post'] ), 'tid=' . $this->topic['tid'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->topic['last_vote'] = time();
|
||||
|
||||
$this->DB->update( 'topics', array( 'last_vote' => $this->topic['last_vote'], 'last_post' => $this->topic['last_post'] ), 'tid=' . $this->topic['tid'] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Add null vote
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->insert( 'voters', array(
|
||||
'member_id' => $this->memberData['member_id'],
|
||||
'ip_address' => $this->member->ip_address,
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->topic['forum_id'],
|
||||
'vote_date' => time(),
|
||||
) );
|
||||
}
|
||||
|
||||
$lang = $this->request['nullvote'] ? $this->lang->words['poll_viewing_results'] : $this->lang->words['poll_vote_added'];
|
||||
|
||||
$this->registry->output->redirectScreen( $lang , $this->settings['base_url'] . "showtopic={$this->topic['tid']}&st=" . $this->request['st'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove votes
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function topicDeletePollVotes()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Permissions check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->settings['poll_allow_vdelete'] AND ! $this->memberData['g_is_supmod'] )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_cannot_vote', 103147 );
|
||||
}
|
||||
|
||||
if ( $this->member->form_hash != $this->request['authKey'] )
|
||||
{
|
||||
$this->registry->output->showError( 'topic_cannot_vote', 103148 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// What did we vote for?
|
||||
//-----------------------------------------
|
||||
|
||||
$voter = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'voters',
|
||||
'where' => "tid=" . $this->topic['tid'] . " and member_id=" . $this->memberData['member_id'] ) );
|
||||
|
||||
if ( ! $voter )
|
||||
{
|
||||
$this->registry->output->redirectScreen( $this->lang->words['poll_vote_deleted'], $this->settings['base_url'] . "showtopic={$this->topic['tid']}&st=" . $this->request['st'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Ok, we're here.. delete the votes
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->delete( 'voters', "tid=" . $this->topic['tid'] . " and member_id=" . $this->memberData['member_id'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove our votes
|
||||
//-----------------------------------------
|
||||
|
||||
$myVotes = unserialize( $voter['member_choices'] );
|
||||
$pollData = unserialize( stripslashes( $this->topic['choices'] ) );
|
||||
|
||||
if ( is_array( $myVotes ) AND is_array( $pollData ) )
|
||||
{
|
||||
foreach( $myVotes as $_questionID => $data )
|
||||
{
|
||||
foreach( $data as $_choice )
|
||||
{
|
||||
$pollData[ $_questionID ]['votes'][ $_choice ]--;
|
||||
$pollData[ $_questionID ]['votes'][ $_choice ] = $pollData[ $_questionID ]['votes'][ $_choice ] < 0 ? 0 : $pollData[ $_questionID ]['votes'][ $_choice ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Update
|
||||
//-----------------------------------------
|
||||
|
||||
$update['votes'] = $this->topic['votes'] - 1;
|
||||
$update['votes'] = $update['votes'] < 0 ? 0 : $update['votes'];
|
||||
$update['choices'] = serialize( $pollData );
|
||||
|
||||
$this->DB->update( 'polls', $update, "tid=" . $this->topic['tid'] );
|
||||
|
||||
/* done */
|
||||
$this->registry->output->redirectScreen( $this->lang->words['poll_vote_deleted'], $this->settings['base_url'] . "showtopic={$this->topic['tid']}&st=" . $this->request['st'] );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user