| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/ergofito/webadmin/content/aboutus/ |
Upload File : |
<?php
include_once('../../check_login.php');
ini_set('display_errors',0);
$id =$_POST['id'];
unset($_POST['id']);
if($id){
//update db
$data = $_POST;
unset($data['x']);
unset($data['y']);
$data['lastupdate'] = $nowdate;
$data['lastupby'] = $_SESSION['cmsloginid'];
$sql = mysql_install($data,'aboutus','edit','refid');
$data['refid']=$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()));
}
$action = 'Save Success';
}else{
//refid
$sql = "select max(refid) as maxid from aboutus";
if (!($sth = $dbh->prepare($sql))) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
if (!$sth->execute()) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$_POST['refid'] = $row{"maxid"} + 1;
//sort
$sql = "select max(sort) as maxid from aboutus where type='".$type."'";
if (!($sth = $dbh->prepare($sql))) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
if (!$sth->execute()) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$_POST['sort'] = $row{"maxid"} + 1;
//insert db
$data = $_POST;
unset($data['x']);
unset($data['y']);
$data['lastupdate'] = $nowdate;
$data['lastupby'] = $_SESSION['cmsloginid'];
$sql = mysql_install($data,'news','add');
$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()));
}
$action = 'Add Success';
}
// Upload File
if ($_FILES["photo"]['name'] <> '') {
//check if image type is valid or not
$filename = $_FILES["photo"]['name'];
preg_match("/\.([^\.]+)$/", $filename, $file_ext);
$newfilename = random_string(10) . "_aboutus_refid_" . $id . "." . $file_ext[1]; // default length 8
move_uploaded_file($_FILES["photo"]['tmp_name'], "../../../file/aboutus/" . $newfilename) or die ("Could not copy the file");
$photo = $newfilename;
unset($data);
unset($parameters);
$data['photo'] = $photo;
$sql = mysql_install($data,'aboutus','edit','refid');
$data['refid']=$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()));
}
}
header("Location: aboutus_index.php?msg=".$action);
exit();
?>