[BETA]Cash on Index page(for Cash/Points) 0.6.3

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply
User avatar
www.digitaly.nl
Registered User
Posts: 17
Joined: Tue Sep 23, 2003 5:08 pm

Post by www.digitaly.nl »

Here it is:

Code: Select all

<?php
/***************************************************************************
 *                          admin_cash_indexpage.php
 *                            -------------------
 *   begin                : Tuesday, Sep 09, 2003
 *   copyright            : (C) 2003 naderman
 *   email                : nils_adermann@hotmail.com
 *
 *   $Id: admin_cash_indexpage.php,v 1.0.0.0 2003/09/09 14:12:37 naderman $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   copyright (C) 2003  naderman
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   http://www.gnu.org/copyleft/gpl.html
 *
 ***************************************************************************/

define('IN_PHPBB', 1);

if(        !empty($setmodules) )
{
        $file = basename(__FILE__);
        $module['Cash Mod']['Cash_Index Page'] = $file;
        return;
}

//
// Lets set the root dir for phpBB
//
$phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);
//
//check for userlevel
//
if( !$userdata['session_logged_in'] )
{
        header('Location: ' . append_sid("login.$phpEx?redirect=admin/admin_cash_indexpage.$phpEx", true));
}

if( $userdata['user_level'] != ADMIN )
{
        message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}
//end check

// CASH ON INDEX

