Ejemplo n.º 1
0
function typeList($cacheDir)
{
    if (is_file($cacheDir)) {
        //缓存文件存在
        //判断是否过期
        $dir = fopen($cacheDir, "r+");
        $birthTime = fgets($dir);
        //读取完后指针停留在第二行开头
        $now = time();
        if ($now - $birthTime > 30 * 24 * 3600) {
            rewind($dir);
            //让指针回到头部
            $content = getCatList();
            $content = $birthTime . "\r\n\t\t\t\t                    " . $content;
            $re = fwrite($dir, $content);
            fclose($dir);
            return str_replace("birthTime", "", $content);
        } else {
            $content = fread($dir, filesize($cacheDir));
            fclose($dir);
            return $content;
        }
    } else {
        //缓存文件不存在
        //生成缓存文件
        $content = getCatList();
        //调用函数得到分类字符串
        $birthTime = time();
        //获取缓存文件的生成时间
        $content = $birthTime . "\r\n\t\t\t\t   " . $content;
        //”\r“是文本的换行符,拼接成字符串
        $dir = fopen($cacheDir, "w");
        $re = fwrite($dir, $content);
        //成功返回写入字符数,失败返回false
        fclose($dir);
        return str_replace("{$birthTime}", "", $content);
    }
}
Ejemplo n.º 2
0
    foreach ($sel_org as $value) {
        $sel[] = $value['orgid'];
    }
    if (in_array('other', $orgids)) {
        $sel[] = 'other';
        $sel_org[] = array('orgname' => '无机构人员', 'orgid' => 'other', 'forgid' => 1);
    }
}
if ($news['uids']) {
    $uids = explode(',', $news['uids']);
    $sel_user = C::t('user')->fetch_all($uids);
    foreach ($sel_user as $value) {
        $sel[] = 'uid_' . $value['uid'];
    }
}
if ($news['type'] == 1) {
    //图片内容时,获取图片数组
    $pics = C::t('news_pic')->fetch_all_by_newid($newid);
}
$catlist = getCatList();
//更新查阅
C::t('news')->increase($newid, array('views' => 1));
if ($_G['uid']) {
    if ($vid = DB::result_first("select vid from %t where newid=%d and uid=%d", array('news_viewer', $newid, $_G['uid']))) {
        DB::query("update %t SET views=views+1 where vid=%d", array('news_viewer', $vid));
    } else {
        $addviewer = array('newid' => $newid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => TIMESTAMP);
        C::t('news_viewer')->insert($addviewer);
    }
}
include template('news_view');
Ejemplo n.º 3
0
    function print_post()
    {
        echo '<h1>
	<a href="' . HTTP_SERVER . $this->post_link . '.html">' . html_entity_decode($this->post_h1) . '</a>
</h1>
<h3>
	posted by
	<a href="' . HTTP_SERVER . 'about-me.html">' . AUTHOR . '</a>
	under ' . getCatList($this->cats) . ' on ' . format_date($this->post_created) . '

</h3>
<p class="desc">
	' . html_entity_decode($this->post_h2) . '
</p>
' . $this->post_ps . '
<div class="updates">
	<p>
	This post has been updated from its original form on ' . format_date($this->post_modified) . '- originally posted on ' . format_date($this->post_created) . '.
	</p>
</div>
<div class="postfoot">
	<p>
		Tagged under: ' . getTagList($this->tags) . '
	</p>
</div>
<div class="postfoot">
	<p>
		' . $this->comments . ' Comments
	</p>
</div>';
    }
Ejemplo n.º 4
0
?>
<div id="newquiz" style="margin-top: 50px;">
  <form action="<?php 
echo "functions.php?action=addcat";
?>
" method="post" id="profile_edit">
	<fieldset id="category">
		<legend>Category</legend>
		<ul>
            <li><div class="cat_ajax_status" id="cat_ajax_status" >Click Add to Add new Category / Edit to edit selected category</div></li>
			<li>
				<label for="category"><span class="required">Categories</span></label>
				<select name="category" id="cat_list">
                    <option value="" class="inactive" selected="selected" > -- </option>
                    <?php 
