Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 85 additions & 0 deletions admin/auctionreporting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/***************************************************************************
* copyright : (C) 2008 - 2017 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';

if (isset($_POST['action']) && $_POST['action'] == 'update') {

if (isset($_POST['reporting']['allow_reporting'])) {
$system->writesetting("allow_reporting", $_POST['reporting']['allow_reporting'], 'bool');
} else {
$system->writesetting("allow_reporting", false, 'bool');
}

if (isset($_POST['reporting'])) {
foreach ($_POST['reporting'] as $reporting_id => $reporting) {
if (isset($_POST['delete']) && in_array($reporting_id, $_POST['delete'])) {
$query = "UPDATE " . $DBPrefix . "reporting_options
SET removed = :removed
WHERE id = :id";
$params = [
[':id', $reporting['id'], 'int'],
[':removed', true, 'bool'],
];
$db->query($query, $params);
} else {
$query = "UPDATE " . $DBPrefix . "reporting_options
SET reason = :reason,
WHERE id = :id";
$params = [
[':id', $reporting['id'], 'int'],
[':reason', $reporting['reason'], 'str'],
];
$db->query($query, $params);
}
}
}

if ($_POST['new_reason'] != '') {
$reason = $_POST['new_reason'];
$query = "INSERT INTO " . $DBPrefix . "reporting_options (reason) VALUES (:reason)";
$params = [
[':reason', $reason, 'str'],
];
$db->query($query, $params);
}

$template->assign_block_vars('alerts', array('TYPE' => 'success', 'MESSAGE' => $MSG['reasons_updated']));
}


$query = "SELECT * FROM " . $DBPrefix . "reporting_options WHERE removed = false";
$db->direct_query($query);
while ($reason_type = $db->fetch()) {
$template->assign_block_vars('reporting', array(
'REASON' => $reason_type['reason'],
'ID' => $reason_type['id']
));
}


$template->assign_vars(array('ALLOW' => $system->SETTINGS['allow_reporting']));



include 'header.php';
$template->set_filenames(array(
'body' => 'auctionreporting.tpl'
));
$template->display('body');
include 'footer.php';
140 changes: 140 additions & 0 deletions admin/dismissreport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php
/***************************************************************************
* copyright : (C) 2008 - 2017 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 = 'auctions';
include '../common.php';
include INCLUDE_PATH . 'functions_admin.php';
include 'loggedin.inc.php';

// Data check
if (!isset($_REQUEST['id'])) {
$URL = $_SESSION['RETURN_LIST'];
header('location: ' . $URL);
exit;
}

if (isset($_POST['action']) && $_POST['action'] == "Yes") {
$catscontrol = new MPTTcategories();
$report_id = intval($_POST['id']);
// uses same parameters in every query
$params = array();
$params[] = array(':reportid', $report_id, 'int');


// Set report as dismissed
$query = "UPDATE " . $DBPrefix . "reportedauctions SET dismiss = true WHERE id = :reportid";
$db->query($query, $params);
/*
// get auction data
$query = "SELECT category, num_bids, suspended, closed FROM " . $DBPrefix . "auctions WHERE id = :auc_id";
$db->query($query, $params);
$auc_data = $db->result();

if ($auc_data['suspended'] == 2) {
$query = "DELETE FROM `" . $DBPrefix . "auction_moderation` WHERE auction_id = :auc_id";
$db->query($query, $params);
}

// Delete related values
$query = "DELETE FROM " . $DBPrefix . "auctions WHERE id = :auc_id";
$db->query($query, $params);

// delete bids
$query = "DELETE FROM " . $DBPrefix . "bids WHERE auction = :auc_id";
$db->query($query, $params);

// Delete proxybids
$query = "DELETE FROM " . $DBPrefix . "proxybid WHERE itemid = :auc_id";
$db->query($query, $params);

// Delete file in counters
$query = "DELETE FROM " . $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 " . $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 " . $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);
}
}

// Delete auctions images
if (is_dir(UPLOAD_PATH . $auc_id)) {
if ($dir = opendir(UPLOAD_PATH . $auc_id)) {
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
@unlink(UPLOAD_PATH . $auc_id . '/' . $file);
}
}
closedir($dir);
rmdir(UPLOAD_PATH . $auc_id);
}
}
*/
$URL = $_SESSION['RETURN_LIST'];
//unset($_SESSION['RETURN_LIST']);
header('location: ' . $URL);
exit;
} elseif (isset($_POST['action']) && $_POST['action'] == "No") {
$URL = $_SESSION['RETURN_LIST'];
//unset($_SESSION['RETURN_LIST']);
header('location: ' . $URL);
exit;
}

