/home/banprang/.trash/files/coremain.3/module/welcome_page/first_page_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
<?php
import_request_variables
('pG''p_');
if(
$p_bg!="")                        {  $bg=trim($p_bg);                                            }
if(
$p_page_type!="")        {  $page_type=trim($p_page_type);                }

$main_pic=trim($_FILES['main_pic']['name']);
$sub_pic=trim($_FILES['sub_pic']['name']);

bar_header ("แก้ไขข้อมูลหน้าแรก");
echo 
"<br/>";

$pass_1 0;
$pass_2 0;
// skip first page
if($page_type==1)
{
    
$page_write "<title>บริษัท โคราช กรุ๊ป วิศวกรรม จำกัด</title>\n";
    
$page_write.="<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
            
    if(
file_exists($_SERVER["DOCUMENT_ROOT"]."/index.html"))
    {        
        
    
$file_index_write  fopen($_SERVER["DOCUMENT_ROOT"]."/index.html","w") or die ("can't read file");
    
fwrite($file_index_write,$page_write) or die ("can't write file");
    
fclose($file_index_write);
    }
    
}else if (
$page_type==2)
{

// upload picture

if($main_pic!="")
{    
        
$main_pic_name $main_pic;
        
        
// tempolary folder keep file
    //    mkdir ($_SESSION['web_name']."/mail_temp/$folder_temp",0777);
        
                    
$dlink=$_SERVER["DOCUMENT_ROOT"]."/first_pic/".$main_pic_name;
                    
$temp_name=$_FILES['main_pic']['tmp_name'];
                    if (
is_uploaded_file($_FILES['main_pic']['tmp_name'])) {
                        if(!
move_uploaded_file($temp_name,$dlink)){
                            echo 
"<br/><font color='red'>cannot send file , try again<br/></font>";
                            die;
                            echo 
"<meta http-equiv='refresh' content='2; url=index.php?mod=first_page_edit&path=welcome_page'>" ;
                        }
                        else
                            
$pass_1 1;
    }
}
if(
$sub_pic!="")
{    
        
$sub_pic_name $sub_pic;
        
        
// tempolary folder keep file
    //    mkdir ($_SESSION['web_name']."/mail_temp/$folder_temp",0777);
        
                    
$dlink=$_SERVER["DOCUMENT_ROOT"]."/first_pic/".$sub_pic_name;
                    
$temp_name=$_FILES['sub_pic']['tmp_name'];
                    if (
is_uploaded_file($_FILES['sub_pic']['tmp_name'])) {
                        if(!
move_uploaded_file($temp_name,$dlink)){
                            echo 
"<br/><font color='red'>cannot send file , try again<br/></font>";
                            die;
                            echo 
"<meta http-equiv='refresh' content='2; url=index.php?mod=first_page_edit&path=welcome_page'>" ;
                        }
                        else
                            
$pass_2 1;
    }
}


    
$page_write "";
    
$page_write.="<html>";
    
$page_write.= "<title>บริษัท โคราช กรุ๊ป วิศวกรรม จำกัด</title>\n";
    
$page_write.="<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n";
    
$page_write.= "<body bgcolor='".$bg."'>";
    if(
$pass_1 ==1)
        
$page_write.="<center><img src='first_pic/$main_pic_name' border='0'></center>\n";
    if(
$pass_2 ==1)
    
$page_write.= "<center><a href='index.php'><img src='first_pic/$sub_pic_name' border='0'/></font></a></center>";
    
$page_write.= "</body>";

$page_write.="</html>";


    if(
file_exists($_SERVER["DOCUMENT_ROOT"]."/index.html"))
    {            
    
$file_index_write  fopen($_SERVER["DOCUMENT_ROOT"]."/index.html","w") or die ("can't read file");
    
fwrite($file_index_write,$page_write) or die ("can't write file");
    
fclose($file_index_write);
    }
    echo 
"<br/><center>แก้ไขข้อมูลสำเร็จแล้ว</center><br/>";
echo 
"<meta http-equiv='refresh' content='2; url=index.php'>" ;
}
?>