## v5.24 -> apr. 05, 2006
session_start();
include_once ("config/config.php");
if ($setts['stores_enabled']!="Y") {
echo "";
} else {
include ("themes/".$setts['default_theme']."/header.php");
header5("$lang[stores_directory]");
### first we sort the stores.
(string) $cntUser = NULL;
$getStoreUsers = mysql_query("SELECT count(a.id) AS c_id, u.id AS u_id FROM probid_auctions a, probid_users u WHERE
a.active=1 AND a.closed=0 AND a.deleted!=1 AND a.ownerid=u.id AND u.active=1 AND u.aboutpage_type=2 AND a.listin!='auction' GROUP BY u.id") or die(mysql_error());
while ($storeUsers=mysql_fetch_array($getStoreUsers)) {
$runQuery[$stcnt++] = mysql_query("UPDATE probid_users SET nb_items = '".$storeUsers['c_id']."' WHERE id= '".$storeUsers['u_id']."'");
## we save the user list in a variable
$cntUser .= $storeUsers['u_id']." ";
}
$cntUser = eregi_replace(" ",",",trim($cntUser));
$resetNbItemsQuery = (!empty($cntUser)) ? " AND id NOT IN (".$cntUser.") " : "";
$resetNbItems = mysql_query("UPDATE probid_users SET nb_items='0' WHERE active=1 AND aboutpage_type=2 ".$resetNbItemsQuery);
if ($_GET['start'] == "") $start = 0;
else $start = $_GET['start'];
$limit = 20;
if ($_GET['search']=="yes"&&trim($_GET['username'])!="") {
$addQuery = " AND username LIKE '%".$_GET['username']."%'";
}
$additionalVars = "&search=".$_GET['search']."&username=".$_GET['username'];
$getStores = mysql_query("SELECT id, shop_logo, username, store_name, aboutmepage, nb_items FROM probid_users WHERE
active='1' AND store_active='1' AND aboutpage_type='2'".$addQuery." ORDER BY nb_items DESC LIMIT ".$start.",".$limit) or die(mysql_error());
$totalStores = getSqlNumber("SELECT id FROM probid_users WHERE
active='1' AND store_active='1' AND aboutpage_type='2'".$addQuery);
$isStores = mysql_num_rows($getStores);
if ($isStores>0) { ?>