/home/banprang/domains/plai.go.th/public_html/coremain/header_addmenu.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
session_start
();
include (
"function_import_request.php");
echo
"<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
echo
"<link href='coremain/ccs/style.php' rel='stylesheet' type='text/css'>";
import_request_variables('pG''p_');
//#5.3#//if($p_folder_name!="")            {            $folder_name=trim($p_folder_name);        }
$folder_name = isset($p_folder_name) ? $p_folder_name '';
//#5.3#//if($_SESSION[folder_name]=="")    {            $_SESSION[folder_name]=$folder_name;    }
$_SESSION['folder_name'] = $_SESSION['folder_name'] == '' $folder_name $_SESSION['folder_name'];
//#5.3#//if($p_add_menu!="")                {            $add_menu=trim($p_add_menu);            }
$add_menu = isset($p_add_menu) ? $p_add_menu '';
//#5.3#//if($p_name!="")                    {            $name=trim($p_name);                    }
$name = isset($p_name) ? $p_name '';
//#5.3#//if($p_namemenu!="")                {            $namemenu=trim($p_namemenu);            }
$namemenu = isset($p_namemenu) ? $p_namemenu '';
//#5.3#//if($p_type_module!="")            {            $type_module=trim($p_type_module);        }
$type_module = isset($p_type_module) ? $p_type_module '';
//#5.3#//if($p_left_right!="")            {            $left_right=trim($p_left_right);        }
$left_right = isset($p_left_right) ? $p_left_right '';
//#5.3#//if($p_theme_!="")                {            $theme_=trim($p_theme_);                }
$theme_ = isset($p_theme_) ? $p_theme_ '';
//#5.3#//if($p_id_modules!="")                {            $id_modules=trim($p_id_modules);                }
$id_modules = isset($p_id_modules) ? $p_id_modules '';
//#5.3#//if($p_id_graph!="")                    {            $id_graph=trim($p_id_graph);                }
$id_graph = isset($p_id_graph) ? $p_id_graph '';
//#5.3#//if($id_modules=="") $id_modules=1;
$id_modules $id_modules == '' $id_modules;
//#5.3#//if($_SESSION[themes_]=="") $_SESSION[themes_]=$theme_;
$_SESSION['themes_'] = $_SESSION['themes_'] == '' $theme_ $_SESSION['themes_'];

include(
"../coremain/connec_out.php");
include(
"../coremain/function_msg.php");
include(
"function_form.php");
include(
"function_sql_query.php");
echo 
"<title>จัดการเมนูกราฟฟิค</title>";

$userfile1_name = isset($_FILES['userfile1']['name']) ? trim($_FILES['userfile1']['name']) : '';
if (
$userfile1_name != "") {
  
$strings substr($userfile1_name, -4);
  if (
$strings != ".gif" and $strings != ".jpg" and $strings != ".GIF" and $strings != ".JPG") {
    echo
"<center><br>ไฟล์ที่ $numberfile ชนิดไฟล์ไม่ถูกต้อง <br>ไฟล์ต้องมีนามสกุลเป็น .gif หรือ .jpg เท่านั้น <br>และขนาดไฟล์ต้องไม่เกิน 2 Mb.<br><br>";
    echo 
"<FORM METHOD=POST ACTION='header_addmenu.php'>";
    echo
"<INPUT TYPE='hidden' name='id_modules' value='$id_modules'>";
    echo
"<INPUT TYPE='submit' value='Back' onmouseover='this.style.cursor=hand'>";
    echo
"</FORM>";
    exit;
  }
}

// Create_Filename
if ($userfile1_name != "") {
  
$name1 create_filename($userfile1_name);
  
$dlink "../coremain/images/menu/$_SESSION[themes_]/1/" $name1;
  
upload_file_to_server($dlink$_FILES['userfile1']);

  
// CHECK ขนาดความกว้างและสูงของไฟล์เมนู
  
list($width$height$type$attr) = getimagesize("../coremain/images/menu/$_SESSION[themes_]/1/$name1");
  if (
$width 190 or $width 190) {
    
unlink("../coremain/images/menu/$_SESSION[themes_]/1/$name1");
    print 
"<br><br><br><center>ความกว้างของไฟล์เมนูต้องเท่ากับ 190 Pixel<br>";
    echo 
"<FORM METHOD=POST ACTION='header_addmenu.php'>";
    echo
"<INPUT TYPE='hidden' name='id_modules' value='$id_modules'>";
    echo
"<INPUT TYPE='submit' value='Back' onmouseover='this.style.cursor=hand'>";
    echo
"</FORM>";
    exit;
  }
  if (
$height 38 or $height 38) {
    
unlink("../coremain/images/menu/$_SESSION[themes_]/1/$name1");
    print 
"<br><br><br><center>ความสูงของไฟล์เมนูต้องเท่ากับ 38 Pixel<br>";
    echo 
"<FORM METHOD=POST ACTION='header_addmenu.php'>";
    echo
"<INPUT TYPE='hidden' name='id_modules' value='$id_modules'>";
    echo
"<INPUT TYPE='submit' value='Back' onmouseover='this.style.cursor=hand'>";
    echo
"</FORM>";
    exit;
  }

  
// Insert base
  
$sql "INSERT INTO `cms_graphic` (`id_graphic` ,`id_module` ,`name` ) VALUES (NULL , '$id_modules', '$name1')";
  
mysql_query($sql);
}

