php生成静态文件

    // 生成静态文件
    public function gethtml()
    {
        $html = Db::name('seo');
        $id = input('id');
        $params = input('post.');
        $ids = implode(',', $params['ids']);
        $a = explode(",", $ids);
        $ids = $params['ids'];
        for ($i = 0; $i < count($a); $i++) {
            $t=Db::name('seo')->where(array('id' => $a[$i]))->find();
            $c=Db::name('seo_cate')->where(array('id' => $t['tid']))->find();
            $data = file_get_contents(http().$_SERVER['SERVER_NAME']."/get/'.$a[$i].'.html");
            $myfile = fopen('post/'.$c['alias'].$a[$i].'.html', "w") or die("Unable to open file!");
            fwrite($myfile, $data);
            Db::name('seo')->where("id = $a[$i]")->update(array('post'=>1));
        }
        return json(array('code' => 1, 'msg' => '批量生成成功'));
    }


分类: PHP 点赞(0) 收藏

评论