Remove cutenews/yui, use twitter bootstrap css
[contractdashboard.git] / images.mdu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
<?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"); }



$allowed_extensions = array("gif", "jpg", "png", "bmp", "jpe", "jpeg");






// ********************************************************************************

// 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( "<img src='$config_http_script_dir/data/upimages/$image' border=0>" );
                </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) {
                         var area = '$area';

                                alternativeText = document.forms['properties'].alternativeText.value;
                                imageAlign = document.forms['properties'].imageAlign.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 border=\\\"\"+ imageBorder +\"\\\" align=\\\"\"+ imageAlign +\"\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
                        ";

                        if($wysiwyg){

                      echo"
                      MYRTE=window.opener.document.getElementById(area).contentWindow;
                      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;
                      MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement);

                      ";


                        }
                        else{ echo"opener.document.getElementById(area).value += finalImage;"; }

//                      echo"alert(finalImage);";

                        echo"

                                window.close();
                                //opener.document.getElementById(area).focus();


                        }

                        function PopupPic(sPicURL) {
                                window.open('$PHP_SELF?mod=images&action=preview&image='+sPicURL, '', 'resizable=1,HEIGHT=200,WIDTH=200');
                        }

                                window.resizeTo(410, 550);
                                self.focus();

                        //-->

                        </script>";

    }else{ echoheader("images","Manage Images"); }



// ********************************************************************************

// Upload Image(s)

// ********************************************************************************

if($subaction == "upload")
{



for ($image_i = 1; $image_i < ($images_number+1); $image_i++) {
     $current_image = 'image_'.$image_i;

     $image = $_FILES[$current_image]['tmp_name'];
     $image_name = $_FILES[$current_image]['name'];
     $image_name = str_replace(" ", "_", $image_name);

     $img_name_arr = explode(".",$image_name);
     $type = end($img_name_arr);


     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( !(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>";
     }
     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";
                    if(file_exists($config_path_image_upload."/".$image_name))
                    {
                     $img_result .= "<br><font color=green>$image_name -> Image was uploaded</font>";
                     if($action == "quick"){
                        $img_result .= " <a title=\"Inser this image in the $my_area\" href=\"javascript:insertimage('$image_name');\">[insert it]</a>";
                     }
                    }//if file is uploaded succesfully

     }
}



}


//
// Add the JS for multyple image upload.
//
echo<<<HTMLJS

<script language='javascript'>

function AddRowsToTable() {
     var tbl = document.getElementById('tblSample');
     var lastRow = tbl.rows.length;

     // if there's no header row in the table, then iteration = lastRow + 1
     var iteration = lastRow+1;
     var row = tbl.insertRow(lastRow);

     var cellRight = row.insertCell(0);
     var el = document.createElement('input');
     el.setAttribute('type', 'file');
     el.setAttribute('name', 'image_' + iteration);
     el.setAttribute('size', '30');
     el.setAttribute('value', iteration);
     cellRight.appendChild(el);

     document.getElementById('images_number').value = iteration;
}
function RemoveRowFromTable() {
     var tbl = document.getElementById('tblSample');
     var lastRow = tbl.rows.length;
     if (lastRow > 1){
              tbl.deleteRow(lastRow - 1);
               document.getElementById('images_number').value =  document.getElementById('images_number').value - 1;
     }
}

</script>

HTMLJS;



echo<<<HTML
<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%>
    <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"><input type="file" size="30" name="image_1"></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
 <tr>
  <td>
  <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='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>

</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'>
    <input type=hidden name='images_number' id='images_number' value='1'>
 </form>

HTML;


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=none>None</option>
          <option value=left>Left</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>

     </table>
</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>
    <b>Uploaded Images</b>
    </tr>

    <tr >

        <td height=1>
<FORM action='$PHP_SELF?mod=images' 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))
    {
         //Yes we'll store them in array for sorting
         $images_in_dir[] = $file;
    }
    natcasesort($images_in_dir);
    reset($images_in_dir);
    foreach ($images_in_dir as $file) {




        $img_name_arr = explode(".",$file);
            $img_type          = end($img_name_arr);


                if ( (in_array($img_type, $allowed_extensions) or in_array(strtolower($img_type), $allowed_extensions)) and $file != ".." and $file != "." and is_file($config_path_image_upload."/".$file))

            {

            $i++;

            $this_size =  filesize($config_path_image_upload."/".$file);

                $total_size += $this_size;

            $img_info = getimagesize($config_path_image_upload."/".$file);

            if( $i%2 != 0 ){ $bg = "bgcolor=#F7F6F4"; }

                    else{ $bg = ""; }



            if($action == "quick")

            {

                $my_area = str_replace("_", " ", $area);

                echo"

                <tr $bg><td height=16 width=1px> <a title='Preview this image' href=\"javascript:PopupPic('$file')\"><img style='border:0px;' src='skins/images/view_image.gif'></a>
                <td height=16 width=100%>

                <a title=\"Insert this image in the $my_area\" href=\"javascript:insertimage('$file')\">$file</a>



                <td height=16 align=right>

                            $img_info[0]x$img_info[1]&nbsp;&nbsp;



                            <td height=16 align=right>

                        &nbsp;". formatsize($this_size) ."

                            </tr>";

            }

            else

            {

                    echo"<tr $bg><td height=16>

                            &nbsp;

                            <td height=16 width=63% >

                            <a target=_blank href=\"". $config_path_image_upload ."/$file\">$file</a>



                <td height=16 align=right>

                            $img_info[0]x$img_info[1]



                            <td height=16 align=right>

                        &nbsp;". formatsize($this_size) ."

                        <td width=70 height=16 align=right>
                <input type=checkbox name=images[$file] value=\"$file\">

                            </tr>";

            }

            }

        }



    if($i > 0){

            echo"<tr ><td height=16>";


                if($action != "quick"){
                           echo" <td colspan=4 align=right>
                   <br><input type=submit value='Delete Selected Images'>
                            </tr>";

                }

            echo"<tr heigh=1>
                <td  width=14>
                &nbsp;
                <td >
                <br /><b>Total size</b>
            <td>&nbsp;
            <td align=right>

                <br /><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"); }
//        if(!file_exists($config_path_image_upload."/".$image) or !$image){ msg("error","Error !!!","Could not delete image", "$PHP_SELF?mod=images"); }
        foreach($images as $image){
                unlink($config_path_image_upload."/".$image) or print("Could not delete image <b>$file</b>");
        }
        msg("info","Image(s) Deleted","The image was successfully deleted.", "$PHP_SELF?mod=images");

}



?>