| 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/(Del)discoverylearning.com.hk/webadmin/ |
Upload File : |
<?php require("configure.php");
$GalleryCatTitleen = htmlspecialchars($_POST["GalleryCatTitleen"],ENT_QUOTES);
$GalleryCatTitletc = htmlspecialchars($_POST["GalleryCatTitletc"],ENT_QUOTES);
$GalleryCatTitlesc = htmlspecialchars($_POST["GalleryCatTitlesc"],ENT_QUOTES);
$GalleryCatDate = htmlspecialchars($_POST["GalleryCatDate"],ENT_QUOTES);
$GalleryCatSort = $_POST["GalleryCatSort"];
/*print_r($_POST);
exit;*/
$sql = "select max(GalleryCatId) as maxid ";
$sql .= "from GalleryCat ";
$result=mysql_query($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$GalleryCatId = $row{maxid}+1;
// copy image
if ($_FILES['GalleryCatCover']['name'] <> '')
{
copy ($_FILES['GalleryCatCover']['tmp_name'], "gallerycover/".$GalleryCatId."_".$_FILES['GalleryCatCover']['name'])
or die ("Could not copy");
$GalleryCatCover = $GalleryCatId."_".$_FILES['GalleryCatCover']['name'];
$GalleryCatCover = htmlspecialchars($GalleryCatCover,ENT_QUOTES);
$image = "gallerycover/".$GalleryCatId."_".$_FILES['GalleryCatCover']['name'];
createthumb($image, $image, 120, 120);
}
else
{
$GalleryCatCover = "";
}
// End upload image code
function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode('.',$name);
if (preg_match('/jpg|jpeg|JPG|JPEG/',$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/gif|GIF/',$system[1])){
$src_img=imagecreatefromgif($name);
}
if (preg_match('/png|PNG/',$system[1])){
$src_img=imagecreatefrompng($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
/*$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);*/
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img = imagecreatetruecolor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
$red = imagecolorallocate($dst_img, 255, 0, 0);
$green = imagecolorallocate($dst_img, 0, 255, 0);
$blue = imagecolorallocate($dst_img, 0, 0, 255);
$black = imagecolorallocate($dst_img, 0, 0, 0);
// Make the background transparent
imagecolortransparent($dst_img, $black);
// Draw a red rectangle
imagefilledrectangle($dst_img, 4, 4, 50, 25, $red, $green, $blue);
if (preg_match("/png|PNG/",$system[1])){
imagepng($dst_img, './imagecolortransparent.png', 100);
} else if (preg_match("/gif|GIF/",$system[1])) {
imagegif($dst_img, './imagecolortransparent.gif', 100);
} else {
imagejpeg($dst_img,$filename, 100);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
if ($GalleryCatSort == '' || $GalleryCatSort == '0') {
$sql = "select max(GalleryCatSort) as maxid ";
$sql .= "from GalleryCat ";
$result=mysql_query($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$GalleryCatSort = $row{maxid}+1;
}
if( mysql_num_rows(mysql_query("SELECT GalleryCatId FROM GalleryCat WHERE GalleryCatSort=$GalleryCatSort ")) > 0){
mysql_query("UPDATE GalleryCat SET GalleryCatSort= GalleryCatSort+1 WHERE GalleryCatSort >=$GalleryCatSort ");
}
$sql = "insert into GalleryCat (GalleryCatId, GalleryCatTitleen, GalleryCatTitletc, GalleryCatTitlesc, GalleryCatDate, GalleryCatCover, GalleryCatSort) values ('$GalleryCatId', '$GalleryCatTitleen', '$GalleryCatTitletc', '$GalleryCatTitlesc', '$GalleryCatDate', '$GalleryCatCover', '$GalleryCatSort')";
mysql_query($sql);
if( mysql_errno() > 0 ){
echo 'Gallery Category Add Error:<br />'. mysql_error() .'<br />SQL: '. $sql;
exit;
}
mysql_close($dbh);
header("Location: gallerycat_index.php?msg=Add Successful");
?>