Re: Advanced image module for CuteNews
Thankyou for your help.
Dear CuteNews Users! Please feel free to contact us via our new Feedback Form and please send information about bugs to our bug tracker.
You are not logged in. Please login or register.
CutePHP Forums → Script Feedback and Suggestion → Advanced image module for CuteNews
Thankyou for your help.
Hello!
I'm experiencing this issue: when I upload one image, I can't see it under "Uploaded Images".
It's weird, 'cause the image is uploaded and the respective thumb is created (I've checked via ftp and they both are there). So why don't they appear on the Uploaded Images list?
Thanks in advance!
might be due to chmod settings not being 777 or a missing .htaccess file
might be due to chmod settings not being 777 or a missing .htaccess file
For precaution, I put 777 chmod settings to the whole "cutenews" folder (and sub-folders), but the situation doesn't change. :\
Hi have the same problem as "zelldi" but every new directory is created with the 755 permissions an the files upload under 644 permissions, not enogh for generate thumbnails or use that images from cutenews editor.
Is there a way to modify the code in the images.mdu for create folders and upload files under different permissions?
Many thank's in advance
JMFDCV
a few pages back there are instructions for chmod after upload.
OK, solved the most part of the problems.
Only have to solve one more issue.
Now i can upload images to the main directory and create subfolders with 0777 permissions but i can't upload images to the new directories and the system doesn't create the thumbs folder.
Here the code:
//Create /thumbs folder
if(!file_exists($config_path_image_upload.'/thumbs'))
@mkdir($config_path_image_upload.'/thumbs');
chmod($config_path_image_upload.'/thumbs',0777);
Any idea?
Part of the code what i modify is the follow:
// ********************************************************************************
// Upload Image(s)
// ********************************************************************************
//Rename image
if ($action == 'rename' and $image and $name){
$dir = end(explode("/", $path));
@rename($path.'/'.$image, $path.'/'.$name);
@rename($path.'/thumbs/'.$image, $path.'/thumbs/'.$name);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.($path == $static_path_image_upload ? '' : $dir).'&start_from='.$start_from.'";</script>';
}
//Rename subfolder
if ($action == 'change_dir' and $new_name){
$new_name = str_replace(" ", "_", $new_name);
$path_arr = explode("/", $config_path_image_upload);
$length = strlen(end($path_arr))+1;
$new_path = substr($config_path_image_upload, 0, -$length);
if(file_exists($new_path.'/'.$new_name)) echo "<font color=red>Error, ".$new_name." already exists.</font>";
else{
@rename($config_path_image_upload, $new_path.'/'.$new_name);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$new_name.'";</script>';
}
}
//Create subfolder
if ($action == 'create_dir' and $new_dir){
$new_dir = str_replace(" ", "_", $new_dir);
if(file_exists($config_path_image_upload.'/'.$new_dir)) echo "<font color=red>Error, ".$new_dir." already exists.</font>";
else{
@mkdir($config_path_image_upload.'/'.$new_dir);
chmod($config_path_image_upload.'/'.$new_dir,0777);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$new_dir.'";</script>';
create_htaccess($config_path_image_upload.'/'.$new_dir.'/.htaccess');
}
}
//Delete empty subfolder
if ($action == "delete_dir"){
unlink($config_path_image_upload.'/thumbs/.htaccess');
rmdir($config_path_image_upload.'/thumbs');
unlink($config_path_image_upload.'/.htaccess');
rmdir($config_path_image_upload);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images";</script>';
}
//Move file
if ($action == "move_file"){
if(!file_exists($config_path_image_upload.'/'.$file)){
copy($old_path.'/'.$file, $config_path_image_upload.'/'.$file);
copy($old_path.'/thumbs/'.$file, $config_path_image_upload.'/thumbs/'.$file);
unlink($old_path.'/'.$file);
unlink($old_path.'/thumbs/'.$file);
//echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$folder.'";</script>';
}
}
//Upload image
if($subaction == "upload")
{
for ($i = 0; $i < count($_FILES['image']['name'])-1; $i++) {
$image = $_FILES['image']['tmp_name'][$i];
$image_name = $_FILES['image']['name'][$i];
$image_name = str_replace(" ", "_", $image_name);
$img_name_arr = explode(".",$image_name);
$type = end($img_name_arr);
if($image_name == ""){ $img_result .= "
<font color=red>$current_image -> No File Specified For Upload!</font>"; }
elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "
<font color=red>$image_name -> Image already exist!</font>";}
elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){
$img_result .= "
<font color=red>$image_name ->This type of file is not allowed !!!</font>";
}
else
{
@copy($image, $config_path_image_upload.'/'.$image_name) or $img_result = "<font color=red>Not able to upload image.</font>
Make sure that file upload is enabled or contact your server administrator.";
chmod($image, $config_path_image_upload.'/'.$image_name, 0777);
//Add watermark (text)
if ($watermark and $watermark_text != "") {
if($watermark_font == "none") {
@add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'));
}
else {
@add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'), 'data/watermark/'.$watermark_font);
}
}
//Add watermark (image)
if ($merge) {
@mergePix($config_path_image_upload.'/'.$image_name, 'data/watermark/'.$watermark_image, $config_path_image_upload.'/'.$image_name, $hotspot2, ($merge_transition ? $merge_transition : '40'));
}
//Make thumb
if ($max < 1 or $max == "") {$max = 100;}
if ($square == "yes") {
make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'square');
chmod($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'square',0777);
}
else make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'normal');
chmod($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'normal',0777);
//Shadow
if ($shadow == "yes") {
shadow($config_path_image_upload."/".$image_name);
shadow($config_path_image_upload."/thumbs/".$image_name);
}
if(file_exists($config_path_image_upload."/".$image_name))
{
$img_result .= "
<font color=green>$image_name -> Image was uploaded</font>";
}//if file is uploaded succesfully
}
}
}
Thanks in advance, any help will be appreciated.
about the uploading, does the main dir have a .htaccess file? (it's a hidden file)
if yes your subdires should have one as well.
If no, make sure your subdirs have none either.
The Main directory have a .htaccess file with the follow content:
Order Deny,Allow
Allow from all
And any new directory what i create is empty.
Other issue is when i move an img from the main to a new directory this is deleted from the main directory and nothing happens.
Thanks.
create_htaccess()
if the new directory is empty, must be that the chmodd didn't work, or that the quoted function doesn't have access to write file. Have you checked with an ftp client if the new made directories do have chmodd value 777? Cause i see you use chmod(foldername, 0777), and the php chmod() doesn't always do what you think it does. Sometimes you need 777 instead of 0777 and sometimes it never does what it's supposed to do. That's the whole reason why when installing Cn you manually need to chmodd files, and it isn't done through coding.
the disappearing images when moving is a result of not having proper permissions on the subfolders.
Hi, i did many probes, it only works perfect when i create manually via ftp a new subfolder (with the sub-subfolder thumbs) and everything that with the 777 permissions gived from the ftp software.
When i create a subfolder via CN it doesn't admit any permissions change, even if I try to change from ftp software.
Any suggestion will be appreciated
Many thanks in advance
Hi,
I installed your module. I can upload images but when I insert it, in the WYSIWYG editor, the path to the file is wrong, i got :
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpg
instead of
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpg
Can you help me
Thank you
Hi,
I installed your module. I can upload images but when I insert it, in the WYSIWYG editor, the path to the file is wrong, i got :
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpg
instead of
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpg
Can you help meThank you
Oups excuse me for the edit message...
Another question : How can we delete uploading images ? there's no butoon for this
Thank you
How about that button "Delete selected images" ?
How about that button "Delete selected images" ?
Yes I got that button, oups...
As for the path to images.. any idea ?
Thank you
ah you mean like a folder or directory?
You can't. Should be doable to do when i have some time. Shouldn't be that much of a problem and shouldn't be that much work. Do mention the hack version you're using.
I feel the same. I do not see the Delete button images, and sometimes I go up 3 images and only 2 and I still do not see the button. Also I have preblemas with thumbnails...
Try to clean the directories to back up images, sometimes raises but sometimes not, has gone mad, of course I have paging problems in the imaging module.
What about the wrong path to image ?
I got
http://www.mywebsite.com/cutenews_utf8bata/upimages/4a.jpg
instead of
http://www.mywebsite.com/cutenews_utf8b/data/upimages/4a.jpg
Where do I can fix it ?
Thanx
What about the wrong path to image ?
I got
http://www.mywebsite.com/cutenews_utf8bata/upimages/4a.jpg
instead of
http://www.mywebsite.com/cutenews_utf8b/data/upimages/4a.jpgWhere do I can fix it ?
Thanx
Image.mdu Check the file in the folder of cutenews INK, surely there find 3 lines pointing to the variable where the image looks.
I hope to help greetings!
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpg
hmmm, it wouldn't have strange if it had said
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpgas then there is just a / missing. But the d of data is missing as well O_o
hmmm, it wouldn't have strange if it had said
http://www.mywebsite.com/cutenews_utf8b … ges/4a.jpgas then there is just a / missing. But the d of data is missing as well O_o
Please help me ....
try sharing your images.mdu with pastebin.com
FOr whatever reason your file must be corrupted and as christianphp said: it's a matter of locating where where the apth is created and what is going wrong in your file.
try sharing your images.mdu with pastebin.com
FOr whatever reason your file must be corrupted and as christianphp said: it's a matter of locating where where the apth is created and what is going wrong in your file.
Here is image.mdu
<?PHP
///////////////////////////////////////////////////////////////////
//Original images.mdu modified by FI-DD
//https://cutephp.com/forum/index.php?showuser=2775
//http://english.cutenews.ru/forum/profile.php?mode=viewprofile&u=2
///////////////////////////////////////////////////////////////////
if($member_db[1] > 3 or ($member_db[1] != 1 and $action == "doimagedelete")){ msg("error", "Access Denied", "You don't have permission to manage images"); }
$allowed_extensions = array("gif", "jpg", "bmp", "png", "jpe", "jpeg");
/////////////////////////
//Configuration of popups
/////////////////////////
$popup_in_news = false;
$popup_in_manager = false;
$images_per_page = 10;
/////////////////////////
//Configuration of missing thumbs
//(If you have images without thumbs they will automatically be generated with the following parameters.)
$missing_thumbs_size = 150;
$missing_thumbs_format = "normal"; //Change to "square" for squared thumbs or to "normal" to keep the dimensions
//////////////////////////////////
$static_path_image_upload = $config_path_image_upload;
$folder = $_GET['folder'];
$config_path_image_upload = $config_path_image_upload.($folder == '' ? '' : '/'.$folder);
//Create /thumbs folder
if(!file_exists($config_path_image_upload.'/thumbs')) @mkdir($config_path_image_upload.'/thumbs');
//Create .htaccess file
create_htaccess($config_path_image_upload.'/thumbs/.htaccess');
// ********************************************************************************
// Show Preview of Image
// ********************************************************************************
if($action == "preview"){
echo <<<PREVIEWHTML
<HTML>
<HEAD>
<TITLE>Image Preview</TITLE>
<script language='javascript'>
var NS = (navigator.appName=="Netscape")?true:false;
function fitPic() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight-1);
self.focus();
};
</script>
</HEAD>
<BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">
<script language='javascript'>
document.write( "<table border=0 style="height:100%; width:100%; text-align:center;"><tr><td>" );
document.write( "[img]$path/$image[/img]" );
document.write( "</td></tr></table>" );
</script>
</BODY>
</HTML>
PREVIEWHTML;
}
// ********************************************************************************
// Show Images List
// ********************************************************************************
elseif($action != "doimagedelete")
{
if($action == "quick")
{
echo"<html>
<head>
<title>Insert Image</title>
<style type="text/css">
<!--
select, option, textarea, input {
BORDER: #808080 1px solid;
COLOR: #000000;
FONT-SIZE: 11px;
FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff
}
BODY, TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;}
a:active,a:visited,a:link {font-size : 10px; color: #808080; font-family: verdana; text-decoration: none;}
a:hover {font-size : 10px; color: darkblue; font-weight:bold; text-decoration: none; }
.panel { border: 1px dotted silver; background-color: #F7F6F4;}
-->
</style>
</head>
<body bgcolor=#FFFFFF>
<script language="javascript" type="text/javascript">
<!--
function insertimage(selectedImage, path, link1, link2) {
var area = '$area';
alternativeText = document.forms['properties'].alternativeText.value;
imageAlign = document.forms['properties'].imageAlign.value;
imageBorder = document.forms['properties'].imageBorder.value;
hSpace = document.forms['properties'].hSpace.value;
vSpace = document.forms['properties'].vSpace.value;
finalImage = link1 +"<img border=""+ imageBorder +"" align=""+ imageAlign +"" alt=""+ alternativeText +"" hspace=""+ hSpace +"" vspace=""+ vSpace +"" src="".$config_http_script_dir.substr($config_path_image_upload, 1)."/"+ path +""+ selectedImage +"">" + link2;
";
if($wysiwyg){
echo"
MYRTE=window.opener.document.getElementById(area).contentWindow;
window.opener.currentRTE=area;
MYRTE.document.body.innerHTML += link1 +"<img border=""+ imageBorder +"" align=""+ imageAlign +"" alt=""+ alternativeText +"" hspace=""+ hSpace +"" vspace=""+ vSpace +"" src="".$config_http_script_dir.substr($config_path_image_upload, 1)."/"+ path +""+ selectedImage +"">" + link2;
";
}
else{ echo"opener.document.getElementById(area).value += finalImage;"; }
echo"
window.close();
//opener.document.getElementById(area).focus();
}
function PopupPic(sPicURL, path) {
window.open('$PHP_SELF?mod=images&action=preview&image='+sPicURL+'&path='+path, '', 'resizable=1,HEIGHT=200,WIDTH=200');
}
function changealt(img_name) {
document.forms['properties'].alternativeText.value = img_name;
}
window.resizeTo(850, 600);
self.focus();
//-->
</script>";
}else{ echoheader("images","Manage Images"); }
// ********************************************************************************
// Upload Image(s)
// ********************************************************************************
//Rename image
if ($action == 'rename' and $image and $name){
$dir = end(explode("/", $path));
@rename($path.'/'.$image, $path.'/'.$name);
@rename($path.'/thumbs/'.$image, $path.'/thumbs/'.$name);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.($path == $static_path_image_upload ? '' : $dir).'&start_from='.$start_from.'";</script>';
}
//Rename subfolder
if ($action == 'change_dir' and $new_name){
$new_name = str_replace(" ", "_", $new_name);
$path_arr = explode("/", $config_path_image_upload);
$length = strlen(end($path_arr))+1;
$new_path = substr($config_path_image_upload, 0, -$length);
if(file_exists($new_path.'/'.$new_name)) echo "<font color=red>Error, ".$new_name." already exists.</font>";
else{
@rename($config_path_image_upload, $new_path.'/'.$new_name);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$new_name.'";</script>';
}
}
//Create subfolder
if ($action == 'create_dir' and $new_dir){
$new_dir = str_replace(" ", "_", $new_dir);
if(file_exists($config_path_image_upload.'/'.$new_dir)) echo "<font color=red>Error, ".$new_dir." already exists.</font>";
else{
@mkdir($config_path_image_upload.'/'.$new_dir);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$new_dir.'";</script>';
create_htaccess($config_path_image_upload.'/'.$new_dir.'/.htaccess');
}
}
//Delete empty subfolder
if ($action == "delete_dir"){
unlink($config_path_image_upload.'/thumbs/.htaccess');
rmdir($config_path_image_upload.'/thumbs');
unlink($config_path_image_upload.'/.htaccess');
rmdir($config_path_image_upload);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images";</script>';
}
//Move file
if ($action == "move_file"){
if(!file_exists($config_path_image_upload.'/'.$file)){
copy($old_path.'/'.$file, $config_path_image_upload.'/'.$file);
copy($old_path.'/thumbs/'.$file, $config_path_image_upload.'/thumbs/'.$file);
unlink($old_path.'/'.$file);
unlink($old_path.'/thumbs/'.$file);
//echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$folder.'";</script>';
}
}
//Upload image
if($subaction == "upload")
{
for ($i = 0; $i < count($_FILES['image']['name'])-1; $i++) {
$image = $_FILES['image']['tmp_name'][$i];
$image_name = $_FILES['image']['name'][$i];
$image_name = str_replace(" ", "_", $image_name);
$img_name_arr = explode(".",$image_name);
$type = end($img_name_arr);
if($image_name == ""){ $img_result .= "
<font color=red>$current_image -> No File Specified For Upload!</font>"; }
elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "
<font color=red>$image_name -> Image already exist!</font>";}
elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){
$img_result .= "
<font color=red>$image_name ->This type of file is not allowed !!!</font>";
}
else
{
@copy($image, $config_path_image_upload.'/'.$image_name) or $img_result = "<font color=red>Not able to upload image.</font>
Make sure that file upload is enabled or contact your server administrator.";
//Add watermark (text)
if ($watermark and $watermark_text != "") {
if($watermark_font == "none") {
@add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'));
}
else {
@add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'), 'data/watermark/'.$watermark_font);
}
}
//Add watermark (image)
if ($merge) {
@mergePix($config_path_image_upload.'/'.$image_name, 'data/watermark/'.$watermark_image, $config_path_image_upload.'/'.$image_name, $hotspot2, ($merge_transition ? $merge_transition : '40'));
}
//Make thumb
if ($max < 1 or $max == "") {$max = 100;}
if ($square == "yes") {
make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'square');
}
else make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'normal');
//Rounded corners
if($corners){
if($corners_thumb){
roundedCorners($config_path_image_upload.'/thumbs/'.$image_name, $corners_thumb_radius, $corners_thumb_background);
}
if($corners_image){
roundedCorners($config_path_image_upload.'/'.$image_name, $corners_image_radius, $corners_image_background);
}
}
//Shadow
if ($shadow == "yes") {
shadow($config_path_image_upload."/".$image_name);
shadow($config_path_image_upload."/thumbs/".$image_name);
}
if(file_exists($config_path_image_upload."/".$image_name))
{
$img_result .= "
<font color=green>$image_name -> Image was uploaded</font>";
}//if file is uploaded succesfully
}
}
}
//////////////
//Upload Form
//////////////
?>
<form name="form" id="form" action="<?=$PHP_SELF; ?>?mod=images&folder=<?=$folder; ?>" method="post" enctype="multipart/form-data">
<table border="0" cellpading="0" cellspacing="0" width="100%">
<td height="33">
[b]Upload Image[/b]
<table border="0" cellpading="0" cellspacing="0" class="panel" cellpadding="8">
<tr>
<td height="25">
<table border="0" cellspacing="0" cellpadding="0" id="tblSample">
<tr id="row">
<td width="1" colspan="2">
<script language="javascript">
f = 0
function file_uploader(which){
if (which < f) return
f ++
d = document.getElementById('images_'+f)
d.innerHTML = '<input type="file" name="image['+f+']" id="images_'+f+'" value="" onchange="file_uploader('+f+');" />
<span id="images_'+(f+1)+'">'
}
document.writeln('<input type="file" name="image[0]" value="" onchange="file_uploader(0);" />
')
document.writeln('<span id="images_1"></span>')
function showpreview(image,name){
if (image != ""){
document.images[name].src = image;
} else {
document.images[name].src = "skins/images/blank.gif";
}
}
</script>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
<tr>
<td>
<input type="text" name="max" value="130" size="4"> Width of the thumb
</td>
</tr>
<tr>
<td>
<input style="border:0px; background-color:#F7F6F4;" type="checkbox" name="square" id="square" value="yes" checked><label title="Crop the thumb (width = height)" for="square">Crop the thumb</label>
</td></tr>
<tr>
<td><input style="border:0px; background-color:#F7F6F4;" type="checkbox" name="shadow" id="shadow" value="yes" checked><label title="Add a shadow to the thumb" for="shadow">Add a shadow</label>
</td>
</tr>
<tr>
<td>
<?
//Check for watermark fonts and images
$dir = opendir("data/watermark");
while ($single_file = readdir($dir)){
$file_ending = strtolower(end(explode('.', $single_file)));
if ($file_ending == "jpg" or $file_ending == "jpeg" or $file_ending == "gif" or $file_ending == "png"){
$watermarks[] = $single_file;
}
if ($file_ending == "ttf"){
$fonts[] = $single_file;
}
}
?>
<label for="watermark"><input style="border:0px; background-color:#F7F6F4;" type="checkbox" name="watermark" id="watermark" onclick="java script:ShowOrHide('make_watermark')"<?=(!extension_loaded('gd') ? ' disabled' : ''); ?>>Create watermark (text)</label>
<span id="make_watermark" style="display: none;">
<table width="200" align="center">
<tr>
<td>Text</td><td>Color</td><td>Size</td>
</tr>
<tr>
<td><input type="text" name="watermark_text" size="10" value="[date]"></td>
<td><input type="text" name="textcolor" maxlength="6" size="3" value="FFFFFF"></td>
<td><input type="text" name="textsize" maxlength="2" size="1" value="12"></td>
</tr>
<tr><td> </td></tr>
<tr>
<td>Position</td><td>Font</td>
</tr>
<tr>
<td><input type="radio" name="hotspot1" value="1"> <input type="radio" name="hotspot1" value="2"> <input type="radio" name="hotspot1" value="3">
<input type="radio" name="hotspot1" value="4"> <input type="radio" name="hotspot1" value="5" checked> <input type="radio" name="hotspot1" value="6">
<input type="radio" name="hotspot1" value="7"> <input type="radio" name="hotspot1" value="8"> <input type="radio" name="hotspot1" value="9"></td>
<td valign="top">
<? if($fonts) { ?>
<select name="watermark_font">
<option value="none">Select</option>
<? foreach($fonts as $font) {
echo '<option value="'.$font.'">'.$font.'</option>';
}
?>
</select>
<? } else {echo "No fonts installed";} ?>
</td>
</tr>
</table></td></tr>
</span>
<tr><td>
<label for="merge"><input style="border:0px; background-color:#F7F6F4;" type="checkbox" name="merge" id="merge" onclick="java script:ShowOrHide('make_merge')"<?=(!extension_loaded('gd') ? ' disabled' : ''); ?>>Create watermark (image)</label>
<span id="make_merge" style="display: none;">
<table width="200" align="center">
<tr>
<td>Transition</td>
</tr>
<tr>
<td><input type="text" name="merge_transition" maxlength="2" size="1" value="40"></td><td>(1 = invisible,
99 = full)</td>
</tr>
<tr><td> </td></tr>
<tr>
<td>Position</td><td>Watermark</td>
</tr>
<tr>
<td width="50%"><input type="radio" name="hotspot2" value="1"> <input type="radio" name="hotspot2" value="5"> <input type="radio" name="hotspot2" value="2">
<input type="radio" name="hotspot2" value="8"> <input type="radio" name="hotspot2" value="0" checked> <input type="radio" name="hotspot2" value="6">
<input type="radio" name="hotspot2" value="4"> <input type="radio" name="hotspot2" value="7"> <input type="radio" name="hotspot2" value="3"></td>
<td width="50%" valign="top">
<? if($watermarks) { ?>
<select onchange="showpreview('data/watermark/'+this.options[this.selectedIndex].value, 'previewimage')" name="watermark_image">
<? foreach($watermarks as $watermark_image) {
echo '<option value="'.$watermark_image.'">'.$watermark_image.'</option>';
}
?>
</select>
<img name="previewimage" width="100px" src="data/watermark/<?=$watermarks[0]; ?>" align="left" style="margin: 5px;">
<? }
else { echo "No watermark images"; }
?>
</td>
</tr>
</table>
</span>
</td></tr>
<tr><td>
<label for="corners"><input style="border:0px; background-color:#F7F6F4;" type="checkbox" name="corners" id="corners" onclick="java script:ShowOrHide('make_corners')"<?=(!extension_loaded('gd') ? ' disabled' : ''); ?>>Create rounded corners</label>
<span id="make_corners" style="display: none;">
<table width="250" align="right">
<tr><td><input type="checkbox" name="corners_image" checked="checked" />Image</td><td>
<input type="text" name="corners_image_radius" size="5" value="25" /> Radius
<input type="text" name="corners_image_background" size="5" value="ffffff" /> Background</td></tr>
<tr><td><input type="checkbox" name="corners_thumb" checked="checked" />Thumbnail</td><td>
<input type="text" name="corners_thumb_radius" size="5" value="15" /> Radius
<input type="text" name="corners_thumb_background" size="5" value="ffffff" /> Background</td></tr>
</table>
</span>
</td></tr>
<tr>
<td>
<INPUT TYPE="SUBMIT" name="submit" VALUE="Upload" style="font-weight:bold;"> Â
<input style="border:0px; background-color:#F7F6F4;" type=checkbox name=overwrite id=overwrite value=1><label title='Overwrite file(s) if exist' for=overwrite> Overwrite</label>
</td>
</tr>
</table>
<?=$img_result; ?>
</table>
<input type=hidden name=wysiwyg value='<?=$wysiwyg; ?>'>
<input type=hidden name=subaction value=upload>
<input type=hidden name=area value='<?=$area; ?>'>
<input type=hidden name=action value='<?=$action; ?>'>
</form>
<?
//////////////////
//Image properties
//////////////////
if($action == "quick"){
echo"
<form name="properties">
<table style='margin-top:10px;' border=0 cellpading=0 cellspacing=0 width=100%>
<td height=33>
[b]Image Properties[/b]
<table border=0 cellpading=0 cellspacing=0 class="panel" style='padding:5px'width=290px; >
<tr>
<td width=80>Alt. Text: </td>
<td><input tabindex=1 type=text name="alternativeText" style="width:150;"></td>
</tr>
<tr>
<td>Image Align</td>
<td>
<select name='imageAlign' style='width:150'>
<option value=left>Left</option>
<option value=none>None</option>
<option value=right>Right</option>
</select>
</td>
</tr>
<tr>
<td>Border</td>
<td><input type=text value='0' name=imageBorder style="width:35"> pixels</td>
</tr>
<tr>
<td>hspace</td>
<td><input type=text value='10' name=hSpace style="width:35"> pixels</td>
</tr>
<tr>
<td>vspace</td>
<td><input type=text value='5' name=vSpace style="width:35"> pixels</td>
</tr>
</table>
</table></form>";
}
////////////////////////
//Prepare image showing
////////////////////////
echo"<tr><td><img height=1 style="height: 13px !important; height: 1px;" border=0 src="skins/images/blank.gif" width=1></td></tr>";
//Show folder dropdown
echo "<tr><td>
<form action='' method='post'>
<select onchange="window.location=this.options[this.selectedIndex].value">
<option value=$PHP_SELF?mod=images&action=".$_GET['action']."&area=".$_GET['area']."&wysiwyg=".$_GET['wysiwyg']."&folder=".($_GET['folder'] == '' ? ' selected' : '').">Main</option>";
echo get_subfolder($static_path_image_upload);
echo"</select></form>";
//Show folder changing
if($action != "quick" and $_GET['folder'] != ""){
echo '<form action="" method="post">';
echo '<input type="textbox" name="new_name" value="'.$_GET['folder'].'">';
echo '<input type="hidden" name="action" value="change_dir">';
echo ' <input type="submit" value="Change name">';
echo "</form></td></tr>";
}
//Show folder creation
if($action != "quick" and $_GET['folder'] == ""){
echo '<form action="" method="post">';
echo '<input type="textbox" name="new_dir" value="">';
echo '<input type="hidden" name="action" value="create_dir">';
echo ' <input type="submit" value="New dir">';
echo "</form></td></tr>";
}
//Show delete button
if(dir_is_empty($config_path_image_upload) and $_GET['folder'] != ""){
echo '<tr><td><form action="" method="post">';
echo '<input type="hidden" name="action" value="delete_dir">';
echo ' <input type="submit" value="Delete dir">';
echo "</form></td></tr>";
}
echo"".((dir_is_empty($config_path_image_upload) and $_GET['folder'] != "") ? '' : '<tr><td>[b]
Uploaded Images[/b]</td></tr>')."<tr>
<td height=1>
<FORM action='$PHP_SELF?mod=images&folder=$folder' METHOD='POST'>
<table width=100% height=100% cellspacing=0 cellpadding=0>";
$img_dir = opendir($config_path_image_upload);
$i = 0;
while ($file = readdir($img_dir))
{
$img_name_arr = explode(".",$file);
$img_type = end($img_name_arr);
$img_name = substr($file, 0, -(strlen($img_type)+1));
if ((in_array($img_type, $allowed_extensions) or in_array(strtolower($img_type), $allowed_extensions)) and $file != ".." and $file != "." and $file != ".htaccess" and $file != "index.html" and is_file($config_path_image_upload."/".$file))
//Yes we'll store them in array for sorting
$images_in_dir[] = $file;
}
if($images_in_dir){
natcasesort($images_in_dir);
reset($images_in_dir);
//Pagination
$images_per_page = ($images_per_page ? $images_per_page : 21);
$start_from = ($start_from ? $start_from : '');
$i = $start_from;
$j = 0;
//End Pagination
foreach ($images_in_dir as $file) {
//Add missing thumbs
if(!file_exists($config_path_image_upload.'/thumbs/'.$file))
make_thumb($config_path_image_upload.'/'.$file, $config_path_image_upload.'/thumbs/'.$file, $missing_thumbs_size, $missing_thumbs_format);
//Add missing thumbs
//Pagination
if ($j < $start_from){
$j++;
continue;
}
//End Pagination
$i++;
$this_size = filesize($config_path_image_upload."/".$file);
$total_size += $this_size;
$img_info = getimagesize($config_path_image_upload."/".$file);
$img_info_thumb = getimagesize($config_path_image_upload."/thumbs/".$file);
if( $i%2 != 0 ){ $bg = "bgcolor=#F7F6F4"; }
else{ $bg = ""; }
/////////////////////////////////
//List images in addnews/editnews
/////////////////////////////////
if($action == "quick")
{
$my_area = str_replace("_", " ", $area);
$path_big = "";
$path_thumb = "thumbs/";
//If popup_in_news
if ($popup_in_news == true) {
$link1 = htmlspecialchars('[url=java script:popupMedia(]');
}
//Else
else {
$link1 = htmlspecialchars('[url='.$config_http_script_dir.'/data/upimages/'.($folder == '' ? '' : $folder.'/').$file.'"]<td height=16 width=10% align=center><a title='Preview this thumb in a popup' href="java script:PopupPic('".$file."', '".$config_path_image_upload."/thumbs')"><img height='50px' style='border:0px;' src=".$config_http_script_dir.'/data/upimages/'.($folder == '' ? '' : $folder.'/').$file.">[/url]
<td height=16 width=15%>Â Â [url=j]$file[/url]";
}
//Else
else {
echo"
<tr $bg><td height=16 width=10% align=center>[url="]<img height='50px' style='border:0px;' src=".$config_path_image_upload."/thumbs/".$file.">[/url]
<td height=16 width=20%>Â Â [url="]$file[/url]";
}
echo"
<td height=16 width=15%>
<input type="button" value="Insert Image" onMouseOver="java script:changealt('$file')" onClick="java script:insertimage('$file', '$path_big', '$empty_link', '$empty_link')">Â
<td height=16 width=15%>
<input type="button" value="Insert Thumb" onMouseOver="java script:changealt('$file')" onClick="java script:insertimage('$file', '$path_thumb', '$empty_link', '$empty_link')">Â
<td height=16 width=15%>
<input type="button" value="Clickable Thumb" onMouseOver="java script:changealt('$file')" onClick="java script:insertimage('$file', '$path_thumb', '$link1', '$link2')">Â ";
echo "
<td height=16 align=right>
$img_info[0]x$img_info[1]Â Â
<td height=16 align=right>
 ". formatsize($this_size) ."
</tr>";
}
///////////////////////////////
//List images in image manager
///////////////////////////////
else
{
echo"<tr $bg><td height=16>
Â
<td height=16 width=13% >
[url="]<img height='50px' style='border:0px;' src=".$config_path_image_upload."/thumbs/".$file.">[/url]
<td height=16 width=40% >
[url="]$file[/url]
<td width=13%>Move to
<form action='' method='post'>
<select onchange="window.location=this.options[this.selectedIndex].value">
<option value=$PHP_SELF?mod=images&action=move_file&area=".$_GET['area']."&wysiwyg=".$_GET['wysiwyg']."&folder=".($_GET['folder'] == '' ? ' selected' : '')."&old_path=".$config_path_image_upload."&file=".$file.">Main</option>";
echo get_subfolder($static_path_image_upload, $config_path_image_upload, $move = true, $file);
echo"</select>
<td height=16 width=10% >
[url=h][rename][/url]
<td height=16 align=right>
$img_info[0]x$img_info[1]
<td height=16 align=right>
 ". formatsize($this_size) ."
<td width=70 height=16 align=right>
<input type=checkbox name=images[$file] value="$file">
</tr>";
}
//Pagination
if ($i >= $images_per_page + $start_from){
break;
}
//End Pagination
}//End foreach
}//End if($images_in_dir)
//Pagination
if ($start_from > 0){
$previous = $start_from - $images_per_page;
$npp_nav .= '[url=]<<[/url]';
}
if (count($images_in_dir) > $images_per_page){
$npp_nav .= ' [ ';
$enpages_count = @ceil(count($images_in_dir) / $images_per_page);
$enpages_start_from = 0;
$enpages = '';
for ($j = 1; $j <= $enpages_count; $j++){
if ($enpages_start_from != $start_from){
$enpages .= '[url=]'.$j.'[/url] ';
} else {
$enpages .= ' [b] [u]'.$j.'[/u] [/b] ';
}
$enpages_start_from += $images_per_page;
}
$npp_nav .= $enpages;
$npp_nav .= ' ] ';
}
if (count($images_in_dir) > $i){
$npp_nav .= '[url=]>>[/url]';
}
//End pagination
if($i > 0){
echo"<tr ><td colspan="3" height=16>$npp_nav";
if($action != "quick"){
echo" <td colspan=4 align=right>
<input type=submit value='Delete Selected Images'>
</tr>";
}
echo"<tr height=1>
<td width=14>
Â
<td>Â
<td >
[b]Total size[/b]
<td>Â <td>Â <td>Â
<td align=right>
[b]". formatsize($total_size) .'[/b]
</tr>';
}
echo'
</table><input type=hidden name=action value=doimagedelete></form></table>';
if($action != "quick"){ echofooter(); }
}
// ********************************************************************************
// Delete Image
// ********************************************************************************
elseif($action == "doimagedelete")
{
if(!isset($images)){ msg("info","No Images selected","You must select images to be deleted.", "$PHP_SELF?mod=images"); }
foreach($images as $image){
unlink($config_path_image_upload."/".$image) or print("Could not delete image [b]$file[/b]");
unlink($config_path_image_upload."/thumbs/".$image) or print("Could not delete thumb [b]$file[/b]");
}
msg("info","Image(s) Deleted","The image was successfully deleted.", "$PHP_SELF?mod=images");
}
/////////////
//Functions//
/////////////
///////////////////////////
//Function: get_subfolder
//Creates a dropdown for all subfolders
///////////////////////////
function get_subfolder($path, $old_path = false, $move = false, $image = false){
$dir = opendir($path);
while ($subfolder = readdir($dir)) {
if(is_dir($path.'/'.$subfolder) and $subfolder != "." and $subfolder != ".." and $subfolder != "thumbs"){
$all_subfolders .= "<option value=".$PHP_SELF."?mod=images&action=".($move ? 'move_file' : $_GET['action'])."&area=".$_GET['area']."&wysiwyg=".$_GET['wysiwyg']."&folder=$subfolder".($move ? '&old_path='.$old_path.'&file='.$image : '')." ".($_GET['folder'] == $subfolder ? 'selected' : '').">- $subfolder</option>";
}
}
return $all_subfolders;
}
///////////////////////////
//Function: dir_is_empty
//Checks if dir is empty
///////////////////////////
function dir_is_empty($path){
$dir = opendir($path);
$i = 0;
while ($files_in_subfolder = readdir($dir)) {
if($files_in_subfolder != "." and $files_in_subfolder != ".." and $files_in_subfolder != "thumbs" and $files_in_subfolder != ".htaccess"){
$i++;
}
}
if($i == 0) return true;
else return false;
}
///////////////////////////
//Function: create_htaccess
//Creates a .htaccess file
///////////////////////////
function create_htaccess($path_to_file){
if(!file_exists($path_to_file)){
$ht_file = @fopen($path_to_file, w);
$htaccess = "Order Deny,AllownAllow from all";
@fwrite($ht_file, $htaccess);
@fclose($path_to_file);
}
}
//////////////////////
//Function: make_thumb
//Creates a thumbnail
//////////////////////
function make_thumb($src, $dest, $new_size, $way) {
global $type;
$size = getimagesize($src);
$img_width = $size[0];
$img_height = $size[1];
if(($img_width > $new_size) or ($img_height > $new_size)){
//Keep dimensions
if($way == "normal"){
$ratio = $new_size/$img_width;
$new_width = $new_size;
$new_height = $img_height*$ratio;
$off_w = 0;
$off_h = 0;
}
//Crop
else {
if($img_width > $img_height){
$new_width = $new_size;
$new_height = $new_size;
$off_w = ($img_width-$img_height)/2;
$off_h = 0;
$img_width = $img_height;
}
else if ($img_height > $img_width){
$new_width = $new_size;
$new_height = $new_size;
$off_w = 0;
$off_h = ($img_height - $img_width)/2;
$img_height = $img_width;
}
else{
$new_width = $new_size;
$new_height = $new_size;
$off_w = 0;
$off_h = 0;
}
}
if (strtolower($type) == "gif") {
$im_in = @imagecreatefromgif($src);
}
else {
$im_in = @imagecreatefromjpeg($src);
}
$im_out = @imagecreatetruecolor($new_width, $new_height);
@imagecopyresampled($im_out, $im_in, 0, 0, $off_w, $off_h, $new_width, $new_height, $img_width, $img_height);
}
else {
@copy($src, $dest);
}
if (strtolower($type) == "gif") {
@imagegif($im_out, $dest);
}
else {
@imagejpeg($im_out, $dest);
}
}
///////////////////////////
//Function dropshadow
//Adds a dropshadow to the thumb
//Code taken from http://codewalkers.com/tutorials/83/1.html
//////////////////////////////////
function shadow($thumb_in) {
global $type;
define("DS_OFFSET", 5);
define("DS_STEPS", 10);
define("DS_SPREAD", 1);
$background = array("r" => 255, "g" => 255, "b" => 255);
list($o_width, $o_height) = getimagesize($thumb_in);
$width = $o_width + DS_OFFSET;
$height = $o_height + DS_OFFSET;
$image_sh = @imagecreatetruecolor($width, $height);
$step_offset = array("r" => ($background["r"] / DS_STEPS), "g" => ($background["g"] / DS_STEPS), "b" => ($background["b"] / DS_STEPS));
$current_color = $background;
for ($i = 0; $i <= DS_STEPS; $i++) {
$colors[$i] = @imagecolorallocate($image_sh, round($current_color["r"]), round($current_color["g"]), round($current_color["b"]));
$current_color["r"] -= $step_offset["r"];
$current_color["g"] -= $step_offset["g"];
$current_color["b"] -= $step_offset["b"];
}
@imagefilledrectangle($image_sh, 0,0, $width, $height, $colors[0]);
for ($i = 0; $i < count($colors); $i++) {
@imagefilledrectangle($image_sh, DS_OFFSET, DS_OFFSET, $width, $height, $colors[$i]);
$width -= DS_SPREAD;
$height -= DS_SPREAD;
}
if (strtolower($type) == "gif") {
$original_image = @imagecreatefromgif($thumb_in);
}
else {
$original_image = @imagecreatefromjpeg($thumb_in);
}
@imagecopymerge($image_sh, $original_image, 0,0, 0,0, $o_width, $o_height, 100);
if (strtolower($type) == "gif") {
@imagegif($image_sh, $thumb_in);
}
else {
@imagejpeg($image_sh, $thumb_in);
}
}
/////////////////
//Function Watermark
//Code taken from http://edge.dev.box.sk/smsread.php?newsid=310
///////////////////
function add_watermark($thumb_in,$text="[date]",$hotspot=8,$rgbtext="FFFFFF",$font_size=12,$font="Arial.TTF",$datfmt="d-m-Y",$rgbtsdw="000000",$txp=25,$typ=15,$sxp=1,$syp=1) {
$suffx=substr($thumb_in,strlen($thumb_in)-4,4);
$suffx = strtolower($suffx);
if ($suffx==".jpg" || $suffx=="jpeg" || $suffx==".png" || $suffx==".gif") {
$text2 = $text;
$text=str_replace("[date]",date($datfmt),$text);
if ($suffx==".jpg" || $suffx=="jpeg") {
$image=imagecreatefromjpeg($thumb_in);
}
if ($suffx==".png") {
$image=imagecreatefrompng($thumb_in);
}
if ($suffx == ".gif") {
$image=imagecreatefromgif($thumb_in);
}
$rgbtext=HexDec($rgbtext);
$txtr=floor($rgbtext/pow(256,2));
$txtg=floor(($rgbtext%pow(256,2))/pow(256,1));
$txtb=floor((($rgbtext%pow(256,2))%pow(256,1))/pow(256,0));
$rgbtsdw=HexDec($rgbtsdw);
$tsdr=floor($rgbtsdw/pow(256,2));
$tsdg=floor(($rgbtsdw%pow(256,2))/pow(256,1));
$tsdb=floor((($rgbtsdw%pow(256,2))%pow(256,1))/pow(256,0));
$coltext = imagecolorallocate($image,$txtr,$txtg,$txtb);
$coltsdw = imagecolorallocate($image,$tsdr,$tsdg,$tsdb);
if ($hotspot!=0) {
$ix=imagesx($image); $iy=imagesy($image); $tsw=($text2 == "[date]" ? strlen($text)+2 : strlen($text))*$font_size/imagefontwidth($font)*3; $tsh=$font_size/imagefontheight($font);
switch ($hotspot) {
case 1:
$txp=$txp; $typ=$tsh*$tsh+imagefontheight($font)*2+$typ;
break;
case 2:
$txp=floor(($ix-$tsw)/2); $typ=$tsh*$tsh+imagefontheight($font)*2+$typ;
break;
case 3:
$txp=$ix-$tsw-$txp; $typ=$tsh*$tsh+imagefontheight($font)*2+$typ;
break;
case 4:
$txp=$txp; $typ=floor(($iy-$tsh)/2);
break;
case 5:
$txp=floor(($ix-$tsw)/2); $typ=floor(($iy-$tsh)/2);
break;
case 6:
$txp=$ix-$tsw-$txp; $typ=floor(($iy-$tsh)/2);
break;
case 7:
$txp=$txp; $typ=$iy-$tsh-$typ;
break;
case 8:
$txp=floor(($ix-$tsw)/2); $typ=$iy-$tsh-$typ;
break;
case 9:
$txp=$ix-$tsw-$txp; $typ=$iy-$tsh-$typ;
break;
}
}
ImageTTFText($image,$font_size,0,$txp+$sxp,$typ+$syp,$coltsdw,$font,$text);
ImageTTFText($image,$font_size,0,$txp,$typ,$coltext,$font,$text);
if ($suffx==".jpg" || $suffx=="jpeg") {
imagejpeg($image, $thumb_in);
}
if ($suffx==".png") {
imagepng($image, $thumb_in);
}
if ($suffx == ".gif") {
imagegif($image, $thumb_in);
}
}
}
////////////////////
//Function mergePix
//Taken from http://de3.php.net/manual/de/function.imagecopymerge.php
///////////////////////
function mergePix($sourcefile,$insertfile, $targetfile, $pos=0,$transition=30)
{
//Get the resource id?s of the pictures
switch (strtolower(end(explode('.', $sourcefile))))
{
case 'gif':
$sourcefile_id = imageCreateFromGIF($sourcefile);
break;
case 'jpg':
$sourcefile_id = imageCreateFromJPEG($sourcefile);
break;
case 'png':
$sourcefile_id = imageCreateFromPNG($sourcefile);
break;
}
switch (strtolower(end(explode('.', $insertfile))))
{
case 'gif':
$insertfile_id = imageCreateFromGIF($insertfile);
break;
case 'jpg':
$insertfile_id = imageCreateFromJPEG($insertfile);
break;
case 'png':
$insertfile_id = imageCreateFromPNG($insertfile);
break;
}
//Get the sizes of both pix
$sourcefile_width=imageSX($sourcefile_id);
$sourcefile_height=imageSY($sourcefile_id);
$insertfile_width=imageSX($insertfile_id);
$insertfile_height=imageSY($insertfile_id);
//middle
if( $pos == 0 )
{
$dest_x = ( $sourcefile_width / 2 ) - ( $insertfile_width / 2 );
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
}
//top left
if( $pos == 1 )
{
$dest_x = 10;
$dest_y = 10;
}
//top right
if( $pos == 2 )
{
$dest_x = $sourcefile_width - $insertfile_width - 10;
$dest_y = 10;
}
//bottom right
if( $pos == 3 )
{
$dest_x = $sourcefile_width - $insertfile_width - 10;
$dest_y = $sourcefile_height - $insertfile_height - 10;
}
//bottom left
if( $pos == 4 )
{
$dest_x = 10;
$dest_y = $sourcefile_height - $insertfile_height - 10;
}
//top middle
if( $pos == 5 )
{
$dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );
$dest_y = 10;
}
//middle right
if( $pos == 6 )
{
$dest_x = $sourcefile_width - $insertfile_width - 10;
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
}
//bottom middle
if( $pos == 7 )
{
$dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );
$dest_y = $sourcefile_height - $insertfile_height - 10;
}
//middle left
if( $pos == 8 )
{
$dest_x = 10;
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
}
//The main thing : merge the two pix
imageCopyMerge($sourcefile_id, $insertfile_id,$dest_x,$dest_y,0,0,$insertfile_width,$insertfile_height,$transition);
//Create a jpeg/gif/png out of the modified picture
switch (strtolower(end(explode('.', $sourcefile))))
{
case 'gif':
imagegif ($sourcefile_id,"$targetfile");
break;
case 'jpg':
imagejpeg ($sourcefile_id,"$targetfile");
break;
case 'png':
imagepng ($sourcefile_id,"$targetfile");
break;
}
}
/** ------------------------------------------------------------
* Copy and resample an image with rounded corners.
* by Michael Shipanski
* Taken from http://ru2.php.net/manual/de/function.imagecopyresampled.php#80417
* Modified by FI-DD
* ----------------------------------------------------------- */
function roundedCorners($src, $radius, $color) {
global $type;
switch (strtolower($type))
{
case 'gif':
$srcimg = imageCreateFromGIF($src);
break;
case 'jpg':
$srcimg = imageCreateFromJPEG($src);
break;
case 'jpeg':
$srcimg = imageCreateFromJPEG($src);
break;
case 'png':
$srcimg = imageCreateFromPNG($src);
break;
}
$width = imagesx($srcimg);
$height = imagesy($srcimg);
$dstimg = imagecreatetruecolor($width, $height);
$bg = imagecolorallocate($dstimg, hexdec($color{0}.$color{1}),hexdec($color{2}.$color{3}),hexdec($color{4}.$color{5}));
imagefill($dstimg,0,0,$bg);
$srcResized = imagecreatetruecolor($width, $height);
imagecopyresampled($srcResized, $srcimg, 0, 0, 0, 0,
$width, $height, $width, $height);
imagecopy($dstimg, $srcResized, 0+$radius, 0,
$radius, 0, $width-($radius*2), $height);
imagecopy($dstimg, $srcResized, 0, 0+$radius,
0, $radius, $width, $height-($radius*2));
$iterations = array(
array(0, 0, $radius, $radius),
array($width-$radius, 0, $width-$radius, $radius),
array(0, $height-$radius, $radius, $height-$radius),
array($width-$radius, $height-$radius, $width-$radius, $height-$radius)
);
foreach($iterations as $iteration) {
list($x1,$y1,$cx,$cy) = $iteration;
for ($y=$y1; $y<=$y1+$radius; $y++) {
for ($x=$x1; $x<=$x1+$radius; $x++) {
$length = sqrt(pow(($cx - $x), 2) + pow(($cy - $y), 2));
if ($length < $radius) {
imagecopy($dstimg, $srcResized, $x+0, $y+0,
$x, $y, 1, 1);
}
}
}
}
switch (strtolower($type))
{
case 'gif':
imagegif ($dstimg, $src);
break;
case 'jpg':
imagejpeg ($dstimg, $src, 100);
break;
case 'jpeg':
imagejpeg ($dstimg, $src, 100);
break;
case 'png':
imagepng ($dstimg, $src);
break;
}
}
?>
thank you for not posting the whole file at the forums
I'll try yours out when i get time.
CutePHP Forums → Script Feedback and Suggestion → Advanced image module for CuteNews
Powered by PunBB, supported by Informer Technologies, Inc.
The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.