관리-도구
편집 파일: crushftp_functions.js
var NAME_COL = 0; var SIZE_COL = 1; var SIZEF_COL = 2; var DATE_COL = 3; var TYPE_COL = 4; var PRIVS_COL = 5; var PATH_COL = 6; var VIRTUAL_COL = 7; var COMMENT_COL = 8; var SUBITEMS_COL = 9; var reverseProxy = ""; var sortId = NAME_COL; var sortDirection = -1; var dc = ""; var c1 = true; var c2 = true; var c3 = true; var c4 = true; var c5 = true; var c6 = true; var c7 = true; var hiddenItems = 0; var publishUploadedItems = new Array(); var doAutoPublish = false; function StringBuffer() { this.buffer = []; } StringBuffer.prototype.append = function append(string) { this.buffer.push(string); return this; }; StringBuffer.prototype.toString = function toString() { return this.buffer.join(""); }; var lastListObject = null; function expandCollapseList(indexChain) { document.getElementById(indexChain).src=reverseProxy+"/WebInterface/images/wheel.gif"; if (indexChain.indexOf(",") == 0) indexChain = indexChain.substring(1); var indexes = indexChain.split(","); lastListObject = listItems; var lastListObject2 = null; for (var x=0; x<indexes.length; x++) { lastListObject = lastListObject[indexes[x]*1]; lastListObject2 = lastListObject; if (lastListObject[SUBITEMS_COL] != null && lastListObject[SUBITEMS_COL].length > 0) lastListObject = lastListObject[SUBITEMS_COL]; } if (lastListObject2[SUBITEMS_COL] != null) { lastListObject2[SUBITEMS_COL] = null; buildListing(); } else { //location.href.substring(location.href.indexOf("/",9)) var str = lastListObject[PATH_COL]+lastListObject[NAME_COL]+"/"; str = url_decode(str); var actions = new Array(); var o = new Object();o.name="the_action";o.value="QUICKLIST";actions[0] = o; getListJavascript(str, refreshSubDir,actions) } } function url_decode(str) { if (str.indexOf("&") >= 0 || str.indexOf("%") >= 0) { str = replace_str(str,">",">"); str = replace_str(str,"<","<"); str = replace_str(str,"&","&"); str = replace_str(str,"%0D","\r"); str = replace_str(str,"%0A","\n"); str = replace_str(str,"
","\r"); str = replace_str(str,"
","\n"); } return str; } function url_encode(str) { if (str.indexOf(">") >= 0 || str.indexOf("<") >= 0 || str.indexOf("&") >= 0 || str.indexOf("\"") >= 0) { str = replace_str(str,">",">"); str = replace_str(str,"<","<"); str = replace_str(str,"&","&"); str = replace_str(str,"\"",""e;"); } return str; } function url_fix(str) { if (str.indexOf("#") >= 0 || str.indexOf("+") >= 0 || str.indexOf(";") >= 0 || str.indexOf("%") >= 0) { str = replace_str(str,"%","%25"); str = replace_str(str,";","%3B"); str = replace_str(str,"#","%23"); str = replace_str(str,"+","%2B"); str = replace_str(str,"&%3B","&"); } return str; } //remove item = array.splice(index,1); //to delete, set refresh to false, and have a return of the success or failure to delete. Then splice the array and rebuild screen. function refreshSubDir(responseData) { eval(responseData.substring(responseData.indexOf("//LISTING START"),responseData.indexOf("//LISTING END"))); sortId = NAME_COL; sortDirection = -1; generatedListItems.sort(doSort); lastListObject[SUBITEMS_COL] = generatedListItems; buildListing(); } function refreshDir(responseData) { eval(responseData.substring(responseData.indexOf("//PATH START"),responseData.indexOf("//PATH END"))); buildPath(generatedPathItems,reverseProxy); eval(responseData.substring(responseData.indexOf("//LISTING START"),responseData.indexOf("//LISTING END"))); listItems = generatedListItems; buildListing(); } var lastHttpFunc = null; function getListJavascript(thePath, func, actions) { lastHttpFunc = func; if (window.XMLHttpRequest) xmlhttp3 = new XMLHttpRequest(); //firefox else if (window.ActiveXObject) xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP"); //ie xmlhttp3.onreadystatechange=function() { if (xmlhttp3.readyState==4) { var responseData = xmlhttp3.responseText; xmlhttp3 = null; if (responseData == null) responseData = ""; if (responseData.length > 2)lastHttpFunc(responseData); } } xmlhttp3.open("POST", reverseProxy+url_fix(thePath),true); var boundary = "-----------------"+makeBoundary(); var data = ""; for (var x=0; x<actions.length; x++) { var o = actions[x]; data += boundary+"\r\n"+"Content-Disposition: form-data; name=\""+o.name+"\"\r\n\r\n"+o.value+"\r\n"; } data += boundary+"--\r\n"; xmlhttp3.setRequestHeader("Content-Type","multipart/form-data; boundary=" + boundary); xmlhttp3.setRequestHeader("Content-Length", data.length+""); xmlhttp3.send(data); } function makeBoundary() { return makeBoundarySize(11); } function makeBoundarySize(maxLen) { var chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; var rand = ""; for (var i = 0; i < maxLen; i++) rand += chars.charAt(1 * (Math.random() * (chars.length - 1))); return rand; } function buildPath(generatedPathItems,tempUsername) { if (generatedPathItems) pathItems = generatedPathItems; if (tempUsername) username = tempUsername; var html = new StringBuffer(); for (var x=0; x<generatedPathItems.length; x++) { html += "<a class=\"pathItem\" href=\""+url_fix(generatedPathItems[x].href)+"\">"; if (x == 0) { html += username; document.getElementById("homeAnchor").href = url_fix(generatedPathItems[x].href); } else html += replace_str(generatedPathItems[x].name," "," "); html += "/</a> "; } document.getElementById("pathdiv").innerHTML = html; } function highlightOn(row){lastClass=row.className;row.className='highlightedHover';} function highlightOff(row){row.className=lastClass;} function buildListing(generatedListItems,tempReverseProxy, tempDisabledColumns, tempColumnNames) { if (generatedListItems) listItems = generatedListItems; if (tempReverseProxy) reverseProxy = tempReverseProxy; if (tempDisabledColumns) dc = tempDisabledColumns; if (tempColumnNames) columnNames = tempColumnNames; c1=(dc.indexOf(",CHECK_COL,")<0); c2=(dc.indexOf(",NAME_COL,")<0); c3=(dc.indexOf(",NAME_COL,")<0); c4=(dc.indexOf(",SIZE_COL,")<0); c5=(dc.indexOf(",MODIFIED_COL,")<0); c6=(dc.indexOf(",RENAME_COL,")<0); c7=(dc.indexOf(",DELETE_COL,")<0); var html = new StringBuffer(); html.append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" id=\"listingTable\">"); html.append("<tr>"); if(c1)html.append(" <td class=\"listHeaderTD\"><a href=\"javascript:toggleAllCheckboxes();\"><img src=\""+reverseProxy+"/WebInterface/images/toggle.gif\" border=\"0\" /></a></td>"); if(c2)html.append(" <td class=\"listHeaderTD\" align=\"left\" nowrap=\"nowrap\"><a href=\"javascript:sort(TYPE_COL,1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/up.gif\" border=\"0\" /></a> <a href=\"javascript:sort(TYPE_COL,-1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/down.gif\" border=\"0\" /></a> "); if(c3)html.append(" <a href=\"javascript:sort(NAME_COL,1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/up.gif\" border=\"0\" /></a> "+columnNames[NAME_COL]+" <a href=\"javascript:sort(NAME_COL,-1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/down.gif\" border=\"0\" /></a></td>"); if(c4)html.append(" <td class=\"listHeaderTD\" align=\"center\" nowrap=\"nowrap\"><a href=\"javascript:sort(SIZE_COL,1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/up.gif\" border=\"0\" /></a> "+columnNames[SIZE_COL]+" <a href=\"javascript:sort(SIZE_COL,-1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/down.gif\" border=\"0\" /></a></td>"); if(c5)html.append(" <td class=\"listHeaderTD\" colspan=\"2\" align=\"center\" nowrap=\"nowrap\"><a href=\"javascript:sort(DATE_COL,1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/up.gif\" border=\"0\" /></a> "+columnNames[DATE_COL]+" <a href=\"javascript:sort(DATE_COL,-1);buildListing();\"><img src=\""+reverseProxy+"/WebInterface/images/down.gif\" border=\"0\" /></a></td>"); html.append("</tr>"); hiddenItems = 0; buildRows(listItems,html,0,'',dateFormatStr,timeFormatStr);//recurses through subdirs too html.append("</table>"); document.getElementById("dirListing").innerHTML = html.toString(); document.getElementById("itemListCount").innerHTML = replace_str(itemCountText, "?", (listItems.length-hiddenItems) + ""); document.getElementById("SpaceBelowButtons").innerHTML = url_decode(document.getElementById("SpaceBelowButtons").innerHTML); logo(); } function buildRows(listItems,html,indent,indexChain,dateFormatStr,timeFormatStr) { var hideDotItems = readCookie("hideInvisibles"); if (hideDotItems == null || hideDotItems == "") hideDotItems = "false"; var indentStr = ""; for (var x=0;x<indent; x++) { indentStr += " "; } for (var x=0; x<listItems.length; x++) { listItems[x][NAME_COL] = url_decode(listItems[x][NAME_COL]); listItems[x][PATH_COL] = url_decode(listItems[x][PATH_COL]); if (listItems[x][NAME_COL].charAt(0) == "." && hideDotItems == "true") hiddenItems++; html.append(" <tr "+(listItems[x][NAME_COL].charAt(0) == "." && hideDotItems == "true"?"style=\"visibility:hidden;position:absolute;\"":"id=\"normal\"")+" onmouseover=\"highlightOn(this);javascript:showThumbnail('"+indexChain+","+x+"');\" onmouseout=\"highlightOff(this);hideThumbnail('"+indexChain+","+x+"');\">"); var isApp = listItems[x][NAME_COL].toUpperCase().length > 4 && (listItems[x][NAME_COL].toUpperCase().indexOf(".APP") == listItems[x][NAME_COL].toUpperCase().length-4); var hasComment = (listItems[x][COMMENT_COL].length > 0 && listItems[x][PRIVS_COL].indexOf("inherited=true") < 0); if (listItems[x][TYPE_COL] == "DIR" && !isApp) { if(c1)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" class=\"deleteCheckbox\"><input type=\"checkbox\" id=\"folder\" value=\""+listItems[x][PATH_COL]+listItems[x][NAME_COL]+"\" /></td>"); if(c2 && c3) { if (hasComment) html.append(" <td class=\"listTD ToolText\" id=\"rename_"+indexChain+","+x+"\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\">"+indentStr+"<div class=\"ToolText\">"); else html.append (" <td class=\"listTD ToolText\" id=\"rename_"+indexChain+","+x+"\">"+indentStr); html.append(" <a href=\"javascript:expandCollapseList('"+indexChain+","+x+"');\"><img id=\""+indexChain+","+x+"\" src=\""+reverseProxy+"/WebInterface/images/"+(listItems[x][SUBITEMS_COL] != null?"expanded.gif":"collapsed.gif")+"\" alt=\"collapse / expand\" title=\"collapse / expand\" width=\"10\" height=\"10\" border=\"0\" id=\"collapseExpand\" /></a>"); html.append(" <a href=\""+reverseProxy+url_fix(listItems[x][PATH_COL])+url_fix(listItems[x][NAME_COL])+"/\"><img src=\""+reverseProxy+"/WebInterface/images/folder.gif\" alt=\"\" title=\"folder\" width=\"16\" height=\"16\" border=\"0\" id=\"FileFolderImg\" /></a>"); html.append(" <a class=\"listItem\" href=\""+reverseProxy+url_fix(listItems[x][PATH_COL])+url_fix(listItems[x][NAME_COL])+"/\">"+replace_str(listItems[x][NAME_COL]," "," ")+"</a>"); if (window.ActiveXObject && listItems[x][SIZE_COL]*1 > 1024*1024*1024*2) {html.append("<br/><font size=\"-2\">This file is probably too big for IE to handle downloading...</font>");} else if (window.ActiveXObject && listItems[x][SIZE_COL]*1 > 1024*1024*1024*4) {html.append("<br/><font size=\"-2\">This file is too big for IE to handle downloading...You must use Safari or Firefox.</font>");} if (hasComment) html.append("<span>"+url_decode(listItems[x][COMMENT_COL])+"</span>"); if (hasComment) html.append("</div>"); html.append(" </td>"); } if(c4)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" align=\"center\"> </td>"); if(c5)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" align=\"right\">"+formatDate(convertTime(listItems[x][DATE_COL]),dateFormatStr)+"</td>"); if(c5)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" align=\"right\">"+formatDate(convertTime(listItems[x][DATE_COL]),timeFormatStr)+"</td>"); var itemRenameOK = listItems[x][PRIVS_COL].indexOf("rename=true") >= 0 && listItems[x][VIRTUAL_COL].indexOf("true") < 0; var itemDeleteOK = listItems[x][PRIVS_COL].indexOf("delete=true") >= 0 && listItems[x][VIRTUAL_COL].indexOf("true") < 0; if(c6 && (itemRenameOK || itemDeleteOK))html.append(" <td class=\"listTD\">"); if (c6 && itemRenameOK) { html.append(" <div class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\"> "); html.append(" <a href=\"javascript:showRename('"+indexChain+","+x+"');\"><img src=\""+reverseProxy+"/WebInterface/images/edit.gif\" alt=\"\" width=\"16\" height=\"16\" border=\"0\" /></a>"); html.append(" <span><font size=\"-1\">"+web_loc_rename+"</font></span>"); html.append(" </div>"); } if(c6 && (itemRenameOK || itemDeleteOK))html.append(" </td>"); if (c7 && itemDeleteOK) { html.append(" <td class=\"listTD\"><div class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\"><a href=\"javascript:doDeleteFolder('"+indexChain+","+x+"');\"><img src=\""+reverseProxy+"/WebInterface/images/delete.gif\" alt=\"\" width=\"16\" height=\"16\" border=\"0\" /></a><span><font size=\"-1\">"+web_loc_delete+"</font></span></div></td>"); } } if (listItems[x][TYPE_COL] == "FILE" || isApp) { if(c1)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" class=\"deleteCheckbox\"><input type=\"checkbox\" id=\"file\" value=\""+listItems[x][PATH_COL]+listItems[x][NAME_COL]+"\" /></td>"); if(c2 && c3) { var target=""; var ext = ("."+listItems[x][NAME_COL]); ext = ext.substring(ext.lastIndexOf(".")) if (openNewWindowExtensions.toUpperCase().indexOf(ext.toUpperCase()) >= 0) target=" target='_blank' "; var hrefStr = reverseProxy+url_fix(listItems[x][PATH_COL])+url_fix(listItems[x][NAME_COL])+(isApp?".zip":""); //if (listItems[x][PRIVS_COL].indexOf("read=true") < 0) hrefStr = "javascript:alert('Downloads not allowed')"; var hrefStr1 = "<a href=\""+hrefStr+"\">"; var hrefStr2 = "<a "+target+" class=\"listItem\" href=\""+hrefStr+"\">"; if (listItems[x][PRIVS_COL].indexOf("read=true") < 0) hrefStr1 = hrefStr2 = ""; if (hasComment) html.append(" <td class=\"listFileTD\" id=\"rename_"+indexChain+","+x+"\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\">"+indentStr+"<div class=\"ToolText\">"); else html.append (" <td class=\"listFileTD\" id=\"rename_"+indexChain+","+x+"\">"+indentStr); html.append(" "+hrefStr1+"<img src=\""+reverseProxy+"/WebInterface/images/file.gif\" alt=\"\" title=\"file\" width=\"16\" height=\"16\" border=\"0\" id=\"FileFolderImg\" /></a>"); html.append(" "+hrefStr2+listItems[x][NAME_COL]+"</a>"); if (window.ActiveXObject && listItems[x][SIZE_COL]*1 > 1024*1024*1024*2) {html.append("<br/><font size=\"-2\">This file is probably too big for IE to handle downloading...</font>");} else if (window.ActiveXObject && listItems[x][SIZE_COL]*1 > 1024*1024*1024*4) {html.append("<br/><font size=\"-2\">This file is too big for IE to handle downloading...You must use Safari or Firefox.</font>");} if (hasComment) html.append("<span>"+url_decode(listItems[x][COMMENT_COL])+"</span>"); if (hasComment) html.append("</div>"); html.append(" </td>"); } if(c4) { html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\">"); html.append(" <div class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\"> "); html.append(" "+listItems[x][SIZEF_COL]+"<span><font size=\"-1\">"+listItems[x][SIZE_COL]+" bytes</font></span>"); html.append(" </div>"); html.append(" </td>"); } if(c5)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" align=\"right\">"+formatDate(convertTime(listItems[x][DATE_COL]),dateFormatStr)+"</td>"); if(c5)html.append(" <td class=\"listTD listItem\" nowrap=\"nowrap\" align=\"right\">"+formatDate(convertTime(listItems[x][DATE_COL]),timeFormatStr)+"</td>"); var itemRenameOK = listItems[x][PRIVS_COL].indexOf("rename=true") >= 0 && listItems[x][VIRTUAL_COL].indexOf("true") < 0; var itemDeleteOK = listItems[x][PRIVS_COL].indexOf("delete=true") >= 0 && listItems[x][VIRTUAL_COL].indexOf("true") < 0; if(c6 && (itemRenameOK || itemDeleteOK))html.append(" <td class=\"listTD\">"); if (c6 && itemRenameOK) { html.append(" <div class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\"> "); html.append(" <a href=\"javascript:showRename('"+indexChain+","+x+"');\"><img src=\""+reverseProxy+"/WebInterface/images/edit.gif\" alt=\"\" width=\"16\" height=\"16\" border=\"0\" /></a>"); html.append(" <span><font size=\"-1\">"+web_loc_rename+"</font></span>"); html.append(" </div>"); } if(c6 && (itemRenameOK || itemDeleteOK))html.append(" </td>"); if (c7 && itemDeleteOK) { html.append(" <td class=\"listTD\"><div class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover';\" onMouseOut=\"javascript:this.className='ToolText';\"><a href=\"javascript:doDeleteFile('"+indexChain+","+x+"');\"><img src=\""+reverseProxy+"/WebInterface/images/delete.gif\" alt=\"\" width=\"16\" height=\"16\" border=\"0\" /></a><span><font size=\"-1\">"+web_loc_delete+"</font></span></div></td>"); } } html.append("<td id=\"rightSide_"+indexChain+","+x+"\"></td>"); html.append(" </tr>"); if (listItems[x][SUBITEMS_COL] != null && listItems[x][SUBITEMS_COL].length > 0) { buildRows(listItems[x][SUBITEMS_COL],html,indent+1,indexChain+","+x,dateFormatStr,timeFormatStr); } } } function showMessageDiv() { var welcomeMessageShown = readCookie("welcomeMessageShown"); if (welcomeMessageShown == null || welcomeMessageShown == "" || welcomeMessageShown == "false") { var messageMasterRow = document.getElementById("messageRow"); if (messageMasterRow != null) { var msgId = document.getElementById("messageForm").MessageFormId.value; var msgFrequency = document.getElementById("messageForm").MessageFormFrequency.value; var thisMessageShown = readCookie("welcomeMessageShown_"+msgId); if (thisMessageShown != null && msgFrequency.indexOf("always") < 0) return; //don't show it every time, only once ever var str = document.getElementById("messageDivMaster").innerHTML; if (str.indexOf(">") >= 0 || str.indexOf("<") >= 0 || str.indexOf("&") >= 0) { str = replace_str(str,">",">"); str = replace_str(str,"<","<"); str = replace_str(str,"&","&"); document.getElementById("messageDivMaster").innerHTML = str; } showPopup("messageDiv"); } } } function validateMessageForm(theForm) { if (!validateUploadForm(theForm)) { try{alert(url_decode(web_loc_form_required_entry_missing));}catch(e){alert("A required item was not filled in.");} return false; } theForm.onSubmit = null; theForm.submit(); setTimeout("disposeParentDivId('messageDivMaster');",900); setTimeout("disposeParentDivId('messageDiv');",1000); createCookie("welcomeMessageShown","true"); var msgId = document.getElementById("messageForm").MessageFormId.value; createCookie("welcomeMessageShown_"+msgId,"true",365); return false; } function showPasteDiv() { var pasteMasterRow = document.getElementById("pasteRow"); if (pasteMasterRow != null) { var str = document.getElementById("pasteDivMaster").innerHTML; if (str.indexOf(">") >= 0 || str.indexOf("<") >= 0 || str.indexOf("&") >= 0) { str = replace_str(str,">",">"); str = replace_str(str,"<","<"); str = replace_str(str,"&","&"); document.getElementById("pasteDivMaster").innerHTML = str; } showPopup("pasteDiv"); } } function validatePasteForm(theForm) { if (!validateUploadForm(theForm)) { try{alert(url_decode(web_loc_form_required_entry_missing));}catch(e){alert("A required item was not filled in.");} return false; } theForm.onSubmit = null; theForm.submit(); setTimeout("disposeParentDivId('pasteDivMaster');",900); setTimeout("disposeParentDivId('pasteDiv');",1000); return false; } function convertTime(theTime){return new Date(theTime*1);} function sort(id, direction) { sortId = id; sortDirection = direction; listItems.sort(doSort); } //equivalent to Java's compareTo() function. We return -1, or 1 depending on the result. function doSort(a,b) { var sortType = "text"; if (sortId == SIZE_COL) sortType = "number"; else if (sortId == DATE_COL) sortType = "number"; if (sortType == "number") return sortDirection * ((b[sortId]*1 > a[sortId]*1)?1:-1); else if (sortType == "text") return sortDirection * ((b[sortId].toUpperCase() > a[sortId].toUpperCase())?1:-1); else if (sortType == "date") return sortDirection * ((Date.parse(b[sortId]) > Date.parse(a[sortId]))?1:-1); } function showRename(indexChain) { var lastListObject = getRealObject(indexChain); var html = ""; html+="<form onSubmit=\"return doRename('"+indexChain+"',RNFR.value,RNTO.value)\">"; html+="<input type=\"hidden\" name=\"RNFR\" value=\""+lastListObject[NAME_COL]+"\" />"; html+="<input type=\"text\" id=\"rename_field_"+indexChain+"\" name=\"RNTO\" size=\""+(lastListObject[NAME_COL].length+3)+"\" value=\""+lastListObject[NAME_COL]+"\" />"; html+=" <input type=\"button\" value=\""+web_loc_ok+"\" onClick=\"doRename('"+indexChain+"',RNFR.value,RNTO.value);\" />"; html+="</form>"; var div = document.createElement("div"); div.style.position="relative"; div.style.visibility="visible"; div.innerHTML = html; document.getElementById("rename_"+indexChain).appendChild(div); document.getElementById("rename_field_"+indexChain).focus(); } function disposeParentDiv(obj) { while (obj.nodeName.toUpperCase() != "DIV") obj = obj.parentNode; obj.parentNode.removeChild(obj); unLockScreen(); } function disposeParentDivId(obj) { obj = document.getElementById(obj); while (obj.nodeName.toUpperCase() != "DIV") { obj = obj.parentNode; } obj.innerHTML = ""; obj.parentNode.removeChild(obj); unLockScreen(); } function disposeUploadDiv(obj) { disposeParentDiv(obj); document.getElementById("uploadMetaMaster2").id = "uploadMetaMaster"; document.getElementById("uploadDiv2").id = "uploadDiv"; document.getElementById("uploadQueueDiv2").id = "uploadQueueDiv"; document.getElementById("uploadMetaMasterForm2").id = "uploadMetaMasterForm"; } function showSpinner(msg) { var div = document.createElement("div"); div.id = "spinnerDiv"; var newMsg = document.getElementById("spinnerDivMaster").innerHTML; newMsg = newMsg.substring(0,newMsg.toUpperCase().indexOf("<IMG")) + msg + newMsg.substring(newMsg.toUpperCase().indexOf("<IMG")); newMsg = replace_str(newMsg,"Master",""); div.innerHTML = newMsg; div.style.position="absolute"; div.style.visibility="visible"; div.style.zIndex = 25; document.getElementById("buttondiv").appendChild(div); lockScreen(20); if(document.getElementById("searchDiv") != null) div.style.left = (px(document.getElementById("searchDiv").offsetLeft) + px(document.getElementById("searchDiv").offsetWidth)/2 - px(div.offsetWidth)/2)+"px"; if(document.getElementById("searchDiv") != null) div.style.top = (px(document.getElementById("searchDiv").offsetTop) + px(document.getElementById("searchDiv").offsetHeight)/2 - px(div.offsetHeight)/2)+"px"; return true; } function prettyDate2(d){return (d.getMonth()+1) + "/" + d.getDate() + "/" + d.getFullYear();} function prettyDate(d) { return formatDate(d,"dd/MM/yyyy"); } function prettyTime(d) { var curr_hour = d.getHours(); if (curr_hour < 12) a_p = "AM"; else a_p = "PM"; if (curr_hour == 0) curr_hour = 12; if (curr_hour > 12) curr_hour = curr_hour - 12; var curr_min = d.getMinutes(); curr_min = curr_min + ""; if (curr_min.length == 1) curr_min = "0" + curr_min; return curr_hour + ":" + curr_min + " " + a_p; } function createCookies(name,value,days) { for(var x=0; x<10; x++) { var val = ""; if (value.length < 3800) { val = value; value = ""; } else { val = value.substring(0,3800); value = value.substring(3800); } createCookie(name+x,val,days); } } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookies(name) { var result = ""; for (var x=0; x<10; x++) { var val = readCookie(name+x); if (val == null) val = ""; result += val; } return result; } function readCookie(name) { name += "="; var c = document.cookie.split(';'); for(var i=0;i < c.length;i++) { while (c[i].charAt(0)==' ') c[i] = c[i].substring(1,c[i].length); if (c[i].indexOf(name) == 0) return c[i].substring(name.length,c[i].length); } return null; } var currentIndex = 0; var finishedUploadedFiles = ""; var xmlhttp = null; var xmlhttp2 = null; var xmlhttp3 = null; var uploadCount = 0; var startTime = 0; var lastTime = 0; var lastBytes = 0; var uploading = false; var current_dir = ""; function copyForm(sourceForm, destForm,theID) { for (var x=0; x<sourceForm.elements.length; x++) { var dest = document.getElementById(sourceForm.elements[x].name+"_"+theID); if ((sourceForm.elements[x].type == "radio" || sourceForm.elements[x].type == "checkbox") && sourceForm.elements[x].checked == true) { dest.value=sourceForm.elements[x].value; } else if (sourceForm.elements[x].type.indexOf("select") >= 0) { dest.value = sourceForm.elements[x].options[sourceForm.elements[x].selectedIndex].value; } else if (!(sourceForm.elements[x].type == "radio" || sourceForm.elements[x].type == "checkbox")) { dest.value=sourceForm.elements[x].value; } } } function buildHiddenForm(sourceForm, theID) { var index = 0; var names = new Array(); var nameStr = ""; for (var x=0; x<sourceForm.elements.length; x++) { if (nameStr.indexOf(sourceForm.elements[x].name+",") < 0) { names[index] = sourceForm.elements[x].name; nameStr += names[index]+","; index++; } } var formFields = ""; for (var x=0; x<names.length; x++) { formFields += "<input id=\""+names[x]+"_"+theID+"\" type=\"hidden\" name=\"META_"+names[x]+"\" />"; } return formFields; } function validateUploadForm(sourceForm) { var required = new Array(); var okStr = ""; for (var x=0; x<sourceForm.elements.length; x++) { if (sourceForm.elements[x].id == "required") { required[required.length] = sourceForm.elements[x].name; if (sourceForm.elements[x].type == "radio") { if (sourceForm.elements[x].checked == true) okStr += sourceForm.elements[x].name+","; } else if (sourceForm.elements[x].type == "checkbox") { required[required.length-1] = sourceForm.elements[x].name.substring(0,sourceForm.elements[x].name.lastIndexOf("_")); if (sourceForm.elements[x].checked == true) { okStr += sourceForm.elements[x].name.substring(0,sourceForm.elements[x].name.lastIndexOf("_"))+","; } } else if (sourceForm.elements[x].type.indexOf("select") >= 0) { if (sourceForm.elements[x].selectedIndex > 0 || sourceForm.elements[x].options[0].value.length > 0) okStr += sourceForm.elements[x].name+","; } else { if (sourceForm.elements[x].value != "") okStr += sourceForm.elements[x].name+","; } } } var ok = true; for (var x=0; x<required.length; x++) { if (okStr.indexOf(required[x]+",") < 0) ok = false; } return ok; } function returnFalse(){return false;} function replace_str(master_str,find_str,replace_str) { var i = 0; var result = ""; while (master_str.indexOf(find_str,i) != -1) { result += master_str.substring(i,master_str.indexOf(find_str,i)) + replace_str; i = (master_str.indexOf(find_str,i) + find_str.length); } result += master_str.substring(i,master_str.length); return result; } function delete_items() { var items = ""; var files = ""; var folders = ""; var itemList = document.getElementsByTagName("input"); for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); try { if (cb != null) { if (cb.checked && (cb.id == "file" || cb.id == "folder")) { items += cb.value+":"; if (cb.id == "folder" && folders.length < 300) folders += cb.value.substring(cb.value.lastIndexOf("/")+1)+"\r\n"; else if (cb.id != "folder" && files.length < 300) files += cb.value.substring(cb.value.lastIndexOf("/")+1)+"\r\n"; } } } catch(exception) { } } if (folders.length >= 300) folders += "..."; if (files.length >= 300) files += "..."; var ok = true; if (folders.length > 0) { if (!confirm(url_decode(web_loc_delete_folders)+"\r\n\r\n"+folders)) { ok = false; return; } } if (items == "") alert(url_decode(web_loc_no_items_to_delete)); else { if(files != "") ok = confirm(url_decode(web_loc_delete_selected_items_permanently)+"\r\n\r\n"+files); if (ok) { document.crushftp_action.the_action.value="DELE "+items; document.crushftp_action.submit(); } } } function download_items() { var downloadPath = ""; var itemList = document.getElementsByTagName("input"); var itemCount = 0; for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); try { if (cb != null) { if (cb.checked && cb.id == "folder") itemCount = 2; else if (cb.checked && cb.id == "file") { downloadPath = cb.value; itemCount++; } } } catch(exception) { } } if (itemCount != 1) zip_items(); else { document.crushftp_action.the_action.value="DOWNLOAD"; document.crushftp_action.item1.value = downloadPath; document.crushftp_action.submit(); } } function zip_items() { var items = ""; var itemsDisplay = ""; var itemList = document.getElementsByTagName("input"); var itemCount = 0; for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); try { if (cb != null) { if (cb.checked && (cb.id == "file" || cb.id == "folder")) { items += cb.value; if (cb.id == "folder") items+="/"; items += ":"; itemsDisplay += cb.value.substring(cb.value.lastIndexOf("/")+1)+"\r\n"; itemCount++; } } } catch(exception) { } } if (items == "") alert(url_decode(web_loc_no_items_selected_for_download)); else { document.crushftp_action.the_action.value="ZIP "+items; document.crushftp_action.item1.value = ""; if (itemCount > 1) { var name = prompt(url_decode(web_loc_enter_download_zip_filename),web_loc_archive); if (name && name.length > 0) { if (name.toUpperCase().indexOf(".ZIP") < 0) name = name + ".zip"; document.crushftp_action.item1.value=name; document.crushftp_action.action=reverseProxy+"/"; document.crushftp_action.submit(); } } else { document.crushftp_action.submit(); } } } function toggleAllCheckboxes() { var itemList = document.getElementsByTagName("input"); for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); try { if (cb != null && (cb.id == "file" || cb.id == "folder")) cb.checked = !cb.checked; } catch(exception) { } } } function getCurrentFileListStr() { var s = ""; for (var x=0; x<listItems.length; x++) { s += ":"+listItems[x][NAME_COL]+":"; } return s; } function startUploader1() { } function startUploader2() { var s = document.getElementById("crushUploaderDiv").innerHTML; s = replace_str(s,"_applet","applet"); s = replace_str(s,"_param","param"); s = replace_str(s,"urlMaster",location.href); s = replace_str(s,"fileListMaster",url_encode(getCurrentFileListStr())); s = replace_str(s,"CrushUploaderMaster","CrushUploader"); s = url_decode(s); document.getElementById("crushUploaderDiv").innerHTML = s; setTimeout("monitorCrushUploader();",5000); } function cancelUploader() { try{document.CrushUploader.cancelTransfers();}catch(exception){} } function monitorCrushUploader() { var s = ""; try{s = document.CrushUploader.getResult();}catch(exception){} s = s + ""; if (s == "") setTimeout("monitorCrushUploader();",1000); if (s.indexOf("Finished") >= 0) { if (s.indexOf("Working") != 0) alert(s); else { var currentAuth = document.CrushUploader.getCrushAuth(); createCookie("CrushAuth",currentAuth); dynamicRefreshCurrentDir(); setTimeout("disposeParentDiv(document.getElementById('CrushUploader'));",1000); } } else if (s.indexOf("Working") >= 0) setTimeout("monitorCrushUploader();",100); } function loadCrushUpplet() { showPopup("crushUploaderDiv",startUploader1,startUploader2); } function lockScreen(zindex) { var maxHeight = window.innerHeight; if (!maxHeight || px(document.body.offsetHeight) > maxHeight) maxHeight = px(document.body.offsetHeight)+20; if (!maxHeight || px(document.body.scrollHeight) > maxHeight) maxHeight = px(document.body.scrollHeight)+20; maxHeight -= 30; var div = document.getElementById("hideScreenDiv"); div.style.display="block"; div.style.zIndex=zindex; div.style.left = "0px"; div.style.top = "0px"; div.style.height=(px(document.body.scrollTop)+maxHeight)+"px"; } function unLockScreen() { var div = document.getElementById("hideScreenDiv"); div.style.display="none"; div.style.zIndex=-1; } var maxX = 0; var maxY = 0; var animater = null; var xIncrement = 30; var yIncrement = 30; var animateIterations = 10; var animateSpeed = 10; var popupDoneFunc1 = null; var popupDoneFunc2 = null; function showPopup(divName,func1,func2) { popupDoneFunc1 = func1; popupDoneFunc2 = func2; var div = null; lockScreen(10); div = document.createElement("div"); div.id = divName; div.style.position="absolute"; div.style.visibility="visible"; div.style.zIndex = 15; div.innerHTML = document.getElementById(div.id+"Master").innerHTML; div.style.left = (px(document.body.clientWidth)/2 - px(div.offsetWidth)/2) + "px"; div.style.top = (100 + px(document.getElementById("buttondivPopups").offsetHeight)) + "px"; document.getElementById("buttondivPopups").appendChild(div); maxX = px(div.offsetWidth); maxY = px(div.offsetHeight); xIncrement = maxX / animateIterations; yIncrement = maxY / animateIterations; div.innerHTML = ""; div.style.visibility="visible"; div.style.width="10px"; div.style.height="10px"; animater = div; setTimeout("animatePopup();",animateSpeed); } function px(s) { s = s+""; if (s.indexOf("px") >= 0) s = s.substring(0, s.length - 2); return s*1; } function animatePopup() { var w = px(animater.style.width); var h = px(animater.style.height); if (w < maxX) { animater.style.width = (w + xIncrement)+"px"; animater.style.left = (px(animater.style.left) - (xIncrement/2))+"px"; } if (h < maxY) { animater.style.height = (h + yIncrement)+"px"; animater.style.top = (px(animater.style.top) - (yIncrement/2))+"px"; } var hh = 0; if (navigator.appName.indexOf("Microsoft")!=-1)hh=document.body.clientHeight; else hh = window.innerHeight; animater.style.left = (px(document.body.clientWidth)/2 - px(animater.offsetWidth)/2)+"px"; animater.style.top = (px(hh)/2 - px(animater.offsetHeight)/2)+"px"; if (h < maxY || w < maxX) { setTimeout("animatePopup();",animateSpeed); } else { animater.style.width = ""; animater.style.height = ""; var s = document.getElementById(animater.id+"Master").innerHTML; if (popupDoneFunc1 != null) popupDoneFunc1(); popupDoneFunc1 = null; animater.innerHTML = s; if (popupDoneFunc2 != null) popupDoneFunc2(); popupDoneFunc2 = null; animater.style.left = (px(document.body.clientWidth)/2 - px(animater.offsetWidth)/2)+"px"; animater.style.top = (px(hh)/2 - px(animater.offsetHeight)/2)+"px"; var inputs = animater.getElementsByTagName("input"); for (var x=0; x<inputs.length; x++) { if (inputs[x].type=="text" || inputs[x].type=="password") { inputs[x].focus(); break; } } } } function browserUploader() { showPopup("uploadContainerDiv",uploadPopupDone1,uploadPopupDone2); } function uploadPopupDone1() { document.getElementById("uploadMetaMaster").id = "uploadMetaMaster2"; document.getElementById("uploadDiv").id = "uploadDiv2"; document.getElementById("uploadQueueDiv").id = "uploadQueueDiv2"; document.getElementById("uploadMetaMasterForm").id = "uploadMetaMasterForm2"; } function uploadPopupDone2() { newUpload(location.href.substring(location.href.indexOf("/",9))); } function hideUpload() { var div = document.getElementById("uploadContainer"); div.style.visibility = "hidden"; div.style.left="-3000px"; div.style.top="-3000px"; unLockScreen(); } var lastRnto = ""; function doRename(indexChain,rnfr,rnto) { var lastListObject = getRealObject(indexChain); if(rnfr != null && rnto != "") { lastRnto = rnto; lastIndexChain = indexChain; var actions = new Array(); var o = new Object();o.name="the_action";o.value="RNFR "+lastListObject[PATH_COL]+rnfr+":RNTO "+lastListObject[PATH_COL]+rnto;actions[0] = o; o = new Object();o.name="refresh";o.value="false";actions[1] = o; getListJavascript(lastListObject[PATH_COL], renameDone, actions); } return false; } var lastIndexChain = ""; function renameDone(responseData) { if (responseData.indexOf("~~~OK~~~") >= 0) { var lastListObject = getRealObject(lastIndexChain); lastListObject[NAME_COL] = lastRnto; buildListing(); } else alert(responseData); } function deleteDone(responseData) { if (responseData.indexOf("~~~OK~~~") >= 0) { var lastListObjectParent = getRealObjectParent(lastIndexChain,false); var lastListObjectIndex = getRealObjectParent(lastIndexChain,true); lastListObjectParent.splice(lastListObjectIndex,1); buildListing(); } else alert(responseData); } function doDeleteFile(indexChain) { var lastListObject = getRealObject(indexChain); var itemName = lastListObject[NAME_COL]; if(confirm(url_decode(web_loc_delete_this_file)+"\r\n\r\n"+itemName)) { lastIndexChain = indexChain; var actions = new Array(); var o = new Object();o.name="the_action";o.value="DELE "+lastListObject[PATH_COL]+itemName;actions[0] = o; o = new Object();o.name="refresh";o.value="false";actions[1] = o; getListJavascript(lastListObject[PATH_COL], deleteDone, actions); } } function doDeleteFolder(indexChain) { var lastListObject = getRealObject(indexChain); if (!lastListObject[TYPE_COL] || (lastListObject[TYPE_COL] != "DIR" && lastListObject[TYPE_COL] != "FILE")) { var lastListObjectParent = getRealObjectParent(indexChain,false); var lastListObjectIndex = getRealObjectParent(indexChain,true); lastListObject = lastListObjectParent[lastListObjectIndex]; } var itemName = lastListObject[NAME_COL]; if (confirm(url_decode(web_loc_delete_folder_and_contents)+"\r\n\r\n"+itemName)) { lastIndexChain = indexChain; var actions = new Array(); var o = new Object();o.name="the_action";o.value="DELE "+lastListObject[PATH_COL]+itemName;actions[0] = o; o = new Object();o.name="refresh";o.value="false";actions[1] = o; getListJavascript(lastListObject[PATH_COL], deleteDone, actions); } } function getRealObject(indexChain) { if (indexChain.indexOf(",") == 0) indexChain = indexChain.substring(1); var indexes = indexChain.split(","); var lastListObject = listItems; for (var x=0; x<indexes.length; x++) { lastListObject = lastListObject[indexes[x]*1]; if (lastListObject[SUBITEMS_COL] != null && lastListObject[SUBITEMS_COL].length > 0) lastListObject = lastListObject[SUBITEMS_COL]; } return lastListObject } function getRealObjectParent(indexChain, index) { if (indexChain.indexOf(",") == 0) indexChain = indexChain.substring(1); if (index) { var i = indexChain*1; if (indexChain.lastIndexOf(",") >= 0) i = indexChain.substring(indexChain.lastIndexOf(",")+1)*1; return i; } else { var o = listItems; if (indexChain.indexOf(",") >= 0) { indexChain = indexChain.substring(0,indexChain.lastIndexOf(",")); o = getRealObject(indexChain); } return o; } } function doLogout() { document.crushftp_action.the_action.value="LOGOUT"; document.crushftp_action.submit(); } function getWebPath() { var path = location.href.substring(location.href.indexOf("/",9),location.href.lastIndexOf("/")+1); if (path.toUpperCase().indexOf("/WEBINTERFACE/") >= 0) path = path.substring(0,path.toUpperCase().indexOf("WEBINTERFACE/")); if (path == "") path = "/"; return path; } function getUrlParam( name ) { var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var tmpURL = window.location.href; var results = regex.exec( tmpURL ); if( results == null ) return ""; else return results[1]; } function anotherNewUpload(uploadFieldItem) { var fName = uploadFieldItem.value; if (fName.indexOf("\\") >= 0) fName = fName.substring(fName.lastIndexOf("\\")+1); else if (fName.indexOf("/") >= 0) fName = fName.substring(fName.lastIndexOf("/")+1); //find an existing matching name for (var xx=0; xx<listItems.length; xx++) { if (fName.toUpperCase() == listItems[xx][NAME_COL].toUpperCase() && finishedUploadedFiles.indexOf(fName) < 0) { if (!confirm(url_decode(web_loc_overwrite_existing_file)+" "+fName)) { old_div = document.getElementById("upload_div_" + uploadCount); old_div.parentNode.removeChild(old_div); uploadCount--; } } } newUpload(current_dir); } function newUpload(the_dir) { var uploadDiv = document.getElementById("uploadDiv"); //current_dir = the_dir; hideUploadDiv(uploadCount); updateQueuedItems(); uploadCount++; uDiv = document.createElement("div"); uDiv.id = "upload_div_" + uploadCount; uDiv.name = "upload_div_" + uploadCount; var divMeta = document.getElementById("uploadMetaMaster"); if (divMeta.parentNode != uploadDiv) divMeta.parentNode.removeChild(divMeta); divMeta.style.visibility="visible"; divMeta.style.position="relative"; var str = divMeta.innerHTML; if (str.indexOf(">") >= 0 || str.indexOf("<") >= 0 || str.indexOf("&") >= 0) { str = replace_str(str,">",">"); str = replace_str(str,"<","<"); str = replace_str(str,"&","&"); divMeta.innerHTML = str; } if (divMeta.parentNode != uploadDiv) uploadDiv.appendChild(divMeta); //must create form via innerHTML or else IE won't send form data var txt = ""; txt += "<form id=\"upload_form_"+uploadCount+"\" target=\"post_frame\" enctype=\"multipart/form-data\" method=\"post\">"; txt += buildHiddenForm(document.getElementById("uploadMetaMasterForm"),uploadCount); txt += "<input type=\"hidden\" name=\"the_action\" value=\"STOR\" />"; txt += "<font size=\"-1\">"+url_decode(browserUploadText)+"</font><br />"; txt += "<input type=\"file\" name=\"upload_file_"+uploadCount+"_SINGLE_FILE_POST\" id=\"upload_file_"+uploadCount+"\" onchange=\"anotherNewUpload(this);\" />"; txt += "<br/><br/>"; txt += "</form>"; uDiv.innerHTML = txt; uploadDiv.appendChild(uDiv); } function updateQueuedItems() { var uploadQueueDiv = document.getElementById("uploadQueueDiv"); var txt = "<hr/><table cellpadding=\"0\" cellspacing=\"5\">"; var found_one = false; for(var x=1; x<=uploadCount; x++) { uploadQueueDiv.style.visibility = "visible"; var uFile = document.getElementById("upload_file_" + x); if (uFile != null && uFile.value != "") { txt += "<tr><td valign=\"top\">"; txt += " <div class=\"UploadProgress1\" id=\"upload_progress_div1_"+x+"\" ></div>"; txt += " <div class=\"UploadProgress2\" id=\"upload_progress_div2_"+x+"\" ></div>"; txt += "</td>"; var fName = uFile.value; if (fName.indexOf("\\") >= 0) fName = fName.substring(fName.lastIndexOf("\\")+1); else if (fName.indexOf("/") >= 0) fName = fName.substring(fName.lastIndexOf("/")+1); txt += "<td valign=\"top\" height=\"22\">"+fName+"</td>"; txt += "<td height=\"22\"><div id=\"upload_remove_div_"+x+"\" style=\"height:22px;\">"; txt += "<a href=\"javascript:removeUploadItem("+x+");\"><img src=\""+reverseProxy+"/WebInterface/images/delete.gif\" alt=\"\" title=\"\" width=\"16\" height=\"16\" border=\"0\" /></a>"; txt += "</div></td>"; txt += "</tr>"; found_one = true; } } txt += "</table>"; txt += "<div id=\"ubuttondiv\"><div id=\"uploadbuttondiv\"><center><ul id=\"buttonlist\"><li><a href=\"javascript:uploadItems();\" id=\"ButtonUploadFiles\">"+url_decode(browserUploadStartText)+"</a></li></ul></center></div></div>"; if (found_one) uploadQueueDiv.innerHTML = txt; else { uploadQueueDiv.innerHTML = " "; uploadQueueDiv.style.visibility = "hidden"; } } function removeUploadItem(x) { var uDiv = document.getElementById("upload_div_"+x); uDiv.parentNode.removeChild(uDiv); updateQueuedItems(); if (uploading) uploadInProgressSetup(); } function hideUploadDiv(x) { old_div = document.getElementById("upload_div_" + x); if (old_div != null) { old_div.style.position = "absolute"; old_div.style.left = "-10000px"; //must move it off screen or else safari won't send the file data } } function uploadItems() { if (!validateUploadForm(document.getElementById("uploadMetaMasterForm"))) { alert(url_decode(web_loc_required_entry_not_filled_out)); return; } document.getElementById("uploadMetaMaster").style.visibility="hidden"; document.getElementById("uploadMetaMaster").style.position="absolute"; uploading = true; hideUploadDiv(uploadCount); found_one = false; for(var x=1; x<=uploadCount; x++) { var uFile = document.getElementById("upload_file_" + x); if (uFile != null && finishedUploadedFiles.indexOf(uFile.value) < 0) { publishUploadedItems[publishUploadedItems.length] = uFile.value; var removeDiv = document.getElementById("upload_remove_div_"+x); removeDiv.style.visibility="hidden"; var uForm = document.getElementById("upload_form_" + x); copyForm(document.getElementById("uploadMetaMasterForm"),uForm,x); uForm.submit(); var uStatus = document.getElementById("upload_progress_div2_"+x); uStatus.innerHTML = url_decode(web_loc_uploading); currentIndex = x; uploadInProgressSetup(); document.getElementById("upload_progress_div2_"+x).style.visibility='visible'; document.getElementById("upload_progress_div1_"+x).style.visibility='visible'; startTime = new Date().getTime(); setTimeout('updateProgress();',3000);//give 3 seconds for the form submissions to start its upload. found_one = true; break; } } if (!found_one)//all uploads are done { dynamicRefreshCurrentDir(); setTimeout("disposeUploadDiv(document.getElementById('uploadContainerDiv'));",1000); finishedUploadedFiles = ""; if (doAutoPublish) doAutoPublishDone(); } } function uploadInProgressSetup() { var removeDiv = document.getElementById("upload_remove_div_"+currentIndex); removeDiv.style.visibility="hidden"; var bgProgressBar = document.getElementById("upload_progress_div2_"+currentIndex).style.visibility='visible'; var fgProgressBar = document.getElementById("upload_progress_div1_"+currentIndex).style.visibility='visible'; var uploadButtonDiv = document.getElementById("uploadbuttondiv"); uploadButtonDiv = uploadButtonDiv.parentNode; uploadButtonDiv.style.visibility="hidden"; uploadButtonDiv.style.position="absolute"; } var now = null; function updateProgress() { if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); //firefox else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //ie xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { now = new Date().getTime(); var responseData = xmlhttp.responseText; if (responseData == null) responseData = ""; if (responseData.indexOf("PROGRESS:") >= 0) { part1 = responseData.substring("PROGRESS:".length,responseData.indexOf("/")); part2 = responseData.substring(responseData.indexOf("/")+1,responseData.indexOf(";")); part1 = part1*1; part2 = part2*1; xmlhttp = null; //calculate speeds if (lastTime != 0) { var elapsed = now - lastTime; var bytes = part1 - lastBytes var speed = (bytes / elapsed) + ""; speed = speed.substring(0,speed.indexOf(".")+2); var remaining = ""; var secs = ((((part2 - part1) / (bytes / elapsed)) / 1000)+1)+""; remaining = formatTime(secs); var stat = document.getElementById("upload_progress_div2_"+currentIndex); var newStr = ""+speed+"Kb/sec, "+remaining+"."; var lastWidth = stat.offsetWidth; stat.style.width = ""; if (secs > 0) stat.innerHTML = newStr; if (stat.offsetWidth < lastWidth) stat.style.width=(lastWidth-5)+"px"; } lastTime = now; lastBytes = part1; if (part1 < part2) { var newpos = parseInt(((part1 / part2) * document.getElementById("upload_progress_div2_"+currentIndex).offsetWidth-5) + ""); var prg = document.getElementById("upload_progress_div1_"+currentIndex); if (newpos < 0) newpos = 0; prg.style.width=newpos+"px"; uploadInProgressSetup(); } setTimeout('updateProgress();',1000); } else { if (responseData.length > 2) { startNextUpload("Failed"); doAutoPublish = false; alert(responseData); } } } } var uFile = document.getElementById("upload_file_"+currentIndex); if (uFile != null) { theFileName = uFile.value; if (theFileName.lastIndexOf("/") >= 0) theFileName = theFileName.substring(theFileName.lastIndexOf("/")+1); else if (theFileName.lastIndexOf("\\") >= 0) theFileName = theFileName.substring(theFileName.lastIndexOf("\\")+1); xmlhttp.open("POST", reverseProxy+current_dir+theFileName,true); var boundary = "-----------------"+makeBoundary(); var data = boundary+"\r\n"+"Content-Disposition: form-data; name=\"the_action\"\r\n\r\nSIZE\r\n"+boundary+"--\r\n"; xmlhttp.setRequestHeader("Content-Type","multipart/form-data; boundary=" + boundary); xmlhttp.setRequestHeader("Content-Length", data.length+""); xmlhttp.send(data); } } function startNextUpload(msg) { var uFile = document.getElementById("upload_file_"+currentIndex); setTimeout('updateProgress();',1); finishedUploadedFiles += "*"+uFile.value+"*"; var stat = document.getElementById("upload_progress_div2_"+currentIndex); var diff = 0; if (now == null) diff = -1000; else diff = now-startTime; if (diff < -1000) diff = -1000; stat.innerHTML = msg+". "+url_decode(web_loc_upload_took)+" " + formatTime(((diff/1000)+1) + "")+"."; var prg = document.getElementById("upload_progress_div1_"+currentIndex); prg.style.width = (document.getElementById("upload_progress_div2_"+currentIndex).offsetWidth-5)+"px"; lastTime = 0; setTimeout('uploadItems();',5); //dynamicRefreshCurrentDir(); //this might create excessive load for many files at once in a large directory } function endsWith(str, s) { str = str.toUpperCase(); s = s.toUpperCase(); if (str.lastIndexOf(s) == str.length - s.length && str.lastIndexOf(s) >= 0) return true; return false; } var badImagePreviewList = ""; var exifScanList = ""; var cachedExif = ""; function showThumbnail(indexChain) { if (siteStr.indexOf("(CrushImagePreview)") < 0) return; var lastListObject = getRealObject(indexChain); if (endsWith(lastListObject[NAME_COL],'.jpg') || endsWith(lastListObject[NAME_COL],'.jpeg') || endsWith(lastListObject[NAME_COL],'.gif') || endsWith(lastListObject[NAME_COL],'.png') || endsWith(lastListObject[NAME_COL],'.bmp') || endsWith(lastListObject[NAME_COL],'.ai') || endsWith(lastListObject[NAME_COL],'.psd') || endsWith(lastListObject[NAME_COL],'.tif') || endsWith(lastListObject[NAME_COL],'.tiff') || endsWith(lastListObject[NAME_COL],'.pdf') || endsWith(lastListObject[NAME_COL],'.cr2') || endsWith(lastListObject[NAME_COL],'.dng') || endsWith(lastListObject[NAME_COL],'.crw') || endsWith(lastListObject[NAME_COL],'.dcr') || endsWith(lastListObject[NAME_COL],'.mrw') || endsWith(lastListObject[NAME_COL],'.nef') || endsWith(lastListObject[NAME_COL],'.orf') || endsWith(lastListObject[NAME_COL],'.pef') || endsWith(lastListObject[NAME_COL],'.srf') || endsWith(lastListObject[NAME_COL],'.eps') || endsWith(lastListObject[NAME_COL],'.pict') || endsWith(lastListObject[NAME_COL],'.cin') || endsWith(lastListObject[NAME_COL],'.dpx')) { var html = ""; var imagePath = reverseProxy+"/WebInterface/images/CrushImagePreview"+url_fix(lastListObject[PATH_COL])+url_fix(lastListObject[NAME_COL]); if (badImagePreviewList.indexOf(replace_str(imagePath," ","%20")) >= 0) return; html += "<center><table cellpadding='5'><tr><td><img onerror=\"badImagePreviewList+='('+this.src+')';hideThumbnail();\" src=\""+imagePath+".jpg\"/></td></tr></table></center>"; var obj = document.getElementById("tempThumbnailDiv"); if (obj != null) obj.parentNode.removeChild(obj); var div = document.createElement("div"); if (cachedExif.indexOf(imagePath+".exif") >= 0) { var s = cachedExif.substring(cachedExif.indexOf(imagePath+".exif")+(imagePath+".exif").length,cachedExif.indexOf("~"+imagePath+".exif")); html += s; } else if (exifScanList.indexOf(imagePath+".exif\r\n") < 0) getHttpResponseData(imagePath+".exif",div); div.id="tempThumbnailDiv"; div.style.position="absolute"; div.style.visibility="visible"; div.innerHTML = html; div.style.zIndex = 15; div.className='highlightedHover'; document.getElementById("rightSide_"+indexChain).appendChild(div); lastThumbnail = div; div.style.top = (px(div.offsetTop)-14) + "px"; setThumbnailTop(); } } function setThumbnailTop() { var div = lastThumbnail; if (px(div.offsetHeight) < 100) { setTimeout('setThumbnailTop();',100); return; } if (px(div.offsetTop) + px(div.offsetHeight) > px(window.innerHeight)) { div.style.top = (px(div.offsetTop)-px(div.offsetHeight)+28) + "px"; } } var lastExifDiv = null; var lastExifUrl = ""; var exifBusy = false; function getHttpResponseData(url,div) { if (exifBusy) return; else exifBusy = true; lastExifDiv = div; lastExifUrl = url; if (window.XMLHttpRequest) xmlhttp2 = new XMLHttpRequest(); //firefox else if (window.ActiveXObject) xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP"); //ie xmlhttp2.onreadystatechange=function() { if (xmlhttp2.readyState==4) { var responseData = xmlhttp2.responseText; if (responseData == null) responseData = ""; if (responseData.indexOf("does not") >= 0) responseData = ""; cachedExif += lastExifUrl+"\r\n"+responseData+"\r\n~"+lastExifUrl; lastExifDiv.innerHTML += responseData; exifBusy = false; } } xmlhttp2.open("GET", url,true); xmlhttp2.send(""); } function hideThumbnail(indexChain) { var obj = document.getElementById("tempThumbnailDiv"); if (obj != null) obj.parentNode.removeChild(obj); } function getSearchProgress() { if (window.XMLHttpRequest) xmlhttp3 = new XMLHttpRequest(); //firefox else if (window.ActiveXObject) xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP"); //ie xmlhttp3.onreadystatechange=function() { if (xmlhttp3.readyState==4) { var responseData = xmlhttp3.responseText; document.getElementById("spinnerProgress").innerHTML = responseData; xmlhttp3 = null; setTimeout('getSearchProgress();',3000); } } xmlhttp3.open("POST", current_dir,true); var boundary = "-----------------"+makeBoundary(); var data = boundary+"\r\n"+"Content-Disposition: form-data; name=\"the_action\"\r\n\r\nSEARCHPROGRESS\r\n"+boundary+"--\r\n"; xmlhttp3.setRequestHeader("Content-Type","multipart/form-data; boundary=" + boundary); xmlhttp3.setRequestHeader("Content-Length", data.length+""); xmlhttp3.send(data); } function dynamicRefreshCurrentDir() { var actions = new Array(); var o = new Object();o.name="the_action";o.value="QUICKLIST";actions[0] = o; getListJavascript(url_decode(current_dir), dynamicRefreshCurrentDirDone,actions); } function dynamicRefreshCurrentDirDone(responseData) { eval(responseData.substring(responseData.indexOf("//LISTING START"),responseData.indexOf("//LISTING END"))); var myList = generatedListItems; for (var x=myList.length-1; x>=0; x--) { var item = myList[x]; //see if this item is in our list, if not, add it in var found = false; for (var xx=listItems.length-1; xx>=0; xx--) { if (url_decode(listItems[xx][NAME_COL]) == url_decode(myList[x][NAME_COL])) { listItems[xx] = myList[x]; found = true; } } if (!found) { listItems[listItems.length] = myList[x]; } } sort(sortId, sortDirection); buildListing(); } function formatTime(secs) { var remaining = ""; secs = secs.substring(0,secs.indexOf(".")) * 1; var mins = (secs / 60) + ""; mins = mins.substring(0,mins.indexOf(".")) * 1; if (mins > 0) { secs -= (mins*60); remaining = mins + " "+web_loc_min+", " + secs + " "+web_loc_secs; } else { remaining = secs + " "+web_loc_secs; } return remaining; } var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat'); function LZ(x) {return(x<0||x>9?"":"0")+x} function formatDate(date,format) { format=format+""; var result=""; var i_format=0; var c=""; var token=""; var y=date.getYear()+""; var M=date.getMonth()+1; var d=date.getDate(); var E=date.getDay(); var H=date.getHours(); var m=date.getMinutes(); var s=date.getSeconds(); var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k; // Convert real date parts into formatted versions var value=new Object(); if (y.length < 4) {y=""+(y-0+1900);} value["y"]=""+y; value["yyyy"]=y; value["yy"]=y.substring(2,4); value["M"]=M; value["MM"]=LZ(M); value["MMM"]=MONTH_NAMES[M-1]; value["NNN"]=MONTH_NAMES[M+11]; value["d"]=d; value["dd"]=LZ(d); value["E"]=DAY_NAMES[E+7]; value["EE"]=DAY_NAMES[E]; value["H"]=H; value["HH"]=LZ(H); if (H==0){value["h"]=12;} else if (H>12){value["h"]=H-12;} else {value["h"]=H;} value["hh"]=LZ(value["h"]); if (H>11){value["K"]=H-12;} else {value["K"]=H;} value["k"]=H+1; value["KK"]=LZ(value["K"]); value["kk"]=LZ(value["k"]); if (H > 11) { value["a"]="PM"; } else { value["a"]="AM"; } if (H > 11) { value["A"]="PM"; } else { value["A"]="AM"; } if (H > 11) { value["aa"]="PM"; } else { value["aa"]="AM"; } if (H > 11) { value["AA"]="PM"; } else { value["AA"]="AM"; } value["m"]=m; value["mm"]=LZ(m); value["s"]=s; value["ss"]=LZ(s); while (i_format < format.length) { c=format.charAt(i_format); token=""; while ((format.charAt(i_format)==c) && (i_format < format.length)) { token += format.charAt(i_format++); } if (value[token] != null) { result=result + value[token]; } else { result=result + token; } } return result; } function doCopy() { var s = getSelectedPaths(); if (s.length > 0) { createCookie("cutCopyPaste","copy:"+s); inverseRows(); setTimeout("inverseRows();",200); } else { alert(web_loc_no_items_selected); } } function doCut() { var s = getSelectedPaths(); if (s.length > 0) { createCookie("cutCopyPaste","cut:"+s); inverseRows(); setTimeout("inverseRows();",200); } else { alert(web_loc_no_items_selected); } } function doPaste() { var existingItems = readCookie("cutCopyPaste"); if (existingItems == null) existingItems = ""; if (existingItems != "") { var actions = new Array(); var o = new Object();o.name="the_action";o.value="PASTE "+existingItems;actions[0] = o; o = new Object();o.name="refresh";o.value="false";actions[1] = o; getListJavascript(getWebPath(), pasteDone, actions); } else { alert(web_loc_no_items_have_been_copied_cut_no_paste); } } function pasteDone(responseData) { if (responseData.indexOf("~~~OK~~~") >= 0) { var existingItems = readCookie("cutCopyPaste"); if (existingItems.indexOf("cut:") == 0) createCookie("cutCopyPaste","");//wipe the cookie dynamicRefreshCurrentDir(); showPasteDiv(); } else alert(responseData); } function inverseRows(visible) { var objs = getSelectedObjects(); for (var x=0; x<objs.length; x++) { if (objs[x].parentNode.parentNode.style.visibility == "hidden") objs[x].parentNode.parentNode.style.visibility = ""; else objs[x].parentNode.parentNode.style.visibility = "hidden"; } } function getSelectedPaths() { var itemList = document.getElementsByTagName("input"); var itemsStr = ""; for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); if (cb != null && cb.checked && (cb.id == "file" || cb.id == "folder")) { var s = cb.value; if (cb.id == "folder") s+="/"; itemsStr += s+":"; } } return itemsStr.length>0?itemsStr.substring(0,itemsStr.length-1):""; } function getSelectedObjects() { var itemList = document.getElementsByTagName("input"); var itemsObj = new Array(); for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); if (cb != null && cb.checked && (cb.id == "file" || cb.id == "folder")) { itemsObj[itemsObj.length] = cb; } } return itemsObj; } function addToBasket() { var error_msg = ""; var existingItems = readCookies("crushBasket"); if (existingItems == null) existingItems = ""; var items = new Array(); var itemList = document.getElementsByTagName("input"); for (var i = 0; i < itemList.length; i++) { var cb = itemList.item(i); try { if (cb != null) { if (cb.checked && (cb.id == "file" || cb.id == "folder")) { var s = cb.value; if (cb.id == "folder") s+="/"; if (existingItems.indexOf(s+":") < 0) { items[items.length] = new Object(); items[items.length-1].path = s; } else { error_msg = "Duplicate items were skipped."; } cb.checked = false; } } } catch(exception) { alert(exception); } } var itemsStr = ""; for (var x = 0; x < items.length; x++) { for (var xx = 0; xx < listItems.length; xx++) { if (items[x].path == listItems[xx][PATH_COL]+listItems[xx][NAME_COL]) { items[x].size = listItems[x][SIZE_COL]; items[x].sizef = listItems[x][SIZEF_COL]; } else if (items[x].path == listItems[xx][PATH_COL]+listItems[xx][NAME_COL]+"/") { items[x].size = 0; items[x].sizef = ""; } } itemsStr += items[x].path+":"+items[x].size+":"+items[x].sizef+":"; } createCookies("crushBasket",existingItems+itemsStr); var existingItems2 = readCookies("crushBasket"); if ((existingItems+itemsStr).length > existingItems2.length) { createCookies("crushBasket",existingItems); alert(web_loc_basket_full); } var len = ((existingItems+itemsStr).split(":").length-1) / 3; alert(items.length + " "+web_loc_items_added_to_basket+" \r\n"+web_loc_there_are_now+" " + len + " "+web_loc_items_in_your_basket+"\r\n\r\n"+error_msg); } function manageBasket() { showPopup("crushBasketDiv"); refreshBasket(); } function refreshBasket() { if (document.getElementById("crushBasketDiv").innerHTML == "") { setTimeout("refreshBasket();",100); } else { var div1 = document.getElementById("crushBasketDiv"); var div2 = div1.getElementsByTagName("div")[0]; var existingItems = readCookies("crushBasket"); if (existingItems == null) existingItems = ""; var items = existingItems.split(":"); var html = new StringBuffer(); if (items.length-1 == 0) { html.append("<i>There are currently no items in your basket.</i>"); } else { html.append("<center><a href=\"javascript:clearBasket('Clear all items from the basket?');\">Clear Basket</a></center><br/>"); } html.append("<form><table>"); var totalSize = 0.0; for (var x=0; x<items.length-1; x++) { html.append("<tr>"); html.append("<td><a href=\"javascript:removeBasketItem("+x+");\">[remove]</a></td>"); // html.append("<td><input type=\"checkbox\" id=\""+items[x+0]+"\"/></td>"); html.append("<td>"+items[x+0]+"</td>"); html.append("<td>"+items[x+2]+"</td>"); html.append("</tr>"); totalSize += items[x+1]*1; x+=2; } html.append("</table>"); if (items.length-1 > 0) { html.append("<br/><center>Total Size: "+formatBytes(totalSize)+"<br/><i>(Folder selections not calculated.)</i></center>"); html.append("<br/><center><input type=\"button\" onClick=\"basketZip();\" value=\"Download All Items As .ZIP\"/></form></center>"); } div2.innerHTML = html; } } function formatBytes(bytes) { if ((bytes / 1024).toFixed(0) == 0) return bytes + " bytes"; else if ((bytes / 1024 / 1024).toFixed(0) == 0) return (bytes / 1024).toFixed(1) + " Kb"; else if ((bytes / 1024 / 1024 / 1024).toFixed(0) == 0) return (bytes / 1024 / 1024).toFixed(1) + " Mb"; else if ((bytes / 1024 / 1024 / 1024 / 1024).toFixed(0) == 0) return (bytes / 1024 / 1024 / 1024).toFixed(1) + " Gb"; else if ((bytes / 1024 / 1024 / 1024 / 1024 / 1024).toFixed(0) == 0) return (bytes / 1024 / 1024 / 1024 / 1024).toFixed(1) + " Tb"; } function validateMKD(str) { if (str.indexOf(":") >= 0) { alert("':' is an invalid character."); return false; } else if (str.indexOf(";") >= 0) { alert("';' is an invalid character."); return false; } return showSpinner('Creating Directory...'); } function basketZip() { var existingItems = readCookies("crushBasket"); if (existingItems == null) existingItems = ""; var items = existingItems.split(":"); var itemsStr = ""; var itemCount = 0; for (var x=0; x<items.length-1; x++) { itemsStr += items[x+0]+":"; itemCount++; x+=2; } document.crushftp_action.the_action.value="ZIP "+itemsStr; if (itemCount > 1) { var name = prompt(url_decode(web_loc_enter_download_zip_filename),web_loc_archive); if (name && name.length > 0) { if (name.toUpperCase().indexOf(".ZIP") < 0) name = name + ".zip"; document.crushftp_action.item1.value=name; document.crushftp_action.action=reverseProxy+"/"; document.crushftp_action.submit(); clearBasket(); } } else { document.crushftp_action.submit(); clearBasket(); } var div1 = document.getElementById("crushBasketDiv"); disposeParentDiv(div1); } function clearBasket(warn_msg) { if (warn_msg == null || warn_msg == "" || confirm(warn_msg)) { createCookies("crushBasket",""); } refreshBasket(); } function removeBasketItem(remove_index) { var existingItems = readCookies("crushBasket"); if (existingItems == null) existingItems = ""; var items = existingItems.split(":"); var itemsStr = ""; for (var x=0; x<items.length-1; x++) { if (x != remove_index) { itemsStr += items[x+0]+":"+items[x+1]+":"+items[x+2]+":"; } x+=2; } createCookies("crushBasket",itemsStr); refreshBasket(); } function updateProxyPort() { var protocol = document.loginForm.protocol.options[document.loginForm.protocol.selectedIndex].text; if (protocol == "FTP") document.loginForm.port.value="21"; else if (protocol == "FTPS") document.loginForm.port.value="21"; else if (protocol == "FTPS Implicit") document.loginForm.port.value="990"; else if (protocol == "SFTP") document.loginForm.port.value="22"; } function doProxyFormSubmit() { if (document.loginForm.ip.value == "") { alert("You must specify a host."); return false; } var u = document.loginForm.user.value; var p = document.loginForm.pass.value; document.loginForm.user.value = proxy_url_encode(u); document.loginForm.pass.value = proxy_url_encode(p); document.loginForm.submit(); return false; } function proxy_url_encode(uu) { uu = replace_str(uu,"%","---PERCENT---"); uu = replace_str(uu,"#","%23"); uu = replace_str(uu,"@","%40"); uu = replace_str(uu,":","%3A"); uu = replace_str(uu,"/","%2F"); uu = replace_str(uu,"\\","%5C"); uu = replace_str(uu,"+","---PLUS---"); uu = replace_str(uu," ","%20"); return uu; } function checkAdhocProxy() { if (!siteprivs) return false; if (siteprivs.indexOf("(SITE_ADHOCWEBFTPPROXY)") >= 0) { var item1 = document.getElementById("adhoc1"); var item2 = document.getElementById("adhoc2"); item1.style.visibility="visible"; item1.style.position="relative"; item2.style.visibility="visible"; item2.style.position="relative"; } } function setupWhitelistProxy() { if (!whitelist) return false; if (siteprivs.indexOf("(SITE_WEBFTPPROXY)") < 0) return false; var whitelist_sel = document.getElementById("whitelist"); for (var x=0; x<whitelist.length; x++) { var add_str = whitelist[x].protocol+"://"+whitelist[x].host; if (whitelist[x].protocol == "FTP" && whitelist[x].port != "21") add_str += ":"+whitelist[x].port; if (whitelist[x].protocol == "FTPS" && whitelist[x].port != "21") add_str += ":"+whitelist[x].port; if (whitelist[x].protocol == "SFTP" && whitelist[x].port != "22") add_str += ":"+whitelist[x].port; add_str += "/"; whitelist_sel.options[whitelist_sel.options.length] = new Option(whitelist[x].proxyName+" "+add_str,add_str); } } function whitelistUpdateProxy() { if (document.getElementById("whitelist").selectedIndex > 0) { var item = whitelist[document.getElementById("whitelist").selectedIndex-1]; if (item.protocol == "FTP") document.loginForm.protocol.selectedIndex = 0; else if (item.protocol == "FTPS") document.loginForm.protocol.selectedIndex = 1; else if (item.protocol == "SFTP") document.loginForm.protocol.selectedIndex = 2; document.loginForm.ip.value = item.host; document.loginForm.port.value = item.port; } } var startingButtonBarTop = -1; function updateButtonBar() //hover float buttons { if (startingButtonBarTop == -1) { document.getElementById('buttondiv').style.position='absolute'; startingButtonBarTop = px(document.getElementById('buttondiv').offsetTop); document.getElementById('buttondiv').style.position='relative'; } if (document.body.scrollTop - startingButtonBarTop <= 0) { document.getElementById('buttondiv').style.position='relative'; document.getElementById('buttondiv').style.top = '0px'; } else { document.getElementById('buttondiv').style.position='absolute'; document.getElementById('buttondiv').style.top = document.body.scrollTop+'px'; } setTimeout("updateButtonBar()",100); } var lastPublicPath = ""; var lastPublicUser = ""; var lastPublicPass = ""; var lastPublicExistingItems = ""; var lastPublicSeparator = "_"; function setupPublic() { setupPublicItems(getSelectedPaths()); } function setupPublicItems(existingItems) { lastPublicExistingItems = existingItems; lastPublicUser = makeBoundarySize(4); lastPublicPass = makeBoundarySize(4); if (lastPublicExistingItems != "") { var actions = new Array(); var o = new Object();o.name="the_action";o.value="MKD "+lastPublicUser+lastPublicSeparator+lastPublicPass;actions[0] = o; o = new Object();o.name="refresh";o.value="false";actions[1] = o; getListJavascript("/publicMagicDir/", publicMkdDone, actions); } else { alert("You must select the items to publish."); } } function publicDone(responseData) { if (responseData.indexOf("~~~OK~~~") >= 0) { prompt("Copy and paste this URL to access the files:",lastPublicPath); } else alert(responseData); lastPublicPath = ""; lastPublicUser = ""; lastPublicPass = ""; } function publicMkdDone(responseData) { var existingItems = "cut:"+lastPublicExistingItems; if (responseData.indexOf("~~~OK~~~") >= 0) { var actions = new Array(); var o = new Object();o.name="the_action";o.value="PASTE "+existingItems;actions[0] = o; o = new Object();o.name="refresh";o.value="false";actions[1] = o; getListJavascript("/publicMagicDir/"+lastPublicUser+lastPublicSeparator+lastPublicPass+"/", publicDone, actions); var partUrl = location.href; partUrl = partUrl.substring(0,partUrl.indexOf("/",9)+1); lastPublicPath = partUrl+"WebInterface/login.html?username="+lastPublicUser+"&password="+lastPublicPass+"&path=/"; } else { alert(responseData); lastPublicPath = ""; lastPublicUser = ""; lastPublicPass = ""; } } function doAutoPublishBrowser() { publishUploadedItems = new Array(); doAutoPublish = true; browserUploader(); } function doAutoPublishDone() { doAutoPublish = false; var existingItems = ""; for (var x=0; x<publishUploadedItems.length; x++) { if (x > 0) existingItems += ":"; var fName = publishUploadedItems[x]; if (fName.indexOf("\\") >= 0) fName = fName.substring(fName.lastIndexOf("\\")+1); else if (fName.indexOf("/") >= 0) fName = fName.substring(fName.lastIndexOf("/")+1); existingItems += current_dir+fName; } setupPublicItems(existingItems); } function launchCrushWebStart() { var partUrl = location.href; partUrl = partUrl.substring(0,partUrl.indexOf("/",9)); post_frame.location.href=reverseProxy+"/WebInterface/crushftp.jnlp?url="+partUrl+reverseProxy; } function logo() { if (allow_alt_logo) setTimeout("logo2();",100); } function logo2() { document.getElementById("alternateLogo").src = current_dir+".logo.png"; document.getElementById("alternateLogo").style.visibility = "visible"; } function badAlternateLogo() { document.getElementById("alternateLogo").style.visibility = "hidden"; } function SITE_ACK() { var actions = new Array(); var o = new Object();o.name="the_action";o.value="SITE ACK";actions[0] = o; getListJavascript(current_dir, SITE_ACK_DONE, actions); } function SITE_ACK_DONE(responseData) { alert(responseData); location.href = location.href.substring(0,location.href.lastIndexOf("/",location.href.length-2)); } function requestEmailedPassword() { if (document.loginForm.username.value == "") alert("Please enter your username first."); else { var actions = new Array(); var o = new Object();o.name="the_action";o.value="EMAILPASSWORD";actions[0] = o; o = new Object();o.name="username";o.value=document.loginForm.username.value;actions[1] = o; getAjaxResult('/',actions); document.getElementById("forgotPasswordDiv").innerHTML="<center>Processing...</center>"; } } function getAjaxResult(thePath, actions) { if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); //firefox else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //ie xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { var responseData = xmlhttp.responseText; xmlhttp = null; document.getElementById("forgotPasswordDiv").innerHTML=responseData; } } xmlhttp.open("POST", reverseProxy+url_fix(thePath),true); var boundary = "-----------------"+makeBoundary(); var data = ""; for (var x=0; x<actions.length; x++) { var o = actions[x]; data += boundary+"\r\n"+"Content-Disposition: form-data; name=\""+o.name+"\"\r\n\r\n"+o.value+"\r\n"; } data += boundary+"--\r\n"; xmlhttp.setRequestHeader("Content-Type","multipart/form-data; boundary=" + boundary); xmlhttp.setRequestHeader("Content-Length", data.length+""); xmlhttp.send(data); } function setupLoginForm(theForm) { var path = getWebPath(); theForm.action=path; if (getUrlParam("username") != "") { theForm.username.value=getUrlParam("username"); theForm.password.value=getUrlParam("password"); theForm.referer.value=getUrlParam("path"); theForm.submit(); return; } theForm.username.focus(); if (document.referrer && document.referrer != "" && document.referrer.indexOf(location.href.substring(path.indexOf("/",9))) >= 0) { path = document.referrer; path = path.substring(path.indexOf("/",9)); theForm.referer.value=path; } var referer = readCookie('referer'); if (referer != null) theForm.referer.value=referer; createCookie("welcomeMessageShown","false"); reverseProxy = getWebPath(); if (reverseProxy == "/") reverseProxy = ""; } function doLogin5() { try { document.loginForm.loginButton.value = "Authenticating..."; document.loginForm.loginButton.disabled = true; document.getElementById("loginWheel").style.visibility=""; } catch(e) { } createCookie("Crush5WI","true",9999); var actions = new Array(); var o = new Object();o.name="command";o.value="login";actions[0] = o; o = new Object();o.name="username";o.value=document.loginForm.username.value;actions[1] = o; o = new Object();o.name="password";o.value=document.loginForm.password.value;actions[2] = o; getLoginAjaxResult('/WebInterface/function/',actions); return false; } function getLoginAjaxResult(thePath, actions) { if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); //firefox else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //ie xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { if (loginForm.wv) { if (loginForm.wv.options[loginForm.wv.selectedIndex].value == "4") { createCookie("Crush5WI","false",9999); createCookie("Crush5HTML","true",9999); } else { createCookie("Crush5WI","true",9999); createCookie("Crush5HTML","false",9999); } } var responseData = xmlhttp.responseText; xmlhttp = null; if (responseData.indexOf("<response>success</response>") >= 0) { try{document.loginForm.loginButton.value = "Logged in! Loading page...";}catch(e){} var theReferer = loginForm.referer.value; if (theReferer == "/WebInterface/login.html") theReferer = "/"; var addOn = reverseProxy+theReferer; if (endsWith(reverseProxy,"/") && theReferer == "/") addOn = reverseProxy; location.href = location.href.substring(0, location.href.indexOf("/",9)) + addOn; } else { try { document.loginForm.loginButton.value = "Login"; document.loginForm.loginButton.disabled = false; document.getElementById("loginWheel").style.visibility="hidden"; } catch(e) { } var m = responseData.substring(responseData.indexOf("<message>")+"<message>".length); m = m.substring(0,m.indexOf("</message>")); alert(m); } } } xmlhttp.open("POST", reverseProxy+url_fix(thePath),true); var boundary = "-----------------"+makeBoundary(); var data = ""; for (var x=0; x<actions.length; x++) { var o = actions[x]; data += o.name+"="+replace_str(o.value,"&","%26")+"&"; } data = data.substring(0,data.length-1); xmlhttp.setRequestHeader("Content-Length", data.length+""); xmlhttp.send(data); }