Esempio n. 1
0
     if (in_array($v['cuid'], $ocuids)) {
         $ucidsarr[$k] = $v['title'];
     }
 }
 $page = empty($page) ? 1 : max(1, intval($page));
 submitcheck('bfilter') && ($page = 1);
 $caid = empty($caid) ? 0 : max(0, intval($caid));
 $checked = isset($checked) ? $checked : '-1';
 $valid = isset($valid) ? $valid : '-1';
 $keyword = empty($keyword) ? '' : $keyword;
 $wheresql = "cu.mid='{$memberid}'";
 $fromsql = "FROM {$tblprefix}offers cu LEFT JOIN {$tblprefix}archives a ON a.aid=cu.aid";
 //栏目范围
 $caids = array();
 if ($caid) {
     $caids = cnsonids($caid, $catalogs);
     if (!empty($u_caids)) {
         $caids = array_intersect($caids, $u_caids);
     }
 } elseif (!empty($u_caids)) {
     $caids = $u_caids;
 }
 if ($caids) {
     $wheresql .= " AND a.caid " . multi_str($caids);
 } elseif (!empty($u_caids)) {
     $no_list = true;
 }
 //审核状态范围
 if ($checked != -1) {
     if ($u_checked != -1 && $checked != $u_checked) {
         $no_list = true;
Esempio n. 2
0
        amessage('cconfigsaddfinish', axaction(6, "?entry={$entry}&action=cnconfigs{$param_suffix}"));
    }
} elseif ($action == 'cnodescommon') {
    $page = !empty($page) ? max(1, intval($page)) : 1;
    submitcheck('bfilter') && ($page = 1);
    $viewdetail = empty($viewdetail) ? 0 : $viewdetail;
    $keyword = empty($keyword) ? '' : $keyword;
    $caid = !isset($caid) ? '0' : $caid;
    $mainline = !isset($mainline) ? '-1' : $mainline;
    $cnlevel = !isset($cnlevel) ? '0' : $cnlevel;
    $inconfig = !isset($inconfig) ? '-1' : $inconfig;
    $fromsql = "FROM {$tblprefix}cnodes";
    $wheresql = "sid={$sid}";
    $mainline != -1 && ($wheresql .= " AND mainline='{$mainline}'");
    $cnlevel && ($wheresql .= " AND cnlevel='{$cnlevel}'");
    !empty($caid) && ($wheresql .= " AND caid " . multi_str(cnsonids($caid, $catalogs)));
    $keyword && ($wheresql .= " AND ename LIKE '%" . str_replace(array(' ', '*'), '%', addcslashes($keyword, '%_')) . "%'");
    $inconfig != '-1' && ($wheresql .= " AND inconfig='{$inconfig}'");
    $filterstr = '';
    foreach (array('keyword', 'viewdetail', 'caid', 'mainline', 'cnlevel', 'inconfig') as $k) {
        $filterstr .= "&{$k}=" . urlencode(${$k});
    }
    foreach ($cotypes as $coid => $cotype) {
        if ($cotype['sortable']) {
            ${"ccid{$coid}"} = isset(${"ccid{$coid}"}) ? ${"ccid{$coid}"} : 0;
            if (!empty(${"ccid{$coid}"})) {
                $filterstr .= "&ccid{$coid}=" . ${"ccid{$coid}"};
                $wheresql .= " AND ename REGEXP 'ccid{$coid}=" . ${"ccid{$coid}"} . "(&|\$)'";
            }
        }
    }
Esempio n. 3
0
 function deal_search($fpre = '')
 {
     //$fpre为查询字串中的表别名,如a.,c.,m.等
     if (!$this->field['available'] || !$this->field['issearch']) {
         return;
     }
     $fn = $this->field['ename'];
     global ${$fn}, ${$fn . 'str'}, ${$fn . 'from'}, ${$fn . 'to'}, ${$fn . '_0'}, ${$fn . '_1'}, ${$fn . 'diff'};
     if ($this->field['datatype'] == 'select') {
         if ($this->field['issearch'] == '1') {
             if (${$fn} != '') {
                 $this->searchstr = $fpre . $fn . "='" . ${$fn} . "'";
                 $this->filterstr = $fn . "=" . rawurlencode(stripslashes(${$fn}));
             }
         } else {
             if (!empty(${$fn})) {
                 ${$fn . 'str'} = implode("\t", ${$fn});
             } elseif (!empty(${$fn . 'str'})) {
                 ${$fn} = explode("\t", ${$fn . 'str'});
             } else {
                 ${$fn . 'str'} = '';
             }
             if (${$fn . 'str'} != '') {
                 $this->searchstr = $fpre . $fn . " " . multi_str(${$fn});
                 $this->filterstr = $fn . "str=" . rawurlencode(stripslashes(${$fn . 'str'}));
             }
         }
     } elseif ($this->field['datatype'] == 'mselect') {
         if ($this->field['issearch'] == '1') {
             if (${$fn} != '') {
                 $this->searchstr = $fpre . $fn . " LIKE '%" . str_replace(array(' ', '*'), '%', addcslashes(${$fn}, '%_')) . "%'";
                 $this->filterstr = $fn . "=" . rawurlencode(stripslashes(${$fn}));
             }
         } else {
             if (!empty(${$fn})) {
                 ${$fn . 'str'} = implode("\t", ${$fn});
             } elseif (!empty(${$fn . 'str'})) {
                 ${$fn} = explode("\t", ${$fn . 'str'});
             } else {
                 ${$fn . 'str'} = '';
             }
             if (${$fn . 'str'} != '') {
                 foreach (${$fn} as $v) {
                     $this->searchstr .= ($this->searchstr ? ' OR ' : '') . $fpre . $fn . " LIKE '%" . str_replace(array(' ', '*'), '%', addcslashes($v, '%_')) . "%'";
                 }
                 $this->searchstr = '(' . $this->searchstr . ')';
                 $this->filterstr = $fn . "str=" . rawurlencode(stripslashes(${$fn . 'str'}));
             }
         }
     } elseif ($this->field['datatype'] == 'text') {
         ${$fn} = empty(${$fn}) ? '' : cutstr(trim(${$fn}), 20, '');
         if (${$fn} != '') {
             $this->searchstr = $this->field['issearch'] == 1 ? $fpre . $fn . "='" . ${$fn} . "'" : $fpre . $fn . " LIKE '%" . str_replace(array(' ', '*'), '%', addcslashes(${$fn}, '%_')) . "%'";
             $this->filterstr = $fn . "=" . rawurlencode(stripslashes(${$fn}));
         }
     } elseif ($this->field['datatype'] == 'cacc') {
         if (${$fn} = empty(${$fn}) ? 0 : max(0, intval(${$fn}))) {
             $arr = $this->field['length'] ? read_cache('coclasses', $this->field['length']) : read_cache('acatalogs');
             $this->searchstr = caccsql($fpre . $fn, $this->field['issearch'] == 1 ? array(${$fn}) : cnsonids(${$fn}, $arr), $this->field['max']);
             $this->filterstr = $fn . "=" . ${$fn};
         }
     } elseif ($this->field['datatype'] == 'map') {
         if (${$fn . 'diff'} = empty(${$fn . 'diff'}) ? 0 : abs(${$fn . 'diff'})) {
             $this->searchstr = mapsql(${$fn . '_0'}, ${$fn . '_1'}, ${$fn . 'diff'}, $this->field['issearch'], $fpre . $fn);
             $this->filterstr = $fn . '_0=' . ${$fn . '_0'} . '&' . $fn . '_1=' . ${$fn . '_1'} . '&' . $fn . 'diff=' . ${$fn . 'diff'};
         }
     } elseif (in_array($this->field['datatype'], array('int', 'float', 'date'))) {
         if ($this->field['issearch'] == '1') {
             ${$fn} = trim(${$fn});
             if ($this->field['datatype'] == 'date' && !isdate(${$fn}) || in_array($this->field['datatype'], array('int', 'float')) && !is_numeric(${$fn})) {
                 ${$fn} = '';
             }
             if (${$fn} != '') {
                 $this->field['datatype'] == 'int' && (${$fn} = intval(${$fn}));
                 $this->field['datatype'] == 'float' && (${$fn} = floatval(${$fn}));
                 $this->searchstr = $this->field['datatype'] == 'date' ? $fpre . $fn . "='" . strtotime(${$fn}) . "'" : $fpre . $fn . "='" . ${$fn} . "'";
                 $this->filterstr = $fn . "=" . rawurlencode(${$fn});
             }
         } else {
             ${$fn . 'from'} = trim(${$fn . 'from'});
             if ($this->field['datatype'] == 'date' && !isdate(${$fn . 'from'}) || in_array($this->field['datatype'], array('int', 'float')) && !is_numeric(${$fn . 'from'})) {
                 ${$fn . 'from'} = '';
             }
             if (${$fn . 'from'} != '') {
                 $this->field['datatype'] == 'int' && (${$fn . 'from'} = intval(${$fn . 'from'}));
                 $this->field['datatype'] == 'float' && (${$fn . 'from'} = floatval(${$fn . 'from'}));
                 $this->searchstr = $this->field['datatype'] == 'date' ? $fpre . $fn . ">='" . strtotime(${$fn . 'from'}) . "'" : $fpre . $fn . ">='" . ${$fn . 'from'} . "'";
                 $this->filterstr = $fn . "from=" . rawurlencode(${$fn . 'from'});
             }
             ${$fn . 'to'} = trim(${$fn . 'to'});
             if ($this->field['datatype'] == 'date' && !isdate(${$fn . 'to'}) || in_array($this->field['datatype'], array('int', 'float')) && !is_numeric(${$fn . 'to'})) {
                 ${$fn . 'to'} = '';
             }
             if (${$fn . 'to'} != '') {
                 $this->field['datatype'] == 'int' && (${$fn . 'to'} = intval(${$fn . 'to'}));
                 $this->field['datatype'] == 'float' && (${$fn . 'to'} = floatval(${$fn . 'to'}));
                 $this->searchstr .= ($this->searchstr ? " AND " : "") . $fpre . $fn . "<'" . ($this->field['datatype'] == 'date' ? strtotime(${$fn . 'to'}) : ${$fn . 'to'}) . "'";
                 $this->filterstr .= ($this->filterstr ? '&' : '') . $fn . "to=" . rawurlencode(${$fn . 'to'});
             }
         }
     }
     return;
 }
Esempio n. 4
0
function cn_statsum()
{
    //暂时不处理层的关系//需要更新缓存
    global $db, $tblprefix, $timestamp, $cotypestats, $cnodestatcircle, $cotypes, $subsites, $acatalogs;
    $cachetimefile = M_ROOT . './dynamic/stats/cotypesum_time.cac';
    if (empty($cotypestats) || $timestamp - @filemtime($cachetimefile) < $cnodestatcircle * 3600) {
        return;
    }
    $statarr = array_filter(explode(',', $cotypestats));
    if (!$statarr) {
        return;
    }
    @set_time_limit(1000);
    @ignore_user_abort(TRUE);
    load_cache('cotypes,acatalogs');
    if (in_array('ca', $statarr)) {
        $query = $db->query("SELECT caid,COUNT(aid) AS archives,SUM(clicks) AS clicks FROM {$tblprefix}archives GROUP BY caid");
        while ($item = $db->fetch_array($query)) {
            $db->query("UPDATE {$tblprefix}catalogs SET archives='{$item['archives']}',clicks='{$item['clicks']}' WHERE caid='{$item['caid']}'", 'UNBUFFERED');
        }
        foreach ($acatalogs as $k1 => $v1) {
            $ids = cnsonids($k1, $acatalogs);
            if (count($ids) > 1) {
                $row = $db->fetch_one("SELECT SUM(archives) AS archives,SUM(clicks) AS clicks FROM {$tblprefix}catalogs WHERE caid " . multi_str($ids));
                $db->query("UPDATE {$tblprefix}catalogs SET archives='{$row['archives']}',clicks='{$row['clicks']}' WHERE caid='{$k1}'", 'UNBUFFERED');
            }
        }
        $sids = array_keys($subsites);
        $sids[] = 0;
        foreach ($sids as $v) {
            updatecache('catalogs', '', $v);
        }
    }
    foreach ($cotypes as $k => $v) {
        if (!$v['self_reg'] && in_array($k, $statarr)) {
            $coclasses = read_cache('coclasses', $k);
            foreach ($coclasses as $k1 => $v1) {
                if ($cnsql = cnsql($k, $k1, '')) {
                    $row = $db->fetch_one("SELECT COUNT(aid) AS archives,SUM(clicks) AS clicks FROM {$tblprefix}archives WHERE {$cnsql}");
                    $db->query("UPDATE {$tblprefix}coclass SET archives='{$row['archives']}',clicks='{$row['clicks']}' WHERE ccid='{$k1}'", 'UNBUFFERED');
                }
            }
            foreach ($coclasses as $k1 => $v1) {
                $ids = cnsonids($k1, $coclasses);
                if (count($ids) > 1 && ($cnsql = cnsql($k, $ids, ''))) {
                    $row = $db->fetch_one("SELECT SUM(archives) AS archives,SUM(clicks) AS clicks FROM {$tblprefix}coclass WHERE {$cnsql}");
                    $db->query("UPDATE {$tblprefix}coclass SET archives='{$row['archives']}',clicks='{$row['clicks']}' WHERE ccid='{$k1}'", 'UNBUFFERED');
                }
            }
            updatecache('coclasses', $k);
        }
    }
    unset($coclasses);
    if (@($fp = fopen($cachetimefile, 'w'))) {
        fclose($fp);
    }
    return;
}
Esempio n. 5
0
if ($caid) {
    $_da['catalog'] = $catalogs[$caid]['title'];
    if ($cnsql = cnsql(0, cnsonids($caid, $catalogs), 'a.')) {
        $wherestr .= " AND {$cnsql}";
    }
    $filterstr .= ($filterstr ? '&' : '') . "caid={$caid}";
}
//分类因素
foreach ($cotypes as $k => $v) {
    ${"ccid{$k}"} = empty(${"ccid{$k}"}) ? 0 : max(0, intval(${"ccid{$k}"}));
    $_da["ccid{$k}"] = ${"ccid{$k}"};
    $_da['ccid' . $k . 'title'] = '';
    if (${"ccid{$k}"}) {
        $coclasses = read_cache('coclasses', $k);
        $_da['ccid' . $k . 'title'] = $coclasses[${"ccid{$k}"}]['title'];
        if ($cnsql = cnsql($k, cnsonids(${"ccid{$k}"}, $coclasses), 'a.')) {
            $wherestr .= " AND {$cnsql}";
        }
        $filterstr .= ($filterstr ? '&' : '') . "ccid{$k}=" . ${"ccid{$k}"};
    }
}
//处理indays多少天以内添加的
$indays = empty($indays) ? 0 : max(0, intval($indays));
$_da['indays'] = $indays;
if ($indays) {
    $wherestr .= " AND a.createdate>'" . ($timestamp - 86400 * $indays) . "'";
    $filterstr .= ($filterstr ? '&' : '') . "indays={$indays}";
}
//处理outdays多少天以前添加的
$outdays = empty($outdays) ? 0 : max(0, intval($outdays));
$_da['outdays'] = $outdays;
Esempio n. 6
0
 $keyword && ($wheresql .= " AND (a.mname LIKE '%" . str_replace(array(' ', '*'), '%', addcslashes($keyword, '%_')) . "%' OR a.subject LIKE '%" . str_replace(array(' ', '*'), '%', addcslashes($keyword, '%_')) . "%')");
 $indays && ($wheresql .= " AND a.createdate>'" . ($timestamp - 86400 * $indays) . "'");
 $outdays && ($wheresql .= " AND a.createdate<'" . ($timestamp - 86400 * $outdays) . "'");
 $filterstr = '';
 foreach (array('nauid', 'viewdetail', 'caid', 'chid', 'keyword', 'indays', 'outdays') as $k) {
     ${$k} && ($filterstr .= "&{$k}=" . rawurlencode(stripslashes(${$k})));
 }
 foreach (array('status') as $k) {
     ${$k} != -1 && ($filterstr .= "&{$k}=" . ${$k});
 }
 foreach ($cotypes as $coid => $cotype) {
     ${"ccid{$coid}"} = isset(${"ccid{$coid}"}) ? max(0, intval(${"ccid{$coid}"})) : 0;
     $ccids = array();
     if (!empty(${"ccid{$coid}"})) {
         $coclasses = read_cache('coclasses', $coid);
         $ccids = cnsonids(${"ccid{$coid}"}, $coclasses);
         if (!empty(${'u_ccids' . $coid})) {
             $ccids = array_intersect($ccids, ${'u_ccids' . $coid});
         }
     } elseif (!empty(${'u_ccids' . $coid})) {
         $ccids = ${'u_ccids' . $coid};
     }
     if (!empty($ccids)) {
         if ($cnsql = cnsql($coid, $ccids, 'a.')) {
             $wheresql .= " AND {$cnsql}";
         }
     } elseif (!empty(${"ccid{$coid}"}) || !empty(${'u_ccids' . $coid})) {
         $no_list = true;
     }
     ${"ccid{$coid}"} && ($filterstr .= "&ccid{$coid}=" . ${"ccid{$coid}"});
 }