/** * 更新伪静态规则 */ function m__update_url() { htaccess(); iis_httpd_ini(); nginx(); die('{"code":"0","msg":"更新伪静态规则成功"}'); }
function m__edit() { global $url_re_obj, $logs_obj; check_level("A0301"); $post = $_POST; //解码数据 foreach ($post as $key => $val) { $post[$key] = urldecode($val); } if (!is_numeric($post['url_id'])) { die('{"code":"210","msg":"规则节点ID必须是数字"}'); } if (empty($post['url_title'])) { die('{"code":"220","msg":"规则节点名称不能为空"}'); } if (!preg_match('~^[A-Za-z][A-Za-z]*[a-z0-9_]*$~', $post['url_title'])) { die('{"code":"230","msg":"规则节点名称必须以字母开头,只允许字母、下划线"}'); } if (empty($post['url_true'])) { die('{"code":"230","msg":"动态地址规则不能为空"}'); } if (empty($post['url_rule'])) { die('{"code":"230","msg":"伪静态地址规则不能为空"}'); } if ($post['url_id'] > 0) { // 编辑 $res = $url_re_obj->update($post, $post['url_id']); //更新缓存 //$c -> update_url_config(); //$c -> update_cate(); //生成伪静态文件(.htaccess) //htaccess(); //iis_httpd_ini(); $logs_obj->insert("更新伪静态成功"); if ($res) { die('{"code":"0","msg":"更新规则成功"}'); } die('{"code":"240","msg":"更新规则失败"}'); } else { // 添加 //判断节点是否存在 /*$rs=$dbm->query("select * from ".TB_PREFIX . "url_rewrite where url_title='{$_POST['url_title']}'"); if(count($rs['list'])>0) die('{"code":"100","msg":"'.$_POST['url_title'].'节点名称不能重复"}'); unset($_POST['url_id']); $res = $dbm -> single_insert(TB_PREFIX . "url_rewrite", $_POST);*/ //更新缓存 $c->update_url_config(); $c->update_cate(); //生成伪静态文件(.htaccess) htaccess(); iis_httpd_ini(); if (empty($res['error']) && $res['autoid'] > 0) { die('{"code":"0","msg":"添加规则成功"}'); } die('{"code":"250","msg":"添加规则失败,请核对重试"}'); } }