[2.0.18] Cash Mod

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
1036
66%
Very Good
239
15%
Good
121
8%
Fair
36
2%
Poor
126
8%
 
Total votes: 1558

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 5:57 pm

jaded_marla wrote: Fatal error: Class 'sql_db' not found


Has your forum ever worked? This error is saying that the DB type you have defined in config.php is wrong.

Also, your linecount in common is about 20 off... Are you sure you did not delete something from common.php that you should not have?

K34nu
Registered User
Posts: 7
Joined: Thu Dec 07, 2006 11:55 am

Post by K34nu » Fri Dec 08, 2006 6:04 pm

@Jackanape
So should I split up the query? Also, if all re-adding the "Posting.php" means is to get rid of any changes, doesn't that mean that the line wasn't in their in the firstplace? So wouldn't the script have to be fixed?

Sorry if Iv got that wrong, thats just what iv gatherd from it.

Also, does that mean I have to install the script by-hand?

Thanks!
-Keanu

User avatar
Scriptmaster10
Registered User
Posts: 107
Joined: Mon Aug 29, 2005 5:47 pm
Location: The Heart of England

Post by Scriptmaster10 » Fri Dec 08, 2006 6:42 pm

Sorry, just everything is going wrong lately

Code: Select all

<?php

// This file modified for Effects Store for Shop 3

/***************************************************************************
 *                           usercp_viewprofile.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: usercp_viewprofile.php,v 1.5.2.6 2005/09/14 18:14:30 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   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.
 *
 *
 ***************************************************************************/

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
	exit;
}

if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
{
	message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
$profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);

if (!$profiledata)
{
	message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}

$sql = "SELECT *
	FROM " . RANKS_TABLE . "
	ORDER BY rank_special, rank_min";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
}

$ranksrow = array();
while ( $row = $db->sql_fetchrow($result) )
{
	$ranksrow[] = $row;
}
$db->sql_freeresult($result);

//
// Output page header and profile_view template
//
$template->set_filenames(array(
	'body' => 'profile_view_body.tpl')
);
make_jumpbox('viewforum.'.$phpEx);

//
// Calculate the number of days this user has been a member ($memberdays)
// Then calculate their posts per day
//
$regdate = $profiledata['user_regdate'];
$memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
$posts_per_day = $profiledata['user_posts'] / $memberdays;

// Get the users percentage of total posts
if ( $profiledata['user_posts'] != 0  )
{
	$total_posts = get_db_stat('postcount');
	$percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0;
}
else
{
	$percentage = 0;
}

$avatar_img = '';
if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] )
{
	switch( $profiledata['user_avatar_type'] )
	{
		case USER_AVATAR_UPLOAD:
			$avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
			break;
		case USER_AVATAR_REMOTE:
			$avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
			break;
		case USER_AVATAR_GALLERY:
			$avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
			break;
	}
}

$poster_rank = '';
$rank_image = '';
if ( $profiledata['user_rank'] )
{
	for($i = 0; $i < count($ranksrow); $i++)
	{
		if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] )
		{
			$poster_rank = $ranksrow[$i]['rank_title'];
			$rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
		}
	}
}
else
{
	for($i = 0; $i < count($ranksrow); $i++)
	{
		if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )
		{
			$poster_rank = $ranksrow[$i]['rank_title'];
			$rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
		}
	}
}

$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']);
$pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';

if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN )
{
	$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email'];

	$email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
	$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
}
else
{
	$email_img = '&nbsp;';
	$email = '&nbsp;';
}

$www_img = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '&nbsp;';
$www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : '&nbsp;';

