/home/banprang/domains/plai.go.th/public_html/coremain/module/popup/popup_add_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
<?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_add']="เพิ่มข้อมูล";
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_date!="")                                        {  $date=trim($p_date);                                                        }
if(
$p_month!="")                                    {  $month=trim($p_month);                                                    }
if(
$p_year!="")                                        {  $year=trim($p_year);                                                            }
$date_post=$year.$month.$date;
if(
$p_date1!="")                                        {  $date1=trim($p_date1);                                                    }
if(
$p_month1!="")                                    {  $month1=trim($p_month1);                                                }
if(
$p_year1!="")                                        {  $year1=trim($p_year1);                                                    }
$date_line=$year1.$month1.$date1;

if(
$p_who!="")                                        {  $who=trim($p_who);                                                            }
if(
$p_widths!="")                                    {  $widths=trim($p_widths);                                                    }
if(
$p_heights!="")                                    {  $heights=trim($p_heights);                                                }

$userfile1_name=trim($_FILES['userfile1']['name']);


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>ชนิดไฟล์ไม่ถูกต้อง <br>ไฟล์ต้องมีนามสกุลเป็น .gif หรือ .jpg หรือ .swf เท่านั้น<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_popup";
        
$resultmax1=mysql_query($sqlmax1);
        
$datamax1=mysql_fetch_row($resultmax1);
        
// ชื่อไฟล์
        
$strings=substr($userfile1_name,-4);
        
$name1="pic1$datamax1[0]$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)){
                        }
                    }
}


//*******เพิ่มข้อมูลลงในฐาน*************************************************
// หาค่า id สูงสุด + 1
$sqlmax1="select max(id+1) from cms_popup";
$resultmax1=mysql_query($sqlmax1);
$datamax1=mysql_fetch_row($resultmax1);        if ($datamax1[0]=="")        {            $datamax1[0]="1";        }

    
$sql "INSERT INTO cms_popup(id,topic,fulltexts,who,date_post,date_line,pic1,status,widths,heights) values('$datamax1[0]','$topic','$fulltexts','$_SESSION[name_post]','$date_post','$date_line','$name1','1','$widths','$heights')";

    
$result mysql_query($sql) or die(mysql_error());
    
$sql="UPDATE `cms_popup` SET `status` = '0' WHERE status='1' and id!='$datamax1[0]'";
    
$result mysql_query($sql) or die(mysql_error());

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