Пример #1
0
 public function modi()
 {
     $this->news["id"] = isset($_REQUEST["id"]) ? $_REQUEST["id"] : "";
     if (empty($this->news["id"])) {
         $this->addActionError("id", "id为空");
         return parent::ERROR;
     }
     $this->news["news_title"] = isset($_REQUEST["news_title"]) ? $_REQUEST["news_title"] : "";
     if (empty($this->news["news_title"])) {
         $this->addActionError("news", "标题为空");
         return parent::ERROR;
     }
     $this->news["news_type"] = isset($_REQUEST["news_type"]) ? $_REQUEST["news_type"] : "1";
     $this->news["news_content"] = isset($_REQUEST["news_content"]) ? $_REQUEST["news_content"] : "";
     if (empty($this->news["news_content"])) {
         $this->addActionError("news", "文章内容为空");
         return parent::ERROR;
     }
     /*截取前20个字, strip_tags指去掉html标记*/
     $this->news["news_content_short"] = substr(clearHtml($this->news["news_content"]), 0, 20);
     $this->news["news_content_short"] = empty($this->news["news_content_short"]) ? "此条新闻没有文本内容" : $this->news["news_content_short"];
     $this->news["uid"] = isset($_REQUEST["uid"]) ? $_REQUEST["uid"] : "admin";
     $this->news["isPublish"] = isset($_REQUEST["isPublish"]) ? $_REQUEST["isPublish"] : "1";
     $this->news["news_post_time"] = !empty($_REQUEST["news_post_time"]) ? $_REQUEST["news_post_time"] : date("Y-m-d H:i:s", time());
     $sql = "update " . $this->mysqlConfig["db_perfix"] . "web_news \r\n\t\t\t\tset \r\n\t\t\t\tnews_title = '{$this->news["news_title"]}',\r\n\t\t\t\tnews_content = '{$this->news["news_content"]}',\r\n\t\t\t\tnews_type_id = '{$this->news["news_type"]}',\r\n\t\t\t\tnews_content_short = '{$this->news["news_content_short"]}',\r\n\t\t\t\tuid = '{$this->news["uid"]}',\r\n\t\t\t\tisPublish = '{$this->news["isPublish"]}',\r\n\t\t\t\tnews_post_time = '{$this->news["news_post_time"]}',\r\n\t\t\t\tnews_title = '{$this->news["news_title"]}'\r\n\t\t\t\twhere id = {$this->news["id"]}\r\n\t\t\t\t";
     $rs = sqlExecute($sql);
     return parent::SUCCESS;
 }
Пример #2
0
function runScript($textToInsert, $conn, $key)
{
    $link = selectDataFromDatabase($key, $conn);
    $htmlFileName = duplicateHtml($link, $key);
    $html = downloadAndCreateImage($link, $htmlFileName);
    changingLinks($html, 1, $link);
    $element = $html->find('head', 0);
    $element->innertext = $element->innertext . $textToInsert;
    $html->save($htmlFileName);
    clearHtml($html);
}