echo getCatList($db, $_SESSION['UA_DETAILS']['randid'], $_SESSION['UA_DETAILS']['level']);
?>
                </select>
            </li>
            <li>
            <label ><span class="required">Select Action</span></label>
                <div class="spl_button">
                     <a id="cat_add" href="#Action">Add</a>
                </div>
                <div class="spl_button">
                     <a id="cat_edit" href="#Action">Edit</a>
                </div>
                <div class="spl_button">
                     <a id="cat_del" href="#Action">Del</a>
                </div>
			</li>
Ejemplo n.º 5
0
     default:
         fatal_error("Invalid sort direction passed");
         break;
 }
 // Tell the template we need the sort box at the top
 $context['shop_inv']['sort'] = true;
 // Are we only displaying a certain category?
 if (isset($_GET['cat']) && $_GET['cat'] != -1) {
     $context['shop_inv']['category'] = (int) $_GET['cat'];
     $catClause = 'WHERE category = ' . $context['shop_inv']['category'];
 } else {
     $context['shop_inv']['category'] = -1;
     $catClause = '';
 }
 // List of all categories
 $context['shop_inv']['categories'] = getCatList();
 // Get the number of items available
 $context['shop_inv']['item_count'] = mysql_result(db_query("\n\t\tSELECT COUNT(id)\n\t\tFROM {$db_prefix}shop_items\n\t\t{$catClause}", __FILE__, __LINE__), 0);
 // If the page is not set, assume page 1
 if (!isset($_GET['page'])) {
     $_GET['page'] = 1;
 }
 // If items per page not set, assume 15
 if (!isset($modSettings['shopItemsPerPage'])) {
     $modSettings['shopItemsPerPage'] = 15;
 }
 // The page count - Total number of items divided by number per page
 $context['shop_inv']['pages']['total'] = ceil($context['shop_inv']['item_count'] / $modSettings['shopItemsPerPage']);
 // First item
 $firstItem = $_GET['page'] * $modSettings['shopItemsPerPage'] - $modSettings['shopItemsPerPage'];
 // Start with empty items array
