vB.org Release Thread
uCash & uShop 0.95



uCash & uShop
Introduction
uCash & uShop(uCS), is a hack, "like" Lesanes vB2 Store hack. The idea is the same, but the coding is not. uCS, was developed with big boards in mind as well as small ones. It allows almost total control of every action and who has access to it. That said, if there are any questions please ask at vBulletin.org or GeekyDesigns.com

uCash & uShop credits
Concept:
Zachery Woods
Matthew Gordon
PHP Code:
Matthew Gordon
- misc: Zachery Woods, Stefan "Xenon", g-force2k2
Templates:
Zachery Woods
- misc: Matthew Gordon
Other contributions:
Assassingod
Kura
Oblivion Knight
Hobbes
Stefan "Xenon"
g-force2k2
Features:
uCash
  • Fully configurable database table/field for integrating with other systems that uses points.
  • Master On/Off Switch
  • Global Points Per Thread Setting
  • Global Points Per Reply Setting
  • Global Points Per Thread View Setting
  • Points Per Good Reputation
  • Points Per Bad Reputation
  • Points Per Referral
  • Points Per Shout Setting (if GeekyDesign's Shoutbox Hack 1.02 or above is installed.)
  • Round to x Decimal Places (for a cash/change system)
  • Modify Points in the User Manager
  • Per-Forum Points Per Thread Setting (multiplied by the global setting to get the final value)
  • Per-Forum Points Per Reply Setting (multiplied by the global setting to get the final value)
  • Per-Forum Points Per Thread View Setting (multiplied by the global setting to get the final value)
uShop
  • Currently 18 actions are available - Donate, Change Custom Title, Change Other User's Custom Title, Change Username, Glowing Username, Colored Username, Bold Username, Italicized Username, Admin Donate, Bank, Secondary Usergroup, Sticky Thread, Thief!, Buy Forum Password, Buy Forum Access, Deny Forum Access, Give Forum Access, Arcade Pass (If Arcade Pass Hack v3 is installed.)
  • Quantity System
  • Quantity Refill (Set a number of seconds between refills and quantity is automatically refilled when accessing the main store script.)
  • Richest x Users
  • Top x Most Sold Actions
  • Purchase History
  • Senoir Discount (based on age - if they are older than x years, they get a discount (also setable))
  • Loyal Member Discount (based on days registered - if they have been registered for x days, they get a discount (also setable))
  • Usergroup Discount (give your staff a price cut!)
  • Shortname (only setable while in debug mode - can be used in links (also used in some functions))
  • Setable Action Description
  • Setable Display Order
  • Setable Cost
  • Setable Quantity and Quantity Refill (when/if quantities are refilled)
  • Setable Allowed Usergroups Via Checkboxes (usergroups that are not allowed do not see the action at all and cannot access it)
  • Setable Denied Usergroups Via Checkboxes (users that are a member of this usergroup cannot use the action)
  • Setable Image Location (if not location is specified, no image is shown)
  • Show In Store (if it is set to no, you will not see the action in the store, but can still access it via direct link)
  • Setable Active Status (if it isn't active, it goes *poof* from the store and is not accessable until it is set active again)
  • Update Display Order, Cost, Tax, Sold, Quantity Refill, and Quantity en masse.
  • You can duplicate the "Secondary Usergroup" (or other actions for that matter) action and define which usergroups are joinable for each action by duplicating the action file and setting the joinable groups at the top (so you can allow different usergroups to be joined for different prices)
  • Secondary Usergroup is an extremely powerful action - you can give people access to forums, higher PM quotas, the ability to see invisible users, access to free custom title changing, etc.
  • Action Specific Variables System - specific variblables set per action. You can add and edit these variables in debug mode - or you can just change the value while editing an action as if it were any other variable.
  • Copy an action (useful for actions like secondary usergroup and those dealing with forums if you want each forum/usergroup to have a different cost/quantity/etc)
  • Very few queries! (On the main page, there are 6 queries - 5 from vB3 and 1 from the store - and that's just for the richest users!)
  • Setting to allow BBCode in Custom Titles.
  • Configurable: reputation given for x amount of points donated.
  • Configurable: reputation lost for successful and unsuccessful theft attempts.
  • Configurable: x percent bank interest percent over x seconds.
Help & Support
Please ask at GeekyDesigns.com or in the thread at vBulletin.org. Anyone trying to contact us via email, private message, or any other means will be ignored.
Copyright
This script is © 2003 - 2004 GeekyDesigns.com
This script is NOT to be re-distributed in any way or placed on a website for download without permission.
All copyright notes in the script itself must remain unchanged.


Installation Instructions
Step 1 - Upload New Files
Upload all uCash & uShop files to their proper directories

Step 2 - Run the Install Script
Now it's time to add the uCash & uShop settings, templates, phrases, database fields/tables, etc. Run the install script from your browser by going to http://yoursite.com/forum/admincp/ushop_install.php.

This script will make all necessary changes to your database and install the templates, phrases, settings, and etc for you.

Step 3 - File Changes
In your /forum/admincp/forum.php file: (2 Changes)

Find:
			'warnall' => 0

Replace with:
			// ## <ucs>
			'warnall' => 0,
			'uttpoints_perthread' => 1,
			'uttpoints_perreply' => 1,
			'uttpoints_perview' => 1
			// ## </ucs>


Find:
	print_yes_no_row($vbphrase['show_forum_on_forum_jump'], 'options[showonforumjump]', $forum['showonforumjump']);

Add Below:
	// ## <ucs>
	$vbphrase['uttpoints_forumoptions_title'] = "uTT Points System Options";
	$vbphrase['uttpoints_forumoptions_perthread'] = "Points Per Thread?<dfn>This setting is multiplied by the default value defined in the 'vBulletin Options' page of the Admin CP. A value of 1 uses the default, 2 doubles it, etc.</dfn>";
	$vbphrase['uttpoints_forumoptions_perreply'] = "Points Per Reply?<dfn>This setting is multiplied by the default value defined in the 'vBulletin Options' page of the Admin CP. A value of 1 uses the default, 2 doubles it, etc.</dfn>";
	$vbphrase['uttpoints_forumoptions_perview'] = "Points Per View?<dfn>This setting is multiplied by the default value defined in the 'vBulletin Options' page of the Admin CP. A value of 1 uses the default, 2 doubles it, etc.</dfn>";
	
	print_table_header($vbphrase['uttpoints_forumoptions_title']);
	
	print_input_row($vbphrase['uttpoints_forumoptions_perthread'], 'forum[uttpoints_perthread]', $forum['uttpoints_perthread']);
	print_input_row($vbphrase['uttpoints_forumoptions_perreply'], 'forum[uttpoints_perreply]', $forum['uttpoints_perreply']);
	print_input_row($vbphrase['uttpoints_forumoptions_perview'], 'forum[uttpoints_perview]', $forum['uttpoints_perview']);
	// ## </ucs>


In your /forum/admincp/index.php file: (1 Change)

Find:
	$printhr = false;
	if (can_administer('canadminstyles'))

Add Above:
	// ## <ucs> 
	construct_nav_option("uTT Point System Settings", 'options.php?dogroup=uttpoints', '<br />');
	construct_nav_option("uTT Store Settings", 'options.php?dogroup=uttstore', '<br />');
	construct_nav_option("Action Manager", 'uttstoreadmin.php?do=modify', '<br />');
	construct_nav_option("Add Action", 'uttstoreadmin.php?do=add', '<br />');
	construct_nav_group("uTT Store Hack", '<hr />'); 
	// ## </ucs> 


In your /forum/admincp/user.php file: (1 Change)

Find:
	print_input_row($vbphrase['post_count'], 'user[posts]', $user['posts']);

Add Below:
	// ## <ucs>
	// uTT Points System
	if ($vboptions['uttpoints_pointtable'] == "user") {
		print_input_row("Points:", "user[$vboptions[uttpoints_pointsfield]]", $user[$vboptions[uttpoints_pointsfield]]);
	}
	// ## </ucs>


In your /forum/admincp/usergroup.php file: (2 Changes)

Find:
				'profilepicmaxwidth' => 100, 'profilepicmaxheight' => 100, 'profilepicmaxsize' => 25000

Replace With:
				// ## <ucs>
				'profilepicmaxwidth' => 100, 'profilepicmaxheight' => 100, 'profilepicmaxsize' => 25000, 'uttstore_discount' => 0
				// ## </ucs>


Find:
	print_yes_no_row($vbphrase['other_users_can_be_posted'], 'usergroup[canbeusernoted]', $ug_bitfield['canbeusernoted']);
	print_table_break();

Add Below:
	// ## <ucs> 
	$vbphrase['uttstore_cpusergroup_title'] = "uTT Store Settings"; 
	$vbphrase['uttstore_cpusergroup_discount'] = "Usergroup Discount?<dfn>Set this to the percent that is taken off the normal cost for this usergroup (negative adds cost). Set to '0' to have no effect.</dfn>"; 

	print_table_header($vbphrase['uttstore_cpusergroup_title']); 
	print_input_row($vbphrase['uttstore_cpusergroup_discount'], 'usergroup[uttstore_discount]', $usergroup['uttstore_discount']); 
	print_table_break(); 
	// ## </ucs>


In your /forum/includes/functions.php file: (1 Change)

Find:
	$user['musername'] = $usergroupcache["$displaygroupid"]['opentag'] . $username . $usergroupcache["$displaygroupid"]['closetag'];

Replace With:
// ## <ucs>
	$user['musername'] = $username;
	($user['uttstore_italicsusername'] != '0' && $user['uttstore_italicsusername'] != '' ? $user['musername'] = "<i>" . $user['musername'] . "</i>" : "");
	($user['uttstore_boldusername'] != '0' && $user['uttstore_boldusername'] != '' ? $user['musername'] = "<b>" . $user['musername'] . "</b>" : "");
	($user['uttstore_usernamecolor'] != '0' && $user['uttstore_usernamecolor'] != '' ? $user['musername'] = "<font color=\"$user[uttstore_usernamecolor]\">" . $user['musername'] . "</font>" : "");
	$user['musername'] = $usergroupcache["$displaygroupid"]['opentag'] . $user['musername'] . $usergroupcache["$displaygroupid"]['closetag'];
// ## </ucs>


In your /forum/includes/functions_newpost.php file: (1 Change)

Find:
		$DB_site->query("
			UPDATE " . TABLE_PREFIX . "user SET
				$doposts
				$dotitle
				lastpost = " . TIMENOW . "
			WHERE userid = $bbuserinfo[userid]
		");

Add Below:
// ## <ucs>
		// ### START UTT POINTS SYSTEM  ###
		if ($vboptions['uttpoints_enablesystem'] == '1')
		{ // It's enabled! Yay!
			if ($type == 'thread')
			{ // We're doing a thread, not a reply.
				if ($vboptions['uttpoints_perthread'] != '0' && $foruminfo['uttpoints_perthread'] != '0')
				{ // Both needed values are not 0... good.
					$givethempoints = ($vboptions['uttpoints_perthread'] * $foruminfo['uttpoints_perthread']);
				}
			}
			else
			{ // This time we're replying.
				if ($vboptions['uttpoints_perreply'] != '0' && $foruminfo['uttpoints_perreply'] != '0')
				{ // Both needed values are not 0... good.
					$givethempoints = ($vboptions['uttpoints_perreply'] * $foruminfo['uttpoints_perreply']);
				}
			}
			if (isset($givethempoints))
			{ // If they get money....
				// Send the query and we're done.
				$DB_site->query("UPDATE ".TABLE_PREFIX . $vboptions[uttpoints_pointtable]." SET ".$vboptions[uttpoints_pointsfield]."=".$vboptions[uttpoints_pointsfield]."+".$givethempoints." WHERE userid='$bbuserinfo[userid]'");
			}
		}
// ## </ucs> 


In your /forum/includes/functions_showthread.php file: (1 Change)

Find:
	// do posts from ignored users

Add Above:
// ## <ucs>
	// uTT Points System
	// Make it appear more like money.
	// Thanks g-force2k2 and Xenon!
	if ($vboptions['uttpoints_enablesystem'] == '1')
	{ // It's enabled! Yay!
		$points = $post[$vboptions[uttpoints_pointsfield]];
		$points = round($points, $vboptions['uttpoints_rounddecimal']);
		$points = number_format($points, $vboptions['uttpoints_rounddecimal'], '.', '');
	}
	// uTT Store Hack
	// Note sure if I even need this, but a safety percausion anyways...
	$post['uttstore_glow'] = htmlspecialchars($post['uttstore_glow']);
	$post['uttstore_usernamecolor'] = htmlspecialchars($post['uttstore_usernamecolor']);
// ## </ucs>


In your /forum/includes/init.php file: (1 Change)

Find:
			'stylecache'

Replace With:
// ## <ucs>
			'stylecache',
			'utt_store_act'
// ## </ucs>


In your /forum/member.php file: (1 Change)

Find:
$show['profilelinks'] = iif($show['member'] OR $userinfo['showvcard'], true, false);

Add Below:
// ## <ucs>
// uTT Points System
// Make it appear more like money.
// Thanks g-force2k2 and Xenon!
if ($vboptions['uttpoints_enablesystem'] == '1')
{ // It's enabled! Yay!
	$points = $userinfo[$vboptions[uttpoints_pointsfield]];
	$points = round($points, $vboptions['uttpoints_rounddecimal']);
	$points = number_format($points, $vboptions['uttpoints_rounddecimal'], '.', '');
}
// ## </ucs>


In your /forum/register.php file: (1 Change)

Find:
		$userid = $DB_site->insert_id();

Add Below:
		// ## <ucs>
		if (intval($testreferrerid['userid']) != '0') {
			if ($vboptions['uttpoints_enablesystem'] == '1')
			{ // It's enabled! Yay!
				if ($vboptions['uttpoints_pointsperreferral'] != '0')
				{ // Needed value is not 0... good.
					$givethempoints = $vboptions['uttpoints_pointsperreferral'];
				}
				if (isset($givethempoints))
				{ // If they get money....
					// Send the query and we're done.
					$DB_site->query("UPDATE ".TABLE_PREFIX . $vboptions[uttpoints_pointtable]." SET ".$vboptions[uttpoints_pointsfield]."=".$vboptions[uttpoints_pointsfield]."+".$givethempoints." WHERE userid='".intval($testreferrerid['userid'])."'");
				}
			}
		}
		// ## </ucs>


In your /forum/reputation.php file: (1 Change)

Find:
	$DB_site->query("
		INSERT INTO " . TABLE_PREFIX . "reputation (postid, reputation, userid, whoadded, reason, dateline)
		VALUES ($postid, $score, $userid, $bbuserinfo[userid], '" . addslashes(fetch_censored_text($reason)) . "','" . TIMENOW . "')
	");

Add Below:
	// ## <ucs>
	if ($vboptions['uttpoints_enablesystem'] == '1')
	{ // It's enabled! Yay!
		if ($score > '0')
		{ // If the amount of reputation is positive...
			if ($vboptions['uttpoints_pointsforgreputation'] != '0')
			{ // Needed value is not 0... good.
					$givethempoints = ($vboptions['uttpoints_pointsforgreputation'] * $score);
			}
		}
		else
		{ // If the amount of reputation is negative...
			if ($vboptions['uttpoints_pointsforbreputation'] != '0')
			{ // Needed value is not 0... good.
					$givethempoints = ($vboptions['uttpoints_pointsforbreputation'] * $score);
			}
		}
		if (isset($givethempoints))
		{ // If they get money....
			// Send the query and we're done.
			$DB_site->query("UPDATE ".TABLE_PREFIX . $vboptions[uttpoints_pointtable]." SET ".$vboptions[uttpoints_pointsfield]."=".$vboptions[uttpoints_pointsfield]."+".$givethempoints." WHERE userid='$userinfo[userid]'");
		}
	} 
	// ## </ucs>


In your /forum/showthread.php file: (1 Change)

Find:
	// or doing it once an hour
	$DB_site->shutdown_query("
		INSERT INTO " . TABLE_PREFIX . "threadviews (threadid)
		VALUES (" . intval($threadinfo['threadid']) . ')'
	);
}

Add Below:
// ## <ucs>
if ($vboptions['uttpoints_enablesystem'] == '1')
{ // It's enabled! Yay!
	if ($thread['postuserid'] != $bbuserinfo['userid'])
	{ // Don't give points if the user viewing the thread is the one who created it.
		if ($vboptions['uttpoints_perview'] != '0' && $forum['uttpoints_perview'] != '0')
		{ // Both needed values are not 0... good.
				$givethempoints = ($vboptions['uttpoints_perview'] * $forum['uttpoints_perview']);
		}
	}
	if (isset($givethempoints))
	{ // If they get money....
		// Send the query and we're done.
		$DB_site->shutdown_query("UPDATE ".TABLE_PREFIX . $vboptions[uttpoints_pointtable]." SET ".$vboptions[uttpoints_pointsfield]."=".$vboptions[uttpoints_pointsfield]."+".$givethempoints." WHERE userid='$thread[postuserid]'");
	}
}
// ## </ucs>


In your /forum/global.php file: (2 Changes)

Find:
	// navbar construction
	'navbar',
	'navbar_link',

Add Below:
	'navbar_uttstore_actions',


Find: (THIS IS LOCATED NEAR THE VERY BOTTOM OF GLOBAL.PHP.)
if (DB_QUERIES)
{
	$pageendtime = microtime();
	$starttime = explode(' ', $pagestarttime);
	$endtime = explode(' ', $pageendtime);
	$aftertime = $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
	echo "End call of global.php:  $aftertime\n";
	echo "\n<hr />\n\n";
}

Add Above:
// ## <ucs>
// Unserialize uShop Actions.
$storeactions = unserialize($datastore['utt_store_act']);

// Make a list of the all the actions...
foreach ($storeactions as $actionid => $theaction) {
	if ($theaction['active'] == "1") {
		$allowed = explode(",", $theaction['allowedgroups']);
		foreach ($allowed as $allow) {
			if (is_member_of(array('userid'=>$bbuserinfo['userid'], 'usergroupid'=>$bbuserinfo['usergroupid'], 'membergroupids'=>$bbuserinfo['membergroupids']), $allow)) {
				$canenter = "1";
			}
		}
		$denied = explode(",", $theaction['deniedgroups']);
		foreach ($denied as $deny) {
			if (is_member_of(array('userid'=>$bbuserinfo['userid'], 'usergroupid'=>$bbuserinfo['usergroupid'], 'membergroupids'=>$bbuserinfo['membergroupids']), $deny)) {
				unset($canenter);
			}
		}
		if (!isset($canenter)) {
			$canenter = "0";
		}
		if (THIS_SCRIPT == 'ushop') {
			if ($canenter == 1) {
				$action1[$actionid] = $theaction;
			}
			if ($theaction['showinstore'] == 1) {
				(isset($actioncount) ? $actioncount++ : $actioncount = "1");
			}
		}
		if ($canenter == 1 && $theaction['showinstore'] == 1) {
			eval('$ushop_navbar .= "' . fetch_template('navbar_uttstore_actions') . '";');
		}
	}
}
// The end all solution.
unset($theaction);
unset($storeactions);
if (THIS_SCRIPT == 'ushop') {
	$storeactions = $action1;
}
unset($action1);
// ## </ucs>


Step 4 - Template Changes
In your MEMBERINFO template: (1 Change)
Find:
$vbphrase[referrals]: <strong>$referrals</strong>

Replace with:
$vbphrase[referrals]: <strong>$referrals</strong><br />
					<if condition="$bbuserinfo['usergroupid'] == '6'"><a href="ushop.php?do=a&shortname=admindonate&userid=$post[userid]" target="_blank">Points</a><else />Points</if>: <strong>$points</strong> (<a href="ushop.php?do=a&shortname=donate&userid=$post[userid]" target="_blank">Donate</a>)
				</div>
			</div>
<else />
			<div class="fieldset">
				<div style="padding:$stylevar[formspacer]px">
					<if condition="$bbuserinfo['usergroupid'] == '6'"><a href="ushop.php?do=a&shortname=admindonate&userid=$post[userid]" target="_blank">Points</a><else />Points</if>: <strong>$points</strong> (<a href="ushop.php?do=a&shortname=donate&userid=$post[userid]" target="_blank">Donate</a>)


In your postbit and/or postbit_legacy template template: (2 Changes)
Find:
<div id="postmenu_$post[postid]">

Replace with:
<if condition="$post['uttstore_glow']"><div id="postmenu_$post[postid]" style="width:100%; filter:Glow(color=$post[uttstore_glow], strength=5);"><else /><div id="postmenu_$post[postid]"></if>

Find:
$vbphrase[posts]: $post[posts]

Replace with:
$vbphrase[posts]: $post[posts] | 	<if condition="$bbuserinfo['usergroupid'] == '6'"><a href="ushop.php?do=a&shortname=admindonate&userid=$post[userid]" target="_blank">Points</a><else />Points</if>: $points (<a href="ushop.php?do=a&shortname=donate&userid=$post[userid]" target="_blank">Donate</a>)

In your navbar template template: (2 Changes)
Find:
<td class="vbmenu_control"><a href="calendar.php?$session[sessionurl]">$vbphrase[calendar]</a></td>

Add after:
<td id="shop" class="vbmenu_control"><a href="#shop">Store</a><script type="text/javascript"> vbmenu_register("shop");</script></td>

Find:
	</div>
	<!-- / user cp tools menu -->
	</if>


Add Below:
<!-- shop menu -->
<div class="vbmenu_popup" id="shop_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
		<tr><td class="thead"><a href="ushop.php$session[sessionurl]">uShop Menu</a></td></tr>		
		<tr><td class="vbmenu_option"><a href="ushop.php?do=a&shortname=bank">Bank</a></td></tr>
		<tr><td class="vbmenu_option"><a href="ushop.php?do=richestusers">Richest Members</a></td></tr>
		<tr><td class="vbmenu_option"><a href="ushop.php?do=mostsold">Most Sold</a></td></tr>
		<tr><td class="vbmenu_option"><a href="ushop.php?do=userhistory">History</a></td></tr>
		<tr><td class="thead"><a href="ushop.php$session[sessionurl]">Actions</a></td></tr>
$ushop_navbar
</table>
	</div>
	<!-- / shop menu -->

Step 6 - Enjoy!
Your Admin Control Panel should contain links to edit the configuration of uCS and all of the purchasable actions. Edit these to your liking. Enjoy :)


uCash & uShop © 2003 - 2004 GeekyDesigns.com