if ($_POST['process'] != 'Submit') {

        if ($board_config['cash_richdis'] == 'yes') {
                $richdis = 'checked';
                $richoff = '';
        }
        if ($board_config['cash_richdis'] == 'no') {
                $richdis = '';
                $richoff = 'checked';
        }
        if ($board_config['cash_userdis'] == 'yes') {
                $userdis = 'checked';
                $useroff = '';
        }
        if ($board_config['cash_userdis'] == 'no') {
                $userdis = '';
                $useroff = 'checked';
        }
        if ($board_config['cash_preorpost'] == 'prefix') {
                $pre = 'checked';
                $post = '';
        }
        if ($board_config['cash_preorpost'] == 'postfix') {
                $pre = '';
                $post = 'checked';
        }
        if ($board_config['cash_komma'] == 'komma') {
                $kom = 'checked';
                $br = '';
        }
        if ($board_config['cash_komma'] == 'br') {
                $kom = '';
                $br = 'checked';
        }
        if ($board_config['cash_pointsorcash'] == 'cash') {
                $cash = 'checked';
                $points = '';
        }
        if ($board_config['cash_pointsorcash'] == 'points') {
                $cash = '';
                $points = 'checked';
        }

        $overall = '<form method="POST" action="'.append_sid("admin_cash_indexpage.$phpEx").'">
        <table width="100%" cellpadding="4" cellspacing="1" border="0">
          <tr>
                <th width="50%"  class="thHead" colspan="2"><center>'.$lang['admin_cash_indexpage_config'].'</center></th>
          </tr>
          <tr>
                <td width="75%" class="row1">'.$lang['admin_cash_indexpage_richdis'].'</td>
                <td width="25%" class="row2">'.$lang['Yes'].'<input type="radio" name="R1" value="dis" '.$richdis.'>'.$lang['No'].'<input type="radio" name="R1" value="off" '.$richoff.'></td>
          </tr>
          <tr>
                <td width="75%" class="row1">'.$lang['admin_cash_indexpage_num'].'</td>
                <td width="25%" class="row2"><input type="text" name="num" size="20" value="'.$board_config['cash_richnum'].'"></td>
          </tr>
          <tr>
                <td width="75%" class="row1">'.$lang['admin_cash_indexpage_userdis'].'</td>
                <td width="25%" class="row2">'.$lang['Yes'].'<input type="radio" name="U1" value="dis" '.$userdis.'>'.$lang['No'].'<input type="radio" name="U1" value="off" '.$useroff.'></td>
          </tr>
          <tr>
                <td width="75%" class="row1">'.$lang['admin_cash_indexpage_preorpost'].'</td>
                <td width="25%" class="row2">'.$lang['Yes'].'<input type="radio" name="P1" value="pre" '.$pre.'>'.$lang['No'].'<input type="radio" name="P1" value="post" '.$post.'></td>
          </tr>
          <tr>
                <td width="75%" class="row1">'.$lang['admin_cash_indexpage_komma'].'</td>
                <td width="25%" class="row2">,<input type="radio" name="K1" value="kom" '.$kom.'>&br></input><input type="radio" name="K1" value="br" '.$br.'></td>
          </tr>
          <tr>
                <td width="75%" class="row1">'.$lang['admin_cash_indexpage_pointsorcash'].'</td>
                <td width="25%" class="row2">Cash Mod<input type="radio" name="C1" value="cash" '.$cash.'>Points System</input><input type="radio" name="C1" value="points" '.$points.'></td>
          </tr>
          <tr>
                <td width="50%"  height="18" class="catBottom" colspan="2"><center><input type="Submit" value="'.$lang['Submit'].'" name="process" size="20" class="button"></form></center></td>
          </tr>
        </table>
';
}
if ($_POST['process'] == 'Submit') {

        if ($_POST['R1'] == 'dis') {
                $sql = "update " . CONFIG_TABLE . " set config_value='yes' where config_name='cash_richdis'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }

        if ($_POST['R1'] == 'off') {
                $sql = "update " . CONFIG_TABLE . " set config_value='no' where config_name='cash_richdis'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }
        if ($_POST['num'] != NULL) {
                $sql = "update " . CONFIG_TABLE . " set config_value='{$_POST['num']}' where config_name='cash_richnum'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }
        if ($_POST['U1'] == 'dis') {
                $sql = "update " . CONFIG_TABLE . " set config_value='yes' where config_name='cash_userdis'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }

        if ($_POST['U1'] == 'off') {
                $sql = "update " . CONFIG_TABLE . " set config_value='no' where config_name='cash_userdis'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }
        if ($_POST['P1'] == 'pre') {
                $sql = "update " . CONFIG_TABLE . " set config_value='prefix' where config_name='cash_preorpost'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }

        if ($_POST['P1'] == 'post') {
                $sql = "update " . CONFIG_TABLE . " set config_value='postfix' where config_name='cash_preorpost'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }
        if ($_POST['K1'] == 'kom') {
                $sql = "update " . CONFIG_TABLE . " set config_value='komma' where config_name='cash_komma'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }

        if ($_POST['K1'] == 'br') {
                $sql = "update " . CONFIG_TABLE . " set config_value='br' where config_name='cash_komma'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }
        if ($_POST['C1'] == 'cash') {
                $sql = "update " . CONFIG_TABLE . " set config_value='cash' where config_name='cash_pointsorcash'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }

        if ($_POST['C1'] == 'points') {
                $sql = "update " . CONFIG_TABLE . " set config_value='points' where config_name='cash_pointsorcash'";
                if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Cash on Index config<br>'.mysql_error()); }
        }

        $overall = '
        <table width="100%" cellpadding="4" cellspacing="1" border="0">
          <tr>
                <th width="50%"  class="thHead" colspan="2"><center>'.$lang['admin_cash_indexpage_config'].'</center></th>
          </tr>
          <tr>
                <td class="row1" width="100%">'.$lang['admin_updated'].'. | <b><a href="'.append_sid("admin_cash_indexpage.$phpEx").'">'.$lang['admin_return'].'</a></b></td>
          </tr>
        </table>';

}




// END CASH ON INDEX

$template->assign_vars(array(
        'OVERALL' => "$overall",
        'TTL' => $lang['cash_indexpage_title'],
        'DESCRIPTION' => $lang['admin_cash_indexpage_description'],
));
$template->set_filenames(array(
        'body' => 'admin/cash_indexpage_config.tpl')
);
//
// Generate the page
//
$template->pparse('body');

include('page_footer_admin.' . $phpEx);


?>
User avatar
naderman
Consultant
Consultant
Posts: 3736
Joined: Fri Aug 01, 2003 10:06 pm
Location: Berlin, Germany
Name: Nils Adermann
Contact:

Post by naderman »

There can't be any other reason for this than a not ran install file. I really don't know what the problem could be. :?
I appreciate gifts from my Amazon wishlist.
naderman.de twitter: @naderman
User avatar
www.digitaly.nl
Registered User
Posts: 17
Joined: Tue Sep 23, 2003 5:08 pm

Post by www.digitaly.nl »

I don't know, but the admin doesn't work, after some edits it works fine on the index
User avatar
www.digitaly.nl
Registered User
Posts: 17
Joined: Tue Sep 23, 2003 5:08 pm

Post by www.digitaly.nl »

Do you want to tell what to add in mysql, mayby the install file don't work
User avatar
Admin Of Rhymcrimez
Registered User
Posts: 6
Joined: Sat Sep 27, 2003 12:49 pm
Contact:

Post by Admin Of Rhymcrimez »

Can anyone tell me it in english..nah,can someone go through the steps for me.because,i download the CASH thing right.it goes directly into WINZIP.after that,i don't know what to do from there.i don't know how to add it to my site or nothing.anyone can help me out?
User avatar
naderman
Consultant
Consultant
Posts: 3736
Joined: Fri Aug 01, 2003 10:06 pm
Location: Berlin, Germany
Name: Nils Adermann
Contact:

Post by naderman »

www.digitaly.nl wrote: Do you want to tell what to add in mysql, mayby the install file don't work


INSERT INTO phpbb_config (config_name, config_value) VALUES
('cash_richdis', 'yes'),
('cash_richnum', '1'),
('cash_userdis', 'yes'),
('cash_preorpost', 'postfix'),
('cash_komma', 'komma'),
('cash_pointsorcash', 'cash');
Admin Of Rhymcrimez wrote: Can anyone tell me it in english..nah,can someone go through the steps for me.because,i download the CASH thing right.it goes directly into WINZIP.after that,i don't know what to do from there.i don't know how to add it to my site or nothing.anyone can help me out?


Unzip all files to any folder you like. Then follow the install052.txt file.
I appreciate gifts from my Amazon wishlist.
naderman.de twitter: @naderman
User avatar
naderman
Consultant
Consultant
Posts: 3736
Joined: Fri Aug 01, 2003 10:06 pm
Location: Berlin, Germany
Name: Nils Adermann
Contact:

Post by naderman »

wedge_06 are you still interested in the statistics part?

this is what you would have to add somewhere in the statistics.php:

Code: Select all

//
// RICHEST USERS MOD
//

// change this to the number of displayed users
$display_limit = 3;


//
// SELECT CASH FIELD NAMES
//


$field_limit = 1000;
$sql = "SELECT cash_dbfield, cash_exchange, cash_name, cash_image, cash_imageurl
FROM " . CASH_TABLE . "
WHERE (cash_id <> -1 )
ORDER BY cash_exchange ASC
LIMIT " . $field_limit;

if ( !($result = $db->sql_query($sql)) )
{
        message_die(GENERAL_ERROR, "Couldn't retrieve cash data", "", __LINE__, __FILE__, $sql);
}

$cash_countfields = $db->sql_numrows($result);
$cash_data = $db->sql_fetchrowset($result);

for ($i = 0; $i < $cash_countfields; $i++)
{
        if ($cash_data[$i]['cash_imageurl'] == '')
        {
                $cashs_name = $cash_data[$i]['cash_name'];
        }
        else
        {
                $cashs_name = '<img border="0" src="'.$phpbb_root_path.''.$cash_data[$i]['cash_imageurl'].'">';
        }
        $cash_field = $cash_data[$i]['cash_dbfield'];
        $cash_change = $cash_data[$i]['cash_exchange'];
        $cash_sqls = ''.$cash_sqls.', '.$cash_field.'';
        $cash_order = ''.$cash_order.'('.$cash_field.' / '.$cash_change.') + ';
        $cashname_html .= '<th colspan="1" class="thTop" align="center" width="10%"><strong>'.$cashs_name.'</strong></th>';

}
$template->assign_vars(array(
        'L_TOP_RICH' => 'The richest users',
        'L_RICH' => '<th colspan="1" class="thTop" align="center" width="10%"><strong>Total ('.$cash_data[0]['cash_name'].')</strong></th>'.$cashname_html)
);


//
// SELECT RICHEST USER
//
$sql = "SELECT user_id, username $cash_sqls
FROM " . USERS_TABLE . "
WHERE (user_id <> " . ANONYMOUS . " )
ORDER BY ( $cash_order 0) DESC
LIMIT " . $display_limit;

if ( !($result = $db->sql_query($sql)) )
{
        message_die(GENERAL_ERROR, "Couldn't retrieve users data", "", __LINE__, __FILE__, $sql);
}

$user_countusers = $db->sql_numrows($result);
$user_data = $db->sql_fetchrowset($result);

for ($i = 0; $i < $user_countusers; $i++)
{
        $cashs = '';
        $class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
        $richests_cash = 0;
        for ($j = 0; $j < $cash_countfields; $j++)
        {
                $cash_field = $cash_data[$j]['cash_dbfield'];
                $cash_change = $cash_data[$j]['cash_exchange'];
                $richests_cash = $richests_cash + ($user_data[$i][$cash_field]/$cash_change);
                $cashs .= '<td class="'.$class.'" align="center" width="10%"><span class="gen">'.$user_data[$i][$cash_field].'</span></td>';
        }
        $cash = '<td class="'.$class.'" align="center" width="10%"><span class="gen">'.$richests_cash.'</span></td>'.$cashs.'';

        $class = ( !($i+1 % 2) ) ? $theme['td_class2'] : $theme['td_class1'];

        $template->assign_block_vars('rich', array(
                'RANK' => $i+1,
                'CLASS' => $class,
                'USERNAME' => $user_data[$i]['username'],
                'URL' => append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $user_data[$i]['user_id']),
                'RICH' => $cash)
        );
}

//
// END OF RICHEST USER MOD
//
and this in the statistics_body.tpl:

Code: Select all

<table border="0" cellpadding="4" cellspacing="1" class="forumline" width="100%">
  <tr>
    <td class="catHead" align="center" colspan="6">
   <span class="cattitle">{L_TOP_RICH}</span>
    </td>
  </tr>
   <tr>
    <th colspan="1" class="thCornerL" align="center"><strong>{L_RANK}</strong></th>
    <th colspan="1" class="thTop" align="center" width="10%"><strong>{L_USERNAME}</strong></th>
    {L_RICH}
  </tr>
  <!-- BEGIN rich -->
  <tr>
    <td class="{rich.CLASS}" align="left" width="10%"><span class="gen">{rich.RANK}</span></td>
    <td class="{rich.CLASS}" align="left" width="10%"><span class="gen"><a href="{rich.URL}">{rich.USERNAME}</a></span></td>
    {rich.RICH}
  </tr>
  <!-- END rich -->
</table>
This may only work on Statistics Mod 1.2.2 but I dunno. I only know 1.2.2 and not the Beta3 thing. If you have any problems just tell me and I'll try to help. To change the number of displayed users you have to change the 3 in $display_limit = 3; to the number you like.

Hope you like it. :D
I appreciate gifts from my Amazon wishlist.
naderman.de twitter: @naderman
wedge_06
Registered User
Posts: 30
Joined: Fri Jul 25, 2003 12:26 pm
Location: Nice (France)

Post by wedge_06 »

oh ! thanks a lot !!! ;)

I think I will test with the last statistics mod to see...

because i dont have the 1.2.2 version...
User avatar
naderman
Consultant
Consultant
Posts: 3736
Joined: Fri Aug 01, 2003 10:06 pm
Location: Berlin, Germany
Name: Nils Adermann
Contact:

Post by naderman »

If you find out how it works with that stats mod tell me how you did it please. :)
I appreciate gifts from my Amazon wishlist.
naderman.de twitter: @naderman
User avatar
drumstix42
Registered User
Posts: 1100
Joined: Tue Sep 24, 2002 11:01 pm
Location: NJ
Contact:

Post by drumstix42 »

Argh. I don't understand. Such a simple mod but it's not working.

Using Cash MOD

Currency: user_points

When I view the Online Box, this is what comes out:

The richest user is: You have (2568 ).


What's wrong?!
Need a phpBB update or mod installed? PM me for any questions and pricing!
HostMonster.com (Unlimited Space, Unlimited Transfer, Unlimited Domains, $6.95/month )
User avatar
drumstix42
Registered User
Posts: 1100
Joined: Tue Sep 24, 2002 11:01 pm
Location: NJ
Contact:

Post by drumstix42 »

What the.... if I change the settings in the Cash Forum Index in the Control Panel, it now shows:

The richest user is: You have (2568 Points).

still doesn't show it correctly... but it shows the name of the currenc... O_o
Need a phpBB update or mod installed? PM me for any questions and pricing!
HostMonster.com (Unlimited Space, Unlimited Transfer, Unlimited Domains, $6.95/month )
AngelicX
Registered User
Posts: 23
Joined: Tue Oct 07, 2003 6:06 pm

Post by AngelicX »

hey, I got kinda lost here.. does this work with the points mod?
kamahl
Registered User
Posts: 328
Joined: Sat Jan 04, 2003 4:38 pm
Location: Ogden, Utah

Post by kamahl »

drumstix42 wrote: What the.... if I change the settings in the Cash Forum Index in the Control Panel, it now shows:

The richest user is: You have (2568 Points).

still doesn't show it correctly... but it shows the name of the currenc... O_o


In the admin panel, check "Cash index page" under Cash Mod. What is "How many users shall be listed?" set to?


___________

And yes, it appears to work with the points mod.
[ The 10 Count Forums Powered by phpBB3.0 | 400 Wrestling Avatars ]
User avatar
naderman
Consultant
Consultant
Posts: 3736
Joined: Fri Aug 01, 2003 10:06 pm
Location: Berlin, Germany
Name: Nils Adermann
Contact:

Post by naderman »

AngelicX wrote: hey, I got kinda lost here.. does this work with the points mod?
Look at the topic's title! YES, it does. :D
I appreciate gifts from my Amazon wishlist.
naderman.de twitter: @naderman
User avatar
drumstix42
Registered User
Posts: 1100
Joined: Tue Sep 24, 2002 11:01 pm
Location: NJ
Contact:

Post by drumstix42 »

I get this when I click to not show richest user:
Couldn't retrieve users data

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

SELECT user_id FROM phpbb_users WHERE user_id = 2 AND user_id <> -1 ORDER BY ( 0) DESC LIMIT

Line : 402
File : /home/drumstix/public_html/forums/index.php
Need a phpBB update or mod installed? PM me for any questions and pricing!
HostMonster.com (Unlimited Space, Unlimited Transfer, Unlimited Domains, $6.95/month )
Post Reply

Return to “[2.0.x] MODs in Development”