/home/banprang/domains/plai.go.th/public_html/coremain/module/download/adddownload_form.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
// Status Package Module
$status_module=select_query("status_module","cms_status_module","id","28");
if(
$status_module[0]!=1)    {    
    
fieldset_no_module();
}
if(
id_sub_permission(7)!=1){    
    
permission_fail();            
}
$navig['download']="ดาวน์โหลด";
$navig['adddownload_form_topic']="เพิ่มข้อมูล";
navigator($navig);
echo 
"<br>";
bar_header("ดาวน์โหลด"); // Bar_Header
fieldset_top("ดาวน์โหลด");
import_request_variables('pG''p_');
if(
$p_add!="")                            {  $add=trim($p_add);                                            }
if(
$p_topic!="")                            {  $topic=trim($p_topic);                                        }
if(
$p_download_url!="")                        {  $download_url=trim($p_download_url);                                }
if(
$p_id_group!="")                    {  $id_group=trim($p_id_group);                            }
$userfile1_name=trim($_FILES['userfile1']['name']);
if(
$p_detail!="")                    {  $detail=trim($p_detail);                            }


// add topic download
if ($add == "1" && $topic != "") {
  if (
$userfile1_name != "") {
    
//$strings1 = substr($userfile1_name, -4);
    
$strings1 get_file_type($userfile1_name);
    if (
$strings1 == ".php" or $strings1 == ".asp") {
      echo
"<center><br>ไฟล์ประกอบไม่อนุญาตให้ Upload <br>เนื่องจากชนิดไฟล์เสียงต่อความเสียหายของระบบ<br><br>";
      echo
"<a href='javascript:history.back()'><font color='ff0000'>[แก้ไขใหม่]</font></center></a>";
//      include('coremain/footer.php');
      
exit;
    }
  }
  
//********************** ตรวจสอบว่า มีการ Upload File ที่ 1 หรือไม*******************************************่
  
if ($userfile1_name != "") {     // กำหนดชื่อไฟล์ที่ upload ใหม่ ทั้งนี้เพื่อให้ ไฟล์ไม่ซ้ำกัน
    
$sqlmax1 "select max(id+1)  from cms_download";
    
$resultmax1 mysql_query($sqlmax1);
    
$datamax1 mysql_fetch_row($resultmax1);
    
// ชื่อไฟล์
    
$strings substr($userfile1_name, -4);
    
$name1 "files$datamax1[0]$strings";
    
$dlink "$_SESSION[web_name]/mainfile/" $name1;
    
$temp_name $_FILES['userfile1'];
    
upload_file_to_server($dlink$temp_name);
//    if (is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
//      if (!move_uploaded_file($temp_name, $dlink)) {
//        
//      }
//    }
  
}
  
$sql "SELECT detail FROM cms_download";
  
$result mysql_query($sql);
  
$x mysql_error();
  if (
$x != "") {
    
$sql "ALTER TABLE `cms_download` ADD `detail` TEXT NOT NULL AFTER `status`";
    
mysql_query($sql);
  }

  
$sql "INSERT INTO cms_download(id,topic,download,id_group,status,detail) values(Null,'$topic','$name1','$id_group','1','$detail')";
  
$result mysql_query($sql) or die(mysql_error());

  echo
"<br><br><center>ข้อมูลได้ถูกเพิ่มแล้ว<br><br></enter>";
  echo 
"<meta http-equiv='refresh' content='2; url=index.php?mod=download&path=download'>";
//  include('coremain/footer.php');
  
exit;
}
?>

<br>
<form  name="add" enctype="multipart/form-data"  action="index.php?mod=adddownload_form&add=1&id_group=<?php echo $id_group ?>&path=download" method="post" onSubmit="return checkadd()">
  <table width="100%" border="0" align="center" cellpadding="1" cellspacing="3">

    <tr height="30">
      <td width=17%><div align="left"><img src='coremain/images/marker.gif'> <b>ชื่อไฟล์</b></div></td> 
      <td width=73%><div align="left"><input name="topic" type="text" size="40"></td> 
    </tr>

    <?php text_editor('450''260''รายละเอียดไฟล์''2'$values'detail'); ?>
    
<!--          <tr height="30">

            <td><div align="left"><img src='coremain/images/marker.gif'> <b>รายละเอียดไฟล์</b></div></td> 
            <td>
              <?php
//              $oFCKeditor = new FCKeditor('detail');
//              $oFCKeditor->BasePath = 'coremain/editor/';
//              $oFCKeditor->Value = $values;
//              $oFCKeditor->Width = 450;
//              $oFCKeditor->Height = 260;
//              $oFCKeditor->Create();
              
?>
            </td> 
          </tr>-->
    <tr>
      <td><div align="left"><img src='coremain/images/marker.gif'> <b>Upload File</b></div></td> 
      <td><input name="userfile1" type="file" size="40">&nbsp; <img src='coremain/images/bu.gif' border='0' title='ต้องเป็นไฟล์ที่ไม่ใช่ .php หรือ .asp หรือ .exe' onmouseover=this.style.cursor='hand'></td> 
    </tr>
    
    <?php button_text('เพิ่มข้อมูล''Submit'); ?>
<!--      <tr height="45">
            <td></td> 
            <td>
              <input type="submit" name="Submit" value="เพิ่มข้อมูล" onmouseover="this.style.cursor='hand'">
            </td> 
          </tr>-->

  </table>
</form> 
<?php fieldset_down();?>

<script language="javascript">
  function checkadd() {
    if(document.add.topic.value=="") {
      alert("กรุณากรอกเนื้อหาดาวน์โหลด !") ;
      document.add.topic.focus() ;
      return false ;
    }else if(document.add.userfile1.value=="") {
      alert("กรุณาเลือกไฟล์ที่จะ Upload !") ;
      document.add.userfile1.focus() ;
      return false ;
    }else 
      return true ;
  }
</script>