PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website quảng cáo PHP/admin/content_intro_m.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 320 lines | 292 code | 28 blank | 0 comment | 32 complexity | 40f5ae0d003ed4af2948510cf808b38e MD5 | raw file
  1. <? // Config
  2. $codeSelect = $multiLanguage == 0 ? "code='".$_lang."_intro'" : "code='vn_intro' or code='en_intro'";
  3. $tableCategoryConfig = 'tbl_content_category';
  4. $tableConfig = 'tbl_content';
  5. $actConfig = 'intro';
  6. $arraySourceCombo = getArrayCombo($tableCategoryConfig,'id','name',$codeSelect);
  7. ?>
  8. <?
  9. if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
  10. echo '<script language="javascript" src="../lib/scripts/editor.js"></script>';
  11. else
  12. echo '<script language="javascript" src="../lib/scripts/moz/editor.js"></script>'?>
  13. <script language="javascript">
  14. function btnSave_onclick(){
  15. if(test_empty(document.frmForm.txtName.value)){
  16. alert('Hãy nhập "tên" !');
  17. document.frmForm.txtName.focus();
  18. return false;
  19. }
  20. document.forms.frmForm.elements.txtSubject.value = oEdit0.getHTMLBody();
  21. document.forms.frmForm.elements.txtDetailShort.value = oEdit1.getHTMLBody();
  22. return true;
  23. }
  24. </script>
  25. <? $errMsg =''?>
  26. <?
  27. $path = "../images/content";
  28. $pathdb = "images/content";
  29. if (isset($_POST['btnSave'])){
  30. $code = isset($_POST['txtCode']) ? trim($_POST['txtCode']) : '';
  31. $name = isset($_POST['txtName']) ? trim($_POST['txtName']) : '';
  32. $parent = $_POST['ddCat'];
  33. $subject = isset($_POST['txtSubject']) ? trim($_POST['txtSubject']) : '';
  34. $detail_short = isset($_POST['txtDetailShort']) ? trim($_POST['txtDetailShort']) : '';
  35. $detail = isset($_POST['txtDetail']) ? trim($_POST['txtDetail']) : '';
  36. $sort = isset($_POST['txtSort']) ? trim($_POST['txtSort']) : 0;
  37. $status = $_POST['chkStatus']!='' ? 1 : 0;
  38. $catInfo = getRecord($tableCategoryConfig, 'id='.$parent);
  39. $lang = $catInfo['lang'];
  40. if ($name=="") $errMsg .= "Hãy nhập tên danh mục !<br>";
  41. $errMsg .= checkUpload($_FILES["txtImage"],".jpg;.gif;.bmp",500*1024,0);
  42. $errMsg .= checkUpload($_FILES["txtImageLarge"],".jpg;.gif;.bmp",500*1024,0);
  43. if ($errMsg==''){
  44. if (!empty($_POST['id'])){
  45. $oldid = $_POST['id'];
  46. $sql = "update ".$tableConfig." set code='".$code."',name='".$name."', parent='".$parent."',subject='".$subject."',detail_short='".$detail_short."',detail='".$detail."', sort='".$sort."', status='".$status."',last_modified=now(), lang='".$lang."' where id='".$oldid."'";
  47. }else{
  48. $sql = "insert into ".$tableConfig." (code, name, parent, subject, detail_short, detail, sort, status, date_added, last_modified, lang) values ('".$code."','".$name."','".$parent."','".$subject."','".$detail_short."','".$detail."','".$sort."','".$status."',now(),now(),'".$lang."')";
  49. }
  50. if (mysql_query($sql,$conn)){
  51. if(empty($_POST['id'])) $oldid = mysql_insert_id();
  52. $r = getRecord($tableConfig,"id=".$oldid);
  53. $sqlUpdateField = "";
  54. if ($_POST['chkClearImg']==''){
  55. $extsmall=getFileExtention($_FILES['txtImage']['name']);
  56. if (makeUpload($_FILES['txtImage'],"$path/".$actConfig."_s".$oldid.$extsmall)){
  57. @chmod("$path/".$actConfig."_s".$oldid.$extsmall, 0777);
  58. $sqlUpdateField = " image='$pathdb/".$actConfig."_s".$oldid.$extsmall."' ";
  59. }
  60. }else{
  61. if(file_exists('../'.$r['image'])) @unlink('../'.$r['image']);
  62. $sqlUpdateField = " image='' ";
  63. }
  64. if ($_POST['chkClearImgLarge']==''){
  65. $extlarge=getFileExtention($_FILES['txtImageLarge']['name']);
  66. if (makeUpload($_FILES['txtImageLarge'],"$path/".$actConfig."_l".$oldid.$extlarge)){
  67. @chmod("$path/".$actConfig."_l".$oldid.$extlarge, 0777);
  68. if($sqlUpdateField != "") $sqlUpdateField .= ",";
  69. $sqlUpdateField .= " image_large='$pathdb/".$actConfig."_l".$oldid.$extlarge."' ";
  70. }
  71. }else{
  72. if(file_exists('../'.$r['image_large'])) @unlink('../'.$r['image_large']);
  73. if($sqlUpdateField != "") $sqlUpdateField .= ",";
  74. $sqlUpdateField .= " image_large='' ";
  75. }
  76. if($sqlUpdateField!='') {
  77. $sqlUpdate = "update ".$tableConfig." set $sqlUpdateField where id='".$oldid."'";
  78. mysql_query($sqlUpdate,$conn);
  79. }
  80. }else{
  81. $errMsg = "Không thể cập nhật !";
  82. }
  83. }
  84. if ($errMsg == '')
  85. echo '<script>window.location="./?act='.$actConfig.'&cat='.$_REQUEST['cat'].'&page='.$_REQUEST['page'].'&code=1"</script>';
  86. }else{
  87. if (isset($_GET['id'])){
  88. $oldid=$_GET['id'];
  89. $page = $_GET['page'];
  90. $sql = "select * from ".$tableConfig." where id='".$oldid."'";
  91. if ($result = mysql_query($sql,$conn)) {
  92. $row=mysql_fetch_array($result);
  93. $code = $row['code'];
  94. $name = $row['name'];
  95. $parent = $row['parent'];
  96. $subject = $row['subject'];
  97. $detail_short = $row['detail_short'];
  98. $detail = $row['detail'];
  99. $image = $row['image'];
  100. $image_large = $row['image_large'];
  101. $sort = $row['sort'];
  102. $status = $row['status'];
  103. $date_added = $row['date_added'];
  104. $last_modified = $row['last_modified'];
  105. }
  106. }
  107. }
  108. ?>
  109. <pre id="idTemporary0" name="idTemporary0" style="display:none">
  110. <? if(isset($subject)){echo $subject;}?>
  111. </pre>
  112. <pre id="idTemporary1" name="idTemporary1" style="display:none">
  113. <? if(isset($detail_short)){echo $detail_short;}?>
  114. </pre>
  115. <form method="post" name="frmForm" enctype="multipart/form-data" action="./">
  116. <input type="hidden" name="txtSubject" id="txtSubject">
  117. <input type="hidden" name="txtDetailShort" id="txtDetailShort">
  118. <input type="hidden" name="txtDetail" id="txtDetail">
  119. <input type="hidden" name="act" value="<?=$actConfig?>_m">
  120. <input type="hidden" name="id" value="<?=$_REQUEST['id']?>">
  121. <input type="hidden" name="page" value="<?=$_REQUEST['page']?>">
  122. <table border="1" cellpadding="0" cellspacing="0" bordercolor="#0069A8" width="100%">
  123. <tr>
  124. <td width="45%">
  125. <table border="0" cellpadding="2" bordercolor="#111111" width="100%" cellspacing="0">
  126. <tr><td height="10"></td></tr>
  127. <tr>
  128. <td colspan="3" align="center">
  129. <table width="100%">
  130. <? if($image!='' || $image_large!=''){?>
  131. <tr>
  132. <td width="15%"></td>
  133. <td width="40%" align="center" class="smallfont">
  134. <? if ($image!=''){ echo '<img border="0" src="../'.$image.'" width="100"><br><br>Hình ảnh';}?>
  135. </td>
  136. <td width="40%" align="center" class="smallfont">
  137. <? if ($image_large!=''){ echo '<img border="0" src="../'.$image_large.'" width="100"><br><br>Hình (kích thước lớn)';}?>
  138. </td>
  139. <td width="15%"></td>
  140. </tr>
  141. <? }//else{echo '<tr><td colspan="3" class="smallfont" align="center">Chưa có hình ảnh !</td></tr>';}?>
  142. <tr><td colspan="4" height="10"></td></tr>
  143. <tr><td colspan="4" height="1" bgcolor="#999999"></td></tr>
  144. <tr><td colspan="4" height="10"></td></tr>
  145. </table>
  146. </td>
  147. </tr>
  148. <tr>
  149. <td width="15%" class="smallfont" align="right">Tên</td>
  150. <td width="1%" class="smallfont" align="center"><font color="#FF0000">*</font></td>
  151. <td width="83%" class="smallfont">
  152. <input readonly value="<?=$name?>" type="text" name="txtName" class="textbox" size="34">
  153. </td>
  154. </tr>
  155. <tr>
  156. <td width="15%" class="smallfont" align="right">Tiêu đề</td>
  157. <td width="1%" class="smallfont" align="center"></td>
  158. <td width="83%" class="smallfont">
  159. <script>
  160. var oEdit0 = new InnovaEditor("oEdit0");
  161. oEdit0.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
  162. oEdit0.width="100%";
  163. oEdit0.height=150;
  164. oEdit0.features=[
  165. "FullScreen","Search",
  166. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  167. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  168. "CustomTag","HTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent",
  169. "LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
  170. "Table","Guidelines","Absolute","|","Characters","Line",
  171. "Form","Clean","ClearAll","BRK",
  172. "StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
  173. "ParagraphFormatting","CssText","Styles","|",
  174. "Paragraph","FontName","FontSize","|",
  175. "Bold","Italic",
  176. "Underline","Strikethrough","|","Superscript","Subscript","|",
  177. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"
  178. ];
  179. oEdit0.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.php',640,465)";
  180. oEdit0.RENDER(document.getElementById("idTemporary0").innerHTML);
  181. </script>
  182. </td>
  183. </tr>
  184. <tr>
  185. <td width="15%" class="smallfont" align="right">Hình ảnh</td>
  186. <td width="1%" class="smallfont" align="center"></td>
  187. <td width="83%" class="smallfont">
  188. <input type="file" name="txtImage" class="textbox" size="34">
  189. <input type="checkbox" name="chkClearImg" value="on"> Xóa bỏ hình ảnh
  190. </td>
  191. </tr>
  192. <!--<tr>
  193. <td width="15%" class="smallfont" align="right">Hình (kích thước lớn)</td>
  194. <td width="1%" class="smallfont" align="center"></td>
  195. <td width="83%" class="smallfont">
  196. <input type="file" name="txtImageLarge" class="textbox" size="34">
  197. <input type="checkbox" name="chkClearImgLarge" value="on"> Xóa bỏ hình ảnh
  198. </td>
  199. </tr>-->
  200. <tr>
  201. <td width="15%" class="smallfont" align="right">Nội dung </td>
  202. <td width="1%" class="smallfont" align="center"></td>
  203. <td width="83%" class="smallfont">
  204. <script>
  205. var oEdit1 = new InnovaEditor("oEdit1");
  206. oEdit1.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
  207. oEdit1.width="100%";
  208. oEdit1.height=400;
  209. oEdit1.features=[
  210. "FullScreen","Search",
  211. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  212. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  213. "CustomTag","HTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent",
  214. "LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
  215. "Table","Guidelines","Absolute","|","Characters","Line",
  216. "Form","Clean","ClearAll","BRK",
  217. "StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
  218. "ParagraphFormatting","CssText","Styles","|",
  219. "Paragraph","FontName","FontSize","|",
  220. "Bold","Italic",
  221. "Underline","Strikethrough","|","Superscript","Subscript","|",
  222. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"
  223. ];
  224. oEdit1.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.php',640,465)";
  225. oEdit1.RENDER(document.getElementById("idTemporary1").innerHTML);
  226. </script>
  227. </td>
  228. </tr>
  229. <!--<tr>
  230. <td width="15%" class="smallfont" align="right">Thông tin chi tiết</td>
  231. <td width="1%" class="smallfont" align="center"></td>
  232. <td width="83%" class="smallfont">
  233. <script>
  234. var oEdit2= new InnovaEditor("oEdit2");
  235. oEdit2.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
  236. oEdit2.width="100%";
  237. oEdit2.height=400;
  238. oEdit2.features=[
  239. "FullScreen","Search",
  240. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  241. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  242. "CustomTag","HTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent",
  243. "LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
  244. "Table","Guidelines","Absolute","|","Characters","Line",
  245. "Form","Clean","ClearAll","BRK",
  246. "StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
  247. "ParagraphFormatting","CssText","Styles","|",
  248. "Paragraph","FontName","FontSize","|",
  249. "Bold","Italic",
  250. "Underline","Strikethrough","|","Superscript","Subscript","|",
  251. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"
  252. ];
  253. oEdit2.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.php',640,465)";
  254. oEdit2.RENDER(document.getElementById("idTemporary2").innerHTML);
  255. </script>
  256. </td>
  257. </tr>-->
  258. <tr>
  259. <td width="15%" class="smallfont" align="right">Thuộc danh mục</td>
  260. <td width="1%" class="smallfont" align="center"></td>
  261. <td width="83%" class="smallfont">
  262. <?=comboCategory('ddCat',$arraySourceCombo,'smallfont',$parent,0)?>
  263. </td>
  264. </tr>
  265. <!--<tr>
  266. <td width="15%" class="smallfont" align="right">Thứ tự sắp xếp</td>
  267. <td width="1%" class="smallfont" align="right"></td>
  268. <td width="83%" class="smallfont">
  269. <input value="<?=$sort?>" type="text" name="txtSort" class="textbox" size="34">
  270. </td>
  271. </tr>-->
  272. <tr>
  273. <td width="15%" class="smallfont" align="right">Không hiển thị</td>
  274. <td width="1%" class="smallfont" align="center"></td>
  275. <td width="83%" class="smallfont">
  276. <input type="checkbox" name="chkStatus" value="on" <? if ($status>0) echo 'checked' ?>>
  277. </td>
  278. </tr>
  279. <tr>
  280. <td width="15%" class="smallfont"></td>
  281. <td width="1%" class="smallfont" align="center"></td>
  282. <td width="83%" class="smallfont">
  283. <input type="submit" name="btnSave" VALUE="Cập nhật" class=button onclick="return btnSave_onclick()">
  284. <input type="reset" class=button value="Nhập lại">
  285. </td>
  286. </tr>
  287. </table>
  288. </td>
  289. </tr>
  290. </table>
  291. </form>
  292. <? if($errMsg!=''){echo '<p align=center class="err">'.$errMsg.'<br></p>';}?>