* 负责处理新发表文章的逻辑
 * Createed By C860 at 2014-1-19
 */
if (!class_exists('sys')) {
    include_once '../conf/config.php';
}
//需要登录
sys::needLog('../login.php');
//检测数据合法性
if (isset($_POST['title']) && !empty($_POST['title']) && isset($_POST['content']) && !empty($_POST['content']) && isset($_POST['tags']) && !empty($_POST['tags'])) {
    //引入相关模型类
    include_once '../Models/article.php';
    include_once '../Models/tag_relate_article.php';
    include_once '../Models/user_info.php';
    $currentTime = date('Y-m-d H:i:s');
    //新增文章
    if (article::add($_POST['title'], $_POST['content'], $currentTime, $_SESSION['userId'])) {
        $ID = article::getId($_POST['title'], $_SESSION['userId'], $currentTime);
        $tags = explode('|', $_POST['tags']);
        foreach ($tags as $tag) {
            tag_relate_article::add($tag, $ID);
        }
        user_info::increaseArticleCount($_SESSION['userId']);
        sys::alert('发表成功!');
        sys::redirect('../index.php');
    }
} else {
    //引入相关模型类
    include_once 'Models/tag.php';
    $taglist = tag::getAllTags();
}
<?php

/*
 * back_login.php
 * 负责后台登录逻辑
 * Created By C860 at 2014-1-22
 */
include_once '../conf/config.php';
//引入相关模型类
include_once '../Models/user_basic.php';
//检查数据合法性
if (isset($_POST['user']) && !empty($_POST['user']) && isset($_POST['password']) && !empty($_POST['password'])) {
    if (user_basic::check($_POST['user'], $_POST['password'], 1)) {
        $_SESSION['admin'] = user_basic::getUserId($_POST['user']);
        sys::redirect('../back/main.php');
    } else {
        sys::alert('error!');
        sys::redirect('../back/index.php');
    }
}
            if (slider::add($_POST['weight'], $_POST['link'], $_POST['title'], $_POST['img'])) {
                sys::alert('添加成功!');
            } else {
                sys::alert('出现未知错误!');
            }
            sys::redirect('../back/sliderControl.php');
        }
    } else {
        if ($_POST['type'] == 'modify') {
            if (isset($_POST['weight']) && is_numeric($_POST['weight']) && isset($_POST['title']) && !empty($_POST['title']) && isset($_POST['link']) && !empty($_POST['link']) && isset($_POST['img']) && !empty($_POST['img']) && isset($_POST['ID']) && is_numeric($_POST['ID'])) {
                if (slider::update($_POST['ID'], $_POST['weight'], $_POST['link'], $_POST['title'], $_POST['img'])) {
                    sys::alert('修改成功!');
                } else {
                    sys::alert('出现未知错误!');
                }
                sys::redirect('../back/sliderControl.php');
            }
        }
    }
} else {
    if (isset($_GET['type']) && $_GET['type'] == 'delete') {
        if (isset($_GET['id']) && is_numeric($_GET['id'])) {
            if (slider::delete($_GET['id'])) {
                sys::alert('删除成功!');
            } else {
                sys::alert('出现未知错误!');
            }
            sys::redirect('../back/sliderControl.php');
        }
    }
}
include_once '../conf/config.php';
//需要管理员权限
sys::needAdmin('index.php');
//引入相关模型类
include_once '../Models/user_basic.php';
/*
 * paging方法
 * 获取用户信息并分页
 * @author C860
 * @param $perpage int 每页显示条数
 * @return array
 */
function paging($perpage)
{
    if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {
        $curpage = 1;
    } else {
        $curpage = $_GET['page'];
    }
    $rs = user_basic::getTotalInfo($perpage, $curpage);
    return $rs;
}
//设置或取消管理员权限
if (isset($_GET['uid'])) {
    if (user_basic::setIsAdmin($_GET['uid'])) {
        sys::alert('操作成功!');
        sys::redirect('../back/userControl.php');
    } else {
        alert('操作失败!');
    }
}
<?php

/*
 * removeArticle.php
 * 负责删除文章逻辑
 * Created By C860 at 2014-2-28
 */
include_once '../conf/config.php';
//引入相关模型类
include_once '../Models/article.php';
include_once '../Models/user_info.php';
//检验数据合法性
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $article = article::getArticle($id);
    if (sys::hasLogged() && $article != false && $_SESSION['userId'] == $article['user_id']) {
        if (article::removeArticle($id)) {
            sys::alert('删除成功!');
            sys::redirect('../index.php');
        }
    } else {
        sys::redirect('../index.php');
    }
}
<?php

/*
 * checkLog.php
 * 用户登录检测程序
 * Created By C860 at 2014-1-18
 */
