コード例 #1
0
ファイル: Auction.php プロジェクト: Nozlaf/WeBid
 public function removeAuction($auction_id)
 {
     $catscontrol = new MPTTcategories();
     $params = array();
     $params[] = array(':auc_id', $auction_id, 'int');
     // get auction data
     $query = "SELECT category, num_bids, suspended, closed FROM " . $db->DBPrefix . "auctions WHERE id = :auc_id";
     $db->query($query, $params);
     $auc_data = $db->result();
     if ($auc_data['suspended'] == 2) {
         $query = "DELETE FROM `" . $db->DBPrefix . "auction_moderation` WHERE auction_id = :auc_id";
         $db->query($query, $params);
     }
     // Delete related values
     $query = "DELETE FROM " . $db->DBPrefix . "auctions WHERE id = :auc_id";
     $db->query($query, $params);
     // delete bids
     $query = "DELETE FROM " . $db->DBPrefix . "bids WHERE auction = :auc_id";
     $db->query($query, $params);
     // Delete proxybids
     $query = "DELETE FROM " . $db->DBPrefix . "proxybid WHERE itemid = :auc_id";
     $db->query($query, $params);
     // Delete file in counters
     $query = "DELETE FROM " . $db->DBPrefix . "auccounter WHERE auction_id = :auc_id";
     $db->query($query, $params);
     if ($auc_data['suspended'] == 0 && $auc_data['closed'] == 0) {
         // update main counters
         $query = "UPDATE " . $db->DBPrefix . "counters SET auctions = (auctions - 1), bids = (bids - :num_bids)";
         $params = array();
         $params[] = array(':num_bids', $auc_data['num_bids'], 'int');
         $db->query($query, $params);
         // update recursive categories
         $query = "SELECT left_id, right_id, level FROM " . $db->DBPrefix . "categories WHERE cat_id = :cat_id";
         $params = array();
         $params[] = array(':cat_id', $auc_data['category'], 'int');
         $db->query($query, $params);
         $parent_node = $db->result();
         $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
         for ($i = 0; $i < count($crumbs); $i++) {
             $query = "UPDATE " . $db->DBPrefix . "categories SET sub_counter = sub_counter - 1 WHERE cat_id = :cat_id";
             $params = array();
             $params[] = array(':cat_id', $crumbs[$i]['cat_id'], 'int');
             $db->query($query, $params);
         }
     }
     // Delete auctions images
     if (is_dir(UPLOAD_PATH . $auction_id)) {
         if ($dir = opendir(UPLOAD_PATH . $auction_id)) {
             while ($file = readdir($dir)) {
                 if ($file != '.' && $file != '..') {
                     @unlink(UPLOAD_PATH . $auction_id . '/' . $file);
                 }
             }
             closedir($dir);
             rmdir(UPLOAD_PATH . $auction_id);
         }
     }
 }
