When a new bid is placed on an item, this modification to the vbay.php file will send a PM to the old highest bidder from the new highest bidder
in vbay.php search for:
search for:
Code:
require_once('./includes/class_bbcode.php');
add the following immediatelt below
Code:
require_once('./includes/functions_vbay.php');
Search for:
Code:
if ($_REQUEST['do'] == 'bid') {
$check = $db->query("select * from " . TABLE_PREFIX . "vbay_items where id='{$_REQUEST['dobid']}'");
$item = $db->fetch_array($check);
if ($item['owner'] == $vbulletin->userinfo['userid']){
eval(standard_error(fetch_error('vbay_auction_own')));
}
if ($item['completetime'] < time()) {
eval(standard_error(fetch_error('vbay_auction_ended')));
} else {
if ($item['price'] + $item['inc'] > $_POST['bid']) {
eval(standard_error(fetch_error('vbay_bid_higher')));
}
and add the following immediately below:
Code:
// send a PM to old high bidder
if ($item['bids'] > 0) {
$pmhigh_bidder = $vbulletin->db->query("select * from " . TABLE_PREFIX . "user where userid='{$item['highbidder']}'");
$pmbidder = $vbulletin->db->fetch_array($pmhigh_bidder);
$title = "You have been outbid: {$item['name']}";
$message = "Hello, I have just outbid you on this auction! This is an automated system message.";
send_pm($vbulletin->userinfo['username'],$vbulletin->userinfo['userid'],$pmbidder['username'],$title,$message);
}
Another modification I've made is that if a bid is placed in the last 10 minutes of teh auction, teh auction end time is automatically extended to 10 minutes. I do this to stop sniping, and to also make it somewhat more like a 'real' auction as opposed to ebay.
To do this, edit vbay.php and find:
Code:
$db->query("update " . TABLE_PREFIX . "vbay_items set highbidder = " . $vbulletin->userinfo['userid'] . " where id='{$_REQUEST['dobid']}'");
and add the following ABOVE it:
Code:
// Increase end auction time by ten miniutes if bid in last 10 minutes - stops sniping!
$timeremaining = $item['completetime']-time();
if ($timeremaining < 600){
$endstamp = 600 + time();
$db->query("update " . TABLE_PREFIX . "vbay_items set completetime = '{$endstamp}' where id='{$_REQUEST['dobid']}'");
I've also added logging of bids to a simple text file - this is just in my forum root as I don't feel the need to hide it. To add it, edit vbay.php search for
Code:
$vbulletin->url = "vbay.php?do=item&viewitem=" . $_REQUEST['dobid'] . $vbulletin->session->vars['sessionurl'] ."";
and add the following immediately ABOVE it
Code:
$logentry = date('Ymd') . ' ' . strftime('%T') . ' Auction: ' . $_REQUEST['dobid'] . ', Amount: ' . $bid . ', User: ' . $vbulletin->userinfo['username'];
$vbaylog = fopen('./vbaylog.txt','a') or die("can't open vbaylog: $php_errormsg");
fwrite($vbaylog, $logentry . "\r\n");
fflush($vbaylog);
fclose($vbaylog) or die ($php_errormsg);
To view the log, just open vbalog.txt in your browser (
http://yourforum.com/forums/vbaylog.txt) I guess you could create it in the admincp dir if you wanted to hide it - there are no doubt better ways to do most of the above, but it works for me.