include_once '../conf/config.php';
//引入相关模型类
include_once '../Models/user_basic.php';
include_once '../Models/user_info.php';
//检测数据合法性
if (isset($_POST['user']) && !empty($_POST['user']) && isset($_POST['password']) && !empty($_POST['password'])) {
    if (user_basic::check($_POST['user'], $_POST['password'], 0)) {
        $uid = user_basic::getUserId($_POST['user']);
        $nickname = user_info::getNickname($uid);
        //设置SESSION
        $_SESSION['userId'] = $uid;
        $_SESSION['user'] = $_POST['user'];
        $_SESSION['nickname'] = $nickname;
        sys::redirect('../index.php');
    } else {
        sys::alert('用户名或密码错误!');
        sys::redirect('../login.php');
    }
}
Exemple #7
0
function sys_process_session_request()
{
    if (!empty($_REQUEST["popup"]) and !empty($_REQUEST["iframe"])) {
        unset($_REQUEST["iframe"]);
    }
    if (!empty($_REQUEST["iframe"])) {
        sys::$smarty->assign("iframe", 1);
    }
    $keep_vars = array("popup", "preview", "lookup", "eto");
    foreach ($keep_vars as $var) {
        if (empty($_REQUEST[$var])) {
            continue;
        }
        sys::$urladdon .= "&" . $var . "=" . $_REQUEST[$var];
        sys::$smarty->assign($var, $_REQUEST[$var]);
    }
    $_SESSION["view"]["_" . $GLOBALS["tfolder"]] = $GLOBALS["tview"];
    sys::$urladdon = "folder2=" . rawurlencode($GLOBALS["tfolder"]) . "&view2=" . $GLOBALS["tview"] . sys::$urladdon;
    sys::$smarty->assign("urladdon", sys::$urladdon);
    if (!empty($_REQUEST["action_sys"]) and !empty($_SESSION["username"]) and sys_is_super_admin($_SESSION["username"])) {
        admin::process_action_sys();
    }
    if (!empty($_REQUEST["style"])) {
        $_SESSION["theme"] = basename($_REQUEST["style"]);
    }
    sys::$smarty->assign("sys_style", !empty($_SESSION["theme"]) ? $_SESSION["theme"] : DEFAULT_STYLE);
    $table = $GLOBALS["table"];
    if ($GLOBALS["tview"] != $table["view"]) {
        $GLOBALS["tview"] = $table["view"];
    }
    $tview = $GLOBALS["tview"];
    $tfolder = $GLOBALS["tfolder"];
    $tfolders = $GLOBALS["tfolders"];
    $tname = $GLOBALS["tname"];
    $tquota = $GLOBALS["tquota"];
    $anchor = $GLOBALS["sel_folder"]["anchor"];
    if (!empty($_REQUEST["reset_view"])) {
        $_SESSION[$tname][$tview] = array();
        $_SESSION["_" . $tfolder] = array();
        $_SESSION["view"]["_" . $tfolder] = $tview;
        $_SESSION[$tname]["_" . $tfolder] = array();
    }
    $current_view = $table["views"][$tview];
    $cview = $current_view;
    $template = $tview;
    if ($current_view["TEMPLATE"] != "") {
        $template = $current_view["TEMPLATE"];
    }
    if (isset($current_view["SCHEMA"]) and $current_view["SCHEMA"] != "") {
        $table2 = db_get_schema(sys_find_module($current_view["SCHEMA"]));
        $current_view = array_shift($table2["views"]);
        // preserve in search, override for schema=x
        if (!empty($table["att"]["SQL_HANDLER"]) and empty($current_view["SQL_HANDLER"])) {
            $current_view["SQL_HANDLER"] = $table["att"]["SQL_HANDLER"];
        }
        $GLOBALS["table"] = $table2;
        // needed for asset-functions and triggers
        $table["att"] = $table2["att"];
        if ($current_view["TEMPLATE"] != "") {
            $template = $current_view["TEMPLATE"];
        }
    }
    $GLOBALS["current_view"] = $current_view;
    $field_names = array();
    foreach ($current_view["fields"] as $key => $field) {
        if (isset($field["NODB"]) and empty($current_view["SQL_HANDLER"])) {
            continue;
        }
        $field_names[] = $key;
    }
    if (!empty($_SESSION["alert"])) {
        sys::$alert = array_merge(sys::$alert, $_SESSION["alert"]);
        $_SESSION["alert"] = array();
    }
    if (!empty($_SESSION["notification"])) {
        sys::$notification = array_merge(sys::$notification, $_SESSION["notification"]);
        $_SESSION["notification"] = array();
    }
    if (!empty($_SESSION["warning"])) {
        sys::$warning = array_merge(sys::$warning, $_SESSION["warning"]);
        $_SESSION["warning"] = array();
    }
    if ($table["views"][$tview]["SCHEMA_MODE"] != "") {
        $tfolders = _build_merge_folders(array_keys($tfolders), $tfolder, $tview, true);
    }
    $dclick = $current_view["DOUBLECLICK"];
    if ($dclick == "") {
        if (in_array($template, array("display", "free")) and isset($current_view["views"]["details"])) {
            $dclick = "details";
        } else {
            $dclick = "edit";
        }
    }
    if (isset($current_view["MERGE_TABS"])) {
        unset($current_view["tabs"]);
        foreach (array_keys($current_view["fields"]) as $key) {
            $current_view["fields"][$key]["SIMPLE_TAB"] = array("general");
        }
    }
    $tfield_1 = isset($current_view["TFIELD_1"]) ? $current_view["TFIELD_1"] : modify::get_required_field($current_view["fields"]);
    $tfield_2 = isset($current_view["TFIELD_2"]) ? $current_view["TFIELD_2"] : "";
    // TODO2 reduce ??
    $t = array("anchor" => $anchor, "att" => $table["att"], "buttons" => $current_view["buttons"], "custom_name" => $table["att"]["CUSTOM_NAME"], "data" => array(), "default_sql" => $current_view["DEFAULT_SQL"], "disable_tabs" => isset($current_view["DISABLE_TABS"]) ? $current_view["DISABLE_TABS"] : "", "doubleclick" => array_key_exists($dclick, $current_view["views"]) ? $dclick : "", "fields" => $current_view["fields"], "fields_all" => $table["fields"], "fields_query" => array_unique(array_merge(array($current_view["id"]), $field_names, array("created", "lastmodified", "createdby", "lastmodifiedby", "folder"))), "field_1" => $tfield_1, "field_2" => $tfield_2, "filter" => isset($current_view["FILTERS"]) ? $current_view["FILTERS"] : "", "filters" => $current_view["filters"], "folder" => $tfolder, "folders" => $tfolders, "folder_preview" => isset($_REQUEST["tpreview"]), "function" => isset($current_view["FUNCTION"]) ? $current_view["FUNCTION"] : "", "id" => $current_view["id"], "isdbfolder" => is_numeric($tfolder) ? true : false, "limit" => $current_view["LIMIT"], "links" => $current_view["links"], "linkstext" => $current_view["linkstext"], "load_css" => isset($table["att"]["LOAD_CSS"]) ? $table["att"]["LOAD_CSS"] : "", "load_js" => isset($table["att"]["LOAD_JS"]) ? $table["att"]["LOAD_JS"] : "", "lookup" => isset($_REQUEST["lookup"]) ? $_REQUEST["lookup"] : "", "order" => $current_view["ORDER"], "orderby" => $current_view["ORDERBY"], "groupby" => $current_view["GROUPBY"], "group" => $current_view["GROUP"], "handler" => $current_view["SQL_HANDLER"], "hidedata" => $_SESSION["hidedata"], "nosinglebuttons" => isset($cview["NOSINGLEBUTTONS"]) ? $cview["NOSINGLEBUTTONS"] : "", "notification" => &sys::$notification, "warning" => &sys::$warning, "noviewbuttons" => isset($cview["NOVIEWBUTTONS"]) ? $cview["NOVIEWBUTTONS"] : "", "page" => 1, "quota" => $tquota, "restore" => $current_view["restore"], "rights" => $GLOBALS["sel_folder"]["rights"], "vright" => isset($cview["RIGHT"]) ? $cview["RIGHT"] : "", "rowfilters" => $current_view["rowfilters"], "rowvalidates" => $current_view["rowvalidates"], "schema_mode" => $current_view["SCHEMA_MODE"], "singlebuttons" => $current_view["singlebuttons"], "sqllimit" => array(), "sqlorder" => "", "sqlvars" => array("folder" => $tfolder, "folders" => array_keys($tfolders)), "sqlvarsnoquote" => array(), "sqlwhere" => $current_view["SQLWHERE"], "sqlwhere_default" => $current_view["SQLWHERE_DEFAULT"], "subitem" => 0, "tabs" => isset($current_view["tabs"]) ? $current_view["tabs"] : array("general" => array("NAME" => "general")), "template" => "asset_" . $template . ".tpl", "template_mode" => isset($current_view["TEMPLATE_MODE"]) ? $current_view["TEMPLATE_MODE"] : "", "title" => $tname, "view" => $tview, "views" => $table["views"][$tview]["views"]);
    $GLOBALS["t"] = $t;
    if (!empty($current_view["SCHEMA_MODE"])) {
        sys_process_schema_request();
    }
}
<?php

/*
 * changePWD.php
 * 负责处理修改密码的逻辑
 * Created By C860 at 2014-1-20
 */
include_once '../conf/config.php';
//引入相关模型类
include_once '../Models/user_basic.php';
//检测数据合法性
if (isset($_POST['oldpwd']) && !empty($_POST['oldpwd']) && isset($_POST['newpwd']) && !empty($_POST['newpwd'])) {
    //检测旧密码是否正确
    if (user_basic::check($_SESSION['user'], $_POST['oldpwd'], 0)) {
        //替换旧密码为新密码
        if (user_basic::changePassword($_SESSION['userId'], $_POST['newpwd'])) {
            sys::alert('修改密码成功!请重新登录!');
            sys::logout();
            sys::redirect('../login.php');
        }
    }
}
Exemple #9
0
<?php

/*
 * article.php
 * 负责文章显示页面的逻辑
 * Created By C860 at 2014-2-7
 */
include_once 'conf/config.php';
//引入相关模型类
include_once 'Models/article.php';
include_once 'Models/user_info.php';
//检验数据合法性
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $article = article::getArticle($id);
    $author = user_info::getNickname($article['user_id']);
    if (!$article || !$author) {
        sys::alert('未知错误!');
        sys::redirect('index.php');
    }
}