/var/www/hkosl.com/alliancealliance/webadmin/static_page_modify.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
<?php
    
require_once ("check_login.php");
    require_once(
"function_cropimg.php");
    require_once(
"mime_type_lib.php");

    
$id $_POST["id"];
    
$link_or_page $_POST["link_or_page"];

    foreach (
$arraylangcode as $langcode => $langname) {

        
// Upload File
        
$filelimit 10 1048576//Filelimit in 10MB
        
if ($_FILES["banner_" $langcode]['name'] <> '') {
            if (
$_FILES["banner_" $langcode]['size'] < $filelimit) {

                
//check if image type is valid or not
                
$mime get_file_mime_type($_FILES["banner_" $langcode]['name']);

                if ((
$mime == "image/gif") || ($mime == "image/jpeg") || ($mime == "image/png")) {

                    
$filename $_FILES["banner_" $langcode]['name'];
                    
preg_match("/\.([^\.]+)$/"$filename$file_ext);
                    
$newfilename random_string() . "_static_page_" $id "." $file_ext[1]; // default length 8

                    
move_uploaded_file($_FILES["banner_" $langcode]['tmp_name'], "../images/banner/" $newfilename) or die ("Could not copy the file");

                    
//$banner_path = "../images/slideshow/".$newfilename;

                    //createthumb($banner_path, $banner_path, 680, 350);

                    
$banner[$langcode] = $newfilename;

                } else {
                    echo 
'<script language="javascript">
                alert("Image format should be JPEG, GIF or PNG. Image size should be lower than 10MB");
                history.back();
            </script>'
;

                    exit;
                }

            } else {
                echo 
'<script language="javascript">
                alert("Image format should be JPEG, GIF or PNG. Image size should be lower than 10MB");
                history.back();
            </script>'
;

                exit;
            }

        } else {
            
$banner[$langcode] = "";
            
//$messgae .= "Please select a banner image.\\n\\n";
        
}
    }

    if(
$link_or_page == "link"){
        
$link_to $_POST["link_to"];
        foreach (
$arraylangcode as $langcode => $langname) {
            
//$page_title  =  $_POST["page_".$langcode];

            
$sql "update static_page set link_to=?, lastupdate=?, lastupby=? where id=?";
            
$parameters = array($link_to$nowdate$_SESSION['cmsloginid'], $id);
            
bind_pdo($sql$parameters);
        }
    }

    if(
$link_or_page == "page"){
        
$sql        "update static_page set lastupdate=?, lastupby=?, ";
        
$parameters = array($nowdate$_SESSION['cmsloginid']);

        foreach (
$arraylangcode as $langcode => $langname) {
            
$sql .= "desc_" $langcode "=?, title_" $langcode "=?, ";
            
$parameters[] = $_POST["desc_" $langcode];
            
$parameters[] = $_POST["title_" $langcode];

            if (
$banner[$langcode] != '' || $_POST['delimage_' $langcode] > 0) {
                
$sql .= "banner_" $langcode "=?, ";
                
$parameters[] = $banner[$langcode];

                
//unlink image
                
$unlink_file_path "../images/banner/" $old_menu_info["banner_" $langcode];

                if (
is_file($unlink_file_path)) {
                    
unlink($unlink_file_path);
                }
            }
        }

        
$sql substr_replace($sql"", -2);

        
$sql .= " where id=?";
        
$parameters[] = $id;
        
bind_pdo($sql$parameters);
    }

    
$dbh null;

    
header("Location: static_page_index.php?msg=2");