コード例 #2
0
ファイル: item.php プロジェクト: presh606/WeBid
include 'common.php';
include $include_path . 'membertypes.inc.php';
include $main_path . 'language/' . $language . '/categories.inc.php';
// Get parameters from the URL
foreach ($membertypes as $idm => $memtypearr) {
    $memtypesarr[$memtypearr['feedbacks']] = $memtypearr;
}
ksort($memtypesarr, SORT_NUMERIC);
$id = isset($_SESSION['CURRENT_ITEM']) ? intval($_SESSION['CURRENT_ITEM']) : 0;
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if (!is_numeric($id)) {
    $id = 0;
}
$bidderarray = array();
$bidderarraynum = 1;
$catscontrol = new MPTTcategories();
$_SESSION['CURRENT_ITEM'] = $id;
$_SESSION['REDIRECT_AFTER_LOGIN'] = $system->SETTINGS['siteurl'] . 'item.php?id=' . $id;
// get auction all needed data
$query = "SELECT a.*, ac.counter, u.nick, u.reg_date, u.country, u.zip FROM " . $DBPrefix . "auctions a\n\t\tLEFT JOIN " . $DBPrefix . "users u ON (u.id = a.user)\n\t\tLEFT JOIN " . $DBPrefix . "auccounter ac ON (ac.auction_id = a.id)\n\t\tWHERE a.id = :auction_id LIMIT 1";
$params = array();
$params[] = array(':auction_id', $id, 'int');
$db->query($query, $params);
if ($db->numrows() == 0) {
    $_SESSION['msg_title'] = $ERR_622;
    $_SESSION['msg_body'] = $ERR_623;
    header('location: message.php');
    exit;
}
$auction_data = $db->result();
$category = $auction_data['category'];
コード例 #3
0
if (!$user->is_logged_in()) {
    $_SESSION['REDIRECT_AFTER_LOGIN'] = '******';
    header('location: user_login.php');
    exit;
}
if (in_array($user->user_data['suspended'], array(5, 6, 7))) {
    header('location: message.php');
    exit;
}
if (!$user->can_sell) {
    header('location: user_menu.php?cptab=selling');
    exit;
}
// Process category selection
$box = isset($_POST['box']) ? $_POST['box'] + 1 : 0;
$catscontrol = new MPTTcategories();
$cat_no = isset($_REQUEST['cat_no']) ? $_REQUEST['cat_no'] : 1;
$i = 0;
while (true) {
    if (!isset($_POST['cat' . $i])) {
        break;
    }
    $POST['cat' . $i] = $_POST['cat' . $i];
    $i++;
}
if (isset($_POST['action']) && $_POST['action'] == 'process' && $_POST['box'] == '') {
    $_SESSION['action'] = 1;
    $VARNAME = 'cat' . (count($POST) - 1);
    $_SESSION['SELL_sellcat' . $cat_no] = $POST[$VARNAME];
    $query = "SELECT left_id, right_id FROM " . $DBPrefix . "categories WHERE cat_id = " . intval($_POST[$VARNAME]);
    $res = mysql_query($query);
コード例 #4
0
ファイル: search.php プロジェクト: ronando/WeBid
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version. Although none of the code may be
 *   sold. If you have been sold this script, get a refund.
 ***************************************************************************/
include 'common.php';
include $main_path . 'language/' . $language . '/categories.inc.php';
include $include_path . 'dates.inc.php';
$NOW = time();
$term = $system->cleanvars(trim($_GET['q']));
$cat_id = intval($_GET['id']);
if (strlen($term) == 0) {
    $template->assign_vars(array('ERROR' => $ERR_037, 'NUM_AUCTIONS' => 0, 'TOP_HTML' => ''));
} else {
    $catSQL = '';
    if ($cat_id > 0) {
        $catscontrol = new MPTTcategories();
        $query = "SELECT right_id, left_id FROM " . $DBPrefix . "categories WHERE cat_id = " . $cat_id;
        $res = mysql_query($query);
        $system->check_mysql($res, $query, __LINE__, __FILE__);
        $parent_node = mysql_fetch_assoc($res);
        $children = $catscontrol->get_children_list($parent_node['left_id'], $parent_node['right_id']);
        $childarray = array($cat_id);
        foreach ($children as $k => $v) {
            $childarray[] = $v['cat_id'];
        }
        $catalist = '(';
        $catalist .= implode(',', $childarray);
        $catalist .= ')';
        $catSQL = " AND (category IN " . $catalist;
        if ($system->SETTINGS['extra_cat'] == 'y') {
            $catSQL .= " OR secondcat IN " . $catalist;
コード例 #5
0
ファイル: browse.php プロジェクト: janukasama/ADCAU_SPORTE
/***************************************************************************
 *   copyright				: (C) 2008 - 2014 WeBid
 *   site					: http://www.webidsupport.com/
 ***************************************************************************/
/***************************************************************************
 *   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. Although none of the code may be
 *   sold. If you have been sold this script, get a refund.
 ***************************************************************************/
include 'common.php';
include $include_path . 'dates.inc.php';
include $main_path . 'language/' . $language . '/categories.inc.php';
$catscontrol = new MPTTcategories();
// Get parameters from the URL
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$_SESSION['browse_id'] = $id;
$all_items = true;
$params = array();
if ($id != 0) {
    $query = "SELECT right_id, left_id FROM " . $DBPrefix . "categories WHERE cat_id = :cat_id";
    $params[] = array(':cat_id', $id, 'int');
} else {
    $query = "SELECT right_id, left_id, cat_id FROM " . $DBPrefix . "categories WHERE left_id = 1";
}
$db->query($query, $params);
$parent_node = $db->result();
$id = isset($parent_node['cat_id']) ? $parent_node['cat_id'] : $id;
$catalist = '';
コード例 #6
0
ファイル: deleteuser.php プロジェクト: Nozlaf/WeBid
 ***************************************************************************/
define('InAdmin', 1);
$current_page = 'users';
include '../common.php';
include INCLUDE_PATH . 'functions_admin.php';
include 'loggedin.inc.php';
$id = intval($_REQUEST['id']);
// Data check
if (empty($id) || $id <= 0) {
    header('location: listusers.php?PAGE=' . intval($_REQUEST['offset']));
    exit;
}
$has_auctions = false;
$has_bids = false;
if (isset($_POST['action']) && $_POST['action'] == "Yes") {
    $catscontrol = new MPTTcategories();
    // Check if the users has some auction
    $query = "SELECT COUNT(id) As COUNT FROM " . $DBPrefix . "auctions WHERE user = :user_id";
    $params = array();
    $params[] = array(':user_id', $id, 'int');
    $db->query($query, $params);
    $num_auctions = $db->result('COUNT');
    if ($num_auctions > 0) {
        $has_auctions = true;
    }
    // Check if the user is BIDDER in some auction
    $query = "SELECT COUNT(id) As COUNT FROM " . $DBPrefix . "bids WHERE bidder = :user_id";
    $params = array();
    $params[] = array(':user_id', $id, 'int');
    $db->query($query, $params);
    $num_bids = $db->result('COUNT');
コード例 #7
0
 function callback_process($custom_id, $fee_type, $payment_amount, $currency = NULL)
 {
     global $system, $DBPrefix, $db;
     switch ($fee_type) {
         case 1:
             // add to account balance
             $addquery = '';
             if ($system->SETTINGS['fee_disable_acc'] == 'y') {
                 $query = "SELECT suspended, balance FROM " . $DBPrefix . "users WHERE id = :custom_id";
                 $params = array();
                 $params[] = array(':custom_id', $custom_id, 'int');
                 $db->query($query, $params);
                 $data = $db->result();
                 // reable user account if it was disabled
                 if ($data['suspended'] == 7 && $data['balance'] + $payment_amount >= 0) {
                     $addquery = ', suspended = 0 ';
                 }
             }
             $query = "UPDATE " . $DBPrefix . "users SET balance = balance + :payment" . $addquery . " WHERE id = :user_id";
             $params[] = array(':payment', $payment_amount, 'float');
             $params[] = array(':user_id', $custom_id, 'int');
             $db->query($query, $params);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, date, balance, total, paid) VALUES\n\t\t\t\t\t\t(:user_id, :time_stamp, :payment, :extra_payment, 1)";
             $params = array();
             $params[] = array(':user_id', $custom_id, 'int');
             $params[] = array(':time_stamp', time(), 'int');
             $params[] = array(':payment', $payment_amount, 'float');
             $params[] = array(':extra_payment', $payment_amount, 'float');
             $db->query($query, $params);
             break;
         case 2:
             // pay for an item
             $query = "UPDATE " . $DBPrefix . "winners SET paid = 1 WHERE id = :custom_id";
             $params = array();
             $params[] = array(':custom_id', $custom_id, 'int');
             $db->query($query, $params);
             break;
         case 3:
             // pay signup fee (live mode)
             $query = "UPDATE " . $DBPrefix . "users SET suspended = 0 WHERE id = :custom_id";
             $params = array();
             $params[] = array(':custom_id', $custom_id, 'int');
             $db->query($query, $params);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, date, signup, total, paid) VALUES\n\t\t\t\t\t\t(:get_id, :time_stamp, :payment, :extra_payment, 1)";
             $params = array();
             $params[] = array(':get_id', $custom_id, 'int');
             $params[] = array(':time_stamp', time(), 'int');
             $params[] = array(':payment', $payment_amount, 'float');
             $params[] = array(':extra_payment', $payment_amount, 'float');
             $db->query($query, $params);
             break;
         case 4:
             // pay auction fee (live mode)
             global $user, $MSG;
             $catscontrol = new MPTTcategories();
             $query = "SELECT auc_id FROM " . $DBPrefix . "useraccounts WHERE useracc_id = :useracc_id";
             $params = array();
             $params[] = array(':useracc_id', $custom_id, 'int');
             $db->query($query, $params);
             $auc_id = $db->result('auc_id');
             $query = "UPDATE " . $DBPrefix . "auctions SET suspended = 0 WHERE id = :auc_id";
             $params = array();
             $params[] = array(':auc_id', $auc_id, 'int');
             $db->query($query, $params);
             $query = "UPDATE " . $DBPrefix . "useraccounts SET paid = 1 WHERE auc_id = :auc_id AND setup > 0";
             $params = array();
             $params[] = array(':auc_id', $auc_id, 'int');
             $db->query($query, $params);
             $query = "UPDATE " . $DBPrefix . "counters SET auctions = auctions + 1";
             $db->direct_query($query);
             $query = "UPDATE " . $DBPrefix . "useraccounts SET paid = 1 WHERE useracc_id = :custom_id";
             $params = array();
             $params[] = array(':custom_id', $custom_id, 'int');
             $db->query($query, $params);
             $query = "SELECT category, title, minimum_bid, pict_url, buy_now, reserve_price, auction_type, ends\n\t\t\t\t\tFROM " . $DBPrefix . "auctions WHERE id = :auc_id";
             $params = array();
             $params[] = array(':auc_id', $auc_id, 'int');
             $db->query($query, $params);
             $auc_data = $db->result();
             // auction data
             $auction_id = $auc_id;
             $title = $system->uncleanvars($auc_data['title']);
             $atype = $auc_data['auction_type'];
             $pict_url = $auc_data['pict_url'];
             $minimum_bid = $auc_data['minimum_bid'];
             $reserve_price = $auc_data['reserve_price'];
             $buy_now_price = $auc_data['buy_now'];
             $a_ends = $auc_data['ends'];
             if ($user->user_data['startemailmode'] == 'yes') {
                 include $include_path . 'email_auction_confirmation.php';
             }
             // update recursive categories
             $query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = :cat_id";
             $params = array();
             $params[] = array(':cat_id', $auc_data['category'], 'int');
             $db->query($query, $params);
             $parent_node = $db->result();
             $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
             for ($i = 0; $i < count($crumbs); $i++) {
                 $query = "UPDATE " . $DBPrefix . "categories SET sub_counter = sub_counter + 1 WHERE cat_id = :cat_id";
                 $params = array();
                 $params[] = array(':cat_id', $crumbs[$i]['cat_id'], 'int');
                 $db->query($query, $params);
             }
             break;
         case 5:
             // pay relist fee (live mode)
             $query = "UPDATE " . $DBPrefix . "auctions SET suspended = 0 WHERE id = :custom_id";
             $params = array();
             $params[] = array(':custom_id', $custom_id, 'int');
             $db->query($query, $params);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, auc_id, date, relist, total, paid) VALUES\n\t\t\t\t\t\t(:user_id, :auc_id, :date, :relist, :total, 1)";
             $params = array();
             $params[] = array(':user_id', $custom_id, 'int');
             $params[] = array(':auc_id', $custom_id, 'int');
             $params[] = array(':date', time(), 'int');
             $params[] = array(':relist', $payment_amount, 'float');
             $params[] = array(':total', $payment_amount, 'float');
             $db->query($query, $params);
             break;
         case 6:
             // pay buyer fee (live mode)
             $query = "UPDATE " . $DBPrefix . "winners SET bf_paid = 1 WHERE bf_paid = 0 AND auction = :auction_id AND winner = :winner_id";
             $params = array();
             $params[] = array(':auction_id', $custom_id, 'int');
             $params[] = array(':winner_id', $user->user_data['id'], 'int');
             $db->query($query, $params);
             $query = "UPDATE " . $DBPrefix . "users SET suspended = 0 WHERE id = :user_id";
             $params = array();
             $params[] = array(':user_id', $user->user_data['id'], 'int');
             $db->query($query, $params);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, auc_id, date, buyer, total, paid) VALUES\n\t\t\t\t\t\t(:user_id, :auc_id, :time_stamp, :buyer, :total, 1)";
             $params = array();
             $params[] = array(':user_id', $user->user_data['id'], 'int');
             $params[] = array(':auc_id', $custom_id, 'int');
             $params[] = array(':time_stamp', time(), 'int');
             $params[] = array(':buyer', $payment_amount, 'float');
             $params[] = array(':total', $payment_amount, 'float');
             $db->query($query, $params);
             break;
         case 7:
             // pay final value fee (live mode)
             $query = "UPDATE " . $DBPrefix . "winners SET ff_paid = 1 WHERE ff_paid = 0 AND auction = :auction_id AND seller = :user_id";
             $params = array();
             $params[] = array(':auction_id', $custom_id, 'int');
             $params[] = array(':user_id', $user->user_data['id'], 'int');
             $db->query($query, $params);
             $query = "UPDATE " . $DBPrefix . "users SET suspended = 0 WHERE id = :user_id";
             $params = array();
             $params[] = array(':user_id', $user->user_data['id'], 'int');
             $db->query($query, $params);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, auc_id, date, finalval, total, paid) VALUES\n\t\t\t\t\t\t(:user_id, :auc_id, :time_stamp, :finalval, :total, 1)";
             $params = array();
             $params[] = array(':user_id', $user->user_data['id'], 'int');
             $params[] = array(':auc_id', $custom_id, 'int');
             $params[] = array(':time_stamp', $system->ctime, 'int');
             $params[] = array(':finalval', $payment_amount, 'float');
             $params[] = array(':total', $payment_amount, 'float');
             $db->query($query, $params);
             break;
     }
 }
