/home/banprang/domains/plai.go.th/public_html/coremain/module/popup/popup_edit_output.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
<?php
// Status Package Module
$status_module=select_query("status_module","cms_status_module","id","33");
if(
$status_module[0]!=1)    {    
    
fieldset_no_module();
}
$navig['manage_popup']="จัดการ Popup";
$navig['popup_edit']="แก้ไขข้อมูล";
navigator($navig);
echo
"<br>";
bar_header("แก้ไขข้อมูล"); // Bar_Header
fieldset_top("จัดการ Popup");


import_request_variables('pG''p_');
if(
$p_topic!="")                                    {         $topic=trim($p_topic);                                }
if(
$p_evar!="")                                        {         $fulltexts=trim($p_evar);                            }
if(
$p_widths!="")                                    {         $widths=trim($p_widths);                            }
if(
$p_heights!="")                                    {         $heights=trim($p_heights);                            }
if(
$p_date!="")                                        {         $date=trim($p_date);                                }
if(
$p_month!="")                                    {         $month=trim($p_month);                                }
if(
$p_year!="")                                        {         $year=trim($p_year);                                }
if(
$p_date1!="")                                    {         $date1=trim($p_date1);                                }
if(
$p_month1!="")                                    {         $month1=trim($p_month1);                            }
if(
$p_year1!="")                                    {         $year1=trim($p_year1);                                }
if(
$p_who!="")                                        {         $who=trim($p_who);                                    }
if(
$p_check_out!="")                                {        $check_out=trim($p_check_out);                        }
if(
$p_id_popup_edit!="")                            {         $id_popup_edit=trim($p_id_popup_edit);                }

$userfile1_name=trim($_FILES['userfile1']['name']);
$date_post=$year.$month.$date;
$date_line=$year1.$month1.$date1;

if(
$userfile1_name!=""){
        
$strings1=substr($userfile1_name,-4);
            if(
$strings1!=".gif" and $strings1!=".jpg" and $strings1!=".GIF" and $strings1!=".JPG" and $strings1!=".SWF" and $strings1!=".swf"){
                    echo
"<center><br>ไฟล์ที่ 1 ชนิดไฟล์ไม่ถูกต้อง <br>ไฟล์ต้องมีนามสกุลเป็น .gif หรือ .jpg หรือ .swf เท่านั้น<br><br>";
                    echo
"<a href='javascript:history.back()'><font color='ff0000'>[แก้ไขใหม่]</font></center></a>";
//                    include('coremain/footer.php');
                    
exit;
            }
}

// วันประสิ้นสุดประกาศต้องอยู่หลังวันประกาศเสมอ
if($date_post>$date_line)
{
    echo 
"<br><br><center>วันที่สิ้นสุดวันประกาศ ไม่ถูกต้อง !<br><br>";
                    echo
"<a href='javascript:history.back()'><font color='ff0000'>[แก้ไขใหม่]</font></center></a><br><br>";
//                    include('coremain/footer.php');
    
exit;
}

//********************** ตรวจสอบว่า มีการ Upload File ที่ 1 หรือไม*******************************************่
if($userfile1_name!="")
{        
// ลบไฟล์เก่าออกก่อน    
            
$sql1="select pic1 from cms_popup where id='$id_popup_edit'";
            
$result1=mysql_query($sql1);
            
$data1=mysql_fetch_row($result1);
            if(
$data1[0]!="")        {            unlink("$_SESSION[folder_name]/mainfile/$data1[0]");        }
        
// ชื่อไฟล์
        
$strings=substr($userfile1_name,-4);
        
$date=date("d");
        
$name1="file$date$strings";
                    
$dlink="$_SESSION[folder_name]/mainfile/".$name1;
                    
$temp_name=$_FILES['userfile1']['tmp_name'];
                    if (
is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
                        if(!
move_uploaded_file($temp_name,$dlink)){
                        }
                    }
}

// ไฟล์เก่ายังคงใช้อยู่
if($check_out!="1" and $userfile1_name==""){
            
$sql="select pic1 from cms_popup where id='$id_popup_edit'";
            
$result=mysql_query($sql);
            
$data=mysql_fetch_row($result);
                    if(
$userfile1_name=="")    {        $name1=$data[0];    }
}
if(
$check_out=="1" and $userfile1_name==""){
//ไฟล์เก่าไม่ใช้แล้ว เอาออกจากระบบไปเลย
            
$sql1="select pic1 from cms_popup WHERE id='$id_popup_edit'";
            
$result1=mysql_query($sql1);
            
$data1=mysql_fetch_row($result1);
            if(
$data1[0]!="")        {            unlink("$_SESSION[folder_name]/mainfile/$data1[0]");        $name1="";}
}
echo
"<table width='98%' border='0' cellspacing='1'  align='center' cellpadding='0'>";
echo
"<tr> ";
echo
" <td height='140' valign='top'>";
$sql="UPDATE `cms_popup` SET `topic` = '$topic', `fulltexts` = '$fulltexts', `who` = '$who',`pic1` = '$name1',`date_post` = '$date_post',`date_line` = '$date_line',`widths` = '$widths',`heights` = '$heights'  WHERE `id` = '$id_popup_edit' LIMIT 1";
$result=mysql_query($sql);
echo 
"<center><br><br>ข้อมูลได้ถูกแก้ไขแล้ว</center>"
echo 
"<meta http-equiv='refresh' content='2; url=index.php?mod=manage_popup&path=popup'>" ;

echo
"</td>  </tr>  </table>";
fieldset_down();
?>