<?php 


/** 
***************************************************
*欢迎使用免费版SiteTeam企业建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.SiteTeam.cn 
***************************************************
**/




if(!defined('IN_SITETEAM')) { exit('Access Denied'); } if (!empty($_POST['dosubmit'])) { $key = $_COOKIE['key']; if (empty($key)) { go_url("admin.php?action=article&operation=list&category={$category}", "缺少category参数！"); } $article_info_file = $user_article_dir . "/{$category}/{$key}.txt"; $indexdata = $savedata = $_POST['data']; $savedata['content'] = stripslashes($savedata['content']); if ($auto_image == 1) { $remote_file = array(); if (preg_match_all('/src=[\'|"]+([^\'"]+\.[jpg|gif|png|jpeg]+)[\'|"]+/is', $savedata['content'], $temp)) { $temp = $temp[1]; if (is_array($temp) && count($temp)) { foreach ($temp as $v) { if (preg_match('/^http:\/\//is', $v)) { if (!preg_match('/^http:\/\/' . preg_quote($site_url) . '/is', $v)) { $remote_file[md5($v)] = $v; } } } } } if (is_array($remote_file) && count($remote_file)) { $year_dir = date("Y", $key); $month_dir = date("md", $key); $user_attachments_dir = "{$user_upload_dir}/public"; if(!file_exists("{$user_attachments_dir}")) mkdir("{$user_attachments_dir}"); if(!file_exists("{$user_attachments_dir}/{$year_dir}")) mkdir("{$user_attachments_dir}/{$year_dir}"); if(!file_exists("{$user_attachments_dir}/{$year_dir}/{$month_dir}")) mkdir("{$user_attachments_dir}/{$year_dir}/{$month_dir}"); } if (is_array($remote_file) && count($remote_file)) { foreach ($remote_file as $k => $v) { $fileinfo = pathinfo($v); $filename = "{$user_attachments_dir}/{$year_dir}/{$month_dir}/{$k}.{$fileinfo['extension']}"; if ($image_file = file_get_contents($v)) { $fp = fopen($filename, "w"); fwrite($fp, $image_file); fclose($fp); $filename = str_replace(SITE_ROOT . '/', '', $filename); $savedata['content'] = str_replace($v, $filename, $savedata['content']); } } } } save_array_file($savedata, $article_info_file); $db = new txtSQL('./data/siteteam'); if ($db->connect('root', 'siteteam')){ $row = $db->execute('select', array('db' => dbname($site_id), 'select' => array('key'), 'table' => 'sm_article', 'where' => array("key = {$key}"), 'limit' => array(0))); $data = array(); if (count($row)) { $data['category'] = $category; $data['body_name'] = $savedata['body_name']; $data['body_title'] = $savedata['body_title']; $data['status'] = $savedata['status']; $data['is_first'] = $savedata['is_first']; $db->update(array('db' => dbname($site_id), 'table' => 'sm_article', 'values' => $data, 'where' => array("key = {$key}"), 'limit' => array(0))); } else { $data['key'] = $key; $data['category'] = $category; $data['body_name'] = $savedata['body_name']; $data['body_title'] = $savedata['body_title']; $data['status'] = $savedata['status']; $data['is_first'] = $savedata['is_first']; $db->insert(array('db' => dbname($site_id), 'table' => 'sm_article', 'values' => $data)) ; } $db->disconnect(); } go_url("admin.php?action=article&operation=list&category={$category}"); } else { $default_structure_file = SITE_ROOT . "/data/default.article.structure.txt"; $default_structure = read_array_file($default_structure_file); $diy_structure_file = $user_data_dir . "/article.structure.txt"; if (file_exists($diy_structure_file)) { $diy_structure = read_array_file($diy_structure_file); $forum_structure = array_merge($default_structure, $diy_structure); } else { $forum_structure = $default_structure; } if (!empty($key) && file_exists($user_article_dir . "/{$category}/{$key}.txt")) { $article_info_file = $user_article_dir . "/{$category}/{$key}.txt"; $article_info = read_array_file($article_info_file); if (is_array($article_info) && count($article_info) > 0) foreach ($article_info as $k => $v) { if (array_key_exists($k, $forum_structure)) $forum_structure[$k]['value'] = $v; } } if (empty($key)) { $key = time(); } ob_start(); setcookie("key", $key); ob_end_flush(); foreach ($forum_structure as $k => $v) { $form[$v['formtype']][$k] = $forum_structure[$k]; } extract($form); if (isset($content['content']['name'])) { $content['content']['name'] .= '<a style="cursor:hand" onclick="create_editor(\'content\');">[开]</a><a style="cursor:hand" onclick="close_editor();">[关]</a><a target="_blank" href="http://ps.net.cn">[图]</a>'; } include "admin/tpl/article_edit.tpl.php"; } ?>