$query = "SELECT
reasongiven.reason AS reason, reporters.nick AS reporter FROM " . $DBPrefix . "reportedauctions reported
RIGHT JOIN " . $DBPrefix . "reporting_options reasongiven ON (reasongiven.id = reported.reason)
RIGHT JOIN " . $DBPrefix . "users reporters ON (reporters.id = reported.user_id) " .
"WHERE reported.id = :reported_id";
$params = array();
$params[] = array(':reported_id', $_GET['id'], 'int');

$db->query($query, $params);
$result = $db->result();
$reason = $result['reason'];
$reporter = $result['reporter'];

$title = "<br>Reason: " . $reason . "<br> Reported by: " . $reporter;

$template->assign_vars(array(
'ID' => $_GET['id'],
'MESSAGE' => sprintf($MSG['confirm_report_dismiss'] . $title),
'TYPE' => 1
));

include 'header.php';
$template->set_filenames(array(
'body' => 'confirm.tpl'
));
$template->display('body');
include 'footer.php';
34 changes: 32 additions & 2 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,39 @@
$ACCESS['uniquevisitors'] = (!isset($ACCESS['uniquevisitors']) || empty($ACCESS['uniquevisitors'])) ? 0 : $ACCESS['uniquevisitors'];
$ACCESS['usersessions'] = (!isset($ACCESS['usersessions']) || empty($ACCESS['usersessions'])) ? 0 : $ACCESS['usersessions'];


/*
* Activation Types
* 0 - Admin activates
* 1 - User Activates
* 2 - Automatic activates
* 3 -
*
* Suspended Types
* 0 - not suspended
* 1 - suspended by admin
* 8 - hasn't been activated by user
* 10 - hasn't been activated by admin
*/

if ($system->SETTINGS['activationtype'] == 0) {
$query = "SELECT COUNT(id) as COUNT FROM " . $DBPrefix . "users WHERE suspended = 10";
$db->direct_query($query);
$uuser_count = $db->result('COUNT');
$usersTBActivated = $db->result('COUNT');
}

if ($system->SETTINGS['activationtype'] == 1) {
$query = "SELECT COUNT(id) as COUNT FROM " . $DBPrefix . "users WHERE suspended = 8";
$db->direct_query($query);
$newUsers = $db->result('COUNT');
}

// suspended users
$query = "SELECT COUNT(id) as COUNT FROM " . $DBPrefix . "users WHERE suspended = 1";
$db->direct_query($query);
$usersSuspended = $db->result('COUNT');


// version check
$realversion = '0.0';
$update_available = false;
Expand Down Expand Up @@ -175,7 +202,10 @@

'C_USERS' => $COUNTERS['users'],
'C_IUSERS' => $COUNTERS['inactiveusers'],
'C_UUSERS' => (isset($uuser_count)) ? $uuser_count : '',
'C_UUSERS' => (isset($usersTBActivated)) ? $usersTBActivated : '',
'C_TBAUSERS' => (isset($usersTBActivated)) ? $usersTBActivated : $newUsers,
'C_NEWUSERS' => (isset($newUsers)) ? $newUsers : '',
'C_SUSPUSERS' => (isset($usersSuspended)) ? $usersSuspended : '',
'C_AUCTIONS' => $COUNTERS['auctions'],
'C_CLOSED' => $COUNTERS['closedauctions'],
'C_BIDS' => $COUNTERS['bids'],
Expand Down
88 changes: 55 additions & 33 deletions admin/listreportedauctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,68 @@
$_SESSION['RETURN_LIST_OFFSET'] = $PAGE;

$query = "SELECT COUNT(a.id) As auctions FROM " . $DBPrefix . "auctions a
INNER JOIN " . $DBPrefix . "reportedauctions r ON (a.id = r.auction_id)
WHERE a.closed = 0 AND a.suspended = 0 " . $user_sql;
INNER JOIN " . $DBPrefix . "reportedauctions r ON (r.auction_id = a.id)
WHERE a.closed = 0 AND r.dismiss = false " . $user_sql;

$db->direct_query($query);

$num_auctions = $db->result('auctions');
$PAGES = ($num_auctions == 0) ? 1 : ceil($num_auctions / $system->SETTINGS['perpage']);

$query = "SELECT a.id, u.nick, a.title, a.starts, a.ends, a.suspended, c.cat_name, COUNT(r.auction_id) as times_reported, m.reason FROM " . $DBPrefix . "auctions a
LEFT JOIN " . $DBPrefix . "users u ON (u.id = a.user)
LEFT JOIN " . $DBPrefix . "categories c ON (c.cat_id = a.category)
INNER JOIN " . $DBPrefix . "reportedauctions r ON (a.id = r.auction_id)
LEFT JOIN " . $DBPrefix . "auction_moderation m ON (a.id = m.auction_id)
WHERE m.reason IS NULL AND a.closed = 0 AND a.suspended = 0 " . $user_sql . " GROUP BY a.id, u.nick, a.title, a.starts, a.ends, a.suspended, c.cat_name, m.reason ORDER BY nick LIMIT :offset, :perpage";