// Delete Graphic
if ($id_graph != "" and $id_modules != "") {
  
delete_filename("cms_graphic""name"$id_graph"../coremain/images/menu/$_SESSION[themes_]/1/""id_graphic");
  
$s "DELETE FROM cms_graphic WHERE id_graphic='$id_graph'";
  
mysql_query($s);
}
/*
if($add_menu==1){
        ?>
        <script language="JavaScript"> 
            window.opener.location.href='../index.php';
            window.close();
        </script>
        <?php
}
*/
?>
<fieldset><center>
  <form name="add">
  <!--<FORM METHOD=POST ACTION='header_addmenu.php?id_modules=$id_modules' name='add' onSubmit='return checkadd()' enctype='multipart/form-data'>-->
  <table width=100% border=0 align=center cellpadding=1 cellspacing=1>
    <tr height='50'>
      <td><img src='coremain/images/marker.gif'>&nbsp;  จัดการเมนูกราฟฟิค : </td>
      <td>
        <select name='id_modules' style='width:200' class="sl_id_modules"><!-- onchange=change_link(this.value);>-->
          <option value="5" <?= $id_modules == 'selected' '' ?>>ใส่ Code Freed RSS</option>
          <option value="4" <?= $id_modules == 'selected' '' ?>>สาส์นจากผู้บริหาร</option>
          <option value="3" <?= $id_modules == 'selected' '' ?>>ลิงค์แสดงรูปใน Blog</option>
          <option value="2" <?= $id_modules == 'selected' '' ?>>สถานที่ท่องเที่ยว / OTOP</option>
          <option value="1" <?= $id_modules == 'selected' '' ?>>เมนูย่อย</option>
        </select>
      </td>
    </tr>
    <tr>
      <td colspan=2>
        <table width=98% border=0 align=center cellpadding=1 cellspacing=1>
        <?php
          $s 
"SELECT * FROM cms_graphic WHERE id_module='$id_modules' order by id_graphic";
          
$r mysql_query($s);
          
$count 0;
          while (
$da mysql_fetch_array($r)) {
            if(
file_exists('images/menu/'$_SESSION['themes_'] .'/1/'$da['name'])){
            
$mots $count 3;
            if (
$mots == 0) {
        
?>
          <tr height='50'>
            <td width='33%'>
              <img src='coremain/images/menu/<?= $_SESSION['themes_'?>/1/<?= $da['name'?>'><br>
              <?php if ($da['id_graphic'] > 52) { ?>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href='header_addmenu.php?id_modules=<?= $id_modules ?>&id_graph=<?= $da['id_graphic'?>'><img src='coremain/images/del1.gif' border=0 onclick='return goURLdel();'></a> ลบเมนู<br>
              <?php ?>
              <br>
            </td>
        <?php } else if ($mots == 1) { ?>
            <td width='33%'>
              <img src='coremain/images/menu/<?= $_SESSION['themes_'?>/1/<?= $da['name'?>'><br>
              <?php if ($da['id_graphic'] > 52) { ?>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href='header_addmenu.php?id_modules=<?= $id_modules ?>&id_graph=<?= $da['id_graphic'?>'><img src='coremain/images/del1.gif' border=0 onclick='return goURLdel();'></a> ลบเมนู<br>
              <?php ?>
                <br>
            </td>
        <?php } elseif ($mots == 2) { ?>
            <td width='33%'>
              <img src='coremain/images/menu/<?= $_SESSION['themes_'?>/1/<?= $da['name'?>'><br>
              <?php if ($da['id_graphic'] > 52) { ?>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href='header_addmenu.php?id_modules=<?= $id_modules ?>&id_graph=<?= $da['id_graphic'?>'><img src='coremain/images/del1.gif' border=0 onclick='return goURLdel();'></a> ลบเมนู<br>
              <?php ?>
                <br>
            </td>
          </tr>
        <?php }
            
$count++;
            }
          }
        
?>
        </table>
      </td>
    </tr>
    <tr height='80'>
      <td valign=center><img src='coremain/images/marker.gif'>&nbsp;เลือกเมนูที่เพิ่ม : </td>
      <td valign=center>
        <input name='userfile1' type='file' size=32>
        <br><font color='ff0000'>รูปต้องมีขนาด&nbsp;กว้าง 190 สูง 38 Pixel</font>
      </td>
    </tr>
    <tr height='10'>
      <td colspan=2 align='center'>
        <INPUT TYPE='submit' value='เพิ่มเมนูกราฟฟิค' onmouseover=this.style.cursor='hand'>
        <INPUT TYPE='hidden' name='add_menu' value='1'>
      </td>
    </tr>
  </table>
  </FORM>
</center></fieldset>


<script language="javascript">
//  function checkadd() {
//    if(document.add.namemenu.value=="") {
//      alert("กรุณากรอก ชื่อ Blog !") ;
//      document.add.namemenu.focus() ;
//      return false ;
//    }else
//      return true ;
//  }
  
  
  var arr_select = { '1' : 'link', '2' : 'picture', '3' : 'sponser', '4' : 'boss_message', '5' : 'code', };
  $('.sl_id_modules').change(function(){
    var id_modules = $(this).val();
    var arrData = [
      { name: 'id_modules', value: id_modules }
    ];
    $.ajax({
      type: 'post',
      url: 'coremain/header_addmenu.php',
      data: arrData,
      success: function(result){
        $('#dialog-popup').html(result);
      }
    });
  });
  
  
  function goURLdel() {
    var blnLink;
    blnLink = confirm("Click OK เพื่อยืนยันการลบข้อมูล?")
    if (!blnLink) { return false; }
    return true;
  }
  
</script>