'MailshellSession')); page_close(); if (isset($imp)) $imp->unpickle(); ////////////////////// end of common stuff for Horde/IMP setup.... include './mail/client/dbconnect.inc'; include ('/home/httpd/html/mail/client/templates/categoryURL_func.inc'); include '/home/httpd/html/mail/client/templates/getImageForRating_func.inc'; require ('./mail/client/templates/categoryPageFunctions.inc'); include './mail/client/templates/getSQLSortDir_func.inc'; $helpcontextlink = "/help/$language/mail/help4p.html#help4p1"; checkParams(); // maximum value which can be stored in userpicks.popularityrank field. // It indicates an unranked user picks list. define ('MAX_VALUE_POPULARITY', 2147483647); ////////////////////////////////////////////////////////////////////////////// // validate some input params ////////////////////////////////////////////////////////////////////////////// function checkParams() { global $listperpage, $page, $startid, $category; if (!isset($category)) $category = 'All'; if (!isset($listperpage) || ((integer)$listperpage) == 0) $listperpage = DEFAULT_ITEMS_PER_PAGE; if (!isset($page) || $page == 0) $page = 1; $startid = ($page * $listperpage) - $listperpage; } ////////////////////////////////////////////////////////////////////////////// // Generate cookie path containing the category ////////////////////////////////////////////////////////////////////////////// function makePageHeading() { global $category; if (strcasecmp($category, 'All') == 0) return '>'; $category = categoryExternalToInternal($category); $catstr = ""; # Decode the characters urlized and convert them back to characters. $categorydec = rawurldecode($category); $categoryarr = explode("/", $categorydec); global $sortedby; $arrcount = count($categoryarr) - 1; $currentCategory = ''; for ($tmpcount = 0; $tmpcount <= $arrcount; $tmpcount++) { if ($tmpcount == $arrcount) { if ($currentCategory != '') $newCat = $currentCategory . '/' . $categoryarr[$tmpcount]; else $newCat = $categoryarr[$tmpcount]; $catstr .= " > " . $categoryarr[$tmpcount] . " >"; $catstr .= " \n"; } else { if ($currentCategory != '') $newCat = $currentCategory . '/' . $categoryarr[$tmpcount]; else $newCat = $categoryarr[$tmpcount]; $catstr .= " > " . $categoryarr[$tmpcount] . ""; $currentCategory = $newCat; } } $buffer .= $catstr; return $buffer; } $title = htmlspecialchars(str_replace('~', ' > ', $category)) . " > Users Picks ($MAILSHELL_TITLE_TEXT)"; // set title of the HTML page. $default->include_dir = './mail/client/templates'; require "$default->include_dir/doctype.inc"; $page_heading = 'List Topics ' . makePageHeading() . ' Users Picks'; $isOffersPage = true; require "$default->include_dir/generic-header.inc"; // Helper function to return current parameters in format suitable for // passing in a url // Returns - url parameters. // Arguments - $includeSort whether to include current sort parameters in // the url. function getParamsForURL($includeSort = true) { global $sortedby; $urlParams = ''; if ($includeSort) { if (isset($sortedby) && $sortedby != '') $urlParams .='&sortedby=' . rawurlencode($sortedby); if (isset($sortdir) && $sortdir != '') $urlParams .='&sortdir=' . rawurlencode($sortdir); } return $urlParams; } // Create column headers of the table. // $sortField - current sort field. // $columnLabel - label for the column function generateColumnHeading($encodedCategory, $sortField, $columnLabel) { global $sortedby, $sortdir; $buffer = ''; $buffer .= '
^ '; } else { $buffer .= '/sortdir/' . ASCENDING . '">v '; } $buffer .= '' . $columnLabel . ''; } else { $buffer .= '">' . $columnLabel . ''; } $buffer .= '
'; return $buffer; } // the supported sort options. $sortbyoptions = "relevance:user name:user picks name:user rating:popularity rank:date added"; // Insert current parameters as hidden fields. Used to // pass parameters when sorting columns of results. function getParamsAsHiddenFields() { global $category; $buffer = ''; return $buffer; } $databasehost = USERPICKSHOST; dbconnect(); // determine total number of public user picks $query = "SELECT COUNT(*) FROM userpicks WHERE public=1"; $result = @mysql_query($query); $totalists = 0; $isAll = ($category == 'All'); if ($result) { $row = @mysql_fetch_row($result); if ($row) $totallists = $row[0]; } if ($totallists > 0) { // Get list of categories in which we should search for user picks. if (!$isAll) { // NEEDSWORK need an index on category.fullname; $safecat = addslashes($category); $query = "SELECT id FROM category WHERE fullpath LIKE '$safecat' OR fullpath LIKE '$safecat/%'"; $result = @mysql_query($query); $catsToSearch = array(); if ($result) { while ($row = @mysql_fetch_row($result)) { $catsToSearch[] = $row[0]; } } $catsToSearchString = implode(',', $catsToSearch); // determine number of user picks. Used to identify pages and totals if ($catsToSearchString == '') $totallists = 0; else { // ugh.. not entirely efficient. $countQuery = "SELECT numpicks FROM usercategorypicks, userpicks WHERE categoryid IN ($catsToSearchString) AND usercategorypicks.pid = userpicks.pid AND userpicks.public = 1 GROUP BY userpicks.pid"; $result = @mysql_query($countQuery); if ($result) $totallists = @mysql_num_rows($result); } } if ($result) { if (($startid + $listperpage) <= $totallists) $endid = $startid + $listperpage; else $endid = $totallists; $citem = $endid - $startid; } if ($totallists > 0) { $query = "SELECT distinct(userpicks.pid), guid, userdisplayname,title,description,rating,DATE_FORMAT(created, '%m/%d/%Y'), IF (popularityrank > 0, popularityrank, " . MAX_VALUE_POPULARITY . ") AS poprank,sponsorLogo, sponsorTag"; $querytables = ' FROM userpicks'; if ($sortedby == 'popularity rank') $secondarySort = ',created ASC'; else $secondarySort = ',poprank ASC'; $sortQualifier = 'WHERE public = 1'; if (!$isAll) { $querytables .= ',usercategorypicks '; } // should be one of the values in $sortbyoptions switch (rawurldecode($sortedby)) { case 'user name': $sortsql = 'ORDER BY userdisplayname ' . getSQLSortDir('ASC'); break; case 'user picks name'; $sortsql = 'ORDER BY title ' . getSQLSortDir('ASC'); break; case 'user rating': $sortsql = 'ORDER BY rating ' . getSQLSortDir('DESC'); break; case 'date added': $sortsql = 'ORDER BY created ' . getSQLSortDir('DESC'); break; case 'popularity rank': $sortsql = 'ORDER BY poprank ' . getSQLSortDir('ASC') . ',sponsorValue ' . getSQLSortDir('DESC') ; break; default: case 'relevance': $sortsql = 'ORDER BY sponsorValue ' . getSQLSortDir('DESC'); if (!$isAll) $sortsql .= ', usercategorypicks.numpicks'; break; } if (isset($catsToSearchString)) { if (isset($sortQualifier) && $sortQualifier != '') $sortQualifier .= ' AND '; else $sortQualifier = 'WHERE '; $sortQualifier .= "usercategorypicks.categoryid IN ($catsToSearchString) AND "; $sortQualifier .= 'userpicks.pid = usercategorypicks.pid'; } $query .= "$querytables $sortQualifier $sortsql $secondarySort LIMIT $startid, $listperpage"; createTable($query); } } //////////////////////////////////////////////////////////////////////////// // Display table of results //////////////////////////////////////////////////////////////////////////// function createTable($query) { global $buffer, $totallists, $category, $startid, $endid; global $sortbyoptions, $sortedby; $result = @mysql_query($query); // error_log("bltest userpicks.html query is $query \n",3,'/tmp/bllog.txt'); $buffer .= '
' . "Users Picks
"; if ($totallists > 0) $buffer .= "showing " . ($startid+1) . "-$endid of $totallists "; $buffer .= '
  '; $buffer .= buildSortBy($sortbyoptions, $sortedby); $buffer .= '