if ( !empty($profiledata['user_icq']) )
{
	$icq_status_img = '<a href="http://wwp.icq.com/' . $profiledata['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $profiledata['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
	$icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
	$icq =  '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>';
}
else
{
	$icq_status_img = '&nbsp;';
	$icq_img = '&nbsp;';
	$icq = '&nbsp;';
}

$aim_img = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '&nbsp;';
$aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '&nbsp;';

$msn_img = ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : '&nbsp;';
$msn = $msn_img;

$yim_img = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
$yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';

$temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&showresults=posts");
$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" title="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" border="0" /></a>';
$search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '</a>' ;$rabbitoshi_link = append_sid("rabbitoshi.$phpEx?" . POST_USERS_URL . "=" . $profiledata['user_id']);

//
// Shop Code
//
if ( $board_config['viewprofile'] == 'images' )
{
	$sql = "SELECT *
		FROM " . USER_ITEMS_TABLE . "
		WHERE user_id='{$profiledata['user_id']}'
			AND ( worn = 0 or worn = 1 )
		GROuP BY `item_name`
		ORDER BY `id`";
	if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error!'); }
	$num_rows = $db->sql_numrows($result);

	$user_items = '<br />';

	for ( $iz = 0; $iz < $num_rows; $iz++ )
	{
		$row = $db->sql_fetchrow($result);

		if (file_exists('shop/images/' . $row['item_name'] . '.jpg'))
		{
			$user_items .= ' <img src="shop/images/' . $row['item_name'] . '.jpg" title="' . $row['item_name'] . '" alt="' . $row['item_name'] . '" />';
		}
		elseif (file_exists('shop/images/' . $row['item_name'] . '.png'))
		{
			$user_items .= ' <img src="shop/images/' . $row['item_name'] . '.png" title="' . $row['item_name'] . '" alt="' . $row['item_name'] . '" />';
		}
		elseif (file_exists('shop/images/' . $row['item_name'] . '.gif'))
		{
			$user_items .= ' <img src="shop/images/' . $row['item_name'] . '.gif" title="' . $row['item_name'] . '" alt="' . $row['item_name'] . '" />';
		}
	}
	$usernameurl = '<a href="'.append_sid('shop.'.$phpEx.'?action=inventory&searchid='.$profiledata['user_id'], true).'" class="gensmall"><b>' . $lang['items'] . '</b></a>: ';
}
elseif ( $board_config['viewprofile'] == 'link' )
{
	$usernameurl = '<a href="'.append_sid('shop.'.$phpEx.'?action=inventory&searchid='.$profiledata['user_id'], true).'" class="gensmall"><b>' . $lang['items'] . '</b></a>';
}


//
// Generate page
//
$page_title = $lang['Viewing_profile'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

if (function_exists('get_html_translation_table'))
{
	$u_search_author = urlencode(strtr($profiledata['username'], array_flip(get_html_translation_table(HTML_ENTITIES))));
}
else
{
	$u_search_author = urlencode(str_replace(array('&', ''', '"', '<', '>'), array('&', "'", '"', '<', '>'), $profiledata['username']));
}

// Bank Code
if ( empty($holding[$poster_id]) )
{
	$sql = "SELECT holding
		FROM " . BANK_TABLE . "
		WHERE user_id = '{$profiledata['user_id']}'";
	$result = $db->sql_query($sql);
	$bank_row = $db->sql_fetchrow($result);

	$bank_row['holding'] = ( empty($bank_row['holding']) ) ? '0' : $bank_row['holding'];
}

$template->assign_vars(array(
	'USERNAME' => $profiledata['username'],
	'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
	'POSTER_RANK' => $poster_rank,
	'RANK_IMAGE' => $rank_image,
    'INVENTORYLINK' => $usernameurl,
    'INVENTORYPICS' => $user_items,
	'POSTS_PER_DAY' => $posts_per_day,
	'POSTS' => $profiledata['user_posts'],
	'PERCENTAGE' => $percentage . '%', 
	'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day), 
	'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage), 

	'SEARCH_IMG' => $search_img,
	'SEARCH' => $search,
'RABBITOSHI_LINK' => $rabbitoshi_link,
	'PM_IMG' => $pm_img,
	'PM' => $pm,
	'EMAIL_IMG' => $email_img,
	'EMAIL' => $email,
	'WWW_IMG' => $www_img,
	'WWW' => $www,
	'ICQ_STATUS_IMG' => $icq_status_img,
	'ICQ_IMG' => $icq_img, 
	'ICQ' => $icq, 
	'AIM_IMG' => $aim_img,
	'AIM' => $aim,
	'MSN_IMG' => $msn_img,
	'MSN' => $msn,
	'YIM_IMG' => $yim_img,
	'YIM' => $yim,
	'BANK_GOLD' => $bank_row['holding'],
	'L_POINTS_NAME' => $board_config['points_name'],

	'L_POINTS_NAME' => $board_config['points_name'],

	'INVENTORYLINK' => $usernameurl,
	'INVENTORYPICS' => $user_items,


	'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : '&nbsp;',
	'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : '&nbsp;',
	'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : '&nbsp;',
	'AVATAR_IMG' => $avatar_img,

	'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']), 
	'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']), 
	'L_AVATAR' => $lang['Avatar'], 
	'L_POSTER_RANK' => $lang['Poster_rank'], 
	'L_JOINED' => $lang['Joined'], 
	'L_TOTAL_POSTS' => $lang['Total_posts'], 
	'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']), 
	'L_CONTACT' => $lang['Contact'],
	'L_EMAIL_ADDRESS' => $lang['Email_address'],
	'L_EMAIL' => $lang['Email'],
	'L_PM' => $lang['Private_Message'],
	'L_ICQ_NUMBER' => $lang['ICQ'],
	'L_YAHOO' => $lang['YIM'],
	'L_AIM' => $lang['AIM'],
	'L_MESSENGER' => $lang['MSNM'],
	'L_WEBSITE' => $lang['Website'],
	'L_LOCATION' => $lang['Location'],
	'L_OCCUPATION' => $lang['Occupation'],
	'L_INTERESTS' => $lang['Interests'],
	'L_BANK' => $lang['bank'],

'L_BANK' => $lang['bank'],

	'L_ITEMS' => $lang['items'],

	'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . $u_search_author),

	'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
);

//-- mod : groupes -----------------------------------------------------------------------------------
//-- add
$user_id = $userdata['user_id'];
$view_user_id = $profiledata['user_id'];
$groups = array();
$sql = '
   SELECT
      g.group_id,
      g.group_name,
      g.group_description,
      g.group_type
   FROM
      '.USER_GROUP_TABLE.' as l,
      '.GROUPS_TABLE.' as g
   WHERE
      l.user_pending = 0 AND
      g.group_single_user = 0 AND
      l.user_id ='. $view_user_id.' AND
      g.group_id = l.group_id
   ORDER BY
      g.group_name,
      g.group_id';
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not read groups', '', __LINE__, __FILE__, $sql);   
while ($group = $db->sql_fetchrow($result)) $groups[] = $group;

$template->assign_vars(array(
   'L_USERGROUPS' => $lang['Usergroups'],
   )
);
if (count($groups) > 0)
{
   for ($i=0; $i < count($groups); $i++)
   {
      $is_ok = false;
      //
      // groupe invisible ?
      if ( ($groups[$i]['group_type'] != GROUP_HIDDEN) || ($userdata['user_level'] == ADMIN) )
      {
         $is_ok=true;
      }
      else
      {
         $group_id = $groups[$i]['group_id'];
         $sql = 'SELECT * FROM '.USER_GROUP_TABLE.' WHERE group_id='.$group_id.' AND user_id='.$user_id.' AND user_pending=0';
         if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Couldn\'t obtain viewer group list', '', __LINE__, __FILE__, $sql);
         $is_ok = ( $group = $db->sql_fetchrow($result) );
      }  // end if ($view_list[$i]['group_type'] == GROUP_HIDDEN)
      //
      // groupe visible : afficher
      if ($is_ok)
      {
         $u_group_name = append_sid("groupcp.php?g=".$groups[$i]['group_id']);
         $l_group_name = $groups[$i]['group_name'];
         $l_group_desc = $groups[$i]['group_description'];
         $template->assign_block_vars('groups',array(
            'U_GROUP_NAME' => $u_group_name,
            'L_GROUP_NAME' => $l_group_name,
            'L_GROUP_DESC' => $l_group_desc,
            )
         );
      }  // end if ($is_ok)
   }  // end for ($i=0; $i < count($groups); $i++)
}  // end if (count($groups) > 0)
//-- mod : groupes ----------------------------------------------------------------------------------- 

//------------------------------------------------------------------------------
// Effects Store for Shop 3 - Begin Code Alteration
//
require_once($phpbb_root_path . 'mods/shopaddons/effects.' . $phpEx);
$effects->profile_check($profiledata);
//
// Effects Store for Shop 3 - End Code Alteration
//------------------------------------------------------------------------------
$cm_viewprofile->post_vars($template,$profiledata,$userdata);

$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>

jaded_marla
Registered User
Posts: 5
Joined: Fri Dec 08, 2006 4:55 am

Post by jaded_marla » Fri Dec 08, 2006 7:08 pm

Unfortunately I did do it by hand. That is surely the problem. LOL!

Anyway, I guess I will go back to the back up. I give up on this one.

And yes my forum has worked before. Has worked before I tried to put this mod on (not that I am blaming the mod).

jaded_marla
Registered User
Posts: 5
Joined: Fri Dec 08, 2006 4:55 am

Post by jaded_marla » Fri Dec 08, 2006 7:42 pm

Hey. I am wondering about something. My root path is phpp2 instead of phpbb. Could that be what the problem is? If so, how do I fix it?

If you are wondering, the forums and site are with a paid server. So, when I edit I can open up the files in Microsoft FrontPage. I can edit the files there and see the line numbers. I just can't copy and paste with the line numbers.

And I restored my common.php file to a backed up version and now that looks right. The error I have now is:
functions_cash.php has not been included.
But, it is there. I see it installed in includes. But is seems to not be recognized so that is why I wonder if the phpbb2 root (instead of phpbb) is the problem.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 8:08 pm

K34nu wrote: doesn't that mean that the line wasn't in their in the firstplace? So wouldn't the script have to be fixed?

Brf wrote:
K34nu wrote:Critical Error

FIND FAILED: In file [posting.php] could not find:

$select_sql = ( !$submit ) ? ", t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';


If you have any mods to Polls, that could be a little messed up. The line it is looking for is in the "poll_delete" selection

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 8:16 pm

jaded_marla wrote: And I restored my common.php file to a backed up version and now that looks right. The error I have now is:
functions_cash.php has not been included.


Yes. It need to be included in common.php, as per the earlier messages.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 8:46 pm

Scriptmaster10 wrote: Sorry, just everything is going wrong lately


Hmmm... weird.... You have CASH in there three times. You would think it would show at least once.

Are you sure you have it enabled to show in usercp in your Cash Settings?

Reeses
Registered User
Posts: 15
Joined: Wed Oct 18, 2006 6:51 pm

Post by Reeses » Fri Dec 08, 2006 9:30 pm

Hi, I'm using an activity mod that supports cash mods, and it recognizes it. But once I add a charge for the game and a reward, after I play the game, and submit the score, I get this error

Code: Select all

Failed to add rewards

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 '= + 3.8 WHERE user_id = 2' at line 2

UPDATE phpbb_users SET = + 3.8 WHERE user_id = 2

Line : 42
File : rewards_api.php

Help?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 9:36 pm

Your SQL statement does not have the db-name of the cash in it....
Reeses wrote:

Code: Select all

  UPDATE phpbb_users SET (missingname) = (missingname)+ 3.8 WHERE user_id = 2

Reeses
Registered User
Posts: 15
Joined: Wed Oct 18, 2006 6:51 pm

Post by Reeses » Fri Dec 08, 2006 9:42 pm

Thanks for the reply.

So what exactly do I need to do?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 9:45 pm

You need to supply the cash dbname in your update statement.

Reeses
Registered User
Posts: 15
Joined: Wed Oct 18, 2006 6:51 pm

Post by Reeses » Fri Dec 08, 2006 9:57 pm

I know pretty much nothing about MySQL...

I'm in the mySQL adminstration, and it obviously has something to do with the table phpbb_users, but what is an update statement? Could you walk me to through this?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51889
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Fri Dec 08, 2006 10:01 pm

No. It has nothing to do with mysql admin.

Your program is not supplying the name of the field to update when it builds its SQL statement. What does that statement look like in the script? It looks like you have a parameter missing when you are calling your rewards_api.

Reeses
Registered User
Posts: 15
Joined: Wed Oct 18, 2006 6:51 pm

Post by Reeses » Fri Dec 08, 2006 10:10 pm

Code: Select all

<?
/***************************************************************************
 *                              rewards_api.php
 *                            -------------------
 *   begin                : Monday, May 15, 2006
 *   copyright            : (C) 2003 Xore, Napoleon, dEfEndEr
 *   email                : mods@xore.ca, admin@phpbb-arcade.com
 *
 *   $Id: rewards_api.php,v 0.5.0 2006/05/15 23:59:59 dEfEndEr $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   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.
 *
 ***************************************************************************/

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}
//
// give rewards to the user
//
function add_reward($user_id,$amount)
{
	global $userdata, $db;
	$dbfield = get_db_reward();
	if ( $userdata['user_id'] == $user_id )
	{
		$userdata[$dbfield] += $amount;
	}
	$sql = "UPDATE " . USERS_TABLE . "
		SET $dbfield = $dbfield + $amount
		WHERE user_id = $user_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, "Failed to add rewards", "", __LINE__, __FILE__, $sql);
	}
}
//
// subdtract rewards from the user
//
function subtract_reward($user_id,$amount)
{
	global $userdata, $db;
	$dbfield = get_db_reward();
	if ( $userdata['user_id'] == $user_id )
	{
		$userdata[$dbfield] -= $amount;
	}
	$sql = "UPDATE " . USERS_TABLE . "
		SET $dbfield = $dbfield - $amount
		WHERE user_id = $user_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, "Failed to subtract rewards", "", __LINE__, __FILE__, $sql);
	}
}
//
// set the user's rewards
//
function set_reward($user_id,$amount)
{
	global $userdata, $db;
	$dbfield = get_db_reward();
	if ( $userdata['user_id'] == $user_id )
	{
		$userdata[$dbfield] = $amount;
	}
	$sql = "UPDATE " . USERS_TABLE . "
		SET $dbfield = $amount
		WHERE user_id = $user_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, "Failed to set rewards", "", __LINE__, __FILE__, $sql);
	}
}
//
// get the user's reward amounts
//
function get_reward($user_id)
{
	global $userdata, $db;
	$dbfield = get_db_reward();
	if ( $userdata['user_id'] == $user_id )
	{
		return $userdata[$dbfield];
	}
	else
	{
		$sql = "SELECT $dbfield
			FROM " . USERS_TABLE . "
			WHERE user_id = $user_id";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, "Failed to get rewards", "", __LINE__, __FILE__, $sql);
		}
		if ( !($row = $db->sql_fetchrow($result)) )
		{
			message_die(GENERAL_ERROR, "Bad user_id or default reward column", "", __LINE__, __FILE__);
		}
		return $row[$dbfield];
	}
}
//
// check if user has $amount minimum rewards
//
function has_reward($user_id, $amount)
{
	$users_amount = get_reward($user_id);
	return ($users_amount >= $amount);
}
//
// Get the rewards dbfield (API-internal function)
//
function get_db_reward()
{
	// All rewards mods must store their default database field in the config table ...
	// 'default_reward_dbfield'
	global $board_config, $arcade;
	
	if(isset($board_config['default_reward_dbfield']))
	{
  	return $board_config['default_reward_dbfield'];
  }
  else
  {
    return $arcade->arcade_config['default_cash'];
  }
}
//
//  New function to get the cash system name from the db filked entered in the Arcade config
//
function get_cash_name()
{
  global $table_prefix, $db, $arcade;
  
  $sql = "SELECT `cash_name` FROM ". $table_prefix . "cash 
    WHERE cash_dbfield = '" . $arcade->arcade_config['default_cash'] . "'";
 	$cashinfo = $db->sql_fetchrow($db->sql_query($sql));

  return $cashinfo['cash_name'];
//      $cash_name = get_cash_name()
}

?>
Here is that file

Post Reply

Return to “[2.0.x] MOD Database Releases”