Example #1
0
function cnsql($coid, $ccids, $pre = '')
{
    global $cotypes;
    if (empty($ccids)) {
        return '';
    }
    if (!is_array($ccids)) {
        $ccids = array($ccids);
    }
    $self = $coid && $cotypes[$coid]['self_reg'] ? 1 : 0;
    $fname = $pre . ($coid ? "ccid{$coid}" : 'caid');
    if ($self) {
        $sqlstr = self_sqlstr($coid, $ccids, $pre);
    } else {
        $sqlstr = $fname . ' ' . multi_str($ccids);
    }
    return $sqlstr;
}
Example #2
0
     $caids = array_merge($caids, $tempids);
     $wherestr .= ($wherestr ? ' AND ' : '') . "a.caid " . multi_str($caids);
 }
 foreach ($cotypes as $coid => $cotype) {
     if (!$chid || !$cotype['chids'] || !in_array($chid, explode(',', $cotype['chids']))) {
         if (${"ccid{$coid}"}) {
             $filterstr .= ($filterstr ? '&' : '') . "ccid{$coid}=" . ${"ccid{$coid}"};
             $ccids = array(${"ccid{$coid}"});
             $tempids = array();
             $coclasses = read_cache('coclasses', $coid);
             $tempids = son_ids($coclasses, ${"ccid{$coid}"}, $tempids);
             $ccids = array_merge($ccids, $tempids);
             if (empty($cotype['self_reg'])) {
                 $wherestr .= ($wherestr ? ' AND ' : '') . "a.ccid{$coid} " . multi_str($ccids);
             } else {
                 $tempstr = self_sqlstr($coid, $ccids, 'a.');
                 $tempstr && ($wherestr .= (!$wherestr ? '' : ' AND ') . $tempstr);
                 unset($tempstr);
             }
         }
     }
 }
 if ($chid) {
     $filterstr .= ($filterstr ? '&' : '') . "chid={$chid}";
     $customtable = "archives_{$chid}";
     $fromstr .= ' LEFT JOIN {$tblprefix}' . $customtable . ' AS c ON (a.aid=c.aid)';
     $wherestr .= ($wherestr ? ' AND ' : '') . "a.chid='{$chid}'";
     $a_field = new cls_field();
     $fields = read_cache('fields', $chid);
     foreach ($fields as $k => $field) {
         if ($field['available'] && $field['issearch']) {
Example #3
0
    $filterstr .= ($filterstr ? '&' : '') . "caid={$caid}";
}
//分类因素
foreach ($cotypes as $k => $v) {
    ${"ccid{$k}"} = empty(${"ccid{$k}"}) ? 0 : max(0, intval(${"ccid{$k}"}));
    $item["ccid{$k}"] = ${"ccid{$k}"};
    $item['ccid' . $k . 'title'] = '';
    if (${"ccid{$k}"}) {
        $coclasses = read_cache('coclasses', $k);
        $item['ccid' . $k . 'title'] = $coclasses[${"ccid{$k}"}]['title'];
        $tempids = array(${"ccid{$k}"});
        $tempids = son_ids($coclasses, ${"ccid{$k}"}, $tempids);
        if (empty($cotype['self_reg'])) {
            $wherestr .= " AND a.ccid{$k} " . multi_str($tempids);
        } else {
            $tempstr = self_sqlstr($k, $tempids, 'a.');
            $tempstr && ($wherestr .= ' AND ' . $tempstr);
        }
        $filterstr .= ($filterstr ? '&' : '') . "ccid{$k}=" . ${"ccid{$k}"};
    }
}
//处理indays多少天以内添加的
$indays = empty($indays) ? 0 : max(0, intval($indays));
$item['indays'] = $indays;
if ($indays) {
    $wherestr .= " AND a.createdate>'" . ($timestamp - 86400 * $indays) . "'";
    $filterstr .= ($filterstr ? '&' : '') . "indays={$indays}";
}
//处理outdays多少天以前添加的
$outdays = empty($outdays) ? 0 : max(0, intval($outdays));
$item['outdays'] = $outdays;
Example #4
0
    if (in_array($k, $vararr)) {
        $v = max(0, intval($v));
        $temparr[$k] = $v;
        $cnstr .= ($cnstr ? '&' : '') . $k . '=' . $v;
        if ($k == 'caid' && !empty($catalogs[$v])) {
            $cn_name .= '-' . $catalogs[$v]['title'];
            $caids = cnsonids($caid, $catalogs);
            $sqlstr .= (empty($sqlstr) ? '' : ' AND ') . "caid='" . $v . "'";
        } elseif (preg_match("/^ccid(\\d+)/is", $k, $matches)) {
            $coid = $matches[1];
            $coclasses = read_cache('coclasses', $coid);
            $cn_name .= '-' . $coclasses[$v]['title'];
            if (empty($cotypes[$coid]['self_reg'])) {
                $sqlstr .= (empty($sqlstr) ? '' : ' AND ') . "ccid{$coid}='" . $v . "'";
            } else {
                $tempstr = self_sqlstr($coid, $v, '');
                $tempstr && ($sqlstr .= (empty($sqlstr) ? '' : ' AND ') . $tempstr);
                unset($tempstr);
            }
        }
    }
}
$mode = 0;
if (empty($cnstr) || !isset($cnodes[$cnstr])) {
    $mode = 1;
    $cn_link = $cms_abs;
} else {
    if (!$curuser->pmbypmids('cread', cn_pmids($cnstr, $sid))) {
        exit(lang('nocatasbrowsepermis'));
    }
    $cnode = cnodearr($cnstr);