<?php require_once("../includes/config.php");
$mysql = new fs_mysql();
$fs->removeMagicQuotes;
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>欢迎光临广西百色农业学校</title>
    <script type="text/javascript" src="/js/about.js"></script>
    <meta name="keywords" content="广西百色农业学校">
    <meta name="Description" content="广西百色农业学校">
    <link rel="stylesheet" href="/Temp/css/swiper.min.css">
    <link rel="stylesheet" href="/Temp/css/swiper-bundle.min.css">
    <link rel="stylesheet" href="/Temp/css/style-bundle.css">
    <link href="/Temp/css/search.css?v=1.668" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="Temp/css/aos.js">
    <link rel="stylesheet" href="Temp/js/banner.js">
    <link rel="stylesheet" href="Temp/css/banner.css">
    <title>搜索结果 - <?= $fs->SiteName; ?></title>
    <meta content="<?= $fs->KeyWords ?>" name=keywords>
    <meta content="<?= $fs->Description ?>" name=description>


    <script src="https://cdn.tailwindcss.com"></script>

    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        clifford: '#da373d',
                    }
                }
            }
        }
    </script>


    <style>
        .wrap {
            width: 1200px;
            margin: auto;
        }

        #mail a {
            width: 220px !important;
        }

        .search-btn {
            background: url("http://bt.wsdns.cn:16801/Temp/images/search.png") #ffffff;
            background-repeat: no-repeat;
            background-position: right center;
            background-size: 40px;

        }

        .list-item{line-height: 3em; display: flex; justify-content: space-between;}
        .list-item span{ color: #7F9DB9}
    </style>
</head>
<body>
<!--头部开始-->
<?= $fs->fs_file('header.htm'); ?>
<div class="box" style="width: auto">
    <!--头部结束-->
    <div style="clear: both;margin-top: 180px;"></div>
    <!-- 中部主体 -->
    <div class="wrap wrap-main">
        <div class="layout layout-main">
            <div class="main">
                <!-- 左侧菜单栏 -->

                <!-- 右侧内容 -->
                <div class="main-right-box">
                    <div class="main-right" style="min-height: 600px">
                        <div class="location py-2">
                            <a href="/">首页</a> > 搜索结果
                        </div>
                        <div class="content clear">
                            <div class="build">

                                <div class="flex justify-center">
                                    <input name="search" id="keyword" value="" placeholder="请输入搜索关键词"
                                           class="search-btn text-xl p-3 border-solid border-gray-200 border-2 w-1/2"
                                           type="text"/>
                                    <button class="search_btn ml-2 text-xl"
                                            style="display: block; width: 100px; background-color: #119819; color: #FFFFFF; border: 2px solid #e5e7eb;"
                                            onclick="search()">
                                        搜索
                                    </button>
                                </div>
                                <div class="main_nr_right_tp py-5">
                                    <ul>
                                        <?php
                                        $currentPage = $fs->IsNumberList($fs->Get("page"));
                                        $keyWord = $fs->Request("keyword");
                                        $news_sort_id = $fs->Get("news_sort_id");
                                        $news_check = $fs->Get("news_check");
                                        $news_by = $fs->Get("news_by");
                                        $condition = "";
                                        $url_Condition = "";
                                        $pageNum = 15;
                                        $type = $_REQUEST['type'];
                                        if ($news_by != "") {
                                            $condition = " and news_sort_id=" . $fs->Get('news_by') . "";
                                            $url_Condition .= "&news_by=" . $fs->Get('news_by');
                                        }
                                        if ($currentPage == 0) {
                                            $startResult = 0;
                                        } else {
                                            $startResult = ($currentPage - 1) * $pageNum;
                                        }
                                        if ($keyWord == "") {
                                            echo "找不到相关的文章，请输入正确关键字！";
//                                            exit;

                                        }
                                        if ($type != "") {
                                            $condition .= " and $type=1";
                                            $url_Condition .= "&type=" . $type;
                                        }

                                        if ($fs->CheckString($keyWord) != "") {
                                            $condition = " and news_title like '%" . $keyWord . "%'";
                                            $url_Condition = $url_Condition . "&keyWord=" . $keyWord;
                                        }

                                        if ($fs->CheckString($news_sort_id) != "") {
                                            $condition = $condition . " and news_sort_id =" . $news_sort_id;
                                            $url_Condition = "&news_sort_id=" . $news_sort_id;
                                        }

                                        if ($news_check = 2) {
                                            //$condition = $condition . " and news_check =0";
                                            //$url_Condition="&news_check=0";
                                        }

                                        $mysql = new fs_mysql();
                                        $sql2 = sprintf("Select * From %s Where 1=1%s  Order by news_order asc,news_id desc limit %s, %s", "fs_news", $condition, $startResult, $pageNum);
                                        $Result = $mysql->Execute($sql2);
                                        //echo $sql2;
                                        if (mysql_num_rows($Result)){
                                        $sql3 = sprintf("Select * From %s Where 1=1%s Order by news_order asc,news_id desc", "fs_news", $condition);
                                        $totalRecord = mysql_num_rows($mysql->Execute($sql3));
                                        $page_str = $fs->PageList($totalRecord, $pageNum, $currentPage, "index.php", $url_Condition, 1);
                                        while ($Rs = mysql_fetch_object($Result)) {

                                            if ($keyWord == "") {
                                                break;
                                            }

                                            ?>
                                            <li class="list-item text-xl py-2"><a href="<?= $Rs->news_url ?>" target="_blank"
                                                                     title="<?= $Rs->news_title ?>"><?= str_replace($keyWord, "<font color=\"#FF0000\">$keyWord</font>", $Rs->news_title) ?></a>
                                                <span><?= substr($Rs->news_date, 0, 10) ?></span>
                                            </li>

                                            <?php
                                        }

                                        ?>


                                    </ul>
                                    <?php if ($keyWord != "") {
                                        echo $page_str;
                                    } ?>



                                    <?
                                    } else {
                                        echo "没有查询到相关内容！";
                                    }
                                    ?>

                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <!-- top of the page -->

    <!-- bottom of the page -->
    <!--尾部开始-->
    <?= $fs->fs_file('footer.htm') ?>
    <!--尾部结束-->


</div>
</body>
</html>

<script>
    function search() {
        const keyword = document.getElementById('keyword');
        window.location.href = "?keyword=" + keyword.value;
    }
</script>