$query = "SELECT
reported.id,
reported.auction_id as reported_auction,
reported.dismiss as dismissed,
auction.id as auction_id,
auction.title,
auction.starts as start_date,
auction.ends as end_date,
auction.suspended,
categories.cat_name as category,
seller.nick as seller_name,
COUNT(w.id) as winners,
reporter.nick as reporter_name,
reason.reason as reason_given "
. "FROM " . $DBPrefix . "reportedauctions reported
RIGHT JOIN " . $DBPrefix . "auctions auction ON (reported.auction_id = auction.id)
LEFT JOIN " . $DBPrefix . "categories categories ON (categories.cat_id = auction.category)
INNER JOIN " . $DBPrefix . "users reporter ON (reporter.id = reported.user_id)
INNER JOIN " . $DBPrefix . "users seller ON (seller.id = auction.user)
INNER JOIN " . $DBPrefix . "reporting_options reason ON (reason.id = reported.reason)
LEFT JOIN " . $DBPrefix . "auction_moderation moderation ON (auction.id = moderation.auction_id)
LEFT JOIN " . $DBPrefix . "winners w ON (w.auction = auction.id)
WHERE moderation.reason IS NULL AND auction.closed = 0 " . $user_sql
. " GROUP BY reported.id, seller.nick, reporter.nick, auction.suspended, moderation.reason
ORDER BY auction.id
LIMIT :offset, :perpage";
$params = array();
$params[] = array(':offset', $OFFSET, 'int');
$params[] = array(':perpage', $system->SETTINGS['perpage'], 'int');
$db->query($query, $params);
$username = '';
while ($row = $db->fetch()) {
$report_counter = 0;
while($row = $db->fetch()) {
//print("Auction Title: " . $row['title'] . " Auction Id: " . $row['auction_id'] . " Category: " . $row['category'] . " Sellers Name: " . $row['seller_name'] . " Reported by: " . $row['reporter_name'] . " For this reason: " . $row['reason_given'] . "<br>");
if (!$row['dismissed']) {
$report_counter +=1;
}
$template->assign_block_vars('auctions', array(
'SUSPENDED' => $row['suspended'],
'TIMESREPORTED' => $row['times_reported'],
'IN_MODERATION_QUEUE' => !is_null($row['reason']),
'ID' => $row['id'],
'TITLE' => htmlspecialchars($row['title']),
'START_TIME' => $dt->printDateTz($row['starts']),
'END_TIME' => $dt->printDateTz($row['ends']),
'USERNAME' => $row['nick'],
'CATEGORY' => $row['cat_name'],
'B_HASWINNERS' => false
));
$username = $row['nick'];
}

// this is used when viewing a users auctions
if ((!isset($username) || empty($username)) && $uid > 0) {
$query = "SELECT nick FROM " . $DBPrefix . "users WHERE id = :user_id";
$params = array();
$params[] = array(':user_id', $uid, 'int');
$db->query($query, $params);
$username = $db->result('nick');
'ID' => $row['auction_id'],
'TITLE' => htmlspecialchars($row['title']),
'START_TIME' => $dt->printDateTz($row['start_date']),
'END_TIME' => $dt->printDateTz($row['end_date']),
'CATEGORY' => $row['category'],
'SELLERNAME' => $row['seller_name'],
'SUSPENDED' => $row['suspended'],
'REPORTERNAME' => $row['reporter_name'],
'REASONGIVEN' => trim($row['reason_given'],' '),
'DISMISSED' => $row['dismissed'],
'REPORTID' => $row['id'],
'REPORTCOUNTER' => $report_counter,
'B_HASWINNERS' => ($row['winners'] == 0) ? false : true,
'TIMESREPORTED' => 1
)
);
}

// get pagenation
Expand All @@ -101,7 +123,7 @@
'PAGE_TITLE' => $MSG['view_reported_auctions'],
'NUM_AUCTIONS' => $num_auctions,
'B_SEARCHUSER' => ($uid > 0),
'USERNAME' => $username,
//'USERNAME' => $username,

'PREV' => ($PAGES > 1 && $PAGE > 1) ? '<a href="' . $system->SETTINGS['siteurl'] . 'admin/listreportedauctions.php?PAGE=' . $PREV . '"><u>' . $MSG['5119'] . '</u></a>&nbsp;&nbsp;' : '',
'NEXT' => ($PAGE < $PAGES) ? '<a href="' . $system->SETTINGS['siteurl'] . 'admin/listreportedauctions.php?PAGE=' . $NEXT . '"><u>' . $MSG['5120'] . '</u></a>' : '',
Expand All @@ -111,7 +133,7 @@

include 'header.php';
$template->set_filenames(array(
'body' => 'listauctions.tpl'
'body' => 'listreportedauctions.tpl'
));
$template->display('body');
include 'footer.php';
Loading