tweak year/agency modifer for queries
[contractdashboard.git] / cutenews / inc / images.mdu
blob:a/cutenews/inc/images.mdu -> blob:b/cutenews/inc/images.mdu
<?PHP <?PHP
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"); } 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", "png", "bmp", "jpe", "jpeg"); $allowed_extensions = array("gif", "jpg", "png", "bmp", "jpe", "jpeg");
// ******************************************************************************** // ********************************************************************************
// Show Preview of Image // Show Preview of Image
// ******************************************************************************** // ********************************************************************************
if($action == "preview"){ if($action == "preview"){
echo <<<PREVIEWHTML echo <<<PREVIEWHTML
<HTML> <HTML>
<HEAD> <HEAD>
<TITLE>Image Preview</TITLE> <TITLE>Image Preview</TITLE>
<script language='javascript'> <script language='javascript'>
var NS = (navigator.appName=="Netscape")?true:false; var NS = (navigator.appName=="Netscape")?true:false;
function fitPic() { function fitPic() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth; iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight; iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width - iWidth; iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight; iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight-1); window.resizeBy(iWidth, iHeight-1);
self.focus(); self.focus();
}; };
</script> </script>
</HEAD> </HEAD>
<BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0"> <BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">
<script language='javascript'> <script language='javascript'>
document.write( "<img src='$config_http_script_dir/data/upimages/$image' border=0>" ); document.write( "<img src='$config_http_script_dir/data/upimages/$image' border=0>" );
</script> </script>
</BODY> </BODY>
</HTML> </HTML>
PREVIEWHTML; PREVIEWHTML;
} }
// ******************************************************************************** // ********************************************************************************
// Show Images List // Show Images List
// ******************************************************************************** // ********************************************************************************
elseif($action != "doimagedelete") elseif($action != "doimagedelete")
{ {
if($action == "quick") if($action == "quick")
{ {
echo"<html> echo"<html>
<head> <head>
<title>Insert Image</title> <title>Insert Image</title>
<style type=\"text/css\"> <style type=\"text/css\">
<!-- <!--
select, option, textarea, input { select, option, textarea, input {
BORDER: #808080 1px solid; BORDER: #808080 1px solid;
COLOR: #000000; COLOR: #000000;
FONT-SIZE: 11px; FONT-SIZE: 11px;
FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff
} }
BODY, TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;} 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: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; } a:hover {font-size : 10px; color: darkblue; font-weight:bold; text-decoration: none; }
.panel { border: 1px dotted silver; background-color: #F7F6F4;} .panel { border: 1px dotted silver; background-color: #F7F6F4;}
--> -->
</style> </style>
</head> </head>
<body bgcolor=#FFFFFF> <body bgcolor=#FFFFFF>
<script language=\"javascript\" type=\"text/javascript\"> <script language=\"javascript\" type=\"text/javascript\">
<!-- <!--
function insertimage(selectedImage) { function insertimage(selectedImage) {
var area = '$area'; var area = '$area';
alternativeText = document.forms['properties'].alternativeText.value; alternativeText = document.forms['properties'].alternativeText.value;
imageAlign = document.forms['properties'].imageAlign.value; imageAlign = document.forms['properties'].imageAlign.value;
imageBorder = document.forms['properties'].imageBorder.value; imageBorder = document.forms['properties'].imageBorder.value;
//finalImage = \" <img style=\\\"border:\"+ imageBorder +\"; vertical-align:\"+ imageAlign +\";\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\"; //finalImage = \" <img style=\\\"border:\"+ imageBorder +\"; vertical-align:\"+ imageAlign +\";\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
finalImage = \" <img border=\\\"\"+ imageBorder +\"\\\" align=\\\"\"+ imageAlign +\"\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\"; finalImage = \" <img border=\\\"\"+ imageBorder +\"\\\" align=\\\"\"+ imageAlign +\"\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
"; ";
if($wysiwyg){ if($wysiwyg){
echo" echo"
MYRTE=window.opener.document.getElementById(area).contentWindow; MYRTE=window.opener.document.getElementById(area).contentWindow;
window.opener.currentRTE=area; MYRTE.document.execCommand('InsertImage', false, '-my-temp-img-url-'); window.opener.currentRTE=area; MYRTE.document.execCommand('InsertImage', false, '-my-temp-img-url-');
replacement = \"$config_http_script_dir/data/upimages/\" + selectedImage + \"\\\" alt=\\\"\" + alternativeText + \"\\\" border=\\\"\" + imageBorder + \"\\\" align=\\\"\" + imageAlign; replacement = \"$config_http_script_dir/data/upimages/\" + selectedImage + \"\\\" alt=\\\"\" + alternativeText + \"\\\" border=\\\"\" + imageBorder + \"\\\" align=\\\"\" + imageAlign;
MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement); MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement);
"; ";
} }
else{ echo"opener.document.getElementById(area).value += finalImage;"; } else{ echo"opener.document.getElementById(area).value += finalImage;"; }
// echo"alert(finalImage);"; // echo"alert(finalImage);";
echo" echo"
window.close(); window.close();
//opener.document.getElementById(area).focus(); //opener.document.getElementById(area).focus();
} }
function PopupPic(sPicURL) { function PopupPic(sPicURL) {
window.open('$PHP_SELF?mod=images&action=preview&image='+sPicURL, '', 'resizable=1,HEIGHT=200,WIDTH=200'); window.open('$PHP_SELF?mod=images&action=preview&image='+sPicURL, '', 'resizable=1,HEIGHT=200,WIDTH=200');
} }
window.resizeTo(410, 550); window.resizeTo(410, 550);
self.focus(); self.focus();
//--> //-->
</script>"; </script>";
}else{ echoheader("images","Manage Images"); } }else{ echoheader("images","Manage Images"); }
// ******************************************************************************** // ********************************************************************************
// Upload Image(s) // Upload Image(s)
// ******************************************************************************** // ********************************************************************************
if($subaction == "upload") if($subaction == "upload")
{ {
for ($image_i = 1; $image_i < ($images_number+1); $image_i++) { for ($image_i = 1; $image_i < ($images_number+1); $image_i++) {
$current_image = 'image_'.$image_i; $current_image = 'image_'.$image_i;
$image = $_FILES[$current_image]['tmp_name']; $image = $_FILES[$current_image]['tmp_name'];
$image_name = $_FILES[$current_image]['name']; $image_name = $_FILES[$current_image]['name'];
$image_name = str_replace(" ", "_", $image_name); $image_name = str_replace(" ", "_", $image_name);
$img_name_arr = explode(".",$image_name); $img_name_arr = explode(".",$image_name);
$type = end($img_name_arr); $type = end($img_name_arr);
if($image_name == ""){ $img_result .= "<br><font color=red>$current_image -> No File Specified For Upload!</font>"; } if($image_name == ""){ $img_result .= "<br><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 .= "<br><font color=red>$image_name -> Image already exist!</font>";} elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "<br><font color=red>$image_name -> Image already exist!</font>";}
elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){ elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){
$img_result .= "<br><font color=red>$image_name ->This type of file is not allowed !!!</font>"; $img_result .= "<br><font color=red>$image_name ->This type of file is not allowed !!!</font>";
} }
else{ //Image is OK, upload it else{ //Image is OK, upload it
@copy($image, $config_path_image_upload."/".$image_name) or $img_result .= "<br><font color=red>$image_name -> Couldn't copy image to server</font><br />Check if file_uploads is allowed in the php.ini file of your server"; @copy($image, $config_path_image_upload."/".$image_name) or $img_result .= "<br><font color=red>$image_name -> Couldn't copy image to server</font><br />Check if file_uploads is allowed in the php.ini file of your server";
if(file_exists($config_path_image_upload."/".$image_name)) if(file_exists($config_path_image_upload."/".$image_name))
{ {
$img_result .= "<br><font color=green>$image_name -> Image was uploaded</font>"; $img_result .= "<br><font color=green>$image_name -> Image was uploaded</font>";
if($action == "quick"){ if($action == "quick"){
$img_result .= " <a title=\"Inser this image in the $my_area\" href=\"javascript:insertimage('$image_name');\">[insert it]</a>"; $img_result .= " <a title=\"Inser this image in the $my_area\" href=\"javascript:insertimage('$image_name');\">[insert it]</a>";
} }
}//if file is uploaded succesfully }//if file is uploaded succesfully
} }
} }
} }
// //
// Add the JS for multyple image upload. // Add the JS for multyple image upload.
// //
echo<<<HTMLJS echo<<<HTMLJS
<script language='javascript'> <script language='javascript'>
function AddRowsToTable() { function AddRowsToTable() {
var tbl = document.getElementById('tblSample'); var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length; var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1 // if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow+1; var iteration = lastRow+1;
var row = tbl.insertRow(lastRow); var row = tbl.insertRow(lastRow);
var cellRight = row.insertCell(0); var cellRight = row.insertCell(0);
var el = document.createElement('input'); var el = document.createElement('input');
el.setAttribute('type', 'file'); el.setAttribute('type', 'file');
el.setAttribute('name', 'image_' + iteration); el.setAttribute('name', 'image_' + iteration);
el.setAttribute('size', '30'); el.setAttribute('size', '30');
el.setAttribute('value', iteration); el.setAttribute('value', iteration);
cellRight.appendChild(el); cellRight.appendChild(el);
document.getElementById('images_number').value = iteration; document.getElementById('images_number').value = iteration;
} }
function RemoveRowFromTable() { function RemoveRowFromTable() {
var tbl = document.getElementById('tblSample'); var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length; var lastRow = tbl.rows.length;
if (lastRow > 1){ if (lastRow > 1){
tbl.deleteRow(lastRow - 1); tbl.deleteRow(lastRow - 1);
document.getElementById('images_number').value = document.getElementById('images_number').value - 1; document.getElementById('images_number').value = document.getElementById('images_number').value - 1;
} }
} }
</script> </script>
HTMLJS; HTMLJS;
echo<<<HTML echo<<<HTML
<form name="form" id="form" action="$PHP_SELF?mod=images" method="post" enctype="multipart/form-data"> <form name="form" id="form" action="$PHP_SELF?mod=images" method="post" enctype="multipart/form-data">
<table border=0 cellpading=0 cellspacing=0 width=100%> <table border=0 cellpading=0 cellspacing=0 width=100%>
<td height=33> <td height=33>
<b>Upload Image</b> <b>Upload Image</b>
<table border=0 cellpading=0 cellspacing=0 class="panel" cellpadding=8> <table border=0 cellpading=0 cellspacing=0 class="panel" cellpadding=8>
<tr> <tr>
<td height=25> <td height=25>
<table border="0" cellspacing="0" cellpadding="0" id="tblSample"> <table border="0" cellspacing="0" cellpadding="0" id="tblSample">
<tr id="row"> <tr id="row">
<td width="1" colspan="2"><input type="file" size="30" name="image_1"></td> <td width="1" colspan="2"><input type="file" size="30" name="image_1"></td>
</tr> </tr>
</table> </table>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;"> <table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
<tr> <tr>
<td> <td>
<INPUT TYPE="SUBMIT" name="submit" VALUE="Upload" style="font-weight:bold;"> &nbsp; <INPUT TYPE="SUBMIT" name="submit" VALUE="Upload" style="font-weight:bold;"> &nbsp;
<input type=button value='-' style="font-weight:bold; width:22px;" title='Remove last file input box' onClick="RemoveRowFromTable();return false;"> <input type=button value='-' style="font-weight:bold; width:22px;" title='Remove last file input box' onClick="RemoveRowFromTable();return false;">
<input type=button value='+' style="font-weight:bold; width:22px;" title='Add another file input box' onClick="AddRowsToTable();return false;"> &nbsp; <input type=button value='+' style="font-weight:bold; width:22px;" title='Add another file input box' onClick="AddRowsToTable();return false;"> &nbsp;
<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> <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> </td>
</tr> </tr>
</table> </table>
$img_result $img_result
</table> </table>
<input type=hidden name=wysiwyg value='$wysiwyg'> <input type=hidden name=wysiwyg value='$wysiwyg'>
<input type=hidden name=subaction value=upload> <input type=hidden name=subaction value=upload>
<input type=hidden name=area value='$area'> <input type=hidden name=area value='$area'>
<input type=hidden name=action value='$action'> <input type=hidden name=action value='$action'>
<input type=hidden name='images_number' id='images_number' value='1'> <input type=hidden name='images_number' id='images_number' value='1'>
</form> </form>
HTML; HTML;
if($action == "quick"){ if($action == "quick"){
echo" echo"
<form name=properties> <form name=properties>
<table style='margin-top:10px;' border=0 cellpading=0 cellspacing=0 width=100%> <table style='margin-top:10px;' border=0 cellpading=0 cellspacing=0 width=100%>
<td height=33> <td height=33>
<b>Image Properties</b> <b>Image Properties</b>
<table border=0 cellpading=0 cellspacing=0 class=\"panel\" style='padding:5px'width=290px; > <table border=0 cellpading=0 cellspacing=0 class=\"panel\" style='padding:5px'width=290px; >
<tr> <tr>
<td width=80>Alt. Text: </td> <td width=80>Alt. Text: </td>
<td><input tabindex=1 type=text name=alternativeText style=\"width:150;\"></td> <td><input tabindex=1 type=text name=alternativeText style=\"width:150;\"></td>
</tr> </tr>
<tr> <tr>
<td>Image Align</td> <td>Image Align</td>
<td> <td>
<select name='imageAlign' style='width:150'> <select name='imageAlign' style='width:150'>
<option value=none>None</option> <option value=none>None</option>
<option value=left>Left</option> <option value=left>Left</option>
<option value=right>Right</option> <option value=right>Right</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Border</td> <td>Border</td>
<td><input type=text value='0' name=imageBorder style=\"width:35\"> pixels</td> <td><input type=text value='0' name=imageBorder style=\"width:35\"> pixels</td>
</tr> </tr>
</table> </table>
</table></form>"; </table></form>";
} }
echo"<tr><td><img height=1 style=\"height: 13px !important; height: 1px;\" border=0 src=\"skins/images/blank.gif\" width=1></tr><tr><td> echo"<tr><td><img height=1 style=\"height: 13px !important; height: 1px;\" border=0 src=\"skins/images/blank.gif\" width=1></tr><tr><td>
<b>Uploaded Images</b> <b>Uploaded Images</b>
</tr> </tr>
<tr > <tr >
<td height=1> <td height=1>
<FORM action='$PHP_SELF?mod=images' METHOD='POST'> <FORM action='$PHP_SELF?mod=images' METHOD='POST'>
<table width=100% height=100% cellspacing=0 cellpadding=0>"; <table width=100% height=100% cellspacing=0 cellpadding=0>";
$img_dir = opendir($config_path_image_upload); $img_dir = opendir($config_path_image_upload);