Exemplo n.º 1
0
 public function __construct($id)
 {
     // Проверяем нет ли такой страницы в кэше
     if ($this->isCached($this->id($id))) {
         // Есть, инициализируем объект содержимым кэша
         parent::__construct($this->title(), $this->content());
     } else {
         // Данные пока не кэшированы, извлекаем
         // содержимое из базы данных
         // $query = "SELECT * FROM static_pages WHERE id = :id LIMIT 1"
         // $sth = $dbh->prepare($query);
         // $sth = $dbh->execute($query, [$id]);
         // $page = $sth->fetch(PDO::FETCH_ASSOC);
         // parent::__construct($page['title'], $page['title']);
         parent::__construct("Контакты", "Содержимое страницы Контакты");
     }
 }
Exemplo n.º 2
0
            $func = 'system-group-del';
            System::check_func($func, FALSE);
            //删除数据
            $sql = "DELETE FROM `sys:group` WHERE id=" . $id;
            System::$db->execute($sql);
            if (System::$db->getAffectedRows()) {
                $_G['project']['message'] = "成功删除用户组!";
                //写入日志
                System::insert_event($func, time(), time(), "删除用户组:" . $_CACHE['system']['group'][$id]["name"]);
            } else {
                $_G['project']['message'] = "未找到指定用户组!";
            }
            break;
    }
    //缓存系统用户组
    Cached::table('system', 'sys:group', array('jsonde' => array('config'), 'serialize' => array('module', 'widget')));
}
//search
$s = getgpc("s");
$q = getgpc('q');
?>
		
	
    <div id="search">
        <form name="form1" method="get" action="?">
            <span class="action">
            	<?php 