'; $buffer .= ''; // add column headings. if (!isset($category)) $category = 'All'; $encodedCategory = makeCategoryURL($category); $buffer .= generateColumnHeading($encodedCategory, 'user name', 'User Name'); $buffer .= generateColumnHeading($encodedCategory, 'user picks name', 'User Picks Name'); $buffer .= generateColumnHeading($encodedCategory, 'user rating', 'User Rating'); $buffer .= generateColumnHeading($encodedCategory, 'popularity rank', 'Popularity Rank'); $buffer .= generateColumnHeading($encodedCategory, 'date added', 'Date Added'); $buffer .= ' '; // display the User Picks Lists. while ($row = @mysql_fetch_row($result)) { if (isset($row[8])) $adLogo = $row[8]; else $adLogo = ''; if (isset($row[9])) $sponsorTag = $row[9]; else $sponsorTag = ''; $pid = htmlspecialchars($row[0]); $buffer .= '
 
'; if ($adLogo != '') // $buffer .= ''; $buffer .= ''; if ($sponsorTag != '') // sponsor tag ; // $buffer .= '
' . htmlspecialchars($sponsorTag) . ''; else { // append user description and id $buffer .= '' . htmlspecialchars($row[2]) . "
(ID:$row[1]) "; } $buffer .= '
' . htmlspecialchars($row[3]) . '
'; if (isset($row[4])) // description if any { $buffer .= ' '; if (strlen($row[4]) > USERPICKS_DESCRIPTION_MAX) $buffer .= htmlspecialchars(substr($row[4], 0, USERPICKS_DESCRIPTION_MAX)) . " ..."; else $buffer .= htmlspecialchars($row[4]); $buffer .= ''; } // tack on the user rating. It is stored as a number from 0-5, so we'll // have to do a conversion before passing to getImageForRating(). $buffer .= '
'; if ($row[5] == 0) { $buffer .= 'unrated'; } else { $buffer .= ''; $buffer .= getImageForRating($row[5] * 20, 0, false) . '
'; } $buffer .= '
'; // popularity rank if ($row[7] == MAX_VALUE_POPULARITY) $buffer .= 'new'; else $buffer .= '' . $row[7] . '
'; $buffer .= '
' . $row[6] . '
· view lists '; } $buffer .= '
  ' . num_pages('/userpicks.html', $startid, $totallists, DEFAULT_ITEMS_PER_PAGE) . '
'; $buffer .= '
 '; $buffer .= buildSortBy($sortbyoptions, $sortedby); $buffer .= '

'; } if ($totallists == 0) { $buffer .= 'No Matching Lists Found!
'; $buffer .= '
[ Edit your pick listings ]

'; } echo $buffer; require "$default->include_dir/generic-footer.inc"; ?>