dirurl);
if ($settings->totalsubcats == '') { $settings->totalsubcats = $db->selectcount('categoriestable', 'validated=1 AND deleted=0 AND hide=0 AND isalbum=0'); $settings->update('totalsubcats'); }
if ($scriptinfo['scriptname'] != 'wsnforum') $settings->deletedmarkers = 'no'; // eliminate markers for deleted links
if (isset($mixtypes)) $settings->mixrecip = $mixtypes;
if ($settings->skiptocat > 0 && !$catid && !$todo && !$action) { $action = 'displaycat'; $catid = $settings->skiptocat; }
if (!is_numeric($settings->skiptocat) && $settings->skiptocat != '' && !$catid && !$todo && !$action)
{
if ($settings->skiptocat == 'albums.php?action=list' && $settings->apacherewrite == 'yes') $settings->skiptocat = $settings->rewritealbumindex;
header("Location: ". $settings->skiptocat);
}
if ($todo == 'subscribe' && $thismember->id > 0)
{
$thiscategory = new category('id', $catid);
if (strstr($thiscategory->subscribers, '|||'. $thismember->id .'|||')) $message = $language->subscribecat_unsubscribe;
else $message = $language->subscribecat_subscribe;
$dest = objectreplacements($redirects['aftersubscribecat'], $thiscategory);
$thiscategory->subscribe($thismember->id);
redirect($message, $dest);
}
if ($todo == 'ordercats') $ordercats = "ORDER BY $catfield $catascdesc";
if (!$ordercats) $ordercats = $settings->ordercats;
if ($settings->ordercats2 != '') $ordercats .= str_replace('ORDER BY ', ',', $settings->ordercats2); // incorp secondary
if (!isset($catcolumns) || $catcolumns < 1) $catcolumns = $settings->catcols;
if (!isset($subcatcolumns) || $subcatcolumns < 1) $subcatcolumns = $settings->subcatcols;
if (!$_COOKIE['testcookie']) makecookie('testcookie', rand(1, 99), time()+999999999); // test that their browser accepts cookies... and set captcha salt
if (!isset($excludetimed))
{
include 'includes/timedactions.php';
}
if (!isset($linkcolumns) || $linkcolumns < 1) $linkcolumns = $settings->linkcols;
if ($settings->orderlinks == 'rotating case') $settings->orderlinks = "ORDER BY case when title >= '". $settings->currentletter ."' then 0 else 1 end, title";
if ((isset($ascdesc) && $ascdesc != '') && (!stristr($ordercats, 'ORDER')))
{
$ordercats = 'ORDER BY '. $ordercats .' '. $ascdesc;
if ($settings->ordercats2 != '') $ordercats .= str_replace('ORDER BY ', ',', $settings->ordercats2);
}
if ($ordercats == '')
{ // let user override value
$ordercats = $settings->ordercats;
if ($settings->ordercats2 != '') $ordercats .= str_replace('ORDER BY ', ',', $settings->ordercats2);
}
// deduce needed widths for table cells
if ($linkcolumns > 0) { $linkwidth = 'width="'.(int)(99/$linkcolumns) .'%"'; $linkwidthstyle = "width: ".(int)(99/$linkcolumns)."%; ";}
if ($catcolumns > 0) { $catwidth = 'width="'.(int)(99/$catcolumns) .'%"'; $catwidthstyle = "width: ".(int)(99/$catcolumns)."%; "; }
if ($subcatcolumns > 0) { $subcatwidth = 'width="'.(int)(99/$subcatcolumns) .'%"'; $subcatwidthstyle = "width: ".(int)(99/$subcatcolumns)."%; "; }
if ($settings->fixedwidth != '') { $linkwidth = 'width="'. $settings->fixedwidth .'"'; $linkwidthstyle = "width: ".(int)(99/$linkcolumns)."%; "; }
if (isset($checkversion)) echo "{$scriptinfo['fullscripttitle']} version check... this is ". $scriptinfo['version'];
if (isset($catname))
{
$catname = rtrim($catname, '/');
if (is_numeric($catname)) $catid = $catname;
}
if ($settings->rewritesubdomains == 'yes')
{ // get first category out of subdomain and move it into front of catname
$subdomain = '';
$pieces = explode('.', $_SERVER['HTTP_HOST']);
if (count($pieces) >= 3 && $pieces[0] != 'www') $subdomain = $pieces[0];
if ($subdomain)
{ // confirmed that a category was passed in subdomain
$_REQUEST['rewritten'] = 1; $_GET['rewritten'] = 1; $rewritten = 1; // in case this is checked anywhere
if ($catname) $catname = $subdomain.'/'.$catname;
else
{
if (!tweakisset('subdomainsections') || ($subdomain != 'downloads' && $subdomain != 'publishers' && $subdomain != 'screenshots'))
{
$catname = $subdomain;
fakerequest('action', 'displaycat');
}
}
}
}
if (isset($catname) && $catname != '' && $catid == '')
{ // determine id based on name and path
$flags['doingcategoryrewrite'] = true;
$catname = str_replace($settings->rewriteampersand, '&', $catname);
if ($settings->skiptocat > 0)
{
$cz = new category('id', $settings->skiptocat);
$catname = urlencode(addspaces($cz->name)) .'/'. $catname;
}
$name = urldecode(trim($catname, '/'));
$name = addspaces($name);
// extract subdirectories
$subs = explode('/', $name);
$o = count($subs);
$startfrom = $o-2;
$thiscatname = $subs[$o - 1];
$altthiscatname = str_replace('&', $settings->rewriteampersand, $thiscatname); // to catch literal 'and's
if (is_numeric($subs[$o-1]))
{
$page = $subs[$o-1];
$startfrom = $o-3;
$thiscatname = $subs[$o - 2];
$name = str_replace('/'. $page, '', $name);
}
for ($x=$startfrom; $x>-1; $x--)
{
$parentlist .= '|||'. $subs[$x];
}
$parentlist .= '|||';
$altparentlist = str_replace('&', $settings->rewriteampersand, $parentlist); // to catch literal 'and's
if ($startfrom > -1 && $subs[0] != '')
{
// problem: ' isn't passed in url, but is in. solution: messy mysql-only stuff.
$where = "validated=1 AND deleted=0 AND (REPLACE(name, ''', '') = '". $thiscatname ."' OR REPLACE(name, ''', '') = '". $altthiscatname ."') AND (REPLACE(parentnames, ''', '') = '". $parentlist ."' OR REPLACE(parentnames, ''', '') = '". $altparentlist ."')";
$q = $db->select('id', 'categoriestable', $where, '', '');
$n = $db->numrows($q);
if ($n) $catid = $db->rowitem($q);
else
{ // if it's not a top level, find it elsewhere. this is necessary for unconventional rewrite schemes like snoopy.com.au (which has second level categories as subdomains)
$where = "validated=1 AND deleted=0 AND (REPLACE(name, ''', '') = '$thiscatname' OR REPLACE(name, ''', '') = '$altthiscatname')";
$catid = $db->selectitem('id', 'categoriestable', $where);
}
}
else
{
$altname = str_replace('&', $settings->rewriteampersand, $name);
$where = "validated=1 AND deleted=0 AND (REPLACE(name, ''', '') = '$name' OR REPLACE(name, ''', '') = '$altname') AND parent=0";
$q = $db->select('id', 'categoriestable', $where, '', '');
$n = $db->numrows($q);
if ($n) $catid = $db->rowitem($q);
else
{ // if it's not a top level, find it elsewhere. this is necessary for unconventional rewrite schemes like snoopy.com.au (which has second level categories as subdomains)
$where = "validated=1 AND deleted=0 AND (REPLACE(name, ''', '') = '$name' OR REPLACE(name, ''', '') = '$altname')";
$catid = $db->selectitem('id', 'categoriestable', $where);
}
}
$flags['doingcategoryrewrite'] = false;
}
if ($action == 'displaycat' && !$catid) endwithbadrequest();
if ($action == 'displaycat' && $catid > 0)
{ // display desired category
$thiscategory = new category('id', $catid); // create proper category object
if ($thiscategory->isalbum)
{ // have to handle albums here because with url rewriting they'll come to index.php
require_once 'includes/displayalbum.php';
}
else
{
require_once 'includes/displaycat.php';
}
}
else
{ // no category selected, so display listing of top level categories
require_once 'includes/displaytop.php';
}
// properly select items in cat and links ordering selectors
$ordering = explode(' ', $ordercats);
// 0: ORDER 1: BY 2: field 3: ASC/DESC
$ourorder = '