Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Board Rules
* Last Updated: $Date: 2009-07-16 10:24:48 -0400 (Thu, 16 Jul 2009) $
* Last Updated: $Date: 2010-06-10 06:36:42 -0400 (Thu, 10 Jun 2010) $
* </pre>
*
* @author $Author $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Rev: 4900 $
* @version $Rev: 6502 $
*/
if ( ! defined( 'IN_IPB' ) )
{
@@ -59,7 +61,7 @@ class public_forums_extras_boardrules extends ipsCommand
//$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->setTitle( $this->settings['gl_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
$this->registry->output->addContent( $this->registry->output->getTemplate('emails')->boardRules( $this->settings['gl_title'], $row['conf_value'] ) );
$this->registry->output->sendOutput();
}
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Default forum extras module section
* Last Updated: $Date: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Rev: 4948 $
* @version $Rev: 5713 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Forward a topic to someone
* Last Updated: $Date: 2009-06-25 19:58:52 -0400 (Thu, 25 Jun 2009) $
* Last Updated: $Date: 2010-10-14 06:42:56 -0400 (Thu, 14 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Revision: 4822 $
* @version $Revision: 6975 $
*
*/
@@ -48,6 +50,8 @@ class public_forums_extras_forward extends ipsCommand
* @var array Array of topic details
*/
private $topic = array();
private $page = array();
/**
* Class entry point
@@ -64,54 +68,77 @@ class public_forums_extras_forward extends ipsCommand
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'] )
/* Via URL and topic title? */
if ( $this->request['url'] AND $this->request['title'] )
{
$this->registry->output->showError( 'forward_no_tid', 10321 );
$this->page['url'] = IPSText::parseCleanValue( IPSText::base64_decode_urlSafe( $this->request['url'] ) );
$this->page['title'] = IPSText::parseCleanValue( urldecode( $this->request['title'] ) );
}
else
{
//-----------------------------------------
// 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 );
}
//-----------------------------------------
// 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 );
//-----------------------------------------
// 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'] );
}
//-----------------------------------------
// Error out if we can not find the topic
//-----------------------------------------
if ( !$this->topic['tid'] )
/* last check */
if ( ! $this->topic['tid'] AND ! $this->page['url'] )
{
$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 );
$this->registry->output->showError( 'forward_no_tid', 10323.2 );
}
ipsRegistry::getClass('class_forums')->forumsCheckAccess( $this->forum['id'] );
/* Ok, I lied. Is this share entry enabled? */
$cache = ipsRegistry::cache()->getCache('sharelinks');
if ( ! is_array( $cache['email'] ) OR ! $cache['email']['share_enabled'] )
{
$this->registry->output->showError( 'forward_turned_off', 103240 );
}
//-----------------------------------------
// What to do?
@@ -141,9 +168,18 @@ class public_forums_extras_forward extends ipsCommand
if ( $this->request['k'] != $this->member->form_hash )
{
$this->registry->getClass('output')->showError( 'no_permission', 2029 );
$this->registry->getClass('output')->showError( 'no_permission', 2029, null, null, 403 );
}
/* Check the CAPTCHA */
if ( $this->settings['bot_antispam_type'] != 'none' )
{
if ( $this->registry->getClass('class_captcha')->validate() !== TRUE )
{
return $this->_showForm('err_reg_code');
}
}
$lang_to_use = 1;
foreach( ipsRegistry::cache()->getCache('lang_data') as $l )
@@ -175,12 +211,9 @@ class public_forums_extras_forward extends ipsCommand
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')->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'];
@@ -196,19 +229,44 @@ class public_forums_extras_forward extends ipsCommand
* @access private
* @return void [Outputs to screen/redirects]
*/
private function _showForm()
private function _showForm( $msg='' )
{
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'] );
if ( $this->topic['tid'] )
{
$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'] );
$subject = $this->topic['title'];
}
else
{
$this->lang->words['send_text'] = str_replace( "<#THE LINK#>" , $this->page['url'] , $this->lang->words['send_text'] );
$this->lang->words['send_text'] = str_replace( "<#USER NAME#>", $this->memberData['members_display_name'], $this->lang->words['send_text'] );
$subject = $this->page['title'];
}
/* CAPTCHA */
if( $this->settings['bot_antispam_type'] != 'none' )
{
$captchaHTML = $this->registry->getClass('class_captcha')->getTemplate();
}
$this->output = $this->registry->getClass('output')->getTemplate('emails')->forward_form( $subject, $this->lang->words['send_text'], '', $captchaHTML, $msg );
if ( $this->topic['tid'] )
{
$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'] . ' - ' . ipsRegistry::$settings['board_name'] );
}
else
{
$this->registry->output->addNavigation( $this->lang->words['title'], '' );
$this->registry->output->setTitle( $this->lang->words['title'] . ' - ' . ipsRegistry::$settings['board_name'] );
}
$this->registry->output->addContent( $this->output );
$this->registry->output->sendOutput();
}
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,17 +1,19 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Emoticon and BBCode Legends
* Last Updated: $Date: 2009-04-21 16:36:40 -0400 (Tue, 21 Apr 2009) $
* Last Updated: $Date: 2010-06-10 06:36:42 -0400 (Thu, 10 Jun 2010) $
* </pre>
*
* @author $Author $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @version $Rev: 4521 $
* @link http://www.invisionpower.com
* @version $Rev: 6502 $
*
*/
@@ -57,7 +59,7 @@ class public_forums_extras_legends extends ipsCommand
}
/* If we have any HTML to print, do so... */
$this->registry->getClass('output')->setTitle( $this->page_title );
$this->registry->getClass('output')->setTitle( $this->page_title . ' - ' . ipsRegistry::$settings['board_name'] );
$this->registry->getClass('output')->popUpWindow( $this->output );
}
@@ -1,198 +1,206 @@
<?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']}&amp;st=" . $this->request['st'] );
}
else
{
$this->registry->output->redirectScreen( $this->lang->words['topic_rated_already'] , $this->settings['base_url'] . "showtopic={$this->topic['tid']}&amp;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']}&amp;st=" . $this->request['st'] );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Add rating fallback
* Last Updated: $Date: 2010-05-07 19:47:39 -0400 (Fri, 07 May 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Revision: 6250 $
*
*/
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 )
{
/* Security Check */
if ( $this->request['secure_key'] != $this->member->form_hash )
{
$this->registry->output->showError( 'usercp_forums_bad_key', 102999, null, null, 403 );
}
//-----------------------------------------
// 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, null, null, 404 );
}
$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, null, null, 404 );
}
if ( ! $this->topic['tid'] )
{
$this->registry->output->showError( 'topics_no_tid', 10347, null, null, 404 );
}
//-----------------------------------------
// Locked topic?
//-----------------------------------------
if ( $this->topic['state'] != 'open' )
{
$this->registry->output->showError( 'topic_rate_locked', 10348, null, null, 403 );
}
if ( ! $this->registry->class_forums->canQueuePosts($this->forum['id']) )
{
if ( $this->topic['approved'] != 1 )
{
$this->registry->output->showError( 'topic_not_approved', 103151, null, null, 403 );
}
}
$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, null, null, 403 );
}
//-----------------------------------------
// 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']}&amp;st=" . $this->request['st'] );
}
else
{
$this->registry->output->redirectScreen( $this->lang->words['topic_rated_already'] , $this->settings['base_url'] . "showtopic={$this->topic['tid']}&amp;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']}&amp;st=" . $this->request['st'] );
}
}
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Member stats functions
* Last Updated: $Date: 2009-10-02 06:39:17 -0400 (Fri, 02 Oct 2009) $
* Last Updated: $Date: 2010-10-18 17:06:14 -0400 (Mon, 18 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Revision: 5198 $
* @version $Revision: 6991 $
*
*/
@@ -28,7 +30,6 @@ class public_forums_extras_stats extends ipsCommand
/**
* Temporary stored output HTML
*
* @access public
* @var string
*/
public $output;
@@ -36,15 +37,13 @@ class public_forums_extras_stats extends ipsCommand
/**
* Forum information
*
* @access private
* @var array Array of forum details
*/
private $forum = array();
protected $forum = array();
/**
* Class entry point
*
* @access public
* @param object Registry reference
* @return void [Outputs to screen/redirects]
*/
@@ -87,7 +86,6 @@ class public_forums_extras_stats extends ipsCommand
/**
* Popup that shows who has posted in a topic
*
* @access public
* @param boolean Return on error instead of printing
* @return string HTML Output
*/
@@ -104,14 +102,14 @@ class public_forums_extras_stats extends ipsCommand
$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',
$topic = $this->DB->buildAndFetch( array( 'select' => 'title, title_seo, forum_id, posts',
'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 )
if ( $topic['posts'] >= 100 )
{
$this->DB->build( array( 'select' => 'COUNT(pid) as pcount, author_id',
'from' => 'posts',
@@ -200,9 +198,20 @@ class public_forums_extras_stats extends ipsCommand
}
}
//-----------------------------------------
// Guests
//-----------------------------------------
$guests = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as guest_posts', 'from' => 'posts', 'where' => "topic_id={$tid} AND queued=0 AND author_id=0" ) );
if( $guests['guest_posts'] )
{
$rows[0] = array( 'author_id' => 0, 'pcount' => $guests['guest_posts'], 'author_name' => $this->lang->words['global_guestname'] );
}
$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'] );
$this->registry->getClass('output')->setTitle( $title .' - ' . $this->lang->words['who_replied_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
/* Set the navigation */
$navigation = $this->registry->getClass('class_forums')->forumsBreadcrumbNav( $forumId );
@@ -224,12 +233,11 @@ class public_forums_extras_stats extends ipsCommand
* 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 )
protected 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'] == "" ) )
@@ -253,7 +261,7 @@ class public_forums_extras_stats extends ipsCommand
return false;
}
$this->registry->getClass('output')->showError( 'stats_missing_tid', 103145 );
$this->registry->getClass('output')->showError( 'stats_missing_tid', 103145, null, null, 404 );
}
$this->forum = $this->DB->buildAndFetch( array( 'select' => '*,title as topic_title', 'from' => 'topics', 'where' => "tid=" . $tid ) );
@@ -269,10 +277,9 @@ class public_forums_extras_stats extends ipsCommand
/**
* Show the forum leaders
*
* @access private
* @return void [Outputs to screen]
*/
private function _showLeaders()
protected function _showLeaders()
{
//-----------------------------------------
// Load online lang file
@@ -319,8 +326,8 @@ class public_forums_extras_stats extends ipsCommand
}
/* Custom Fields */
require_once( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php' );
$custom_fields_class = new customProfileFields();
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
$custom_fields_class = new $classToLoad();
//-----------------------------------------
// Get all members.. (two is more eff. than 1)
@@ -465,6 +472,8 @@ class public_forums_extras_stats extends ipsCommand
{
$this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip( $this->lang->words['leader_global'], $supmods );
}
$upperMods = $used_ids;
//-----------------------------------------
// GET MODERATORS: Normal
@@ -474,29 +483,36 @@ class public_forums_extras_stats extends ipsCommand
foreach( $members as $member )
{
if ( ! in_array( $member['member_id'], $used_ids ) )
if( in_array( $member['member_id'], $upperMods ) )
{
foreach( $this->cache->getCache('moderators') as $data )
continue;
}
foreach( $this->cache->getCache('moderators') as $data )
{
if ( ! in_array( $member['member_id'], $used_ids ) )
{
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'];
$moderators[ $member['member_id'] ] = array_merge( $member, array( 'forums' => array( $data['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'] ) );
$moderators[ $member['member_id'] ] = array_merge( $member, array( 'forums' => array( $data['forum_id'] => $data['forum_id'] ) ) );
$used_ids[] = $member['member_id'];
}
$used_ids[] = $member['member_id'];
}
}
else if( array_key_exists( $member['member_id'], $moderators ) && ( ($data['is_group'] and $data['group_id'] == $member['member_group_id']) || $data['member_id'] == $member['member_id'] ) )
{
$moderators[ $member['member_id'] ]['forums'][ $data['forum_id'] ] = $data['forum_id'];
}
}
}
@@ -510,20 +526,19 @@ class public_forums_extras_stats extends ipsCommand
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'] ] = $i;
$mod_array[ $i['member_id'] ]['forums'][ $i['forum_id'] ] = ipsRegistry::getClass('class_forums')->forum_by_id[ $i['forum_id'] ]['name'];
foreach( $mod_array[ $i['member_id'] ]['forums'] as $fid )
{
if( ipsRegistry::getClass('class_forums')->forum_by_id[ $fid ]['name'] )
{
$mod_array[ $i['member_id'] ]['forums'][ $fid ] = ipsRegistry::getClass('class_forums')->forum_by_id[ $fid ]['name'];
}
else
{
unset($mod_array[ $i['member_id'] ]['forums'][ $fid ]);
}
}
}
if( count( $mod_array ) )
@@ -532,7 +547,7 @@ class public_forums_extras_stats extends ipsCommand
}
}
$this->registry->output->setTitle( $this->lang->words['forum_leaders'] );
$this->registry->output->setTitle( $this->lang->words['forum_leaders'] . ' - ' . ipsRegistry::$settings['board_name'] );
$this->registry->output->addNavigation( $this->lang->words['forum_leaders'], '' );
}
@@ -540,7 +555,6 @@ class public_forums_extras_stats extends ipsCommand
* Critical function to show the database queries
* ...or is it...
*
* @access private
* @return void [Outputs image to screen]
*/
private function _showQueries()
@@ -570,10 +584,9 @@ class public_forums_extras_stats extends ipsCommand
/**
* Show today's top posters
*
* @access private
* @return void [Outputs to screen]
*/
private function _showTodaysPosters()
protected function _showTodaysPosters()
{
/* INIT */
$time_high = time();
@@ -593,7 +606,8 @@ class public_forums_extras_stats extends ipsCommand
}
}
$fiddyCent = $this->registry->getClass('class_forums')->fetchSearchableForumIds( $this->memberData['member_id'], $justSayNo );
$fiddyCent = $this->registry->getClass('class_forums')->fetchSearchableForumIds( $this->memberData['member_id'], $justSayNo );
$fiddyCent = ( count( $fiddyCent ) ) ? $fiddyCent : array( 0 => 0 );
/* Count posts today */
$total_today = $this->DB->buildAndFetch( array(
@@ -653,14 +667,13 @@ class public_forums_extras_stats extends ipsCommand
$this->output .= $this->registry->getClass('output')->getTemplate('stats')->top_posters( $rows );
$this->registry->output->setTitle( $this->lang->words['top_poster_title'] );
$this->registry->output->setTitle( $this->lang->words['top_poster_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
$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()
@@ -692,7 +705,6 @@ class public_forums_extras_stats extends ipsCommand
/**
* 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()
@@ -718,7 +730,6 @@ class public_forums_extras_stats extends ipsCommand
/**
* I began rotting when I was just 13 years old..
*
* @access private
* @return string
*/
private function _myRot13($str)
@@ -1,78 +1,86 @@
<?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'] );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Silly toggle function(?s{0,})
* Last Updated: $Date: 2010-06-08 20:53:45 -0400 (Tue, 08 Jun 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Revision: 6485 $
*
*/
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()
{
/* Security Check */
if ( $this->request['secure_key'] != $this->member->form_hash )
{
$this->registry->output->showError( 'usercp_forums_bad_key', 102998, null, null, 403 );
}
$current = IPSCookie::get('hide_sidebar');
$new = $current ? 0 : 1;
IPSCookie::set( 'hide_sidebar', $new );
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'act=idx', 'false' );
}
}
@@ -1,378 +1,381 @@
<?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']}&amp;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']}&amp;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']}&amp;st=" . $this->request['st'] );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Poll voting
* Last Updated: $Date: 2010-05-07 19:47:39 -0400 (Fri, 07 May 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @since 20th February 2002
* @version $Revision: 6250 $
*
*/
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 )
{
/* Security Check */
if ( $this->request['secure_key'] != $this->member->form_hash )
{
$this->registry->output->showError( 'topic_cannot_vote', 103148, null, null, 403 );
}
//-----------------------------------------
// INIT
//-----------------------------------------
if( !intval( $this->memberData['g_vote_polls'] ) )
{
$this->registry->output->showError( 'topic_cannot_vote', 10349, null, null, 403 );
}
$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, null, null, 404 );
}
//-----------------------------------------
// 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, null, null, 404 );
}
//-----------------------------------------
// Locked topic?
//-----------------------------------------
if ( $this->topic['state'] != 'open' )
{
$this->registry->output->showError( 'topic_vote_locked', 10352, true, null, 403 );
}
if( ! $this->topic['status'] )
{
$this->registry->output->showError( 'topic_cannot_vote', 103152, true, null, 403 );
}
//-----------------------------------------
// 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, null, null, 403 );
}
//-----------------------------------------
// 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']}&amp;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, null, null, 403 );
}
//-----------------------------------------
// 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']}&amp;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']}&amp;st=" . $this->request['st'] );
}
}