function search_form($search_id = false) { global $db, $dl_prefix, $user_prefix, $module_name, $CPG_SESS, $bgcolor3; $searchdata = $_POST; $return = ''; if ($search_id) { if (isset($CPG_SESS[$module_name]['search'][$search_id])) { $searchdata = $CPG_SESS[$module_name]['search'][$search_id]; $return .= '<div style="background-color: ' . $bgcolor3 . '; padding: 3px;">Editing criteria for search #' . $search_id . '; <a href="' . URL::index('&file=search') . '">start new search</a></div>'; } else { $return .= $this->show_error('Invalid or expired search session. Please start a new search below.'); } } $return .= '<form action="' . URL::index('&file=search') . '" method="post" enctype="multipart/form-data" accept-charset="utf-8"> <h3>Keywords</h3><input type="text" name="s_BASICSEARCH" size="53" value="' . (isset($searchdata['s_BASICSEARCH']) ? htmlprepare($searchdata['s_BASICSEARCH']) : '') . '" maxlength="255" /><br /><br /> <div style="float: left; width: 50%"><h3>Basic information</h3> <label class="ulog" for="s_cid">' . _CATEGORY . '</label> ' . DL_Cat::selectbox(isset($searchdata['s_cid']) ? intval($searchdata['s_cid']) : 0, 's_cid', 2) . '<br /> <label class="ulog" for="s_submitter">' . _DLP_SUBMITTEDBY . '</label> <input type="text" name="s_submitter" id="s_submitter" size="30" maxlength="255" value="' . (isset($searchdata['s_submitter']) ? htmlprepare($searchdata['s_submitter']) : '') . '" /><br /> <label class="ulog" for="s_name">' . _AUTHORNAME . '</label> <input type="text" name="s_name" id="s_name" size="30" maxlength="255" value="' . (isset($searchdata['s_name']) ? htmlprepare($searchdata['s_name']) : '') . '" /><br /> <label class="ulog" for="s_email">' . _AUTHOREMAIL . '</label> <input type="text" name="s_email" id="s_email" size="30" maxlength="255" value="' . (isset($searchdata['s_email']) ? htmlprepare($searchdata['s_email']) : '') . '" /><br /> <h3>Special options</h3> <label class="ulog" for="s_pick">' . _DLP_EDPICK . '</label> <input type="checkbox" name="s_pick" id="s_pick" value="1"' . (isset($searchdata['s_pick']) && $searchdata['s_pick'] == 1 ? ' checked="checked"' : '') . ' /> ' . _YES . '<br /> <label class="ulog" for="s_screenshot">Only downloads with screenshot(s)</label> <input type="checkbox" name="s_screenshot" id="s_screenshot" value="1"' . (isset($searchdata['s_screenshot']) && $searchdata['s_screenshot'] == 1 ? ' checked="checked"' : '') . ' /> ' . _YES . '<br /> <label class="ulog" for="s_date">Published in past</label> ' . select_option('s_date', isset($searchdata['s_date']) ? intval($searchdata['s_date']) : '', array('', 3, 7, 14, 30, 60, 90, 180, 365)) . ' days<br /> <label class="ulog" for="s_updated">Updated in past</label> ' . select_option('s_updated', isset($searchdata['s_updated']) ? intval($searchdata['s_updated']) : '', array('', 3, 7, 14, 30, 60, 90, 180, 365)) . ' days</div> <div style="float: right; width: 50%"><h3>Additional information</h3>'; $result = $db->sql_uquery("SELECT * FROM " . $dl_prefix . "_fields \n\t\t\tWHERE visible > 0 \n\t\t\tORDER BY title"); while ($field = $db->sql_fetchrow($result)) { $f_title = defined($field['title']) ? constant($field['title']) : $field['title']; $f_title = $field['visible'] == 2 ? '* ' . $f_title : $f_title; $return .= '<label class="ulog" for="s_' . $field['field'] . '">' . $f_title . '</label>'; if ($field['type'] == 1 || $field['type'] == 3) { $f_value = isset($searchdata['s_' . $field['field']]) ? intval($searchdata['s_' . $field['field']]) : 0; $return .= '<input type="checkbox" name="s_' . $field['field'] . '" id="s_' . $field['field'] . '" value="1"' . ($f_value == 1 ? ' checked="checked"' : '') . ' /> ' . _YES . '<br />'; } else { $f_value = isset($searchdata['s_' . $field['field']]) ? htmlprepare($searchdata['s_' . $field['field']]) : ''; $return .= '<input type="text" name="s_' . $field['field'] . '" id="s_' . $field['field'] . '" size="30" maxlength="' . $field['size'] . '" value="' . $f_value . '" /><br />'; } } $return .= '</div><br /><br /><input type="submit" name="search" value="' . _SEARCH . '" /></form>'; return $return; }
if (!can_admin($module_name)) { $d_queue = $db->sql_count($dl_prefix . '_downloads', "lid!='{$next_id}' AND active=2"); cpg_error('Your download has been queued for review by an administrator<br /><br />At this time, we have <strong>' . $d_queue . '</strong> other downloads awaiting approval', _TB_INFO, URL::index('&file=manage&s=1', true, true)); } DL_Cat::count_dl(); URL::redirect(URL::index('&file=details&id=' . $next_id)); } } } $cats = array(); DL_Cat::list_all($cats); if (count($cats) < 1) { cpg_error('There are no categories in which you can add a download'); } if (can_admin($module_name) || $dl_config['user_catparent']) { $selects = DL_Cat::selectbox($in['cat'], 'in[cat]', false); } else { $selects = '<select class="set" name="in[cat]" id="in[cat]"> <option selected="selected" label="none" value="none">select a category</option>'; foreach ($cats as $cat) { if ($cat['level'] == 1) { if ($selects != '') { $selects .= '</optgroup>'; } $selects .= '<optgroup label="' . $cat['crumb'] . '">'; } else { $selects .= '<option value="' . $cat['cid'] . '"' . (isset($_GET['c']) && $cat['cid'] == intval($_GET['c']) || $cat['cid'] == $in['cat'] ? ' selected="selected"' : '') . '>' . $cat['crumb'] . '</option>'; } } $selects .= '</optgroup></select>'; }
$url = parse_url($row['mirror_url']); $site = shrink_url($url['host']); } else { $site = $MAIN_CFG['server']['domain']; } $cpgtpl->assign_block_vars('dl_item', array('BGCOLOR' => $bgcolor, 'DATE' => generate_date($row['date']), 'TITLE' => $row['title'], 'URL' => URL::index('&file=details&id=' . $row['id']), 'MIRROR' => $row['mirror_url'], 'MIRROR_SITE' => $site, 'REPORT' => $row['report'], 'U_USER' => URL::index('Your_Account&profile=' . $row['uid']), 'USERNAME' => $row['username'], 'U_DISMISS' => URL::index('&file=manage&s=2&dismiss=' . $row['id']), 'U_EDIT' => URL::index('&file=manage&edit=' . $row['lid']))); } } $db->sql_freeresult($result); $cpgtpl->set_filenames(array('body' => 'downloads/my_broken.html')); } else { $pagetitle .= ' ' . _BC_DELIM . ' Current'; $total_author = $db->sql_count($dl_prefix . '_downloads', "submitter='{$userinfo['user_id']}' AND active!=2"); $cpgtpl->assign_vars(array('L_CATEGORY' => _CATEGORY, 'L_EDIT' => _EDIT, 'DL_MENU' => '<span class="gen"><strong>My Downloads</strong></span><br /><a href="' . URL::index() . '">Main Page</a> | <strong>Current Downloads</strong> | <a href="' . URL::index('&file=manage&s=1') . '">Pending Downloads</a> | <a href="' . URL::index('&file=manage&s=2') . '">Broken D/L Reports</a>', 'DL_NO_ITEMS' => $total_author < 1 ? sprintf(_ERROR_NONE_TO_DISPLAY, strtolower(_DOWNLOADS)) : false, 'DL_PAGINATION' => ceil($total_author / $perpage) > 1 ? gen_pagination($total_author, $perpage, $cur_page, '&file=manage') : false)); if ($total_author) { $rating = $db->sql_query("SELECT lid, SUM(score)/COUNT(lid) AS score FROM " . $dl_prefix . "_ratings \n\t\t\tGROUP BY lid"); while ($rows = $db->sql_fetchrow($rating)) { $ratings[$rows[0]]['score'] = $rows[1]; } $result = $db->sql_query("SELECT d.lid, d.cid, d.title, d.active, d.desc_short, SUM(s.hits) as hits, SUM(s.views) as views FROM " . $dl_prefix . "_downloads d\n\t\t\t\tLEFT JOIN " . $dl_prefix . "_stats s ON (s.id = d.lid)\n\t\t\t\tWHERE d.submitter='{$userinfo['user_id']}' AND d.active!=2 \n\t\t\t\tGROUP BY d.lid, d.cid, d.title, d.active, d.desc_short \n\t\t\t\tLIMIT {$perpage} OFFSET {$limit}"); while ($row = $db->sql_fetchrow($result)) { $rating_info = isset($ratings[$row['lid']]['score']) ? get_rating($ratings[$row['lid']]['score'], 1) : get_rating(0, 0); $cpgtpl->assign_block_vars('dl_item', array('TITLE' => $row['title'], 'U_DETAILS' => URL::index('&file=details&id=' . $row['lid']), 'U_EDIT' => URL::index('&file=manage&edit=' . $row['lid']), 'CATEGORY' => DL_Cat::breadcrumb($row['cid']), 'ACTIVE' => $row['active'] == 1 ? _ACTIVE : _INACTIVE, 'IMG_ACTIVE' => dl_image($row['active'] == 1 ? 'checked.png' : 'unchecked.png'), 'IMG_RATE' => $rating_info['image'], 'IMG_POP' => popularity($row['lid']), 'VIEWS' => $row['views'], 'HITS' => $row['hits'])); } $db->sql_freeresult($result); } $cpgtpl->set_filenames(array('body' => 'downloads/my_downloads.html')); } require_once 'header.php'; $cpgtpl->display('body'); }
$rating_info = get_rating($row['score'], $row['votes']); if (!is_admin() && $row['submitter'] != is_user()) { update_views($global_id); } //$modheader .= '<link rel="stylesheet" type="text/css" href="modules/'.$module_name.'/include/style.css" />'; $pagetitle .= $module_title . ' ' . _BC_DELIM . ' ' . $row['title']; if ($row['img_url']) { if (ereg('://', $row['img_url'])) { $row['img_url'] .= '" width="' . $dl_config['dimension_thumb']; } else { $row['img_url'] = dl_thumbimage($row['img_url']); } } $can_dl = can_download($row['active'], $row['access']); //$submitter_count = $db->sql_count($dl_prefix.'_downloads', "submitter='".Fix_Quotes($row['submitter'])."'")-1; $cpgtpl->assign_vars(array('L_SUBMITTEDBY' => _DLP_SUBMITTEDBY, 'L_AUTHORNAME' => _AUTHORNAME, 'L_AUTHOREMAIL' => _AUTHOREMAIL, 'L_PUBLISHED' => _DLP_PUBLISHED, 'L_UPDATED' => _DLP_UPDATED, 'L_DESCRIPTION' => _DESCRIPTION, 'L_CATEGORY' => _CATEGORY, 'L_RATING' => _RATING, 'L_VOTES' => _VOTES, 'L_DOWNLOADS' => _DOWNLOADS, 'L_ACTIVE' => _ACTIVE, 'L_EDIT' => _EDIT, 'L_DELETE' => _DELETE, 'L_ISDLOWNER' => sprintf(_DLP_ISDLOWNER, URL::index('&file=manage&edit=' . $global_id)), 'L_MIRSUB' => sprintf(_DLP_MIRSUB, URL::index('&file=manage&mirrors=' . $global_id)), 'L_EDNOTE' => _DLP_EDNOTE, 'L_MEMREVIEWS' => _DLP_MEMREVIEWS, 'L_PENDREVIEWS' => _DLP_PENDREVIEWS, 'L_BY' => _BY, 'L_ON' => _ON, 'L_PAGE' => _DLP_PAGE, 'L_VIEWALLSCREENS' => _DLP_VIEWALLSCREENS, 'L_POPULARITY' => _POPULARITY, 'L_PAGEVIEWS' => _DLP_PAGEVIEWS, 'L_ADMINTOOLS' => _ADMINISTRATION, 'L_EDPICK' => _DLP_EDPICK, 'DL_MENU' => dl_detail_menu($global_id, $row['title'], $row['pick'], $row['active'], 1), 'DL_CATEGORY' => DL_Cat::breadcrumb($row['cid']), 'DL_SUBMITTER' => is_numeric($row['submitter']) ? '<a href="' . URL::index('&file=search&sa=' . $row['submitter']) . '">' . $row['username'] . '</a>' : $row['submitter'], 'DL_AUTHORNAME' => $row['name'], 'DL_AUTHOREMAIL' => $row['email'] ? spam_protect($row['email']) : false, 'DL_PUBLISHED' => generate_date($row['date']), 'DL_PUBLISHTYPE' => mark_date($row['date'], 3, 1, 'right'), 'DL_UPDATED' => $row['updated'] > $row['date'] ? generate_date($row['updated']) : false, 'DL_UPDATE_TYPE' => $row['updated'] > $row['date'] ? mark_date($row['updated'], 3, 2, 'right') : false, 'DL_DESCRIPTION' => nl2br($row['desc_short']) . (!empty($row['desc_long']) ? decode_bbcode("\n\n" . $row['desc_long'], true) : ''), 'DL_NOTES' => decode_bbcode($row['notes']), 'DL_REVIEWS_ACTIVE' => $dl_config['r_active'], 'IMG_DL_RATING' => $rating_info['image'], 'DL_VOTES' => intval($row['votes']), 'DL_POPULARITY' => popularity($global_id), 'DL_HITS' => intval($row['hits']), 'DL_VIEWS' => intval($row['views']), 'DL_SUB_MIRRORS' => $dl_config['pub_mirror'], 'U_DL_SCREENSHOT' => URL::index('&screen=' . $row['screen']), 'IMG_DL_SCREENSHOT' => $row['img_url'], 'B_DL_ADMIN' => can_admin($module_name), 'DL_IS_OWNER' => $row['submitter'] == $userinfo['user_id'], 'U_DL_DELETE' => URL::admin('&del_dl=' . $global_id), 'U_DL_EDIT' => URL::index('&file=manage&edit=' . $global_id), 'U_DL_MIRSUB' => URL::index('&file=manage&mirrors=' . $global_id), 'U_DL_MIRROR' => URL::index('&mirror=' . $global_id), 'U_DL_MIRRORS' => URL::index('&get=' . $global_id), 'U_DL_ACTIVE' => URL::admin('&active=' . $global_id), 'U_DL_PICK' => URL::admin('&pick=' . $global_id), 'IMG_DL_MIRRORS' => dl_image($can_dl ? 'download.png' : 'register.png'), 'IMG_DL_ACTIVE' => dl_image($row['active'] == 1 ? 'checked.png' : 'unchecked.png'), 'IMG_DL_PICK' => dl_image($row['pick'] ? 'checked.png' : 'unchecked.png'), 'S_DL_ACTIVE' => $row['active'] == 1 ? _YES : _NO, 'S_DL_PICK' => $row['pick'] ? _YES : _NO, 'S_DL_MIRRORS' => $can_dl ? _DLP_DLNOW : _DLP_NADL)); $result = $db->sql_query("SELECT field, title, type FROM " . $dl_prefix . "_fields \n\tWHERE type!=3 AND visible > 0"); if ($db->sql_numrows($result)) { while ($row2 = $db->sql_fetchrow($result)) { if ($row2['type'] == 1) { $row[$row2['field']] = $row[$row2['field']] ? _YES : _NO; } if ($row[$row2['field']]) { $row2['title'] = defined($row2['title']) ? constant($row2['title']) : $row2['title']; if ($row2['field'] == 'homepage' && $row[$row2['field']]) { $row[$row2['field']] = '<a href="' . $row[$row2['field']] . '" target="_blank">' . shrink_url($row[$row2['field']]) . '</a>'; } $cpgtpl->assign_block_vars('dl_field', array('TITLE' => $row2['title'], 'VALUE' => $row[$row2['field']])); } } }
} $cpgtpl->display('body'); } else { require_once 'header.php'; // Editors pick $result = $db->sql_query("SELECT d.lid, d.cid, d.title, d.desc_short, d.screen, s.url as img_url FROM " . $dl_prefix . "_downloads d\n\t\tLEFT JOIN " . $dl_prefix . "_screenshots s ON (s.id = d.screen)\n\t\tWHERE d.pick=1 AND d.active=1 \n\t\tORDER BY RAND()"); $count = $db->sql_numrows($result); $cpgtpl->assign_vars(array('B_EDITORSPICK' => $count)); if ($count) { $picks = $db->sql_fetchrowset($result); $cpgtpl->assign_vars(array('L_READ_MORE' => 'Details', 'U_MOREPICKS' => URL::index('&file=search&key=pick'), 'L_MOREPICKS' => 'View more featured', 'L_VIEW_SHOT' => 'View Screenshot', 'L_FEATURED' => 'Featured download', 'TITLE' => $picks[0]['title'], 'SRC_IMG' => dl_thumbimage($picks[0]['img_url']), 'URL_IMG' => URL::index('&screen=' . $picks[0]['screen']), 'DESC' => nl2br($picks[0]['desc_short']), 'DETAILS' => URL::index('&file=details&id=' . $picks[0]['lid']))); unset($picks); } $db->sql_freeresult($result); // Categories DL_Cat::show(); // Latest downloads $entries = array(); $result = $db->sql_uquery("SELECT lid, title, date FROM " . $dl_prefix . "_downloads \n\t\tWHERE active=1 AND updated<=date \n\t\tORDER BY date DESC \n\t\tLIMIT {$dl_config['front_rank']}"); while ($entry = $db->sql_fetchrow($result)) { $entry['new'] = true; $entries[$entry['date']] = $entry; } $result = $db->sql_uquery("SELECT lid, title, updated FROM " . $dl_prefix . "_downloads \n\t\tWHERE active=1 AND updated>date \n\t\tORDER BY updated DESC \n\t\tLIMIT {$dl_config['front_rank']}"); while ($entry = $db->sql_fetchrow($result)) { $entry['new'] = false; $entries[$entry['updated']] = $entry; } ksort($entries); # Top downloads $result2 = $db->sql_query("SELECT DISTINCT d.lid, d.title, SUM(s.hits) AS hits FROM " . $dl_prefix . "_downloads d\n\tLEFT JOIN " . $dl_prefix . "_stats s ON (s.id = d.lid)\n\tWHERE d.active=1 \n\tGROUP BY d.lid, d.title \n\tORDER BY hits DESC \n\tLIMIT {$dl_config['front_rank']}");