/var/www/hkosl.com/chineseaaedu/webadmin/content/site_info_modifyform/site_info_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
<?php
    
include_once('../../check_login.php');
    require_once(
"../../mime_type_lib.php");
    
$nowdate date("Y-m-d H:i:s"); 
    
//update db
    // Upload File
    
$id $_POST['siteinfoid'];
    
// Upload File
    
if ($_FILES["companylogo"]['name'] <> '') {
        
//check if image type is valid or not
        
$filename $_FILES["companylogo"]['name'];
        
preg_match("/\.([^\.]+)$/"$filename$file_ext);
        
$newfilename random_string(10) . "_logo_" $id "." $file_ext[1]; // default length 8
        
move_uploaded_file($_FILES["companylogo"]['tmp_name'], "../../../file/site_info/" $newfilename) or die ("Could not copy the file");
        
$photo $newfilename;
        
$_POST['companylogo'] = $photo;
    }
    unset(
$_POST['siteinfoid']);
    
$data $_POST;
    unset(
$data['x']);
    unset(
$data['y']);
    unset(
$data['id']);
    
$data['lastupdate'] = $nowdate;
    
$data['lastupby'] = $_SESSION['cmsloginid'];
    
$sql mysql_install($data,'site_info','edit','siteinfoid');
    
$data['siteinfoid'] = $id;
    
$arraykey=array_keys($data);
    for(
$i=0;$i<count($arraykey);$i++){
        
$parameters[$i]=$data[$arraykey[$i]];
    }
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }
    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }
    
$dbh null;
    
header("Location: site_info_modifyform.php?msg=編輯成功");
?>