Exemple #1
0
    }
} else {
    $items = $CAT['item'];
}
$pagesize = $MOD['pagesize'];
$showpage = 1;
$template = $CAT['template'] ? $CAT['template'] : 'list';
$total = max(ceil($items / $MOD['pagesize']), 1);
if (isset($fid) && isset($num)) {
    $page = $fid;
    $topage = $fid + $num - 1;
    $total = $topage < $total ? $topage : $total;
}
for (; $page <= $total; $page++) {
    $offset = ($page - 1) * $pagesize;
    $pages = listpages($CAT, $items, $page, $pagesize);
    $tags = $_tags = $ids = array();
    if ($items) {
        $result = $db->query("SELECT " . $MOD['fields'] . " FROM {$table} WHERE {$condition} ORDER BY " . $MOD['order'] . " LIMIT {$offset},{$pagesize}");
        while ($r = $db->fetch_array($result)) {
            if ($lazy && isset($r['thumb']) && $r['thumb']) {
                $r['thumb'] = DT_SKIN . 'image/lazy.gif" original="' . $r['thumb'];
            }
            $tags[] = $r;
        }
    }
    $seo_file = 'list';
    include DT_ROOT . '/include/seo.inc.php';
    $destoon_task = "moduleid={$moduleid}&html=list&catid={$catid}&page={$page}";
    if ($EXT['wap_enable']) {
        $head_mobile = $EXT['wap_url'] . 'index.php?moduleid=' . $moduleid . '&catid=' . $catid . ($page > 1 ? '&page=' . $page : '');
Exemple #2
0
 function get_list($condition = 'status=3', $order = 'edittime DESC', $cache = '')
 {
     global $MOD, $pages, $page, $pagesize, $offset, $items, $sum;
     if ($page > 1 && $sum) {
         $items = $sum;
     } else {
         $r = $this->db->get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE {$condition}", $cache);
         $items = $r['num'];
     }
     $pages = defined('CATID') ? listpages(1, CATID, $items, $page, $pagesize, 10, $MOD['linkurl']) : pages($items, $page, $pagesize);
     $lists = $catids = $CATS = array();
     $result = $this->db->query("SELECT * FROM {$this->table} WHERE {$condition} ORDER BY {$order} LIMIT {$offset},{$pagesize}", $cache);
     while ($r = $this->db->fetch_array($result)) {
         $r['adddate'] = timetodate($r['addtime'], 5);
         $r['editdate'] = timetodate($r['edittime'], 5);
         $r['alt'] = $r['title'];
         $r['title'] = set_style($r['title'], $r['style']);
         $r['linkurl'] = $MOD['linkurl'] . $r['linkurl'];
         $catids[$r['catid']] = $r['catid'];
         $lists[] = $r;
     }
     if ($catids) {
         $result = $this->db->query("SELECT catid,catname,linkurl FROM {$this->db->pre}category WHERE catid IN (" . implode(',', $catids) . ")");
         while ($r = $this->db->fetch_array($result)) {
             $CATS[$r['catid']] = $r;
         }
         if ($CATS) {
             foreach ($lists as $k => $v) {
                 $lists[$k]['catname'] = $v['catid'] ? $CATS[$v['catid']]['catname'] : '';
                 $lists[$k]['caturl'] = $v['catid'] ? $MOD['linkurl'] . $CATS[$v['catid']]['linkurl'] : '';
             }
         }
     }
     return $lists;
 }
Exemple #3
0
function tag($parameter, $expires = 0)
{
    global $DT, $CFG, $MODULE, $DT_TIME, $db;
    if ($expires > 0) {
        $tag_expires = $expires;
    } else {
        if ($expires == -2) {
            $tag_expires = $CFG['db_expires'];
        } else {
            if ($expires == -1) {
                $tag_expires = 0;
            } else {
                $tag_expires = $CFG['tag_expires'];
            }
        }
    }
    $tag_cache = false;
    $db_cache = $expires == -2 || defined('TOHTML') ? 'CACHE' : '';
    if ($tag_expires && $db_cache != 'CACHE' && strpos($parameter, '&page=') === false) {
        $tag_cache = true;
        $TCF = DT_CACHE . '/tag/' . md5($parameter) . '.htm';
        if (is_file($TCF) && $DT_TIME - filemtime($TCF) < $tag_expires) {
            echo substr(file_get($TCF), 17);
            return;
        }
    }
    $parameter = str_replace(array('&amp;', '%'), array('', '##'), $parameter);
    $parameter = strip_sql($parameter);
    parse_str($parameter, $par);
    if (!is_array($par)) {
        return '';
    }
    $par = dstripslashes($par);
    extract($par, EXTR_SKIP);
    isset($prefix) or $prefix = $db->pre;
    isset($moduleid) or $moduleid = 1;
    if (!isset($MODULE[$moduleid])) {
        return '';
    }
    isset($fields) or $fields = '*';
    isset($catid) or $catid = 0;
    isset($child) or $child = 1;
    isset($areaid) or $areaid = 0;
    isset($areachild) or $areachild = 1;
    isset($dir) && check_name($dir) or $dir = 'tag';
    isset($template) && check_name($template) or $template = 'list';
    isset($condition) or $condition = '1';
    isset($group) or $group = '';
    isset($page) or $page = 1;
    isset($offset) or $offset = 0;
    isset($pagesize) or $pagesize = 10;
    isset($order) or $order = '';
    isset($showpage) or $showpage = 0;
    isset($showcat) or $showcat = 0;
    isset($datetype) or $datetype = 0;
    isset($target) or $target = '';
    isset($class) or $class = '';
    isset($length) or $length = 0;
    isset($introduce) or $introduce = 0;
    isset($debug) or $debug = 0;
    isset($lazy) or $lazy = 0;
    isset($cols) && $cols or $cols = 1;
    if ($catid) {
        if ($moduleid > 4) {
            if (is_numeric($catid)) {
                $CAT = $db->get_one("SELECT child,arrchildid,moduleid FROM {$db->pre}category WHERE catid={$catid}");
                $condition .= $child && $CAT['child'] && $CAT['moduleid'] == $moduleid ? " AND catid IN (" . $CAT['arrchildid'] . ")" : " AND catid={$catid}";
            } else {
                if ($child) {
                    $catids = '';
                    $result = $db->query("SELECT arrchildid FROM {$db->pre}category WHERE catid IN ({$catid})");
                    while ($r = $db->fetch_array($result)) {
                        $catids .= ',' . $r['arrchildid'];
                    }
                    if ($catids) {
                        $catid = substr($catids, 1);
                    }
                }
                $condition .= " AND catid IN ({$catid})";
            }
        } else {
            if ($moduleid == 4) {
                $condition .= " AND catids LIKE '%,{$catid},%'";
            }
        }
    }
    if ($areaid) {
        if (is_numeric($areaid)) {
            $ARE = $db->get_one("SELECT child,arrchildid FROM {$db->pre}area WHERE areaid={$areaid}");
            $condition .= $areachild && $ARE['child'] ? " AND areaid IN (" . $ARE['arrchildid'] . ")" : " AND areaid={$areaid}";
        } else {
            if ($areachild) {
                $areaids = '';
                $result = $db->query("SELECT arrchildid FROM {$db->pre}area WHERE areaid IN ({$areaid})");
                while ($r = $db->fetch_array($result)) {
                    $areaids .= ',' . $r['arrchildid'];
                }
                if ($areaids) {
                    $areaid = substr($areaids, 1);
                }
            }
            $condition .= " AND areaid IN ({$areaid})";
        }
    }
    $table = isset($table) ? $prefix . $table : get_table($moduleid);
    $offset or $offset = ($page - 1) * $pagesize;
    $percent = dround(100 / $cols) . '%';
    $num = 0;
    $order = $order ? ' ORDER BY ' . $order : '';
    $condition = stripslashes($condition);
    $condition = str_replace('##', '%', $condition);
    if ($showpage) {
        $num = $db->count($table, $condition, $tag_expires ? $tag_expires : $CFG['db_expires']);
        $pages = $catid ? listpages(get_cat($catid), $num, $page, $pagesize) : pages($num, $page, $pagesize);
    } else {
        if ($group) {
            $condition .= ' GROUP BY ' . $group;
        }
    }
    if ($page < 2 && strpos($parameter, '&page=') !== false) {
        $db_cache = 'CACHE';
        $tag_expires = $CFG['tag_expires'];
    }
    if ($template == 'null') {
        $db_cache = 'CACHE';
    }
    $query = "SELECT " . $fields . " FROM " . $table . " WHERE " . $condition . $order . " LIMIT " . $offset . "," . $pagesize;
    if ($debug) {
        echo $parameter . '<br/>' . $query . '<br/>';
    }
    $tags = $catids = $CATS = array();
    $result = $db->query($query, $db_cache, $tag_expires);
    while ($r = $db->fetch_array($result)) {
        if ($moduleid == 4 && isset($r['company'])) {
            $r['alt'] = $r['companyname'] = $r['company'];
            if ($length) {
                $r['company'] = dsubstr($r['company'], $length);
            }
        }
        if (isset($r['title'])) {
            $r['title'] = str_replace('"', '&quot;', trim($r['title']));
            $r['alt'] = $r['title'];
            if ($length) {
                $r['title'] = dsubstr($r['title'], $length);
            }
            if (isset($r['style']) && $r['style']) {
                $r['title'] = set_style($r['title'], $r['style']);
            }
        }
        if ($lazy && isset($r['thumb']) && $r['thumb']) {
            $r['thumb'] = DT_SKIN . 'image/lazy.gif" class="lazy" original="' . $r['thumb'];
        }
        if (isset($r['introduce']) && $introduce) {
            $r['introduce'] = dsubstr($r['introduce'], $introduce);
        }
        if (isset($r['linkurl']) && $r['linkurl'] && $moduleid > 4 && strpos($r['linkurl'], '://') === false) {
            $r['linkurl'] = $MODULE[$moduleid]['linkurl'] . $r['linkurl'];
        }
        if ($showcat && $moduleid > 4 && isset($r['catid'])) {
            $catids[$r['catid']] = $r['catid'];
        }
        $tags[] = $r;
    }
    $db->free_result($result);
    if ($showcat && $moduleid > 4 && $catids) {
        $result = $db->query("SELECT catid,catname,linkurl FROM {$db->pre}category WHERE catid IN (" . implode(',', $catids) . ")");
        while ($r = $db->fetch_array($result)) {
            $CATS[$r['catid']] = $r;
        }
        if ($CATS) {
            foreach ($tags as $k => $v) {
                $tags[$k]['catname'] = $v['catid'] ? $CATS[$v['catid']]['catname'] : '';
                $tags[$k]['caturl'] = $v['catid'] ? $MODULE[$moduleid]['linkurl'] . $CATS[$v['catid']]['linkurl'] : '';
            }
        }
    }
    if ($template == 'null') {
        return $tags;
    }
    if ($tag_cache) {
        ob_start();
        include template($template, $dir);
        $contents = ob_get_contents();
        ob_clean();
        file_put($TCF, '<!--' . ($DT_TIME + $tag_expires) . '-->' . $contents);
        echo $contents;
    } else {
        include template($template, $dir);
    }
}
Exemple #4
0
            $items = $db->count($table, $condition, $CFG['db_expires']);
            if ($items != $GRP['post']) {
                $GRP['post'] = $items;
                $db->query("UPDATE {$table}_group SET post={$items} WHERE itemid={$catid}");
            }
        } else {
            $items = $GRP['post'];
        }
    }
}
$pagesize = $MOD['pagesize'];
$offset = ($page - 1) * $pagesize;
if ($typeid) {
    $pages = pages($items, $page, $pagesize);
} else {
    $pages = listpages(array('catid' => $GRP['itemid'], 'catdir' => $GRP['filepath'], 'catname' => $GRP['title'], 'linkurl' => $GRP['linkurl']), $items, $page, $pagesize);
}
$tags = array();
if ($typeid == 0 && $page == 1) {
    $result = $db->query("SELECT " . $MOD['fields'] . " FROM {$table} WHERE status=3 AND ontop=2 ORDER BY addtime DESC LIMIT " . $MOD['maxontop'], 'CACHE');
    while ($r = $db->fetch_array($result)) {
        $r['adddate'] = timetodate($r['addtime'], 5);
        $r['editdate'] = timetodate($r['edittime'], 5);
        if ($lazy && isset($r['thumb']) && $r['thumb']) {
            $r['thumb'] = DT_SKIN . 'image/lazy.gif" original="' . $r['thumb'];
        }
        $r['alt'] = $r['title'];
        $r['title'] = set_style($r['title'], $r['style']);
        $r['linkurl'] = $MOD['linkurl'] . $r['linkurl'];
        if (!$r['username']) {
            $r['username'] = '******';
Exemple #5
0
 function get_list($condition = 'status=3', $order = 'edittime DESC', $cache = '')
 {
     global $MOD, $pages, $page, $pagesize, $offset, $CATEGORY, $items, $sum;
     if ($page > 1 && $sum) {
         $items = $sum;
     } else {
         $r = $this->db->get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE {$condition}", $cache);
         $items = $r['num'];
     }
     $pages = defined('CATID') ? listpages(1, CATID, $items, $page, $pagesize, 10, $MOD['linkurl']) : pages($items, $page, $pagesize);
     $lists = array();
     $result = $this->db->query("SELECT * FROM {$this->table} WHERE {$condition} ORDER BY {$order} LIMIT {$offset},{$pagesize}", $cache);
     while ($r = $this->db->fetch_array($result)) {
         $r['alt'] = $r['title'];
         $r['title'] = set_style($r['title'], $r['style']);
         $r['linkurl'] = $MOD['linkurl'] . $r['linkurl'];
         $r['parentid'] = $CATEGORY[$r['catid']]['parentid'] ? $CATEGORY[$r['catid']]['parentid'] : $r['catid'];
         $lists[] = $r;
     }
     return $lists;
 }
 function listpages($subpages)
 {
     foreach ($subpages as $subpage) {
         echo '<div class="page"><div class="pagename">';
         echo '<span class="name">' . $subpage->title() . '</span>';
         if ($subpage->num() != "") {
             $number = $subpage->num();
         } else {
             $number = "–";
         }
         echo '<span class="number smallbox">' . $number . '</span>';
         echo '<span class="link smallbox active smalllink" data-link="' . $subpage->uri() . '"><i class="icon fa fa-link"></i></span>';
         if ($subpage->children()->count() > 0) {
             echo '<span class="slidedown active smallbox smalllink"><i class="icon fa fa-angle-down"></i></span>';
         } else {
             echo '<span class="slidedown smallbox smalllink">–</span>';
         }
         echo '</div><div class="subpages d' . $subpage->depth() . '" style="background-color: rgba(0,0,0,' . $subpage->depth() / 25 . ')">';
         if ($subpage->children()->count() > 0) {
             listpages($subpages = $subpage->children());
         }
         echo '</div></div>';
     }
 }