コード例 #8
0
 *   copyright				: (C) 2008 - 2014 WeBid
 *   site					: http://www.webidsupport.com/
 ***************************************************************************/
/***************************************************************************
 *   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. Although none of the code may be
 *   sold. If you have been sold this script, get a refund.
 ***************************************************************************/
define('InAdmin', 1);
$current_page = 'settings';
include '../common.php';
include $include_path . 'functions_admin.php';
include 'loggedin.inc.php';
$catscontrol = new MPTTcategories();
function search_cats($parent_id, $level)
{
    global $DBPrefix, $catscontrol;
    $catstr = '';
    $root = $catscontrol->get_virtual_root();
    $tree = $catscontrol->display_tree($root['left_id'], $root['right_id'], '|___');
    return $tree;
}
function rebuild_cat_file()
{
    global $system, $main_path, $DBPrefix, $db;
    $query = "SELECT cat_id, cat_name, parent_id FROM " . $DBPrefix . "categories ORDER BY cat_name";
    $db->direct_query($query);
    $cats = array();
    while ($catarr = $db->result()) {
コード例 #9
0
ファイル: class_fees.php プロジェクト: ronando/WeBid
 function callback_process($custom_id, $fee_type, $payment_amount, $currency = NULL)
 {
     global $system, $DBPrefix;
     switch ($fee_type) {
         case 1:
             // add to account balance
             $addquery = '';
             if ($system->SETTINGS['fee_disable_acc'] == 'y') {
                 $query = "SELECT suspended, balance FROM " . $DBPrefix . "users WHERE id = " . $custom_id;
                 $res = mysql_query($query);
                 $system->check_mysql($res, $query, __LINE__, __FILE__);
                 $data = mysql_fetch_assoc($res);
                 // reable user account if it was disabled
                 if ($data['suspended'] == 7 && $data['balance'] + $payment_amount >= 0) {
                     $addquery = ', suspended = 0 ';
                 }
             }
             $query = "UPDATE " . $DBPrefix . "users SET balance = balance + " . $payment_amount . $addquery . " WHERE id = " . $custom_id;
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, date, balance, total, paid) VALUES\n\t\t\t\t\t\t(" . $custom_id . ", " . time() . ", " . $payment_amount . ", " . $payment_amount . ", 1)";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             break;
         case 2:
             // pay for an item
             $query = "UPDATE " . $DBPrefix . "winners SET paid = 1 WHERE id = " . $custom_id;
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             break;
         case 3:
             // pay signup fee (live mode)
             $query = "UPDATE " . $DBPrefix . "users SET suspended = 0 WHERE id = " . $custom_id;
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, date, signup, total, paid) VALUES\n\t\t\t\t\t\t(" . $custom_id . ", " . time() . ", " . $payment_amount . ", " . $payment_amount . ", 1)";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             break;
         case 4:
             // pay auction fee (live mode)
             global $user, $MSG;
             $catscontrol = new MPTTcategories();
             $query = "SELECT auc_id FROM " . $DBPrefix . "useraccounts WHERE useracc_id = " . $custom_id;
             $res = mysql_query($query);
             $system->check_mysql($res, $query, __LINE__, __FILE__);
             $auc_id = mysql_result($res, 0, 'auc_id');
             $query = "UPDATE " . $DBPrefix . "auctions SET suspended = 0 WHERE id = " . $auc_id;
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             $query = "UPDATE " . $DBPrefix . "useraccounts SET paid = 1 WHERE auc_id = " . $auc_id . " AND setup > 0";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             $query = "UPDATE " . $DBPrefix . "counters SET auctions = auctions + 1";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             $query = "UPDATE " . $DBPrefix . "useraccounts SET paid = 1 WHERE useracc_id = " . $custom_id;
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             $query = "SELECT category, title, minimum_bid, pict_url, buy_now, reserve_price, auction_type, ends\n\t\t\t\t\t\tFROM " . $DBPrefix . "auctions WHERE id = " . $auc_id;
             $res = mysql_query($query);
             $system->check_mysql($res, $query, __LINE__, __FILE__);
             $auc_data = mysql_fetch_assoc($res);
             // auction data
             $auction_id = $auc_id;
             $title = $auc_data['title'];
             $atype = $auc_data['auction_type'];
             $pict_url = $auc_data['pict_url'];
             $minimum_bid = $auc_data['minimum_bid'];
             $reserve_price = $auc_data['reserve_price'];
             $buy_now_price = $auc_data['buy_now'];
             $a_ends = $auc_data['ends'];
             if ($user->user_data['startemailmode'] == 'yes') {
                 include $include_path . 'email_auction_confirmation.php';
             }
             // update recursive categories
             $query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = " . $auc_data['category'];
             $res = mysql_query($query);
             $system->check_mysql($res, $query, __LINE__, __FILE__);
             $parent_node = mysql_fetch_assoc($res);
             $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
             for ($i = 0; $i < count($crumbs); $i++) {
                 $query = "UPDATE " . $DBPrefix . "categories SET sub_counter = sub_counter + 1 WHERE cat_id = " . $crumbs[$i]['cat_id'];
                 $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             }
             break;
         case 5:
             // pay relist fee (live mode)
             $query = "UPDATE " . $DBPrefix . "auctions SET suspended = 0 WHERE id = " . $custom_id;
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, auc_id, date, relist, total, paid) VALUES\n\t\t\t\t\t\t(" . $custom_id . ", " . $custom_id . ", " . time() . ", " . $payment_amount . ", " . $payment_amount . ", 1)";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             break;
         case 6:
             // pay buyer fee (live mode)
             $query = "UPDATE " . $DBPrefix . "winners SET bf_paid = 1 WHERE bf_paid = 0 AND auction = " . $custom_id . " AND winner = " . $user->user_data['id'];
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             $query = "UPDATE " . $DBPrefix . "users SET suspended = 0 WHERE id = " . $user->user_data['id'];
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, auc_id, date, buyer, total, paid) VALUES\n\t\t\t\t\t\t(" . $user->user_data['id'] . ", " . $custom_id . ", " . time() . ", " . $payment_amount . ", " . $payment_amount . ", 1)";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             break;
         case 7:
             // pay final value fee (live mode)
             $query = "UPDATE " . $DBPrefix . "winners SET ff_paid = 1 WHERE ff_paid = 0 AND auction = " . $custom_id . " AND seller = " . $user->user_data['id'];
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             $query = "UPDATE " . $DBPrefix . "users SET suspended = 0 WHERE id = " . $user->user_data['id'];
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             // add invoice
             $query = "INSERT INTO " . $DBPrefix . "useraccounts (user_id, auc_id, date, finalval, total, paid) VALUES\n\t\t\t\t\t\t(" . $user->user_data['id'] . ", " . $custom_id . ", " . time() . ", " . $payment_amount . ", " . $payment_amount . ", 1)";
             $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
             break;
     }
 }
