function createthumb($name,$filename,$new_w,$new_h,$add_logo=0)
{
if (preg_match('/\.(jpg|jpeg)$/i',$filename)){$src_img=imagecreatefromjpeg($name);}
elseif (preg_match('/\.png$/i',$filename)){$src_img=imagecreatefrompng($name);}
else return;
$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);
}
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);
if ($add_logo == 1) {
$logo=imagecreatefromgif('images/logo.png');
imagecopy($dst_img,$logo,0,5,0,0,136,59);
}
if (preg_match('/\.png$/i',$name))
{
imagepng($dst_img,$filename);
} else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
$memberid="".$_COOKIE['memberid']."";
if(!empty($_POST['MyFocus'])) {
if(empty($_POST['title'])) { $error="לא הוכנסה כותרת הבלוג"; }
if(empty($_POST['message'])) { $error="לא הוכנס תוכן הבלוג"; }
if (empty($error)) {
$Mid="".$_GET['Mid']."";
$FromMid="".$_COOKIE['memberid']."";
if(!empty($_FILES['file']['name']))
{
$dir="albums/$id/blogs";
if(!is_dir($dir)) {
make_dir("$id/blogs/"); }
$upname=explode("." , $_FILES['file']['name']);
$name=$upname['0'].".".$upname[1];
$rand=rand(156449,1977777777);
if(eregi("[א-ת]+" , $upname[0])) {
$name=$rand.".".$upname[1]; }
if (file_exists($dir.$name)) {
$name=$rand.".".$upname[1]; }
if($_FILES['file']['size'] >= 1000*1024) {
$error= ", הקובץ גדול מהמותר"; }
if($upname[1] != "jpg" & $upname[1] != "JPG" & $upname[1] != "JPEG" & $upname[1] != "jpeg") {
$error.= "סוג התמונה שניסית להעלות לאתר
אינו מורשה, באפשרותך להעלות את הסוגים הבאים:
.jpg
.JPG
.jpeg
.JPEG";
}else{
$name=$rand.".".$upname[1];
createthumb($file, $dir.'/'.$name, 535, 520,1);
createthumb($file, $dir.'/small_'.$name, 140, 140);
chmod($dir."/".$name, 0755);
$image="albums/$id/blogs/$name";
$timestamp=time();
$sql=mysql_query("INSERT INTO tblBlogs (Mid,BlogTitle,BlogContent,BlogImage,timestamp) VALUES ('$memberid','$_POST[title]','$_POST[message]','$image','$timestamp')")
or die(mysql_error());
} }
?>