if (System::check_func('system-group-add')) {
    ?>
                	<button type="button" class="button" onclick="location.href='group.edit.php';">添加分组</button>
                <?php 
Exemplo n.º 3
0
print "<table class='lista' border='0' width='100%' cellspacing='1' cellpadding='5'>\n";
print "<tr><td class='header' align='center'>" . FORUM . "</td><td class='header' align='center' width='15%'>" . TOPICS . "</td>" . "<td class='header' align='center' width='15%'>" . POSTS . "</td>" . "<td class='header' align='center' width='15%'>" . LASTPOST . "</td></tr>\n";
if ($forums_res->num_rows == 0) {
    print "<tr><td class='lista' colspan='4' align='center'>" . NO_FORUMS . "</td></tr>";
}
while ($forums_arr = $forums_res->fetch_assoc()) {
    if (user::$current["id_level"] < $forums_arr["minclassread"]) {
        continue;
    }
    $forumid = (int) $forums_arr["id"];
    $forumname = security::html_safe(unesc($forums_arr["name"]));
    $forumdescription = security::html_safe(unesc($forums_arr["description"]));
    $topiccount = number_format((int) $forums_arr["topiccount"]);
    $postcount = number_format((int) $forums_arr["postcount"]);
    // Find last post ID
    $lastpostid = Cached::get_forum_last_post($forumid);
    // Get last post info
    $post_res = $db->query("SELECT added, topicid, userid FROM posts WHERE id = " . $lastpostid) or sqlerr(__FILE__, __LINE__);
    if ($post_res->num_rows == 1) {
        $post_arr = $post_res->fetch_assoc() or die(ERR_BAD_LAST_POST);
        $lastposterid = (int) $post_arr["userid"];
        $lastpostdate = get_date_time($post_arr["added"]);
        $lasttopicid = (int) $post_arr["topicid"];
        $user_res = $db->query("SELECT username FROM users WHERE id = " . $lastposterid) or sqlerr(__FILE__, __LINE__);
        $user_arr = $user_res->fetch_assoc();
        $lastposter = security::html_safe($user_arr['username']);
        $topic_res = $db->query("SELECT subject FROM topics WHERE id = " . $lasttopicid) or sqlerr(__FILE__, __LINE__);
        $topic_arr = $topic_res->fetch_assoc();
        $lasttopic = security::html_safe(unesc($topic_arr['subject']));
        //---- Get reply count
        $postsperpage = user::$current["postsperpage"] > 0 ? user::$current["postsperpage"] : 15;
Exemplo n.º 4
0
            System::insert_event($func, time(), time(), "修改用户密码:" . $_CACHE['system']['admin'][$id]["name"]);
        }
        //更改权限
        if ($gid) {
            $func = 'system-account-gid';
            System::check_func($func, FALSE);
            $sql = "UPDATE `sys:admin` SET gid='" . $gid . "' WHERE id=" . $id;
            System::$db->execute($sql);
            //写入日志
            System::insert_event($func, time(), time(), "变更用户组:" . $_CACHE['system']['admin'][$id]["name"]);
        }
        $_G['manager']['id'] == $id && System::admin_update('avatar', $avatar);
        //写入日志
        System::insert_event($func, time(), time(), "修改用户资料:" . $_CACHE['system']['admin'][$id]["name"]);
        //缓存系统用户
        Cached::table('system', 'sys:admin', array('jsonde' => array('config', 'extra')));
        System::redirect($jump ? $jump : "?id=" . $id . "&action=edit", "成功修改用户信息!");
        break;
    case "edit":
        $sql = "SELECT * FROM `sys:admin` WHERE id=" . $id;
        $row = System::$db->getOne($sql);
        $extra = fix_json($row['extra']);
        break;
}
//关闭数据库
System::connect();
/*
安全问题
<select name="question" onchange="showcustomquest(this.value)" style="width:124px">
	<option value="0">无安全问题</option>
	<option value="1">我爸爸的出生地</option>
Exemplo n.º 5
0
<?php

/*
* BtiTracker v1.5.1 is a php tracker system for BitTorrent, easy to setup and configure.
* This tracker is a frontend for DeHackEd's tracker, aka phpBTTracker (now heavely modified). 
* Updated and Maintained by Yupy.
* Copyright (C) 2004-2015 Btiteam.org
*/
global $db, $user;
if (!user::$current || user::$current["id"] == 1) {
    #Do nothing
} else {
    block_begin(BLOCK_USER);
    // user information
    $style = Cached::style_list();
    $langue = Cached::language_list();
    print "\n<tr><td align='center' class='blocklist'>" . USER_NAME . ": " . unesc(user::$current["username"]) . "</td></tr>\n";
    print "<tr><td align='center' class='blocklist'>" . USER_LEVEL . ": " . security::html_safe(user::$current["level"]) . "</td></tr>\n";
    $resmail = $db->query("SELECT COUNT(*) FROM messages WHERE readed = 'no' AND receiver = " . user::$current['uid']);
    if ($resmail && $resmail->num_rows > 0) {
        $mail = $resmail->fetch_row();
        if ($mail[0] > 0) {
            print "<td class='blocklist' align='center'><a href='usercp.php?uid=" . user::$current["uid"] . "&do=pm&action=list'>" . MAILBOX . "</a> (<font color='#FF0000'><b>" . (int) $mail[0] . "</b></font>)</td>\n";
        } else {
            print "<td class='blocklist' align='center'><a href='usercp.php?uid=" . user::$current["uid"] . "&do=pm&action=list'>" . MAILBOX . "</a></td>\n";
        }
    } else {
        print "<tr><td align='center'>" . NO_MAIL . "</td></tr>";
    }
    print "<tr><td align='center' class='blocklist'>";
    include INCL_PATH . 'offset.php';
Exemplo n.º 6
0
         print $option;
     }
     print "</select></td>\n</tr>";
     $fres = Cached::flag_list();
     print "<tr>\n\t<td align='left' class='header'>" . PEER_COUNTRY . ":</td>";
     print "\n\t<td align='left' class='lista' colspan='2'><select name='flag'>\n<option value='0'>---</option>";
     foreach ($fres as $flag) {
         $option = "\n<option ";
         if ($flag["id"] == user::$current["flag"]) {
             $option .= "selected='selected' ";
         }
         $option .= "value='" . (int) $flag["id"] . "'>" . security::html_safe(unesc($flag["name"])) . "</option>";
         print $option;
     }
     print "</select></td>\n</tr>";
     $tres = Cached::timezone_list();
     print "<tr>\n\t<td align='left' class='header'>" . TIMEZONE . ":</td>";
     print "\n\t<td align='left' class='lista' colspan='2'><select name='timezone'>";
     foreach ($tres as $timezone) {
         $option = "\n<option ";
         if ($timezone["difference"] == user::$current["time_offset"]) {
             $option .= "selected=selected ";
         }
         $option .= "value=" . unesc($timezone["difference"]) . ">" . security::html_safe(unesc($timezone["timezone"])) . "</option>";
         print $option;
     }
     print "</select></td>\n</tr>";
     if ($FORUMLINK == "" || $FORUMLINK == "internal") {
         // topics per page
         ?>
 <tr>
Exemplo n.º 7
0
function userlogin()
{
    global $db, $tpl;
    unset($GLOBALS['CURUSER']);
    require_once CLASS_PATH . 'class.Cached.php';
    $ip = vars::$ip;
    $nip = ip2long($ip);
    $ipf = vars::$realip;
    #Check if User is Banned...
    #if (!($row['flags'] & BIT_26)) -- TO-DO
    #$banned = false;
    if (Cached::bans($ip, $reason)) {
        $banned = true;
    } else {
        if ($ip != $ipf) {
            if (Cached::bans($ipf, $reason)) {
                $banned = true;
            }
        }
    }
    if ($banned) {
        header('Content-Type: text/html; charset=utf-8');
        $banned_message = security::html_safe($reason);
        $tpl->assign('banned_message', $banned_message);
        $banned_msg = $tpl->draw('style/base/tpl/banned_message', $return_string = true);
        echo $banned_msg;
        die;
    }
    #End Banned User...
    // guest
    if (empty($_COOKIE["uid"]) || empty($_COOKIE["pass"])) {
        $id = 1;
    }
    if (!isset($_COOKIE["uid"]) && _string::is_hex($_COOKIE["uid"])) {
        $_COOKIE["uid"] = 1;
    }
    $id = max(1, (int) $_COOKIE["uid"]);
    // it's guest
    if (!$id) {
        $id = 1;
    }
    $res = $db->query("SELECT users.pid, users.topicsperpage, users.postsperpage, users.torrentsperpage, users.flag, users.avatar, UNIX_TIMESTAMP(users.lastconnect) AS lastconnect, UNIX_TIMESTAMP(users.joined) AS joined, users.id AS uid, users.username, users.password, users.loginhash, users.random, users.email, users.language, users.style, users.time_offset, users_level.* \n\t    FROM users INNER JOIN users_level ON users.id_level = users_level.id \n\t\tWHERE users.id = " . $id);
    $row = $res->fetch_array(MYSQLI_BOTH);
    user::prepare_user($row);
    if (!$row) {
        $id = 1;
        $res = $db->query("SELECT users.topicsperpage, users.postsperpage, users.torrentsperpage, users.flag, users.avatar, UNIX_TIMESTAMP(users.lastconnect) AS lastconnect, UNIX_TIMESTAMP(users.joined) AS joined, users.id AS uid, users.username, users.password, users.loginhash, users.random, users.email, users.language, users.style, users.time_offset, users_level.* \n\t\t    FROM users INNER JOIN users_level ON users.id_level = users_level.id WHERE users.id = 1");
        $row = $res->fetch_array(MYSQLI_BOTH);
    }
    if (!isset($_COOKIE["pass"])) {
        $_COOKIE["pass"] = "";
    }
    if ($_COOKIE["pass"] != md5($GLOBALS["salting"] . $row["random"] . $row["password"] . $row["random"]) && $id != 1) {
        $id = 1;
        $res = $db->query("SELECT users.topicsperpage, users.postsperpage, users.torrentsperpage, users.flag, users.avatar, UNIX_TIMESTAMP(users.lastconnect) AS lastconnect, UNIX_TIMESTAMP(users.joined) AS joined, users.id AS uid, users.username, users.password, users.loginhash, users.random, users.email, users.language, users.style, users.time_offset, users_level.* \n\t\t    FROM users INNER JOIN users_level ON users.id_level = users_level.id \n\t\t\tWHERE users.id = 1");
        $row = $res->fetch_array(MYSQLI_BOTH);
    }
    #Hide Staff IP's by Yupy...
    $hide_ips = array("Moderator" => 6, "Administrator" => 7, "Owner" => 8);
    // Staff ID level's
    $ip = $row["id_level"] != $hide_ips["Moderator"] ? $ip : "127.0.0.1";
    $ip = $row["id_level"] != $hide_ips["Administrator"] ? $ip : "127.0.0.1";
    $ip = $row["id_level"] != $hide_ips["Owner"] ? $ip : "127.0.0.1";
    if ($id > 1) {
        $db->query("UPDATE users SET lastconnect = NOW(), lip = " . $nip . ", cip = '" . AddSlashes($ip) . "' WHERE id = " . $id);
    } else {
        $db->query("UPDATE users SET lastconnect = NOW(), lip = 0, cip = NULL WHERE id = 1");
    }
    user::$current = $row;
    $GLOBALS['CURUSER'] =& user::$current;
    unset($row);
}
Exemplo n.º 8
0
     $id = intval($_GET["id"]);
     if ($id != $DEFAULT_LANGUAGE) {
         $rlang = $db->query("SELECT * FROM language WHERE id = " . $id);
         $reslang = $rlang->fetch_array(MYSQLI_BOTH);
         $lang = $reslang["language_url"];
         if (unlink($lang)) {
             $db->query("UPDATE users SET language = " . $DEFAULT_LANGUAGE . " WHERE language = " . $id);
             $db->query("DELETE FROM language WHERE id = " . $id);
             MCached::del('language::list');
         } else {
             err_msg(ERROR, DELFAILED);
         }
     }
     redirect("admincp.php?user="******"uid"] . "&code=" . user::$current["random"] . "&do=language&action=read");
 } elseif ($do == "style" && $action == "read") {
     $cat = Cached::style_list();
     block_begin(STYLE_SETTINGS);
     print "<br />&nbsp;&nbsp;<a href='admincp.php?user="******"uid"] . "&code=" . user::$current["random"] . "&do=style&action=add'><img alt='" . INSERT_NEW_STYLE . "' border='0' src='images/new.gif'></a>\n";
     print "<br /><br />\n<table class='lista' width='100%' align='center'>\n";
     print "<tr>\n";
     print "<td class='header' align='center'>" . STYLE_NAME . "</td>\n";
     print "<td class='header' align='center'>" . STYLE_URL . "</td>\n";
     print "<td class='header' align='center'>" . MEMBERS . "</td>\n";
     print "<td class='header' align='center'>" . EDIT . "</td>\n";
     print "<td class='header' align='center'>" . DELETE . "</td>\n";
     print "</tr>\n";
     foreach ($cat as $category) {
         $res = $db->query("SELECT * FROM users WHERE style = " . (int) $category["id"]);
         $total_users = intval(0 + @$res->num_rows);
         print "<tr>\n";
         print "<td class='lista' align='center'>" . security::html_safe(unesc($category["style"])) . "</td>\n";
Exemplo n.º 9
0
<?php

namespace com\github\gooh\CVBacklog;

$appRoot = function ($path) {
    return realpath(__DIR__ . '/../..' . $path);
};
ini_set('log_errors', 1);
ini_set('error_log', $appRoot('/error.log'));
ini_set('display_errors', isset($_GET['debug']));
ini_set('display_startup_errors', isset($_GET['debug']));
ini_set('arg_separator.output', '&');
ini_set('zlib.output_compression', 1);
stream_context_set_default(array('http' => array('ignore_errors' => true, 'user_agent' => 'CV-Backlog (+https://github.com/gooh/CVBacklog)')));
require $appRoot('/autoload.inc.php');
$backlog = new Cached(new Backlog(new Crawler(new Webpage()), new Client(new Questions())), realpath(__DIR__ . '/../cache'));
$backlog->defineCachingForMethod('findAll', 3600);
$controller = new BacklogController($backlog, new Url('http://cvbacklog.herokuapp.com'));
echo $controller->handleRequest();
Exemplo n.º 10
0
/**
 * 存储/获取缓存
 * @param string $key 缓存名称
 * @param mixed $value 向缓存赋值
 * @param int $lifetime 生存时间,秒,如一小时是3600
 * @return boolean
 */
function cache($key, $value = null, $lifetime = 3600)
{
    $cache = new Cached();
    if ($value === '') {
        return $cache->delete($key);
    }
    if ($value === null) {
        return $cache->get($key);
    }
    return $cache->set($key, $value, $lifetime);
}
Exemplo n.º 11
0
function tabella($action, $dati = array())
{
    global $idflag, $link, $idlangue, $idstyle, $db, $USE_IMAGECODE;
    ?>
    <center>
    <p>
	
    <form name="utente" method="post" OnSubmit="return FormControl('<?php 
    echo $action;
    ?>
')" action="<?php 
    echo security::esc_url($_SERVER['PHP_SELF']) . "?act=" . $action . "&returnto=" . urlencode($link);
    ?>
">
    <input type="hidden" name="act" value="<?php 
    echo $action;
    ?>
" />
    <input type="hidden" name="uid" value="<?php 
    echo (int) $dati["id"];
    ?>
" />
    <input type="hidden" name="returnto" value="<?php 
    echo urlencode($link);
    ?>
 "/>
    <input type="hidden" name="language" value="<?php 
    echo $idlangue;
    ?>
 "/>
    <input type="hidden" name="style" value="<?php 
    echo $idstyle;
    ?>
 "/>
    <input type="hidden" name="flag" value="<?php 
    echo $idflag;
    ?>
 "/>
    <input type="hidden" name="username" value="<?php 
    echo security::html_safe($dati["username"]);
    ?>
"/>
    <table width="60%" border="0" class="lista">
    <tr>
    <td align="left" class="header"><?php 
    echo USER_NAME;
    ?>
: </td>
    <td align="left" class="lista">
    <?php 
    if ($action == "mod" || $action == "del") {
        print "\n<input type='text' size='40' name='user' value='" . security::html_safe(unesc($dati['username'])) . "' " . ($action == "mod" ? "" : "readonly") . " />";
    } else {
        print "\n<input type='text' size='40' name='user' />";
    }
    ?>
    </td>
    </tr>
    <?php 
    if (user::$current["uid"] == $dati["id"] && $action == "mod" || $action == "signup" || user::$current["edit_users"] == "yes" && $action == "mod") {
        ?>
    <tr>
    <td align="left" class="header"><?php 
        echo USER_PWD;
        ?>
:</td>
    <td align="left" class="lista"><input type="password" size="40" name="pwd" /></td>
    </tr>
    <tr>
    <td align="left" class="header"><?php 
        echo USER_PWD_AGAIN;
        ?>
:</td>
    <td align="left" class="lista"><input type="password" size="40" name="pwd1" /></td>
    </tr>
    <tr>
    <td align="left" class="header"><?php 
        echo USER_EMAIL;
        ?>
:</td>
    <td align="left" class="lista"><input type="text" size="30" name="email" value="<?php 
        if ($action == "mod") {
            echo security::html_safe($dati['email']);
        }
        ?>
"/></td>
    </tr>
    <?php 
        $lres = Cached::language_list();
        print "<tr>\n\t<td align='left' class='header'>" . USER_LANGUE . ":</td>";
        print "\n\t<td align='left' class='lista'><select name='language'>";
        foreach ($lres as $langue) {
            $option = "\n<option ";
            if ($langue["id"] == $dati["language"]) {
                $option .= "selected='selected' ";
            }
            $option .= "value='" . (int) $langue["id"] . "'>" . security::html_safe($langue["language"]) . "</option>";
            print $option;
        }
        print "</select></td>\n</tr>";
        $sres = Cached::style_list();
        print "<tr>\n\t<td align='left' class='header'>" . USER_STYLE . ":</td>";
        print "\n\t<td align='left' class='lista'><select name='style'>";
        foreach ($sres as $style) {
            $option = "\n<option ";
            if ($style["id"] == $dati["style"]) {
                $option .= "selected='selected' ";
            }
            $option .= "value='" . (int) $style["id"] . "'>" . security::html_safe($style["style"]) . "</option>";
            print $option;
        }
        print "</select></td>\n</tr>";
        $fres = Cached::flag_list();
        print "<tr>\n\t<td align='left' class='header'>" . PEER_COUNTRY . ":</td>";
        print "\n\t<td align='left' class='lista'><select name='flag'>\n<option value='0'>---</option>";
        $thisip = vars::$realip;
        $remotedns = gethostbyaddr($thisip);
        if ($remotedns != $thisip) {
            $remotedns = utf8::strtoupper($remotedns);
            preg_match('/^(.+)\\.([A-Z]{2,3})$/', $remotedns, $tldm);
            if (isset($tldm[2])) {
                $remotedns = $db->real_escape_string($tldm[2]);
            }
        }
        foreach ($fres as $flag) {
            $option = "\n<option ";
            if ($flag["id"] == $dati["flag"] || $flag["domain"] == $remotedns && $action == "signup") {
                $option .= "selected='selected' ";
            }
            $option .= "value='" . (int) $flag["id"] . "'>" . security::html_safe($flag["name"]) . "</option>";
            print $option;
        }
        print "</select></td>\n</tr>";
        $zone = date('Z', vars::$timestamp);
        $daylight = date('I', vars::$timestamp) * 3600;
        $os = $zone - $daylight;
        if ($os != 0) {
            $timeoff = $os / 3600;
        } else {
            $timeoff = 0;
        }
        if (!user::$current || user::$current["uid"] == 1) {
            $dati["time_offset"] = $timeoff;
        }
        $tres = Cached::timezone_list();
        print "<tr>\n\t<td align='left' class='header'>" . TIMEZONE . ":</td>";
        print "\n\t<td align='left' class='lista' colspan='2'>\n<select name='timezone'>";
        foreach ($tres as $timezone) {
            $option = "\n<option ";
            if ($timezone["difference"] == $dati["time_offset"]) {
                $option .= "selected='selected' ";
            }
            $option .= "value='" . $timezone["difference"] . "'>" . security::html_safe(unesc($timezone["timezone"])) . "</option>";
            print $option;
        }
        print "</select></td>\n</tr>";
        // -----------------------------
        // Captcha hack
        // -----------------------------
        // if set to use secure code: try to display imagecode
        if (user::$current['edit_users'] == 'yes' && $action == "mod" && user::$current["uid"] != $dati["id"]) {
            print "<tr>\n\t<td align='left' class='header'>" . USER_LEVEL . ":</td><td align='left' class='lista'>";
            print "<select name='level'>";
            $res = $db->query("SELECT level FROM users_level WHERE id_level <= " . user::$current["id_level"] . " ORDER BY id_level");
            while ($row = $res->fetch_array(MYSQLI_BOTH)) {
                $select = "<option value='" . unesc($row["level"]) . "'";
                if (unesc($dati["level"]) == unesc($row["level"])) {
                    $select .= "selected='selected'";
                }
                $select .= ">" . security::html_safe(unesc($row["level"])) . "</option>\n";
                print $select;
            }
            print "</select></td></tr>";
        } elseif ($USE_IMAGECODE && $action != "mod") {
            if (extension_loaded('gd')) {
                $arr = gd_info();
                if ($arr['FreeType Support'] == 1) {
                    $p = new ocr_captcha();
                    print "<tr>\n\t<td align='left' class='header'>" . IMAGE_CODE . ":</td>";
                    print "\n\t<td align='left' class='lista'><input type='text' name='private_key' value='' maxlength='6' size='6'>\n";
                    print $p->display_captcha(true);
                    $private = $p->generate_private();
                    print "</td>\n</tr>";
                }
            }
        }
        // -----------------------------
        // Captcha hack
        // -----------------------------
    }
    ?>
    <tr>
    <td align="center" class="header"></td>
    <?php 
    if ($action == "del") {
        print "\n<td align='left' class='lista'><input type='submit' name='elimina' value='" . FRM_DELETE . "' />&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='elimina' value='" . FRM_CANCEL . "' /></td>";
    } else {
        print "\n<td align='left' class='lista'><input type='submit' name='conferma' value='" . FRM_CONFIRM . "' />&nbsp;&nbsp;&nbsp;&nbsp;<input type='reset' name='annulla' value='" . FRM_CANCEL . "' /></td>";
    }
    ?>
    </tr>
    </table>
    </form>
    </center>
    </p>
    <?php 
}
Exemplo n.º 12
0
            System::check_func('system-system-set', false);
            $name = getgpc('name');
            $sort = getnum("sort", 0);
            $parent = getnum("parent", 0);
            $parent = $parent ? getnum("category", 0) : $parent;
            $sql = "INSERT INTO `mod:common_category`(appid,name,parent,sort,state,dateline) VALUES('system-district','" . $name . "'," . $parent . "," . $sort . ",1," . time() . ")";
            System::$db->execute($sql);
            $_G['project']['message'] = "新增区域成功!";
            break;
    }
    //更新分类数组缓存
    Cached::multi('system', "SELECT id,name,parent,state FROM `mod:common_category` WHERE appid = 'system-district' ORDER BY sort ASC", 'table.district', array('alias' => 'district'));
    //更新分类脚本缓存
    Cached::script('system', "SELECT id,name,parent FROM `mod:common_category` WHERE appid = 'system-district' ORDER BY sort ASC", "DISTRICT", "mod.district", array('unicode' => array('name')));
}
Cached::loader('system', 'table.district');
?>

	<?php 
