<?php
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'eztrader.php');
require_once "./global.php";
require_once MYBB_ROOT."inc/eztrader.lib.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$parser_options = array(
"allow_html" => 0,
"allow_mycode" => 1,
"allow_smilies" => 1,
"allow_imgcode" => 1,
"filter_badwords" => 1
);
$lang->load("eztrader");
add_breadcrumb($lang->eztrader_text_title, "eztrader.php");
// Load Trader Settings
LoadTraderSettings();
// Load Trader Permissions
TraderLoadPermissions();
// Trader Actions
$subActions = array(
'report' => 'ezTrader_Report',
'report2' => 'ezTrader_Report2',
'submit' => 'ezTrader_Submit',
'detail' => 'ezTrader_ViewDetail',
'delete' => 'ezTrader_Delete',
'delete2' => 'ezTrader_Delete2',
'submit2' => 'ezTrader_Submit2',
);
@$sa = $mybb->input['sa'];
if (!empty($subActions[$sa]))
$subActions[$sa]();
else
ezTrader_mainview();
function ezTrader_mainview()
{
global $mybb;
global $context, $lang, $db, $scripturl, $traderSettings;
@$memid = 487;
if (empty($memid))
ezTrader_fatal_error2($lang->eztrader_nomemberselected, false);
$request = $db->query("
SELECT
username FROM " . TABLE_PREFIX."users
WHERE uid = $memid LIMIT 10");
$row = $db->fetch_array($request);
$mcount = $db->num_rows($request);
if ($mcount != 1)
ezTrader_fatal_error2($lang->eztrader_nomemberselected, false);
$context['traderid'] = $memid;
$context['tradername'] = $row['username'];
$context['page_title'] = $lang->eztrader_feedbacktitle . ' - ' . $row['username'];
$request = $db->query("
SELECT
feedbackid
FROM " . TABLE_PREFIX."trader_feedback
WHERE approved = 1 AND ID_MEMBER =" . $context['traderid']);
$context['tradecount'] = $db->num_rows($request);
$result = $db->query("
SELECT
COUNT(*) AS total,salevalue
FROM " . TABLE_PREFIX."trader_feedback
WHERE approved = 1 AND ID_MEMBER = " . $context['traderid'] . " GROUP BY salevalue" );
$context['neturalcount'] = 0;
$context['pcount'] = 0;
$context['ncount'] = 0;
while($row = $db->fetch_array($result))
{
if ($row['salevalue'] == 0)
{
$context['pcount'] = $row['total'];
}
else if ($row['salevalue'] == 2)
{
$context['ncount'] = $row['total'];
}
else if ($row['salevalue'] == 1)
{
$context['neturalcount'] = $row['total'];
}
}
$db->free_result($result);
$context['tradecount_nonetural'] = ($context['pcount'] + $context['ncount']);
// Get the view type
@$view = (int) $_GET['view'];
if (empty($view))
$view = 0;
$queryextra = '';
switch($view)
{
case 0:
$queryextra = '';
break;
case 1:
$queryextra = ' AND f.saletype = 1';
break;
case 2:
$queryextra = ' AND f.saletype = 0';
break;
case 3:
$queryextra = ' AND f.saletype = 2';
break;
default:
ezTrader_fatal_error2($lang->eztrader_invalidview, false);
break;
}
$context['start'] = (int) $_REQUEST['start'];
$dbresult = $db->query("
SELECT
COUNT(*) AS total
FROM (" . TABLE_PREFIX."trader_feedback AS f)
LEFT JOIN " . TABLE_PREFIX."users AS m ON (f.FeedBackMEMBER_ID = m.uid)
WHERE f.ID_MEMBER = " . $context['traderid'] . " AND f.approved = 1 $queryextra ");
$row = $db->fetch_array($dbresult);
$total = $row['total'];
$db->free_result($dbresult);
$selectClassifiedsSQL = '';
$leftJoinClassifieds = '';
$perpage = $traderSettings['trader_feedbackperpage'];
$page = intval($mybb->input['page']);
if(intval($mybb->input['page']) > 0)
{
$start = ($page-1) *$perpage;
}
else
{
$start = 0;
$page = 1;
}
$dbresult = $db->query("
SELECT
f.saletype, f.feedbackid, f.FeedBackMEMBER_ID, f.topicurl,
f.comment_short, f.salevalue, f.saledate, m.username $selectClassifiedsSQL
FROM (" . TABLE_PREFIX."trader_feedback AS f)
LEFT JOIN " . TABLE_PREFIX."users AS m ON (f.FeedBackMEMBER_ID = m.uid)
$leftJoinClassifieds
WHERE f.ID_MEMBER = " . $context['traderid'] . " AND f.approved = 1 $queryextra ORDER BY f.feedbackid DESC LIMIT $start,$perpage");
$context['trader_feedback'] = array();
while ($row = $db->fetch_array($dbresult))
{
$context['trader_feedback'][] = $row;
}
$db->free_result($dbresult);
$pagingList = multipage($total, $perpage, $page, "eztrader.php?id='" . $context['traderid'] . "view=$view");
// Set the page title
$neturalcount = $context['neturalcount'];
$pcount = $context['pcount'];
$ncount = $context['ncount'];
if ($context['tradecount'] != 0)
$feedpos = round(($pcount / $context['tradecount_nonetural']) * 100, 2);
else
$feedpos = 0;
if ($traderSettings['trader_use_pos_neg'])
$context['tradecount'] = ($context['pcount'] -$context['ncount']);
echo '
<tr><td>' . $lang->eztrader_positivefeedback . $pcount . ' <img src="' . $mybb->settings['bburl'] . '/images/smilies/smile.gif" alt="positive" /></td></tr>
<tr><td>' . $lang->eztrader_neutralfeedback . $neturalcount . ' <img src="' . $mybb->settings['bburl'] . '/images/smilies/undecided.gif" alt="netural" /></td></tr>
<tr><td>' . $lang->eztrader_negativefeedback . $ncount . ' <img src="' . $mybb->settings['bburl'] . '/images/smilies/angry.gif" alt="negative" /></td></tr>
';
echo '
<td align="left" colspan="6">
' . $pagingList . '
</td>
</table>
</td>
</tr>
</table>
</div>';
}
function eztrader_header()
{
global $headerinclude, $context, $header;
echo parse_page('<html>
<head>
<title>' . $context['page_title'] .'</title>
' . $headerinclude . '
</head>
<body>
' . $header);
}
function eztrader_footer()
{
global $footer;
echo $footer;
echo '</body>
</html>';
}
function ezTrader_Delete()
{
global $context, $db, $lang, $parser, $parser_options;
// Check if they are allowed to delete feedback
ezTrader_isAllowedTo('deletefeed');
@$feedid = (int) $_REQUEST['feedid'];
if (empty($feedid))
ezTrader_fatal_error2($lang->eztrader_errnofeedselected, false);
$context['feedid'] = $feedid;
$context['page_title'] = $lang->eztrader_title . ' - ' . $lang->eztrader_deletefeedback;
$result = "SELECT f.saletype, f.feedbackid, f.ID_MEMBER, f.FeedBackMEMBER_ID,
f.comment_short, f.topicurl, f.comment_long, f.salevalue, f.saledate, m.username
FROM " . TABLE_PREFIX."trader_feedback AS f," . TABLE_PREFIX."users AS m
WHERE f.feedbackid = " . $context['feedid'] . " AND f.FeedBackMEMBER_ID = m.uid";
$dbresult = $db->query($result);
$row = $db->fetch_array($dbresult);
$db->free_result($dbresult);
$context['trader_feedback'] = $row;
eztrader_header();
echo '
';
}
?>