예제 #1
0
     } else {
         echo json_encode(false);
     }
     break;
     //修改js模板
 //修改js模板
 case 'modify':
     if (isset($_POST['old_name']) && isset($_POST['name']) && isset($_POST['desc']) && isset($_POST['content']) && preg_match(FILE_REGEX, $_POST['old_name']) && preg_match(FILE_REGEX, $_POST['name'])) {
         if (!is_writable(MY_JS_PATH)) {
             echo json_encode(false);
         } else {
             if ($_POST['old_name'] != $_POST['name']) {
                 delete_js(MY_JS_PATH, $_POST['old_name']);
             }
             save_js_desc(MY_JS_PATH, $_POST['desc'], $_POST['name']);
             save_js_content(MY_JS_PATH, $_POST['content'], $_POST['name']);
             echo json_encode(true);
         }
     } else {
         echo json_encode(false);
     }
     break;
     //获取某一js模板的内容
 //获取某一js模板的内容
 case 'get':
     if (isset($_GET['name']) && preg_match(FILE_REGEX, $_GET['name'])) {
         echo json_encode(load_js_content(MY_JS_PATH, $_GET['name']));
     } else {
         echo json_encode(false);
     }
     break;
예제 #2
0
         $result = save_js_desc(MY_JS_PATH, $_POST['desc'], $_POST['name']) && save_js_content(MY_JS_PATH, $_POST['content'], $_POST['name']);
         echo json_encode($result);
     } else {
         echo json_encode(false);
     }
     break;
     //修改js模板
 //修改js模板
 case 'modify':
     if (isset($_POST['old_name']) && isset($_POST['name']) && isset($_POST['desc']) && isset($_POST['content'])) {
         $result = true;
         if ($_POST['old_name'] != $_POST['name']) {
             $result = delete_js(MY_JS_PATH, $_POST['old_name']);
         }
         if ($result) {
             $result = save_js_desc(MY_JS_PATH, $_POST['desc'], $_POST['name']) && save_js_content(MY_JS_PATH, $_POST['content'], $_POST['name']);
         }
         echo json_encode($result);
     } else {
         echo json_encode(false);
     }
     break;
     //获取某一js模板的内容
 //获取某一js模板的内容
 case 'get':
     if (isset($_GET['name'])) {
         echo json_encode(load_js_content(MY_JS_PATH, $_GET['name']));
     } else {
         echo json_encode(false);
     }
     break;