| 1 |
<?php</span> |
|---|
| 2 |
<span class="code-lang">$root_path = './'; |
|---|
| 3 |
require ($root_path . 'include/config.php'); |
|---|
| 4 |
require ($root_path . 'include/functions_selects.php'); |
|---|
| 5 |
require ($root_path . 'include/functions_check.php'); |
|---|
| 6 |
|
|---|
| 7 |
$userdata = session_pagestart($user_ip); |
|---|
| 8 |
init_userprefs($userdata); |
|---|
| 9 |
loggedinorreturn(); |
|---|
| 10 |
|
|---|
| 11 |
$action = request_var('action', '');</span> |
|---|
| 12 |
<span class="code-lang"> |
|---|
| 13 |
if ( isset($_GET['id']) && !$action ) { |
|---|
| 14 |
$action = 'request_view'; |
|---|
| 15 |
} |
|---|
| 16 |
|
|---|
| 17 |
switch ( $action ) { |
|---|
| 18 |
case 'delete': |
|---|
| 19 |
require_once($root_path . 'include/functions_delete.php'); |
|---|
| 20 |
$ids_ary = request_var('id', array(0=>0)); |
|---|
| 21 |
$ids = array(); |
|---|
| 22 |
if ( sizeof($ids_ary) ) { |
|---|
| 23 |
$sql = 'SELECT userid, id FROM ' . REQUESTS_TABLE . ' WHERE id IN (' . implode(', ', $ids_ary) . ')'; |
|---|
| 24 |
$result = $db->sql_query($sql); |
|---|
| 25 |
|
|---|
| 26 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 27 |
if ( $row['userid'] != $userdata['uid'] && $userdata['class'] < UC_MODERATOR) { |
|---|
| 28 |
continue; |
|---|
| 29 |
} |
|---|
| 30 |
$ids[] = $row['id']; |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
delete_request($ids); |
|---|
| 34 |
meta_refresh(3, append_sid($root_path . 'requests.php')); |
|---|
| 35 |
trigger_error($lang['success_delete']); |
|---|
| 36 |
} |
|---|
| 37 |
else { |
|---|
| 38 |
redirect ( append_sid($root_path . 'requests.php')); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
break; |
|---|
| 42 |
|
|---|
| 43 |
case 'edit': |
|---|
| 44 |
$id = request_var('id', 0); |
|---|
| 45 |
$sql = 'SELECT * FROM ' . REQUESTS_TABLE . ' WHERE id = ' . $id; |
|---|
| 46 |
$result = $db->sql_query($sql); |
|---|
| 47 |
if ( !$row = $db->sql_fetchrow($result) ) { |
|---|
| 48 |
trigger_error(sprintf($lang['invalid_id'], $id)); |
|---|
| 49 |
} |
|---|
| 50 |
if ( $userdata['uid'] != $row['userid'] && $userdata['class'] < UC_MODERATOR ) { |
|---|
| 51 |
trigger_error($lang['access_denied']); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
if ( isset($_POST['submit_edit']) ) { |
|---|
| 55 |
$category = request_var('category', 0); |
|---|
| 56 |
$title = request_var('title', ''); |
|---|
| 57 |
$descr = request_var('descr', ''); |
|---|
| 58 |
|
|---|
| 59 |
if (!$title || !$descr ) { |
|---|
| 60 |
trigger_error($lang['post_something']); |
|---|
| 61 |
} |
|---|
| 62 |
if ( !check_category_id($category) ) { |
|---|
| 63 |
trigger_error( sprintf($lang['invalid_id'], $category) ); |
|---|
| 64 |
} |
|---|
| 65 |
$sql = 'UPDATE ' . REQUESTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array('cat' => $category, |
|---|
| 66 |
'request' => $title, |
|---|
| 67 |
'descr' => $descr)) . ' WHERE id = ' . $id; |
|---|
| 68 |
$db->sql_query($sql); |
|---|
| 69 |
redirect( append_sid('requests.php?id=' . $id)); |
|---|
| 70 |
} |
|---|
| 71 |
else { |
|---|
| 72 |
$template->assign_vars(array( |
|---|
| 73 |
'S_FORM_ACTION' => append_sid('requests.php'), |
|---|
| 74 |
'ID' => $id, |
|---|
| 75 |
'NAME' => $row['request'], |
|---|
| 76 |
'EDIT_REQUEST' => sprintf($lang['edit_request'], $row['request']), |
|---|
| 77 |
'CATS_SELECT' => categories_select($row['cat']), |
|---|
| 78 |
'DESCR' => $row['descr'] |
|---|
| 79 |
)); |
|---|
| 80 |
|
|---|
| 81 |
stdhead (sprintf($lang['edit_request'], $row['request'])); |
|---|
| 82 |
$template->set_filenames(array( |
|---|
| 83 |
'body' => 'requests_edit_body.html' |
|---|
| 84 |
)); |
|---|
| 85 |
stdfoot(); |
|---|
| 86 |
} |
|---|
| 87 |
break; |
|---|
| 88 |
|
|---|
| 89 |
case 'vote': |
|---|
| 90 |
$id = request_var('voteid', 0); |
|---|
| 91 |
|
|---|
| 92 |
$sql = 'SELECT id FROM ' . REQUESTS_VOTES_TABLE . ' WHERE requestid = ' . $id . ' AND userid = ' . $userdata['uid']; |
|---|
| 93 |
$result = $db->sql_query($sql); |
|---|
| 94 |
if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 95 |
trigger_error($lang['dupe_vote']); |
|---|
| 96 |
} |
|---|
| 97 |
else { |
|---|
| 98 |
$sql = 'UPDATE ' . REQUESTS_TABLE . ' SET hits = hits + 1 WHERE id = ' . $id; |
|---|
| 99 |
$db->sql_query($sql); |
|---|
| 100 |
$sql = 'INSERT INTO ' . REQUESTS_VOTES_TABLE . ' (requestid, userid) VALUES(' . $id . ', ' . $userdata['uid'] . ')'; |
|---|
| 101 |
$db->sql_query($sql); |
|---|
| 102 |
|
|---|
| 103 |
meta_refresh(3, append_sid($root_path . 'requests.php?id=' . $id)); |
|---|
| 104 |
trigger_error($lang['sucefully_voted']); |
|---|
| 105 |
} |
|---|
| 106 |
break; |
|---|
| 107 |
|
|---|
| 108 |
case 'reset': |
|---|
| 109 |
$ids_ary = request_var('id', array(0=>0)); |
|---|
| 110 |
$requests_name = array(); |
|---|
| 111 |
|
|---|
| 112 |
if ( sizeof($ids_ary) ) { |
|---|
| 113 |
$sql = 'SELECT id, userid, filledby, request, filled, user_reputation, user_reputation_level, user_rank_id, uid |
|---|
| 114 |
FROM ' . REQUESTS_TABLE . ' r, ' . USERS_TABLE . ' u |
|---|
| 115 |
WHERE id IN (' . implode(', ', $ids_ary) . ') |
|---|
| 116 |
AND r.userid = u.uid |
|---|
| 117 |
AND filledby <> 0'; |
|---|
| 118 |
$result = $db->sql_query($sql); |
|---|
| 119 |
if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 120 |
do { |
|---|
| 121 |
if ( $userdata['uid'] == $row['userid'] || $userdata['class'] >= UC_MODERATOR || $userdata['uid'] == $row['filledby'] ) { |
|---|
| 122 |
$sql = 'UPDATE ' . REQUESTS_TABLE . ' SET filled = 0, filledby = 0 WHERE id = ' . $row['id']; |
|---|
| 123 |
$db->sql_query($sql); |
|---|
| 124 |
|
|---|
| 125 |
update_reputation($row, SIMPATY_FILL_REQUEST, 0); |
|---|
| 126 |
|
|---|
| 127 |
$requests_name[] = $row['request']; |
|---|
| 128 |
} |
|---|
| 129 |
} |
|---|
| 130 |
while ( $row = $db->sql_fetchrow($result) ); |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
meta_refresh(3, append_sid('requests.php')); |
|---|
| 134 |
|
|---|
| 135 |
trigger_error(sprintf($lang['request_succefully_reset'], implode('<br />', $requests_name) )); |
|---|
| 136 |
} |
|---|
| 137 |
} |
|---|
| 138 |
redirect ( append_sid('requests.php')); |
|---|
| 139 |
break; |
|---|
| 140 |
|
|---|
| 141 |
case 'filled': |
|---|
| 142 |
if ( $userdata['class'] < $config['min_class_allow_upload'] ) { |
|---|
| 143 |
trigger_error($lang['access_denied']); |
|---|
| 144 |
} |
|---|
| 145 |
|
|---|
| 146 |
$id = request_var('requestid', 0); |
|---|
| 147 |
$filledurl = request_var('filledurl', ''); |
|---|
| 148 |
|
|---|
| 149 |
$sql = 'SELECT request FROM ' . REQUESTS_TABLE . ' WHERE id = ' . $id . ' AND filled = 0'; |
|---|
| 150 |
$result = $db->sql_query($sql); |
|---|
| 151 |
if ( !($row = $db->sql_fetchrow($result)) ) { |
|---|
| 152 |
trigger_error(sprintf($lang['invalid_id'], $id)); |
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
$requests_name = $row['request']; |
|---|
| 156 |
|
|---|
| 157 |
if ( $seo->seo_opt['url_rewrite'] ) { |
|---|
| 158 |
$filled_torrent_id = $seo->get_url_info('details', $filledurl, 'id'); |
|---|
| 159 |
} |
|---|
| 160 |
else { |
|---|
| 161 |
preg_match('/details.php\?id=([0-9]+)/', $filledurl, $matches); |
|---|
| 162 |
$filled_torrent_id = ( !empty($matches[1]) ? (int) $matches[1] : 0 ); |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
if ( !$filled_torrent_id ) { |
|---|
| 166 |
trigger_error($lang['invalid_url_for_uploaded_torrent']); |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
$sql = 'SELECT name, category FROM ' . TORRENTS_TABLE . ' WHERE fid = ' . $filled_torrent_id . ' AND moderated = 1 AND banned = 0 AND hidden = 0'; |
|---|
| 170 |
$result = $db->sql_query($sql); |
|---|
| 171 |
if ( !$row = $db->sql_fetchrow($result) ) { |
|---|
| 172 |
trigger_error($lang['invalid_url_for_uploaded_torrent']); |
|---|
| 173 |
} |
|---|
| 174 |
$torrent_name = censor_text($row['name']); |
|---|
| 175 |
$cats = $cache->obtain_cats(); |
|---|
| 176 |
|
|---|
| 177 |
$cat_id = $row['category']; |
|---|
| 178 |
$cat_parent_id = ( isset($cats[$cats[$cat_id]['cat_parent']]['cat_id']) ? $cats[$cats[$cat_id]['cat_parent']]['cat_id'] : 0 ); |
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
if ( $cat_parent_id ) { |
|---|
| 182 |
$seo->set_url($cats[$cat_parent_id]['cat_name'], $cat_parent_id, $seo->seo_static['browse']); |
|---|
| 183 |
$seo->set_parent($cat_id, $seo->seo_static['browse'], $cat_parent_id, $seo->seo_static['browse']); |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
$seo->set_url($cats[$cat_id]['cat_name'], $cat_id, $seo->seo_static['browse']); |
|---|
| 187 |
|
|---|
| 188 |
$seo->set_parent($filled_torrent_id, $seo->seo_static['details'], $cat_id, $seo->seo_static['browse']); |
|---|
| 189 |
|
|---|
| 190 |
$seo->set_url($torrent_name, $filled_torrent_id, $seo->seo_static['details']); |
|---|
| 191 |
|
|---|
| 192 |
$seo->set_user_url($userdata['name'], $userdata['uid']); |
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
if ( $seo->seo_opt['url_rewrite'] ) { |
|---|
| 196 |
$u_request = append_sid($root_path . 'requests.php?id=' . $id); |
|---|
| 197 |
$u_request = $seo->drop_sid($u_request); |
|---|
| 198 |
$u_userdetails = append_sid($root_path . 'userdetails.php?id=' . $userdata['uid']); |
|---|
| 199 |
$u_userdetails = $seo->drop_sid($u_userdetails); |
|---|
| 200 |
$u_details = append_sid($root_path . 'details.php?id=' . $filled_torrent_id); |
|---|
| 201 |
$u_details = $seo->drop_sid($u_details); |
|---|
| 202 |
} |
|---|
| 203 |
else { |
|---|
| 204 |
$base_url = generate_base_url(); |
|---|
| 205 |
$u_request = $base_url . '/requests.php?id=' . $id; |
|---|
| 206 |
$u_userdetails = $base_url . '/userdetails.php?id=' . $userdata['uid']; |
|---|
| 207 |
$u_details = $base_url . '/details.php?id=' . $filled_torrent_id; |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
$sql = 'SELECT a.userid, u.language, u.name, u.email, u.notifs, u.language, u.class |
|---|
| 211 |
FROM ' . REQUESTS_VOTES_TABLE . ' a, ' . USERS_TABLE . ' u |
|---|
| 212 |
WHERE a.requestid = ' . $id . ' AND a.userid = u.uid'; |
|---|
| 213 |
$result = $db->sql_query($sql); |
|---|
| 214 |
|
|---|
| 215 |
$pm_ary = array(); |
|---|
| 216 |
|
|---|
| 217 |
while ( $arr = $db->sql_fetchrow($result) ) { |
|---|
| 218 |
require_once($root_path . 'languages/lang_' . $arr['language'] . '/lang_pms.php'); |
|---|
| 219 |
|
|---|
| 220 |
$pm_ary[] = array( |
|---|
| 221 |
'sender' => 0, |
|---|
| 222 |
'receiver' => $arr['userid'], |
|---|
| 223 |
'msg' => sprintf($lang['pm_request_filled_body'], $u_request, $requests_name, $u_userdetails, $userdata['name'], $u_details, $torrent_name), |
|---|
| 224 |
'subject' => $lang['pm_request_filled_subject'], |
|---|
| 225 |
'name' => $arr['name'], |
|---|
| 226 |
'email' => $arr['email'], |
|---|
| 227 |
'notifs' => $arr['notifs'], |
|---|
| 228 |
'language' => $arr['language'], |
|---|
| 229 |
'class' => $arr['class'] |
|---|
| 230 |
); |
|---|
| 231 |
} |
|---|
| 232 |
|
|---|
| 233 |
send_pm($pm_ary); |
|---|
| 234 |
|
|---|
| 235 |
$sql = 'UPDATE ' . REQUESTS_TABLE . ' SET filled = ' . $filled_torrent_id . ', filledby = ' . $userdata['uid'] . ' WHERE id = ' . $id; |
|---|
| 236 |
$db->sql_query($sql); |
|---|
| 237 |
|
|---|
| 238 |
update_reputation($userdata, SIMPATY_FILL_REQUEST, 1); |
|---|
| 239 |
|
|---|
| 240 |
trigger_error(sprintf($lang['request_succefully_filled'], $id, append_sid($root_path . 'details.php?id=' . $filled_torrent_id), $torrent_name, append_sid('requests.php?action=reset&id[]=' . $id) )); |
|---|
| 241 |
break; |
|---|
| 242 |
|
|---|
| 243 |
case 'voteview': |
|---|
| 244 |
|
|---|
| 245 |
$id = request_var('requestid', 0); |
|---|
| 246 |
|
|---|
| 247 |
$sql = 'SELECT COUNT(*) AS count, r.request |
|---|
| 248 |
FROM ' . REQUESTS_VOTES_TABLE . ' a, ' . REQUESTS_TABLE . ' r |
|---|
| 249 |
WHERE a.requestid = ' . $id . ' AND a.requestid = r.id |
|---|
| 250 |
GROUP BY r.id'; |
|---|
| 251 |
$result = $db->sql_query($sql); |
|---|
| 252 |
$count = ( $row = $db->sql_fetchrow($result) ) ? $row['count'] : 0; |
|---|
| 253 |
|
|---|
| 254 |
$perpage = 20; |
|---|
| 255 |
list($pagertop, $pagerbottom, $offset, $limit) = pager($perpage, $count, 'requests.php?action=voteview&requestid=' . $id . '&'); |
|---|
| 256 |
|
|---|
| 257 |
$sql = 'SELECT u.uid, u.name, u.downloaded, u.uploaded, u.class |
|---|
| 258 |
FROM ' . REQUESTS_VOTES_TABLE . ' a, ' . REQUESTS_TABLE . ' r, ' . USERS_TABLE . ' u |
|---|
| 259 |
WHERE a.requestid = ' . $id . ' AND a.requestid = r.id AND a.userid = u.uid'; |
|---|
| 260 |
$result = $db->sql_query_limit($sql, $limit, $offset); |
|---|
| 261 |
|
|---|
| 262 |
$template->assign_vars(array( |
|---|
| 263 |
'TRACKER_URL' => generate_base_url(), |
|---|
| 264 |
'U_VOTE' => append_sid('requests.php?action=vote&voteid=' . $id), |
|---|
| 265 |
'PAGERTOP' => $pagertop, |
|---|
| 266 |
'PAGERBOTTOM' => $pagerbottom, |
|---|
| 267 |
'ID' => $id, |
|---|
| 268 |
'L_VOTES_VIEW' => sprintf($lang['votes_view'], $row['request']) |
|---|
| 269 |
)); |
|---|
| 270 |
|
|---|
| 271 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 272 |
$ratio = get_ratio($row['uploaded'], $row['downloaded']); |
|---|
| 273 |
|
|---|
| 274 |
$template->assign_block_vars('voters_row', array( |
|---|
| 275 |
'U_USERDETAILS' => append_sid('userdetails.php?id=' . $row['uid']), |
|---|
| 276 |
'RATIO' => $ratio, |
|---|
| 277 |
'RATIO_COLOR' => get_ratio_color($ratio), |
|---|
| 278 |
'UPLOADED'=> mksize($row['uploaded']), |
|---|
| 279 |
'DOWNLOADED' => mksize($row['downloaded']), |
|---|
| 280 |
'USERNAME' => get_user_class_color($row['class'], $row['name']) |
|---|
| 281 |
)); |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
stdhead(); |
|---|
| 285 |
$template->set_filenames(array( |
|---|
| 286 |
'body' => 'votesview.html' |
|---|
| 287 |
)); |
|---|
| 288 |
stdfoot(); |
|---|
| 289 |
break; |
|---|
| 290 |
|
|---|
| 291 |
case 'request_view': |
|---|
| 292 |
$id = request_var('id', 0); |
|---|
| 293 |
$sql = 'SELECT r.*, c.name AS cat_name, u.name |
|---|
| 294 |
FROM ' . REQUESTS_TABLE . ' r, ' . CATEGORIES_TABLE . ' c, ' . USERS_TABLE . ' u |
|---|
| 295 |
WHERE r.id = ' . $id . ' AND r.cat = c.id AND r.userid = u.uid'; |
|---|
| 296 |
$result = $db->sql_query($sql); |
|---|
| 297 |
|
|---|
| 298 |
if ( !$row = $db->sql_fetchrow($result) ) { |
|---|
| 299 |
trigger_error (sprintf($lang['invalid_id'], $id)); |
|---|
| 300 |
} |
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
require ($root_path . 'include/bbcode/bbcode.lib.php'); |
|---|
| 304 |
require ($root_path . 'include/functions_post.php'); |
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
if ( $row['userid'] <> ANONYMOUS ) { |
|---|
| 308 |
$requester_name = $row['name']; |
|---|
| 309 |
|
|---|
| 310 |
$seo->set_user_url($requester_name, $row['userid']); |
|---|
| 311 |
|
|---|
| 312 |
$u_requester = append_sid($root_path . 'userdetails.php?id=' . $row['userid']); |
|---|
| 313 |
} |
|---|
| 314 |
else { |
|---|
| 315 |
$requester_name = '<i>' . $lang['unknown'] . '</i>'; |
|---|
| 316 |
$u_requester = ''; |
|---|
| 317 |
} |
|---|
| 318 |
|
|---|
| 319 |
$bb_code = new bbcode($row['descr']); |
|---|
| 320 |
$description = $bb_code->get_html(); |
|---|
| 321 |
$description = censor_text($description); |
|---|
| 322 |
|
|---|
| 323 |
if ( !$row['filled'] ) { |
|---|
| 324 |
$template->assign_block_vars('switch_vote_section', array()); |
|---|
| 325 |
} |
|---|
| 326 |
if ( !$row['filled'] && ( $userdata['class'] >= $config['min_class_allow_upload'] )) { |
|---|
| 327 |
$template->assign_block_vars('switch_fill_request', array()); |
|---|
| 328 |
} |
|---|
| 329 |
if ( $userdata['class'] >= UC_MODERATOR || $userdata['uid'] == $row['userid'] ) { |
|---|
| 330 |
$template->assign_block_vars('switch_edit_section', array()); |
|---|
| 331 |
} |
|---|
| 332 |
|
|---|
| 333 |
set_tracking(TYPE_REQUEST, $id); |
|---|
| 334 |
|
|---|
| 335 |
if ( $row['comments'] ) { |
|---|
| 336 |
list($pagertop, $pagerbottom, $offset, $limit) = pager($config['posts_per_page'], $row['comments'], 'offers.php?id=' . $id . '&', array( 'reverse' => 1 )); |
|---|
| 337 |
|
|---|
| 338 |
commenttable(TYPE_REQUEST, $id, $row['userid'], $offset, $limit); |
|---|
| 339 |
} |
|---|
| 340 |
else { |
|---|
| 341 |
$pagertop = $pagerbottom = ''; |
|---|
| 342 |
} |
|---|
| 343 |
|
|---|
| 344 |
$sql = 'SELECT checkcomm_view_status FROM ' . COMMENTS_NOTIFY_TABLE . ' WHERE checkcomm_userid = ' . $userdata['uid'] . ' AND checkcomm_for_id = ' . $id . ' AND checkcomm_type = ' . TYPE_REQUEST; |
|---|
| 345 |
$result = $db->sql_query($sql); |
|---|
| 346 |
$checkcomm = $db->sql_fetchrow($result); |
|---|
| 347 |
if ( $checkcomm ) { |
|---|
| 348 |
if ( !$checkcomm['checkcomm_view_status'] ) { |
|---|
| 349 |
$sql_priority = ($db_type == 'mysql') ? ' LOW_PRIORITY' : ''; |
|---|
| 350 |
$sql = 'UPDATE' . $sql_priority . ' ' . COMMENTS_NOTIFY_TABLE . ' SET checkcomm_view_status = ' . VIEW_STATUS_VIEWED . ', checkcomm_notify_status = ' . NOTIFY_STATUS_UN_NOTIFIED . ' WHERE checkcomm_userid = ' . $userdata['uid'] . ' AND checkcomm_for_id = ' . $id . ' AND checkcomm_type = ' . TYPE_REQUEST; |
|---|
| 351 |
$db->sql_query($sql); |
|---|
| 352 |
} |
|---|
| 353 |
$check = '<a href="' . append_sid($root_path . 'comment.php?type=' . TYPE_REQUEST . '&action=checkoff&tid=' . $id) . '">' . $lang['checkcomm_off'] . '</a>'; |
|---|
| 354 |
} |
|---|
| 355 |
else { |
|---|
| 356 |
$check = '<a href="' . append_sid($root_path . 'comment.php?type=' . TYPE_REQUEST . '&action=check&tid=' . $id) . '">' . $lang['checkcomm_on'] . '</a>'; |
|---|
| 357 |
} |
|---|
| 358 |
|
|---|
| 359 |
$template->assign_vars(array( |
|---|
| 360 |
'S_FORM_ACTION' => append_sid('requests.php'), |
|---|
| 361 |
'U_REQUESTER' => $u_requester, |
|---|
| 362 |
'U_VOTE' => append_sid('requests.php?action=vote&voteid=' . $id), |
|---|
| 363 |
'U_VOTES' => append_sid('requests.php?action=voteview&requestid=' . $id), |
|---|
| 364 |
'U_DELETE' => append_sid('requests.php?action=delete&id[]=' . $id), |
|---|
| 365 |
'U_RESET' => append_sid('requests.php?action=reset&id[]=' . $id), |
|---|
| 366 |
'U_EDIT' => append_sid('requests.php?action=edit&id=' . $id), |
|---|
| 367 |
'FILL_REQUEST_DESCR' => sprintf($lang['fill_request_descr'], generate_base_url()), |
|---|
| 368 |
'ID' => $id, |
|---|
| 369 |
'REQUEST_DETAILS' => sprintf($lang['request_details'], $row['request']), |
|---|
| 370 |
'REQUEST_NAME' => censor_text($row['request']), |
|---|
| 371 |
'DESCRIPTION' => $description, |
|---|
| 372 |
'ADDED' => create_date($row['added']), |
|---|
| 373 |
'TYPE' => $row['cat_name'], |
|---|
| 374 |
'REQUESTER_ID' => $row['userid'], |
|---|
| 375 |
'REQUESTER_NAME' => $requester_name, |
|---|
| 376 |
'VOTES' => $row['hits'], |
|---|
| 377 |
'COMMENTS_COUNT' => $row['comments'], |
|---|
| 378 |
'U_ADD_COMMENT' => append_sid($root_path . 'comment.php?type=' . TYPE_REQUEST . '&action=add&tid=' . $id ), |
|---|
| 379 |
'CHECK' => $check, |
|---|
| 380 |
'PAGERTOP' => $pagertop, |
|---|
| 381 |
'PAGERBOTTOM' => $pagerbottom, |
|---|
| 382 |
)); |
|---|
| 383 |
|
|---|
| 384 |
stdhead(sprintf($lang['request_details'], $row['request'])); |
|---|
| 385 |
|
|---|
| 386 |
$template->set_filenames(array( |
|---|
| 387 |
'body' => 'requests_view_body.html' |
|---|
| 388 |
)); |
|---|
| 389 |
stdfoot(); |
|---|
| 390 |
break; |
|---|
| 391 |
|
|---|
| 392 |
default: |
|---|
| 393 |
require_once ($root_path . 'include/functions_search.php'); |
|---|
| 394 |
|
|---|
| 395 |
$cats = $cache->obtain_cats(); |
|---|
| 396 |
$cat = request_var('cat', 0); |
|---|
| 397 |
$rid = request_var('rid', 0); |
|---|
| 398 |
$sort = request_var('sort', ''); |
|---|
| 399 |
$searchstr = request_var('s', ''); |
|---|
| 400 |
$search_ids = array(); |
|---|
| 401 |
$count = 0; |
|---|
| 402 |
|
|---|
| 403 |
$cleansearchstr = searchfield($searchstr); |
|---|
| 404 |
if ( empty($searchstr) ) { |
|---|
| 405 |
unset($cleansearchstr); |
|---|
| 406 |
} |
|---|
| 407 |
|
|---|
| 408 |
$pagertop = ''; |
|---|
| 409 |
$pagerbottom = ''; |
|---|
| 410 |
|
|---|
| 411 |
$search_arr = $where = array(); |
|---|
| 412 |
|
|---|
| 413 |
if ( $cat ) { |
|---|
| 414 |
$wherecatina = array(); |
|---|
| 415 |
if ( isset($cats[$cat]) ) { |
|---|
| 416 |
if ( $cats[$cat]['cat_parent'] ) { |
|---|
| 417 |
$wherecatina[] = $cat; |
|---|
| 418 |
} |
|---|
| 419 |
|
|---|
| 420 |
else { |
|---|
| 421 |
foreach ( $cats AS $_key => $_ary ) { |
|---|
| 422 |
if ( $_ary['cat_parent'] == $cat ) { |
|---|
| 423 |
$wherecatina[] = $_key; |
|---|
| 424 |
} |
|---|
| 425 |
} |
|---|
| 426 |
$wherecatina[] = $cat; |
|---|
| 427 |
} |
|---|
| 428 |
} |
|---|
| 429 |
$where[] = 'r.cat IN (' . implode(', ', $wherecatina) . ')'; |
|---|
| 430 |
$search_arr[] = 'cat=' . $cat; |
|---|
| 431 |
} |
|---|
| 432 |
|
|---|
| 433 |
if( $rid ) { |
|---|
| 434 |
$where[] = 'r.userid = ' . $rid; |
|---|
| 435 |
$search_arr[] = 'rid=' . $rid; |
|---|
| 436 |
} |
|---|
| 437 |
|
|---|
| 438 |
if ( isset($cleansearchstr) ) { |
|---|
| 439 |
$search_ids = search_text_in_db($searchstr, 'SELECT r.id FROM ' . REQUESTS_TABLE . ' r', 'r.request'); |
|---|
| 440 |
|
|---|
| 441 |
if ( $count = sizeof($search_ids) ) { |
|---|
| 442 |
$where[] = 'r.id IN (' . implode(', ', $search_ids) . ')'; |
|---|
| 443 |
} |
|---|
| 444 |
$search_arr[] = 's=' . urlencode($cleansearchstr); |
|---|
| 445 |
} |
|---|
| 446 |
|
|---|
| 447 |
$search_arr = implode('&', $search_arr); |
|---|
| 448 |
$search_arr = ( $search_arr ? $search_arr . '&' : '' ); |
|---|
| 449 |
|
|---|
| 450 |
$where_sql = implode(' AND ', $where); |
|---|
| 451 |
$where_sql = ( $where_sql ? 'WHERE ' . $where_sql : '' ); |
|---|
| 452 |
|
|---|
| 453 |
$sort_ary = array( |
|---|
| 454 |
'votes' => 'r.hits DESC', |
|---|
| 455 |
'comments' => 'r.comments DESC', |
|---|
| 456 |
'name' => 'r.request ASC', |
|---|
| 457 |
'requestor' => 'u.name ASC', |
|---|
| 458 |
'filled' => 'r.filled DESC', |
|---|
| 459 |
'added' => 'r.added DESC', |
|---|
| 460 |
); |
|---|
| 461 |
|
|---|
| 462 |
$sort_sql = 'r.filled DESC, r.added DESC'; |
|---|
| 463 |
|
|---|
| 464 |
foreach ( $sort_ary AS $sort_type => $_sort_sql ) { |
|---|
| 465 |
if ( $sort == $sort_type ) { |
|---|
| 466 |
$sort_sql = $_sort_sql; |
|---|
| 467 |
} |
|---|
| 468 |
|
|---|
| 469 |
$template->assign_vars(array( |
|---|
| 470 |
'U_SORT_' . strtoupper($sort_type) => append_sid('requests.php?' . $search_arr . 'sort=' . $sort_type) |
|---|
| 471 |
)); |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
if ( $userdata['class'] < UC_MODERATOR ) { |
|---|
| 475 |
$moderator = false; |
|---|
| 476 |
} |
|---|
| 477 |
else { |
|---|
| 478 |
$moderator = true; |
|---|
| 479 |
} |
|---|
| 480 |
|
|---|
| 481 |
if ( !isset($cleansearchstr)) { |
|---|
| 482 |
$sql = 'SELECT COUNT(*) AS count FROM ' . REQUESTS_TABLE . ' r ' . $where_sql; |
|---|
| 483 |
$result = $db->sql_query($sql); |
|---|
| 484 |
$count = ( $row = $db->sql_fetchrow($result) ) ? intval($row['count']) : 0; |
|---|
| 485 |
} |
|---|
| 486 |
|
|---|
| 487 |
if ( $count ) { |
|---|
| 488 |
$where_sql = ( $where_sql ? $where_sql . ' AND r.userid = u.uid' : 'WHERE r.userid = u.uid'); |
|---|
| 489 |
$perpage = ( $userdata['torrentsperpage'] ? $userdata['torrentsperpage'] : 30 ); |
|---|
| 490 |
|
|---|
| 491 |
list($pagertop, $pagerbottom, $offset, $limit) = pager($perpage, $count, 'requests.php?' . $search_arr . 'sort=' . $sort . '&' ); |
|---|
| 492 |
|
|---|
| 493 |
$sql = 'SELECT u.downloaded, u.uploaded, u.name, u.class, r.filled, r.filledby, r.id, r.userid, r.request, r.added, r.hits, r.comments, u2.name AS filledby_username, u2.uid AS filledby_id, r.cat, t.name AS torrent_name, t.category AS t_category |
|---|
| 494 |
FROM ' . REQUESTS_TABLE . ' r |
|---|
| 495 |
LEFT JOIN ' . USERS_TABLE . ' u2 ON r.filledby = u2.uid |
|---|
| 496 |
LEFT JOIN ' . TORRENTS_TABLE . ' t ON r.filled = t.fid, |
|---|
| 497 |
' . USERS_TABLE . ' u |
|---|
| 498 |
' . $where_sql . ' |
|---|
| 499 |
ORDER BY ' . $sort_sql; |
|---|
| 500 |
$result = $db->sql_query_limit($sql, $limit, $offset); |
|---|
| 501 |
} |
|---|
| 502 |
|
|---|
| 503 |
$cats_select = categories_select($cat, 'cat', true); |
|---|
| 504 |
|
|---|
| 505 |
$request_actions = array('reset', 'delete'); |
|---|
| 506 |
$request_action_options = ''; |
|---|
| 507 |
foreach ( $request_actions AS $_null => $action ) { |
|---|
| 508 |
$request_action_options .= '<option value="' . $action . '">' . $lang[$action] . '</option>'; |
|---|
| 509 |
} |
|---|
| 510 |
|
|---|
| 511 |
$template->assign_vars(array( |
|---|
| 512 |
'S_FORM_ACTION' => append_sid('requests.php'), |
|---|
| 513 |
'U_DO_REQUEST' => ( $userdata['class'] >= UC_USER ? append_sid('upload.php?type=request') : '' ), |
|---|
| 514 |
'U_MY_REQUESTS' => append_sid('requests.php?rid=' . $userdata['uid']), |
|---|
| 515 |
'USER_ID' => $userdata['uid'], |
|---|
| 516 |
'PAGERTOP' => $pagertop, |
|---|
| 517 |
'PAGERBOTTOM' => $pagerbottom, |
|---|
| 518 |
'CATS_SELECT' => $cats_select, |
|---|
| 519 |
'SEARCH_VALUE' => $searchstr, |
|---|
| 520 |
'USED_SEARCH' => isset($cleansearchstr), |
|---|
| 521 |
'HAVE_SEARCH_RESULTS' => ( $count ? true : false ), |
|---|
| 522 |
'CAN_MODERATE' => $moderator, |
|---|
| 523 |
'S_MOD_FORM_ACTION' => append_sid('modtask.php?action=mass_request_action'), |
|---|
| 524 |
'REQUEST_ACTION_OPTIONS' => $request_action_options |
|---|
| 525 |
)); |
|---|
| 526 |
|
|---|
| 527 |
if ( $count ) { |
|---|
| 528 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 529 |
if ( $row['userid'] <> ANONYMOUS ) { |
|---|
| 530 |
$addedby_username = get_user_class_color($row['class'], $row['name']); |
|---|
| 531 |
$ratio = get_ratio($row['uploaded'], $row['downloaded']); |
|---|
| 532 |
$ratio = '<span style="color: ' . get_ratio_color($ratio) . ';">' . $ratio . '</span>'; |
|---|
| 533 |
} |
|---|
| 534 |
else { |
|---|
| 535 |
$ratio = '---'; |
|---|
| 536 |
$addedby_username = '<i>' . $lang['unknown'] . '</i>'; |
|---|
| 537 |
} |
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
if ( $row['filled'] ) { |
|---|
| 541 |
$cat_id = $row['t_category']; |
|---|
| 542 |
$cat_parent_id = ( isset($cats[$cats[$cat_id]['cat_parent']]['cat_id']) ? $cats[$cats[$cat_id]['cat_parent']]['cat_id'] : 0 ); |
|---|
| 543 |
|
|---|
| 544 |
if ( $cat_parent_id ) { |
|---|
| 545 |
$seo->set_url($cats[$cat_parent_id]['cat_name'], $cat_parent_id, $seo->seo_static['browse']); |
|---|
| 546 |
$seo->set_parent($cat_id, $seo->seo_static['browse'], $cat_parent_id, $seo->seo_static['browse']); |
|---|
| 547 |
} |
|---|
| 548 |
|
|---|
| 549 |
$seo->set_url($cats[$cat_id]['cat_name'], $cat_id, $seo->seo_static['browse']); |
|---|
| 550 |
|
|---|
| 551 |
$seo->set_parent($row['filled'], $seo->seo_static['details'], $cat_id, $seo->seo_static['browse']); |
|---|
| 552 |
|
|---|
| 553 |
$seo->set_url($row['torrent_name'], $row['filled'], $seo->seo_static['details']); |
|---|
| 554 |
|
|---|
| 555 |
$seo->set_user_url($row['filledby_username'], $row['filledby_id']); |
|---|
| 556 |
} |
|---|
| 557 |
$seo->set_user_url($row['name'], $row['userid']); |
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 |
$filled = ( $row['filled'] ? append_sid($root_path . 'details.php?id=' . $row['filled']) : '' ); |
|---|
| 561 |
$comment = ( $row['comments'] ?'<a href="' . append_sid('requests.php?id=' . $row['id']) . '#startcomments"><b>' . $row['comments'] . '</b></a>' : 0); |
|---|
| 562 |
$filled_by = ( $row['filled'] ? $lang['filled_by'] .' <a href="' . append_sid($root_path . 'userdetails.php?id=' . $row['filledby_id']) . '">' . $row['filledby_username'] . '</a>':''); |
|---|
| 563 |
$vote_link = ( $row['filled'] ? '' : '<a href="' . append_sid('requests.php?action=vote&voteid=' . $row['id']) . '">' . $lang['vote'] . '</a>' ); |
|---|
| 564 |
|
|---|
| 565 |
$cat_name_display = ( isset($cats[$cats[$row['cat']]['cat_parent']]['cat_name']) ? '<a href="' . append_sid('requests.php?cat=' . $cats[$cats[$row['cat']]['cat_parent']]['cat_id']) . '">' . $cats[$cats[$row['cat']]['cat_parent']]['cat_name'] . '</a> -> <a href="' . append_sid('requests.php?cat=' . $row['cat']) . '">' . $cats[$row['cat']]['cat_name'] . '</a>' : '' ); |
|---|
| 566 |
|
|---|
| 567 |
$template->assign_block_vars('requests_row', array( |
|---|
| 568 |
'U_CAT' => append_sid('requests.php?cat=' . $row['cat']), |
|---|
| 569 |
'U_REQUEST' => ( $filled ? $filled : append_sid('requests.php?id=' . $row['id']) ), |
|---|
| 570 |
'U_REQUESTER' => append_sid($root_path . 'userdetails.php?id=' . $row['userid']), |
|---|
| 571 |
'U_VOTES' => append_sid('requests.php?action=voteview&requestid=' . $row['id']), |
|---|
| 572 |
'CAT_NAME_DISPLAY' => $cat_name_display, |
|---|
| 573 |
'FILLED_COLOR' => ( $filled ? 'background-color:#00CC33;' : '' ), |
|---|
| 574 |
'RATIO' => $ratio, |
|---|
| 575 |
'ADDEDBY_ID' => $row['userid'], |
|---|
| 576 |
'ADDEDBY_USERNAME' => $addedby_username, |
|---|
| 577 |
'FILLED_LINK' => $filled, |
|---|
| 578 |
'COMMENT_LINK' => $comment, |
|---|
| 579 |
'CAT_ID' => $row['cat'], |
|---|
| 580 |
'CAT_IMG' => $cats[$row['cat']]['cat_pic'], |
|---|
| 581 |
'CAT_NAME' => $cats[$row['cat']]['cat_name'], |
|---|
| 582 |
'ID' => $row['id'], |
|---|
| 583 |
'NAME' => censor_text($row['request']), |
|---|
| 584 |
'ADDED' => create_date($row['added']), |
|---|
| 585 |
'FIILED_BY' => $filled_by, |
|---|
| 586 |
'HITS' => $row['hits'], |
|---|
| 587 |
'VOTE_LINK' => $vote_link |
|---|
| 588 |
)); |
|---|
| 589 |
} |
|---|
| 590 |
} |
|---|
| 591 |
|
|---|
| 592 |
stdhead($lang['requests']); |
|---|
| 593 |
$template->set_filenames(array( |
|---|
| 594 |
'body' => 'requests_body.html' |
|---|
| 595 |
)); |
|---|
| 596 |
stdfoot(); |
|---|
| 597 |
break; |
|---|
| 598 |
} |
|---|
| 599 |
?> |
|---|
| 600 |
|
|---|