function createFile($title, $type, $content) { //生成文件 $File = new FileUtil(); $File->writetofile(BASE_PATH . 'upload/webstyle/public/' . $type . '/' . $title . '.' . $type, $content); return $codeFilePath = '/manage/upload/webstyle/public/' . $type . '/' . $title . '.' . $type; }
$db = new DB(); if (isset($_GET['id'])) { $id = $_GET['id']; $sql = "SELECT * FROM `webstyle_module` where id = " . $id; $result = $db->get_one($sql); $listHtml = $db->get_one('SELECT * FROM `webstyle_code` where id =' . $result['html']); $listHtml['content'] = htmlspecialchars($listHtml['content']); $result['html'] = $listHtml; $listCss = $db->get_one('SELECT * FROM `webstyle_code` where id =' . $result['css']); $result['css'] = $listCss; $listJs = $db->get_one('SELECT * FROM `webstyle_code` where id =' . $result['js']); $result['js'] = $listJs; //print_r($result); $tpl->assign("module", $result); $tpl->display("webstyle/update.tpl"); } if (isset($_POST['title'])) { $File = new FileUtil(); $dataJs['content'] = $_POST['cssCode']; $db->update('webstyle_code', $dataJs, 'id=' . $_POST['cssId']); $File->writetofile(BASE_PATH . $_POST['cssFilePath'], $_POST['cssCode']); $dataCss['content'] = $_POST['jsCode']; $db->update('webstyle_code', $dataCss, 'id=' . $_POST['jsId']); $File->writetofile(BASE_PATH . $_POST['jsFilePath'], $_POST['jsCode']); $dataHtml['content'] = $_POST['htmlCode']; $db->update('webstyle_code', $dataHtml, 'id=' . $_POST['htmlId']); $File->writetofile(BASE_PATH . $_POST['htmlFilePath'], $_POST['htmlCode']); $data['title'] = $_POST['title']; $data['content'] = $_POST['content']; $db->update('webstyle_module', $data, 'id=' . $_POST['id']); }