|
|
1 |
<?PHP
|
|
|
2 |
|
|
|
3 |
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"); }
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
$allowed_extensions = array("gif", "jpg", "png", "bmp", "jpe", "jpeg");
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
// ********************************************************************************
|
|
|
15 |
|
|
|
16 |
// Show Preview of Image
|
|
|
17 |
|
|
|
18 |
// ********************************************************************************
|
|
|
19 |
if($action == "preview"){
|
|
|
20 |
|
|
|
21 |
echo <<<PREVIEWHTML
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<HTML>
|
|
|
25 |
<HEAD>
|
|
|
26 |
<TITLE>Image Preview</TITLE>
|
|
|
27 |
<script language='javascript'>
|
|
|
28 |
var NS = (navigator.appName=="Netscape")?true:false;
|
|
|
29 |
|
|
|
30 |
function fitPic() {
|
|
|
31 |
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
|
|
|
32 |
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
|
|
|
33 |
iWidth = document.images[0].width - iWidth;
|
|
|
34 |
iHeight = document.images[0].height - iHeight;
|
|
|
35 |
window.resizeBy(iWidth, iHeight-1);
|
|
|
36 |
self.focus();
|
|
|
37 |
};
|
|
|
38 |
</script>
|
|
|
39 |
</HEAD>
|
|
|
40 |
<BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">
|
|
|
41 |
<script language='javascript'>
|
|
|
42 |
document.write( "<img src='$config_http_script_dir/data/upimages/$image' border=0>" );
|
|
|
43 |
</script>
|
|
|
44 |
</BODY>
|
|
|
45 |
|
|
|
46 |
</HTML>
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
PREVIEWHTML;
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
// ********************************************************************************
|
|
|
53 |
|
|
|
54 |
// Show Images List
|
|
|
55 |
|
|
|
56 |
// ********************************************************************************
|
|
|
57 |
|
|
|
58 |
elseif($action != "doimagedelete")
|
|
|
59 |
|
|
|
60 |
{
|
|
|
61 |
|
|
|
62 |
if($action == "quick")
|
|
|
63 |
|
|
|
64 |
{
|
|
|
65 |
|
|
|
66 |
echo"<html>
|
|
|
67 |
|
|
|
68 |
<head>
|
|
|
69 |
|
|
|
70 |
<title>Insert Image</title>
|
|
|
71 |
|
|
|
72 |
<style type=\"text/css\">
|
|
|
73 |
|
|
|
74 |
<!--
|
|
|
75 |
|
|
|
76 |
select, option, textarea, input {
|
|
|
77 |
|
|
|
78 |
BORDER: #808080 1px solid;
|
|
|
79 |
|
|
|
80 |
COLOR: #000000;
|
|
|
81 |
|
|
|
82 |
FONT-SIZE: 11px;
|
|
|
83 |
|
|
|
84 |
FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff
|
|
|
85 |
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
BODY, TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;}
|
|
|
89 |
|
|
|
90 |
a:active,a:visited,a:link {font-size : 10px; color: #808080; font-family: verdana; text-decoration: none;}
|
|
|
91 |
|
|
|
92 |
a:hover {font-size : 10px; color: darkblue; font-weight:bold; text-decoration: none; }
|
|
|
93 |
.panel { border: 1px dotted silver; background-color: #F7F6F4;}
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
-->
|
|
|
97 |
|
|
|
98 |
</style>
|
|
|
99 |
|
|
|
100 |
</head>
|
|
|
101 |
|
|
|
102 |
<body bgcolor=#FFFFFF>
|
|
|
103 |
|
|
|
104 |
<script language=\"javascript\" type=\"text/javascript\">
|
|
|
105 |
|
|
|
106 |
<!--
|
|
|
107 |
|
|
|
108 |
function insertimage(selectedImage) {
|
|
|
109 |
var area = '$area';
|
|
|
110 |
|
|
|
111 |
alternativeText = document.forms['properties'].alternativeText.value;
|
|
|
112 |
imageAlign = document.forms['properties'].imageAlign.value;
|
|
|
113 |
imageBorder = document.forms['properties'].imageBorder.value;
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
//finalImage = \" <img style=\\\"border:\"+ imageBorder +\"; vertical-align:\"+ imageAlign +\";\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
|
|
|
117 |
|
|
|
118 |
finalImage = \" <img border=\\\"\"+ imageBorder +\"\\\" align=\\\"\"+ imageAlign +\"\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
|
|
|
119 |
";
|
|
|
120 |
|
|
|
121 |
if($wysiwyg){
|
|
|
122 |
|
|
|
123 |
echo"
|
|
|
124 |
MYRTE=window.opener.document.getElementById(area).contentWindow;
|
|
|
125 |
window.opener.currentRTE=area; MYRTE.document.execCommand('InsertImage', false, '-my-temp-img-url-');
|
|
|
126 |
replacement = \"$config_http_script_dir/data/upimages/\" + selectedImage + \"\\\" alt=\\\"\" + alternativeText + \"\\\" border=\\\"\" + imageBorder + \"\\\" align=\\\"\" + imageAlign;
|
|
|
127 |
MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement);
|
|
|
128 |
|
|
|
129 |
";
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
}
|
|
|
133 |
else{ echo"opener.document.getElementById(area).value += finalImage;"; }
|
|
|
134 |
|
|
|
135 |
// echo"alert(finalImage);";
|
|
|
136 |
|
|
|
137 |
echo"
|
|
|
138 |
|
|
|
139 |
window.close();
|
|
|
140 |
//opener.document.getElementById(area).focus();
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
function PopupPic(sPicURL) {
|
|
|
146 |
window.open('$PHP_SELF?mod=images&action=preview&image='+sPicURL, '', 'resizable=1,HEIGHT=200,WIDTH=200');
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
window.resizeTo(410, 550);
|
|
|
150 |
self.focus();
|
|
|
151 |
|
|
|
152 |
//-->
|
|
|
153 |
|
|
|
154 |
</script>";
|
|
|
155 |
|
|
|
156 |
}else{ echoheader("images","Manage Images"); }
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
// ********************************************************************************
|
|
|
161 |
|
|
|
162 |
// Upload Image(s)
|
|
|
163 |
|
|
|
164 |
// ********************************************************************************
|
|
|
165 |
|
|
|
166 |
if($subaction == "upload")
|
|
|
167 |
{
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
for ($image_i = 1; $image_i < ($images_number+1); $image_i++) {
|
|
|
172 |
$current_image = 'image_'.$image_i;
|
|
|
173 |
|
|
|
174 |
$image = $_FILES[$current_image]['tmp_name'];
|
|
|
175 |
$image_name = $_FILES[$current_image]['name'];
|
|
|
176 |
$image_name = str_replace(" ", "_", $image_name);
|
|
|
177 |
|
|
|
178 |
$img_name_arr = explode(".",$image_name);
|
|
|
179 |
$type = end($img_name_arr);
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
if($image_name == ""){ $img_result .= "<br><font color=red>$current_image -> No File Specified For Upload!</font>"; }
|
|
|
183 |
elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "<br><font color=red>$image_name -> Image already exist!</font>";}
|
|
|
184 |
elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){
|
|
|
185 |
$img_result .= "<br><font color=red>$image_name ->This type of file is not allowed !!!</font>";
|
|
|
186 |
}
|
|
|
187 |
else{ //Image is OK, upload it
|
|
|
188 |
|
|
|
189 |
@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";
|
|
|
190 |
if(file_exists($config_path_image_upload."/".$image_name))
|
|
|
191 |
{
|
|
|
192 |
$img_result .= "<br><font color=green>$image_name -> Image was uploaded</font>";
|
|
|
193 |
if($action == "quick"){
|
|
|
194 |
$img_result .= " <a title=\"Inser this image in the $my_area\" href=\"javascript:insertimage('$image_name');\">[insert it]</a>";
|
|
|
195 |
}
|
|
|
196 |
}//if file is uploaded succesfully
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
//
|
|
|
207 |
// Add the JS for multyple image upload.
|
|
|
208 |
//
|
|
|
209 |
echo<<<HTMLJS
|
|
|
210 |
|
|
|
211 |
<script language='javascript'>
|
|
|
212 |
|
|
|
213 |
function AddRowsToTable() {
|
|
|
214 |
var tbl = document.getElementById('tblSample');
|
|
|
215 |
var lastRow = tbl.rows.length;
|
|
|
216 |
|
|
|
217 |
// if there's no header row in the table, then iteration = lastRow + 1
|
|
|
218 |
var iteration = lastRow+1;
|
|
|
219 |
var row = tbl.insertRow(lastRow);
|
|
|
220 |
|
|
|
221 |
var cellRight = row.insertCell(0);
|
|
|
222 |
var el = document.createElement('input');
|
|
|
223 |
el.setAttribute('type', 'file');
|
|
|
224 |
el.setAttribute('name', 'image_' + iteration);
|
|
|
225 |
el.setAttribute('size', '30');
|