[3569] | 1 | |
---|
| 2 | var Xtools = null; |
---|
| 3 | |
---|
| 4 | function load(path,el) |
---|
| 5 | { |
---|
[3019] | 6 | currentPath = path; |
---|
| 7 | contentFolders = document.getElementById('content_folders'); |
---|
| 8 | for (i=0; i < contentFolders.childNodes.length; i++) |
---|
| 9 | if (contentFolders.childNodes[i].className == "sl") |
---|
| 10 | contentFolders.childNodes[i].className = "l"; |
---|
| 11 | el.className = "sl"; |
---|
| 12 | current_folder = currentPath; |
---|
| 13 | if(last_folder != current_folder){ |
---|
| 14 | lastPage = 1; |
---|
| 15 | current_page = 1; |
---|
| 16 | last_folder = current_folder; |
---|
| 17 | offset = 0; |
---|
| 18 | } |
---|
| 19 | toolbar.control('reload'); |
---|
| 20 | } |
---|
| 21 | |
---|
[3610] | 22 | function loadXtools() |
---|
| 23 | { |
---|
| 24 | if( Xtools == null ) |
---|
| 25 | Xtools = new xtools( path_filemanager + "tp/expressowindow/" ); |
---|
| 26 | } |
---|
| 27 | |
---|
[3569] | 28 | function check(element) |
---|
| 29 | { |
---|
[3019] | 30 | element.firstChild.firstChild.checked = true; |
---|
| 31 | } |
---|
| 32 | |
---|
[3569] | 33 | function validateFileExtension(fileName) |
---|
| 34 | { |
---|
[3019] | 35 | var error_flag = false; |
---|
| 36 | var fileExtension = fileName.split("."); |
---|
| 37 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 38 | for(var i=0; i<denyFileExtensions.length; i++) |
---|
| 39 | { |
---|
| 40 | if(denyFileExtensions[i] == fileExtension) |
---|
| 41 | { |
---|
| 42 | error_flag = true; |
---|
| 43 | break; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | if ( error_flag == true ) |
---|
| 49 | { |
---|
| 50 | write_error(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 51 | return false; |
---|
| 52 | } |
---|
| 53 | return true; |
---|
| 54 | } |
---|
| 55 | |
---|
[3569] | 56 | function get_lang(_key) |
---|
| 57 | { |
---|
[3019] | 58 | var key = _key.toLowerCase(); |
---|
| 59 | if(array_lang[key]) |
---|
| 60 | var _value = array_lang[key]; |
---|
| 61 | else |
---|
| 62 | var _value = _key+"*"; |
---|
| 63 | |
---|
| 64 | if(arguments.length > 1) |
---|
| 65 | for(j = 1; typeof(arguments[j]) != 'undefined'; j++) |
---|
| 66 | _value = _value.replace("%"+j,arguments[j]); |
---|
| 67 | return _value; |
---|
| 68 | |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | |
---|
[3569] | 72 | function newEmptyFile() |
---|
| 73 | { |
---|
[3019] | 74 | var name = prompt(get_lang('Enter with the name of new file/directory'), ''); |
---|
| 75 | var input_text = document.getElementById('newfile_or_dir'); |
---|
| 76 | if (name != null && name != '' && validateFileExtension(name)) |
---|
| 77 | { |
---|
| 78 | var fileExtension = name.split("."); |
---|
| 79 | fileExtension = fileExtension[1]; |
---|
| 80 | if (typeof(fileExtension) == 'undefined') |
---|
| 81 | input_text.value = name+".html"; |
---|
| 82 | else |
---|
| 83 | input_text.value = name; |
---|
| 84 | address = document.location.toString(); |
---|
| 85 | address = address.split("&"); |
---|
| 86 | document.location = address[0]+"&newfile.x=1&newfile_or_dir="+input_text.value; |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | } |
---|
[3569] | 90 | |
---|
[3610] | 91 | function newUpload( ) |
---|
[3569] | 92 | { |
---|
[3673] | 93 | if( document.getElementById("dwindownewUpload__parent") == null ) |
---|
[3019] | 94 | { |
---|
[3673] | 95 | var _newUpload = function(data) |
---|
| 96 | { |
---|
| 97 | loadXtools(); |
---|
| 98 | |
---|
| 99 | var pArgs = unserialize(data); |
---|
| 100 | pArgs.lang_add_file = get_lang("Add file"); |
---|
| 101 | pArgs.lang_click_here = get_lang("Click here"); |
---|
| 102 | pArgs.lang_more_files = get_lang("More files"); |
---|
| 103 | pArgs.lang_send_email = get_lang("Send email"); |
---|
| 104 | pArgs.height = 210; |
---|
| 105 | pArgs.path_filemanager = path_filemanager; |
---|
| 106 | pArgs.width = 450; |
---|
[3610] | 107 | |
---|
[3673] | 108 | var _html = Xtools.parse( Xtools.xml("upload_files"), "upload.xsl", pArgs ); |
---|
| 109 | |
---|
| 110 | draw_window( _html, 490, 350, get_lang("upload files"), "newUpload" ); |
---|
[3610] | 111 | |
---|
[3673] | 112 | if( pArgs.emails_to != null ) |
---|
| 113 | sendNotification( pArgs.emails_to ); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | address = document.location.toString(); |
---|
| 117 | address = address.split("?"); |
---|
| 118 | var url = address[0]+"?menuaction=filemanager.uifilemanager.showUploadboxes&path="+base64_encode(currentPath); |
---|
| 119 | cExecute_( url, _newUpload ); |
---|
[3019] | 120 | } |
---|
| 121 | } |
---|
[3569] | 122 | |
---|
| 123 | function newAdvancedUpload() |
---|
| 124 | { |
---|
[3610] | 125 | for ( var i = 0 ; i < navigator.plugins.length; i++ ) |
---|
[3569] | 126 | { |
---|
[3671] | 127 | if ( navigator.plugins[i].name.match('Java') || navigator.plugins[i].name.match('libnpjp2') ) |
---|
[3569] | 128 | { |
---|
[3673] | 129 | _winBuild( "dwindownewUpload" , "remove" ); |
---|
[3610] | 130 | |
---|
| 131 | loadXtools(); |
---|
| 132 | |
---|
| 133 | var pArgs = |
---|
| 134 | { |
---|
| 135 | 'iframe_width' : 515, |
---|
| 136 | 'iframe_height' : 320, |
---|
| 137 | 'iframe_src' : path_filemanager + "inc/uploadApp.php?id="+parseInt(Math.random()*Math.pow(10,15)) |
---|
| 138 | }; |
---|
| 139 | |
---|
| 140 | var _html = Xtools.parse( Xtools.xml("upload_files_advanced"), "uploadAdvanced.xsl", pArgs); |
---|
| 141 | |
---|
| 142 | draw_window( _html, 530, 345, get_lang("Advanced Upload") ); |
---|
| 143 | |
---|
[3408] | 144 | return; |
---|
| 145 | } |
---|
[3569] | 146 | } |
---|
| 147 | |
---|
[3672] | 148 | alert( get_lang("You do not have Java installed, plugin not loaded") + "!" ); |
---|
[3367] | 149 | } |
---|
[3019] | 150 | |
---|
[3367] | 151 | |
---|
[3019] | 152 | (function( ) |
---|
| 153 | { |
---|
| 154 | // TODO: use DES, RSA, PGP, or something strong |
---|
| 155 | var sec_key = null; |
---|
| 156 | function encode( data ) |
---|
| 157 | { |
---|
| 158 | if (data == null) |
---|
| 159 | return null; |
---|
| 160 | ret = ""; |
---|
| 161 | for ( var i=0;(i < data.length && data.charCodeAt(i) > 31); i++ ) |
---|
| 162 | { |
---|
| 163 | ret += String.fromCharCode(data.charCodeAt(i) ^ sec_key.charCodeAt(i)); |
---|
| 164 | } |
---|
| 165 | return ret; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | function crypt( input ) |
---|
| 169 | { |
---|
| 170 | sec_key = input; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | crypt.prototype.encode = encode; |
---|
| 174 | window.crypt = crypt; |
---|
| 175 | })( ); |
---|
| 176 | |
---|
| 177 | /* |
---|
| 178 | * base64.js - Base64 encoding and decoding functions |
---|
| 179 | * |
---|
| 180 | * Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com> |
---|
| 181 | * Released under the MIT license |
---|
| 182 | */ |
---|
| 183 | |
---|
| 184 | function base64_encode(str) { |
---|
| 185 | var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
---|
| 186 | var encoded = []; |
---|
| 187 | var c = 0; |
---|
| 188 | try { var slen = str.length; } catch (e) { write_error(get_lang('you do not have access to %1',currentPath)); return; }; |
---|
| 189 | while (c < slen) { |
---|
| 190 | var b0 = str.charCodeAt(c++); |
---|
| 191 | var b1 = str.charCodeAt(c++); |
---|
| 192 | var b2 = str.charCodeAt(c++); |
---|
| 193 | var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0); |
---|
| 194 | var i0 = (buf & (63 << 18)) >> 18; |
---|
| 195 | var i1 = (buf & (63 << 12)) >> 12; |
---|
| 196 | var i2 = isNaN(b1) ? 64 : (buf & (63 << 6)) >> 6; |
---|
| 197 | var i3 = isNaN(b2) ? 64 : (buf & 63); |
---|
| 198 | encoded[encoded.length] = chars.charAt(i0); |
---|
| 199 | encoded[encoded.length] = chars.charAt(i1); |
---|
| 200 | encoded[encoded.length] = chars.charAt(i2); |
---|
| 201 | encoded[encoded.length] = chars.charAt(i3); |
---|
| 202 | } |
---|
| 203 | var retBuff = escape(encoded.join('')); |
---|
| 204 | return retBuff.replace(/\+/g,"%2B"); |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | function base64_decode(str) { |
---|
| 208 | var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
---|
| 209 | var invalid = { |
---|
| 210 | strlen: (str.length % 4 != 0), |
---|
| 211 | chars: new RegExp('[^' + chars + ']').test(str), |
---|
| 212 | equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str))) |
---|
| 213 | }; |
---|
| 214 | if (invalid.strlen || invalid.chars || invalid.equals) |
---|
| 215 | throw new Error('Invalid base64 data'); |
---|
| 216 | var decoded = []; |
---|
| 217 | var c = 0; |
---|
| 218 | while (c < str.length) { |
---|
| 219 | var i0 = chars.indexOf(str.charAt(c++)); |
---|
| 220 | var i1 = chars.indexOf(str.charAt(c++)); |
---|
| 221 | var i2 = chars.indexOf(str.charAt(c++)); |
---|
| 222 | var i3 = chars.indexOf(str.charAt(c++)); |
---|
| 223 | var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63); |
---|
| 224 | var b0 = (buf & (255 << 16)) >> 16; |
---|
| 225 | var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8; |
---|
| 226 | var b2 = (i3 == 64) ? -1 : (buf & 255); |
---|
| 227 | decoded[decoded.length] = String.fromCharCode(b0); |
---|
| 228 | if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1); |
---|
| 229 | if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2); |
---|
| 230 | } |
---|
| 231 | return decoded.join(''); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | function setRestricted(name){ |
---|
| 236 | var continue_set = confirm(get_lang('This property will change the visibility of all users that have access to this file, continue?')); |
---|
| 237 | if (continue_set) |
---|
| 238 | cExecute_('./index.php?menuaction=filemanager.vfs_functions.setRestricted&file='+base64_encode(name)+'&path='+base64_encode(currentPath),handler.restricted); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | function presetComments(el){ |
---|
| 242 | if (permissions['edit'] == 0){ |
---|
| 243 | el.blur(); |
---|
| 244 | write_error(get_lang('You have no permission to access this file')); |
---|
| 245 | } |
---|
| 246 | oldValue = el.value; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | function setComments(el){ |
---|
| 250 | if (el.value == oldValue) return; |
---|
| 251 | var filename = base64_encode(el.id); |
---|
| 252 | cExecute_('./index.php?menuaction=filemanager.vfs_functions.editComment&file='+filename+'&comment='+base64_encode(el.value),handler.updateComment); |
---|
| 253 | } |
---|
| 254 | |
---|
[3638] | 255 | function enterComments(e,el) |
---|
| 256 | { |
---|
| 257 | if ( e.keyCode == KEY_ENTER ) |
---|
| 258 | { |
---|
[3019] | 259 | el.blur(); |
---|
[3638] | 260 | } |
---|
[3019] | 261 | } |
---|
| 262 | |
---|
[3569] | 263 | function EditColumns( args ) |
---|
| 264 | { |
---|
| 265 | if( args == 'close' ) |
---|
[3019] | 266 | { |
---|
[3569] | 267 | _winBuild("window_tools_view","remove"); |
---|
[3019] | 268 | } |
---|
[3569] | 269 | else if( args == 'save') |
---|
[3019] | 270 | { |
---|
| 271 | var checkBoxes = document.getElementsByName('prefView'); |
---|
[3569] | 272 | |
---|
| 273 | for ( var i = 0 ; i < checkBoxes.length; i++) |
---|
[3019] | 274 | { |
---|
[3569] | 275 | if( checkBoxes[i].checked === true ) |
---|
[3019] | 276 | preferences[checkBoxes[i].value] = '1'; |
---|
| 277 | else |
---|
| 278 | preferences[checkBoxes[i].value] = '0'; |
---|
| 279 | } |
---|
[3569] | 280 | |
---|
[3019] | 281 | cExecute_('./index.php?menuaction=filemanager.user.save_preferences&preferences='+base64_encode(serialize(preferences)),function () { toolbar.control('reload'); EditColumns('close'); }); |
---|
| 282 | } |
---|
[3569] | 283 | else |
---|
| 284 | { |
---|
[3610] | 285 | loadXtools(); |
---|
| 286 | |
---|
[3569] | 287 | var pTools = |
---|
| 288 | { |
---|
| 289 | 'checkList' : preferences['viewList'], |
---|
| 290 | 'checkIcons': preferences['viewIcons'], |
---|
| 291 | 'check_created' : preferences['created'], |
---|
| 292 | 'check_createdby_id' : preferences['createdby_id'], |
---|
| 293 | 'check_comment' : preferences['comment'], |
---|
| 294 | 'check_mime_type' : preferences['mime_type'], |
---|
| 295 | 'check_modified' : preferences['modified'], |
---|
| 296 | 'check_modifiedby_id' : preferences['modifiedby_id'], |
---|
| 297 | 'check_owner' : preferences['owner'], |
---|
| 298 | 'check_size' : preferences['size'], |
---|
| 299 | 'check_version' : preferences['version'], |
---|
| 300 | 'lang_cancel' : get_lang('cancel'), |
---|
| 301 | 'lang_created_by' : get_lang('created by'), |
---|
| 302 | 'lang_created' : get_lang('created'), |
---|
| 303 | 'lang_comment' : get_lang('comment'), |
---|
| 304 | 'lang_modified_by' : get_lang('modified by'), |
---|
| 305 | 'lang_modified' : get_lang('modified'), |
---|
| 306 | 'lang_owner' : get_lang('owner'), |
---|
| 307 | 'lang_save' : get_lang('save'), |
---|
| 308 | 'lang_size' : get_lang('size'), |
---|
| 309 | 'lang_type' : get_lang('type'), |
---|
| 310 | 'lang_version' : get_lang('version'), |
---|
| 311 | 'lang_view_as_list' : get_lang('view as list'), |
---|
| 312 | 'lang_view_as_icons' : get_lang('view as icons'), |
---|
| 313 | 'onclickCancel' : "EditColumns(\'close\')", |
---|
| 314 | 'onclickSave' : "EditColumns(\'save\')" |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | var winTools = |
---|
| 318 | { |
---|
| 319 | id_window : "window_tools_view", |
---|
| 320 | width : 250, |
---|
| 321 | height : 290, |
---|
| 322 | top : 100, |
---|
| 323 | left : 400, |
---|
| 324 | draggable : true, |
---|
| 325 | visible : "display", |
---|
| 326 | resizable : true, |
---|
| 327 | zindex : zIndex++, |
---|
| 328 | title : "Expresso FileManager - " + get_lang('View'), |
---|
| 329 | closeAction : "remove", |
---|
| 330 | content : Xtools.parse(Xtools.xml("view_config"), "view.xsl", pTools) |
---|
| 331 | }; |
---|
| 332 | |
---|
| 333 | _winBuild( winTools ); |
---|
| 334 | } |
---|
[3019] | 335 | } |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | function searchFile(){ |
---|
| 339 | var inputText = document.getElementById('em_message_search'); |
---|
| 340 | if (inputText.value.length < 4) |
---|
| 341 | { |
---|
| 342 | alert(get_lang('Your search must have at least 4 characters')); |
---|
| 343 | return; |
---|
| 344 | } |
---|
| 345 | cExecute_('./index.php?menuaction=filemanager.uifilemanager.search&text='+inputText.value,folderList.drawSearch); |
---|
| 346 | } |
---|
| 347 | function selectAll(el){ |
---|
| 348 | checkBoxes = document.getElementsByName('fileman'); |
---|
| 349 | if (el.checked) |
---|
| 350 | for (i=0; i < checkBoxes.length; i++) |
---|
| 351 | checkBoxes[i].checked = true; |
---|
| 352 | else |
---|
| 353 | for (i=0; i < checkBoxes.length; i++) |
---|
| 354 | checkBoxes[i].checked = false; |
---|
| 355 | |
---|
| 356 | } |
---|
[3610] | 357 | |
---|
| 358 | function borkb(size) |
---|
| 359 | { |
---|
| 360 | var kbyte = 1024; |
---|
| 361 | var mbyte = kbyte*1024; |
---|
| 362 | var gbyte = mbyte*1024; |
---|
| 363 | |
---|
| 364 | if (!size) |
---|
| 365 | { |
---|
| 366 | size = 0; |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | if (size < kbyte) |
---|
| 370 | { |
---|
| 371 | return size + 'B'; |
---|
| 372 | } |
---|
| 373 | else if (size < mbyte) |
---|
| 374 | { |
---|
| 375 | return parseInt(size/kbyte) + 'KB'; |
---|
| 376 | } |
---|
| 377 | else if (size < gbyte) |
---|
| 378 | { |
---|
| 379 | if ( size/mbyte > 100) |
---|
| 380 | return (size/mbyte).toFixed(0) + 'MB'; |
---|
| 381 | else |
---|
| 382 | return (size/mbyte).toFixed(1) + 'MB'; |
---|
| 383 | } |
---|
| 384 | else |
---|
| 385 | { |
---|
| 386 | return (size/gbyte).toFixed(1) + 'GB'; |
---|
| 387 | } |
---|
[3019] | 388 | } |
---|
[3610] | 389 | |
---|
| 390 | function addNewInput() |
---|
| 391 | { |
---|
| 392 | var newElement = document.createElement('div'); |
---|
| 393 | newElement.innerHTML = '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' + |
---|
| 394 | '<input name="upload_comment[]" type="text" style="margin-right:2px;" />' + |
---|
| 395 | '<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>'; |
---|
| 396 | |
---|
| 397 | document.getElementById('uploadOption').parentNode.appendChild(newElement); |
---|
[3019] | 398 | } |
---|
| 399 | |
---|
[3610] | 400 | function removeInput() |
---|
| 401 | { |
---|
| 402 | if( arguments.length > 0 ) |
---|
| 403 | { |
---|
| 404 | var _parent = arguments[0].parentNode; |
---|
| 405 | |
---|
| 406 | _parent.parentNode.removeChild(_parent); |
---|
| 407 | } |
---|
[3415] | 408 | } |
---|
| 409 | |
---|
[3610] | 410 | function sendNotification() |
---|
| 411 | { |
---|
| 412 | var _div = document.getElementById('sendNotifcation'); |
---|
[3638] | 413 | |
---|
| 414 | var _SendNotification = function() |
---|
| 415 | { |
---|
| 416 | var pArgs = |
---|
| 417 | { |
---|
| 418 | 'lang_delete' : get_lang('delete'), |
---|
| 419 | 'lang_send_notification_email_to' : get_lang("Send Notification email to:"), |
---|
| 420 | 'value_email' : ( ( arguments.length > 0 ) ? arguments[0] : "" ) |
---|
| 421 | }; |
---|
[3610] | 422 | |
---|
[3638] | 423 | loadXtools(); |
---|
[3610] | 424 | |
---|
[3638] | 425 | _div.innerHTML += Xtools.parse( Xtools.xml("send_notification"), "send_notification.xsl", pArgs); |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | if( arguments.length > 0 ) |
---|
[3610] | 429 | { |
---|
[3638] | 430 | var emailsTo = arguments[0].split(","); |
---|
[3610] | 431 | |
---|
[3638] | 432 | _div.innerHTML += "<div style='margin:4 2 2 4px;'>" + |
---|
| 433 | "<label style='font-weight: bold;'>" + get_lang('The following addresses will be notified') + " : </label>" + |
---|
| 434 | "</div>"; |
---|
| 435 | for( var i = 0 ; i < emailsTo.length ; i++ ) |
---|
| 436 | { |
---|
| 437 | _SendNotification( emailsTo[i] ); |
---|
| 438 | _div.innerHTML += "<div style='margin:1 2 1 4px;'> - " + emailsTo[i] + "</div>"; |
---|
| 439 | } |
---|
| 440 | _div.innerHTML += "<br/>"; |
---|
| 441 | } |
---|
| 442 | else |
---|
| 443 | _SendNotification(); |
---|
[3610] | 444 | } |
---|
| 445 | |
---|
| 446 | function sendFiles() |
---|
| 447 | { |
---|
[3619] | 448 | var _formUp = document.getElementById('form_up'); |
---|
| 449 | var _uploadFiles = document.getElementsByTagName('input'); |
---|
| 450 | var _flagSend = true; |
---|
| 451 | |
---|
| 452 | for( var i = 0 ; i < _uploadFiles.length ; i++ ) |
---|
| 453 | { |
---|
| 454 | if( _uploadFiles[i].name.indexOf("upload_file") > -1 ) |
---|
| 455 | { |
---|
| 456 | if( _uploadFiles[i].value == "" ) |
---|
| 457 | { |
---|
| 458 | removeInput( _uploadFiles[i] ); |
---|
| 459 | _flagSend = false; |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | if( _flagSend ) |
---|
| 465 | { |
---|
| 466 | cExecuteForm_( _formUp ,handler.upload); |
---|
| 467 | } |
---|
| 468 | else |
---|
| 469 | write_msg(get_lang("No file(s) to send") + "!"); |
---|
| 470 | |
---|
| 471 | close_window(); |
---|
| 472 | } |
---|