<?php

/**
 * 后台 网站更新模块 Model
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: update.class.php 50 2011-12-05 02:56:32Z zhangwentao $
 * http://www.t-mac.org；
 */
class update extends Model
{

    private $db;
    private $ad_table;

    /**
     * 初始化变量　定义私有变量
     */
    public function _init()
    {
        //连接数据库
        $this->db = $this->connect();
        $this->ad_table = DB_PREFIX . 'ad';
    }

    /**
     * 保存
     * @param string $info
     * return Boole
     */
    public function addAd($info, $mode = 'INSERT', $where = '')
    {
        $rs = $this->db->autoExecute($this->ad_table, $info, $mode, $where);
        return $rs;
    }

    public function SpGetNewInfo()
    {
        $nurl = $_SERVER['HTTP_HOST'];
        if (eregi("[a-z\-]{1,}\.[a-z]{2,}", $nurl)) {
            $nurl = urlencode($nurl);
        } else {
            $nurl = "test";
        }
        $offUrl = "http://update.zhu" . "na/" . PHP_SELF . "?m=update&version={$GLOBALS['TmacConfig']['config']['version']}&formurl={$nurl}";
        return $offUrl;
    }

}