echo System::check_func('system-system-set', true);
?>

    <div id="search">
    <form name="find-form" id="find-form" method="post" data-mode="edit" data-valid="true">
      <span class="action">
        <input type="button" value="更新缓存" onclick="if(confirm('确定现在更新分类缓存吗?')){location.href='?action=create';}" class='button'>
      </span>
        
        区域:<input name="name" type="text" class="text" value="" size="20" data-valid-name="分类名称" data-valid-empty="yes" />
        排序:<input name="sort" type="text" class="text digi" value="" data-valid-name="分类排序" data-valid-number="no" />
      <var data-type="tip">从小到大依次排序</var>
Exemplo n.º 13
0
 public static function sql_exec($params, &$smarty)
 {
     global $_G;
     if (!empty($params['sql']) && System::$db) {
         // 创建目录
         $base = create_dir(VI_ROOT . 'cache/dataset/sql/');
         // 缓存地址
         $file = $base . md5($params['sql']) . ".php";
         //////////////////////
         //检查缓存是否有效
         if ($params['cache'] && file_exists($file) && time() - filemtime($file) <= $params['cache'] * 60) {
             $result = unserialize(file_get_contents($file));
         } else {
             switch ($params['type']) {
                 case 'value':
                     $result = System::$db->getValue($params['sql']);
                     break;
                 case 'first':
                     $result = System::$db->getOne($params['sql']);
                     break;
                 default:
                 case 'multi':
                     $result = System::$db->getAll($params['sql']);
                     break;
             }
             //////////////////////
             if ($params['jsonde']) {
                 $params['jsonde'] = explode(',', $params['jsonde']);
             }
             if ($params['serialize']) {
                 $params['serialize'] = explode(',', $params['serialize']);
             }
             if ($result !== FALSE) {
                 switch ($params['type']) {
                     case 'first':
                         $result = Cached::format($result, $params);
                         break;
                     default:
                     case 'multi':
                         foreach ($result as &$row) {
                             $row = Cached::format($row, $params);
                         }
                         break;
                 }
             }
         }
         //////////////////////
         if ($params['cache']) {
             create_file($file, serialize($result));
         }
         //////////////////////
         $smarty->assign($params['assign'], $result);
     }
 }