<?php 


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




if(!defined('IN_SITETEAM')) { exit('Access Denied'); } if (!empty($_POST['dosubmit'])) { $savedata = $_POST['data']; $product_category_file = SITE_ROOT . "/data/setting/{$site_url}/product.category.txt"; if (empty($savedata['category']) || empty($savedata['name'])) { go_url("admin.php?action=product&operation=category_edit", "缺少必填项！"); } if (!preg_match("/^[a-zA-Z]+[\w_]+$/i", $savedata['category'])) { go_url("admin.php?action=product&operation=category_edit", "分类ID只能是英文字母以下下划线，且只能以英文字线开头！"); } if (isset($site_index_url) && !empty($site_index_url)) { if ($site_index_url == $savedata['category']) { go_url("admin.php?action=product&operation=category_edit", "分类ID不能和首页重定义URL名字相同！"); } } $product_category = get_product_category($site_url); if(!empty($savedata['oldcategory'])) { if ($savedata['oldcategory'] != $savedata['category']) { if (array_key_exists($savedata['category'], $product_category)) { go_url("admin.php?action=product&operation=category", "该分类ID已经存在，请另选ID！"); } if (file_exists("{$user_product_dir}/{$savedata['oldcategory']}")) { if (!rename("{$user_product_dir}/{$savedata['oldcategory']}", "{$user_product_dir}/{$savedata['category']}")) { go_url("admin.php?action=product&operation=category", "分类ID更改不成功，请检查相应的文件目录权限！"); } } else { if (!mkdir("{$user_product_dir}/{$savedata['category']}")) { go_url("admin.php?action=product&operation=category", "分类ID更改不成功，请检查相应的文件目录权限！"); } } if (file_exists("{$user_product_dir}/{$savedata['oldcategory']}.index.txt")) { if (!rename("{$user_product_dir}/{$savedata['oldcategory']}.index.txt", "{$user_product_dir}/{$savedata['category']}.index.txt")) { unlink("{$user_product_dir}/{$savedata['oldcategory']}.index.txt"); } } update_product_index($savedata['category']); } unset($product_category[$savedata['oldcategory']]); } else { if (array_key_exists($savedata['category'], $product_category)) { go_url("admin.php?action=product&operation=category", "该分类ID已经存在，请另选ID！"); } if (!file_exists("{$user_product_dir}/{$savedata['category']}")) mkdir("{$user_product_dir}/{$savedata['category']}"); if (!file_exists($product_category_file)) fclose(fopen($product_category_file, "w")); } if (!empty($_FILES['product_css_file']['name'])) { $fileinfo = pathinfo($_FILES['product_css_file']['name']); if (@strtolower($fileinfo['extension']) != "css") { go_url("admin.php?action=product&operation=category", "请上传CSS格式的样式文件！"); } $filename = "{$user_upload_dir}/product_{$savedata['category']}.css"; if (file_exists($filename)) unlink($filename); if (file_exists($savedata['product_css_file']) && preg_match("/^attachments/i", $savedata['product_css_file'])) unlink($savedata['product_css_file']); if (move_uploaded_file($_FILES['product_css_file']['tmp_name'],$filename)) { $savedata['product_css_file'] = str_replace(SITE_ROOT . '/', '', $filename); } } $product_category[$savedata['category']] = array ( "name" => !empty($savedata['name']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['name'])) : "", "icon" => !empty($savedata['icon']) ? strip_tags($savedata['icon']) : "", "sortid" => !empty($savedata['sortid']) ? strip_tags($savedata['sortid']) : "1", "top_title" => !empty($savedata['top_title']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['top_title'])) : "", "top_description" => !empty($savedata['top_description']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['top_description'])) : "", "banner_off" => !empty($savedata['banner_off']) ? strip_tags($savedata['banner_off']) : " ", "product_css_file" => !empty($savedata['product_css_file']) ? strip_tags($savedata['product_css_file']) : " ", "seo_title" => !empty($savedata['seo_title']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['seo_title'])) : "", "seo_description" => !empty($savedata['seo_description']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['seo_description'])) : "", "seo_keywords" => !empty($savedata['seo_keywords']) ? preg_replace("/[\s]+/", " ", strip_tags($savedata['seo_keywords'])) : "" ); ksort($product_category); save_array_file($product_category, $product_category_file, "w+"); if(!empty($savedata['oldcategory'])) { if ($savedata['oldcategory'] != $savedata['category']) { delete_product_index($savedata['oldcategory']); update_product_index($savedata['category']); } } cache_update("setting"); go_url("admin.php", "更新分类信息成功！", "top"); } else { $product_category = get_product_category($site_url); $form['category'] = array("type"=>"varchar", "length" => "255", "name" => "<strong>分类ID</strong>", "class" => "txt", "description" => "必须以英文字母开头且只能是英文字母及数字，且必填"); $form['name'] = array("type"=>"varchar", "length" => "255", "name" => "分类名称", "class" => "txt", "description" => "必填项"); $form['icon'] = array("type"=>"varchar", "length" => "255", "name" => "分类图标", "class" => "txt", "description" => ""); $form['sortid'] = array("type"=>"varchar", "length" => "255", "name" => "分类排序ID", "class" => "txt", "description" => "分类排序ID，产品分类从小到大排序"); $form['top_title'] = array("type"=>"varchar", "length" => "90", "name" => "顶部标题宣传语", "class" => "txt", "description" => ""); $form['product_css_file'] = array("type"=>"file", "length" => 1024 * 1024, "name" => "自定义该栏样式文件", "class" => "uploadbtn marginbot"); $form['top_description'] = array("type"=>"varchar", "length" => "1024", "name" => "顶部标题宣传语简述", "class" => "tarea", "description" => ""); $form['banner_off'] = array("type"=>"varchar", "length" => "2", "name" => "关闭产品系统的BANNER", "class" => "txt", "description" => "关闭请输入“1”，不关闭请输入“4”"); $seo['seo_title'] = array("type"=>"varchar", "length" => "90", "name" => "SEO标题", "class" => "txt", "description" => ""); $seo['seo_description'] = array("type"=>"varchar", "length" => "90", "name" => "SE0描述", "class" => "txt", "description" => ""); $seo['seo_keywords'] = array("type"=>"varchar", "length" => "90", "name" => "SEO关键词", "class" => "txt", "description" => ""); if (!empty($category)) { if (array_key_exists($category, $product_category)) foreach ($product_category[$category] as $k => $v) { if (array_key_exists($k, $form)) $form[$k]['value'] = $v; if (array_key_exists($k, $seo)) $seo[$k]['value'] = $v; } $form['category']['value'] = $category; } include "admin/tpl/product_category_edit.tpl.php"; } ?>