forked from SnowHall/Silurus-Classifieds-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_products.php
executable file
·192 lines (164 loc) · 6.07 KB
/
my_products.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* Silurus Classifieds Builder
*
*
* @author SnowHall - http://snowhall.com
* @website http://snowhall.com/silurus
* @email support@snowhall.com
*
* @version 1.0
* @date May 7, 2009
*
* Silurus is a professionally developed PHP Classifieds script that was built for you.
* Whether you are running classifieds for autos, motorcycles, bicycles, rv's, guns,
* horses, or general merchandise, our product is the right package for you.
* It has template system and no limit to usage with free for any changes.
*
* Copyright (c) 2009
*/
include("./include_php/init.php");
include("./include_php/TemplVotingView.php");
$profileID = intval( $_REQUEST['ID'] );
if($profileID==0) $profileID = $_SESSION['memberID'];
if($profileID == 0) header("location: /");
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(is_array($_POST['delbook']))
foreach ($_POST['delbook'] as $val)
{
mysql_query("update Store set status=1 where userID=".$_SESSION['memberID']." and ID=".intval($val));
}
}
if(intval($_REQUEST['bookID']) > 0)
{
mysql_query("update Store set status=0,date=".time()." where userID=".$_SESSION['memberID']." and ID=".intval($_REQUEST['bookID']));
}
$user = mysql_fetch_assoc(mysql_query("select * from Profiles where ID=".$profileID));
$smarty->assign("user", $user);
if(isset($_SESSION['booklist'][$profileID]['active']) && $_SESSION['booklist'][$profileID]['active'] == 1)
{
$smarty->assign("active", false);
}
else
$smarty->assign("active", true);
if(isset($_SESSION['booklist'][$profileID]['del']) && $_SESSION['booklist'][$profileID]['del'] == 1)
{
$smarty->assign("deleted", false);
}
else
$smarty->assign("deleted", true);
if($profileID == $_SESSION['memberID'])
$smarty->assign("show_action", true);
$oVotingView = new TemplVotingView ('gvoting', 0);
$order = (isset($_REQUEST['border'])?$_REQUEST['border']:'title');
$desc = (isset($_REQUEST['bdesc'])?true:false);
$books = array('order'=>$order, 'desc'=>$desc, 'cur_url'=>'/my_products.php?ID='.$profileID, 'prefix'=>'b', 'list'=>array());
if($profileID == $_SESSION['memberID'])
{
$books['show_action1'] = '/edit_product.php';
$books['show_action2'] = 'delete';
}
if($order == 'date') {$order = 's.date';}
elseif($order == 'price') {$order = 's.price';}
elseif($order == 'quality') {$order = 'c.Title';}
else {$order = 's.Title';}
if(isset($_REQUEST['bdesc'])) $order .= ' desc ';
$iDivis = 10;
$iCurr = 1;
if (!isset($_REQUEST['commPage1']))
{
$sLimit = ' LIMIT 0,'.$iDivis;
}
else
{
if($_REQUEST['commPage1']<=0) $_REQUEST['commPage1'] = 1;
$iCurr = (int)$_REQUEST['commPage1'];
$sLimit = ' LIMIT '.($iCurr - 1)*$iDivis.','.$iDivis;
}
$sQuery = ("select s.*,c.Title as ctitle from Store s inner join StoreCategories c on c.ID=s.categoryID where s.type=0 and s.status=0 and s.userID=$profileID order by $order ");
$rElems = mysql_query( $sQuery );
$iNums = mysql_num_rows($rElems);
$count = (int)($iNums/$iDivis);
if(($iNums/$iDivis) > (int)($iNums/$iDivis)) $count++;
$aPaging = ($iNums > $iDivis ? MakePaging($iNums,$iCurr,$iDivis,4,'commPage1','#sale') : '');
$rElems = mysql_query( $sQuery.$sLimit );
while($book = mysql_fetch_assoc($rElems))
{
if($color == 'f5f5f5') $color = 'ffffff'; else $color = 'f5f5f5';
$temp = array();
$temp['Color'] = $color;
$temp['ID'] = $book['ID'];
$temp['url'] = '/product.php?ID='.$book['ID'];
$temp['Title'] = htmlspecialchars($book['Title']);
$temp['Date'] = date("F jS, Y",$book['date']);
$temp['Price'] = number_format($book['price'],2,".","");
$temp['Vote'] = $vote1;
$temp['ctitle'] = $book['ctitle'];
$books['list'][] = $temp;
}
$smarty->assign("sbooks", $books);
$smarty->assign("aPaging1", $aPaging);
if($profileID == $_SESSION['memberID'])
{
$order = (isset($_REQUEST['dorder'])?$_REQUEST['dorder']:'title');
$desc = (isset($_REQUEST['ddesc'])?true:false);
$books = array('order'=>$order, 'desc'=>$desc, 'cur_url'=>'/my_products.php?ID='.$profileID, 'prefix'=>'d', 'list'=>array());
if($profileID == $_SESSION['memberID'])
{
$books['show_action1'] = '';
$books['show_action2'] = 'repost';
}
if($order == 'date') {$order = 'date';}
elseif($order == 'price') {$order = 'price';}
elseif($order == 'quality') {$order = 'rating';}
else {$order = 'Title';}
if(isset($_REQUEST['ddesc'])) $order .= ' desc ';
$iDivis = 10;
$iCurr = 1;
if (!isset($_REQUEST['commPage2']))
{
$sLimit = ' LIMIT 0,'.$iDivis;
}
else
{
if($_REQUEST['commPage2']<=0) $_REQUEST['commPage2'] = 1;
$iCurr = (int)$_REQUEST['commPage2'];
$sLimit = ' LIMIT '.($iCurr - 1)*$iDivis.','.$iDivis;
}
$sQuery = ("select s.*,c.Title as ctitle from Store s inner join StoreCategories c on c.ID=s.categoryID where s.type=0 and s.status=1 and s.userID=$profileID order by $order ");
$rElems = mysql_query( $sQuery );
$iNums = mysql_num_rows($rElems);
$count = (int)($iNums/$iDivis);
if(($iNums/$iDivis) > (int)($iNums/$iDivis)) $count++;
$aPaging = ($iNums > $iDivis ? MakePaging($iNums,$iCurr,$iDivis,4,'commPage2','#del') : '');
$rElems = mysql_query( $sQuery.$sLimit );
while($book = mysql_fetch_assoc($rElems))
{
$oVotingView->_fRate = $book['rating'];
$vote1 = $oVotingView->getSmallVoting (0,'');
if($color == 'f5f5f5') $color = 'ffffff'; else $color = 'f5f5f5';
$temp = array();
$temp['Color'] = $color;
$temp['ID'] = $book['ID'];
$temp['url'] = '/product.php?ID='.$book['ID'];
$temp['Title'] = htmlspecialchars($book['Title']);
$temp['Date'] = date("F jS, Y",$book['date']);
$temp['Price'] = number_format($book['price'],2,".","");
$temp['Vote'] = $vote1;
$temp['ctitle'] = $book['ctitle'];
$books['list'][] = $temp;
}
$smarty->assign("dbooks", $books);
$smarty->assign("aPaging2", $aPaging);
}
if($profileID == $_SESSION['memberID'])
addNavigation('/profile.php?ID='.$user['ID'],'My Profile');
else
addNavigation('/profile.php?ID='.$user['ID'],$user['fname'].' '.$user['lname']);
$HEADERTEXT='Products for Sale';
addNavigation('',$HEADERTEXT);
$smarty->assign("site_title", $HEADERTEXT." :: ".$gConfig['site_title']);
$smarty->assign("HEADERTEXT", $HEADERTEXT);
show_smarty_template('my_products');
?>