コード例 #10
0
ファイル: functions_admin.php プロジェクト: Nozlaf/WeBid
 function resync_category_counters()
 {
     global $db, $system, $DBPrefix;
     // update categories
     $catscontrol = new MPTTcategories();
     $query = "UPDATE " . $DBPrefix . "categories set counter = 0, sub_counter = 0";
     $db->direct_query($query);
     $query = "SELECT COUNT(*) AS COUNT, category FROM " . $DBPrefix . "auctions\n\t\t\t\tWHERE closed = 0 AND starts <= CURRENT_TIMESTAMP AND suspended = 0 GROUP BY category";
     $db->direct_query($query);
     $cat_data = $db->fetchall();
     foreach ($cat_data as $row) {
         $row['COUNT'] = $row['COUNT'] * 1;
         // force it to be a number
         if ($row['COUNT'] > 0 && !empty($row['category'])) {
             $query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = :cat_id";
             $params = array();
             $params[] = array(':cat_id', $row['category'], 'int');
             $db->query($query, $params);
             $parent_node = $db->result();
             $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
             for ($i = 0; $i < count($crumbs); $i++) {
                 $query = "UPDATE " . $DBPrefix . "categories SET sub_counter = sub_counter + :COUNT WHERE cat_id = :cat_id";
                 $params = array();
                 $params[] = array(':COUNT', $row['COUNT'], 'int');
                 $params[] = array(':cat_id', $crumbs[$i]['cat_id'], 'int');
                 $db->query($query, $params);
             }
             $query = "UPDATE " . $DBPrefix . "categories SET counter = counter + :COUNT WHERE cat_id = :cat_id";
             $params = array();
             $params[] = array(':COUNT', $row['COUNT'], 'int');
             $params[] = array(':cat_id', $row['category'], 'int');
             $db->query($query, $params);
         }
     }
     if ($system->SETTINGS['extra_cat'] == 'y') {
         $query = "SELECT COUNT(*) AS COUNT, secondcat FROM " . $DBPrefix . "auctions\n\t\t\t\t\tWHERE closed = 0 AND starts <= CURRENT_TIMESTAMP AND suspended = 0 AND secondcat != 0 GROUP BY secondcat";
         $db->direct_query($query);
         $cat_data = $db->fetchall();
         foreach ($cat_data as $row) {
             $query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = :cat_id";
             $params = array();
             $params[] = array(':cat_id', $row['secondcat'], 'int');
             $db->query($query, $params);
             $parent_node = $db->result();
             $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
             for ($i = 0; $i < count($crumbs); $i++) {
                 $query = "UPDATE " . $DBPrefix . "categories SET sub_counter = sub_counter + :COUNT WHERE cat_id = :cat_id";
                 $params = array();
                 $params[] = array(':COUNT', $row['COUNT'], 'int');
                 $params[] = array(':cat_id', $crumbs[$i]['cat_id'], 'int');
                 $db->query($query, $params);
             }
             $query = "UPDATE " . $DBPrefix . "categories SET counter = counter + :COUNT WHERE cat_id = :cat_id";
             $params = array();
             $params[] = array(':COUNT', $row['COUNT'], 'int');
             $params[] = array(':cat_id', $row['secondcat'], 'int');
             $db->query($query, $params);
         }
     }
 }