Ejemplo n.º 6
0
function ShopCategories()
{
    global $smcFunc, $txt, $context, $db_prefix, $sourcedir;
    // We need the subs!
    require_once $sourcedir . '/shop/Shop-Subs.php';
    // Are we adding a new category?
    if (isset($_GET['do']) && $_GET['do'] == 'add') {
        // Make sure a value was set
        if (!isset($_POST['cat_name']) || $_POST['cat_name'] == '') {
            fatal_lang_error($txt['shop_enter_cat_name']);
        }
        // Insert the database entry
        $smcFunc['db_insert']('insert', '{db_prefix}shop_categories', array('name' => 'string', 'count' => 'int'), array('name' => $_POST['cat_name'], 'count' => 0), array());
        $context['shop_cat_message'] = $txt['shop_added_cat'];
    } elseif (isset($_GET['do']) && $_GET['do'] == 'del') {
        // Delete it!
        $smcFunc['db_query']('', '
			DELETE FROM {db_prefix}shop_categories
			WHERE ID = {int:id}', array('id' => $_GET['id']));
        // Tell the user
        $context['shop_cat_message'] = sprintf($txt['shop_deleted_cat'], $_GET['id']);
    }
    // Get a list of all the categories
    $context['shop_cats'] = getCatList();
    // We're using the "categories" template
    $context['sub_template'] = 'categories';
    $context['page_title'] = $txt['shop'] . ' - ' . $txt['shop_admin_cat'];
    // Load the actual template
    loadTemplate('ShopAdmin');
}
Ejemplo n.º 7
0
function getCatList($catid = 0, $scatid = 0)
{
    $html = '<ul class="nav nav-pills nav-stacked nav-zstacked" role="tablist" >';
    foreach (C::t('news_cat')->fetch_all_by_pid($catid) as $value) {
        $html .= '<li id="cat_' . $value['catid'] . '" data-catid="' . $value['catid'] . '" data-pid="' . $value['pid'] . '" role="presentation" ' . ($value['catid'] == $scatid ? 'class="active"' : '') . '><a href="' . DZZSCRIPT . '?mod=news&catid=' . $value['catid'] . '"><span class="catname">' . $value['name'] . '</span><span class="cat-ctrl js-popbox" data-href="catmenu&catid=' . $value['catid'] . '"  data-placement="right" data-auto-adapt="true"><i class="glyphicon glyphicon-chevron-right"></i></span></a>';
        $html .= getCatList($value['catid'], $scatid);
        $html .= '</li>';
    }
    $html .= '</ul>';
    return $html;
}
Ejemplo n.º 8
0
function ShopCategories()
{
    global $txt, $context, $db_prefix, $sourcedir;
    adminIndex('shop_cat');
    // We need the subs!
    require_once $sourcedir . '/shop/Shop-Subs.php';
    // Are we adding a new category?
    if (isset($_GET['do']) && $_GET['do'] == 'add') {
        // Make sure a value was set
        if (!isset($_POST['cat_name']) || $_POST['cat_name'] == '') {
            fatal_lang_error($txt['shop_enter_cat_name']);
        }
        // Insert the database entry
        db_query("\n\t\t\tINSERT INTO {$db_prefix}shop_categories\n\t\t\t\t(name, count)\n\t\t\tVALUES\n\t\t\t\t('{$_POST['cat_name']}', 0)", __FILE__, __LINE__);
        $context['shop_cat_message'] = $txt['shop_added_cat'];
    } elseif (isset($_GET['do']) && $_GET['do'] == 'del') {
        // Make sure ID is numeric
        $_GET['id'] = (int) $_GET['id'];
        // Delete it!
        db_query("DELETE FROM {$db_prefix}shop_categories WHERE ID = {$_GET['id']}", __FILE__, __LINE__);
        // Tell the user
        $context['shop_cat_message'] = sprintf($txt['shop_deleted_cat'], $_GET['id']);
    }
    // Get a list of all the categories
    $context['shop_cats'] = getCatList();
    // We're using the "categories" template
    $context['sub_template'] = 'categories';
    $context['page_title'] = $txt['shop'] . ' - ' . $txt['shop_admin_cat'];
    // Load the actual template
    loadTemplate('ShopAdmin');
}
Ejemplo n.º 9
0
    foreach (DB::fetch_all("select n.*,v.vid as isread from %t  n LEFT JOIN %t v ON n.newid=v.newid and v.uid=%d where {$sql} {$orderby} limit {$start},{$perpage}", $param) as $value) {
        $today = strtotime(dgmdate(TIMESTAMP, 'Y-m-d'));
        if ($value['topendtime'] < $today) {
            if ($value['istop']) {
                $updatearr[] = $value['newid'];
            }
            $value['istop'] = 0;
        }
        if ($value['highlightendtime'] < $today) {
            $value['ishighlight'] = 0;
        }
        if ($value['opuid'] && ($opuser = getuserbyuid($value['opuid']))) {
            $value['opauthor'] = $opuser['username'];
        }
        if ($status == 2 && $value['moduid'] && ($moduser = getuserbyuid($value['moduid']))) {
            $value['modusername'] = $moduser['username'];
        }
        $data[] = $value;
    }
    $multi = multi($count, $perpage, $page, $theurl, 'pull-right');
}
if ($topupdate) {
    //置顶时间过期的,设置istop=0
    DB::update('news', array('istop' => 0), "newid IN (" . dimplode($topupdate) . ")");
}
$catlist = getCatList(0, $catid);
//if($ismobile){
//	include template('news_list_mobile');
//}else{
include template('news_list');
//}
Ejemplo n.º 10
0
<?php

if ($posts->post_posts) {
    while ($row = mysql_fetch_assoc($posts->post_posts)) {
        $post = new Post($row['post_id'], 'id');
        ?>
<h1><a href="<?php 
        echo HTTP_SERVER . $post->post_link;
        ?>
.html"><?php 
        echo html_entity_decode($post->post_h1);
        ?>
</a></h1>
<h3>posted by <a href="#">anonynous anon</a> under <?php 
        echo getCatList($post->cats);
        ?>
 on 13th August 2006</h3>
<p class="desc"><?php 
        echo html_entity_decode($post->post_h2);
        ?>
</p>
<?php 
        echo $post->post_ps;
        ?>
<div class="postfoot">
    <p> Tagged under: <?php 
        echo getTagList($post->tags);
        ?>
 </p>
</div>
<div class="postfoot">