Changeset 1087454
- Timestamp:
- 02/11/2015 08:25:18 PM (11 years ago)
- Location:
- gmace/trunk
- Files:
-
- 2 added
- 1 deleted
- 4 edited
-
assets/css/style.css (modified) (2 diffs)
-
assets/js/scripts.js (modified) (5 diffs)
-
gmace.php (modified) (2 diffs)
-
inc (added)
-
inc/editor.php (added)
-
includes (deleted)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
gmace/trunk/assets/css/style.css
r1055988 r1087454 139 139 } 140 140 .filedit_2 #file:hover{ 141 width: 25%;141 width: 40%; 142 142 } 143 143 .filedit_2 #file>span{ … … 201 201 display: none; 202 202 } 203 #file>div>ul.scandir_ul , #file>div>ul.scandir_ul>div>ul.scandir_ul{display: block;}203 #file>div>ul.scandir_ul {display: block;} 204 204 .scandir_span{ 205 205 color: #32324E; -
gmace/trunk/assets/js/scripts.js
r1064647 r1087454 1 var dir=[],file=[],readOnly=[],editors=[], dir_back, THEME_EDITOR, fontSize = 16, 2 submenuColor = jQuery("#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu").css("background"),1 (function($){ 2 var dir = [], file = [], readOnly = [], editors = [], dir_back, THEME_EDITOR, fontSize = 16, 3 3 dirNameAction, dirAction, unlinkUl; 4 jQuery(document).ready(function()4 $(document).ready(function() 5 5 { 6 var submenuColor = $("#adminmenu li.current a.menu-top").css("background-color"); 6 7 getDirBack(); 7 8 8 jQuery("#gm_actions input[type='number'").on("focus", function(){9 jQuery("#gm_actions > div").css("top", "auto");10 jQuery("#gm_actions").css({11 "width": jQuery("#gm_actions").width(),12 "height": jQuery("#gm_actions").height(),9 $("#gm_actions input[type='number'").on("focus", function(){ 10 $("#gm_actions > div").css("top", "auto"); 11 $("#gm_actions").css({ 12 "width": $("#gm_actions").width(), 13 "height": $("#gm_actions").height(), 13 14 "padding": "25px" 14 15 }); 15 16 16 jQuery("#gm_actions input[type='number'").on("blur", function(){17 jQuery("#gm_actions").attr("style", "");18 jQuery("#gm_actions > div").attr("style", "");17 $("#gm_actions input[type='number'").on("blur", function(){ 18 $("#gm_actions").attr("style", ""); 19 $("#gm_actions > div").attr("style", ""); 19 20 }); 20 21 }); 21 22 22 jQuery("#gm_slider").css("background", jQuery("#wpadminbar").css("background"));23 jQuery("#gm_hotbar").css("background", jQuery("#wpadminbar").css("background"));23 $("#gm_slider").css("background", $("#wpadminbar").css("background")); 24 $("#gm_hotbar").css("background", $("#wpadminbar").css("background")); 24 25 25 THEME_EDITOR = jQuery("#filedit").data("theme");26 27 jQuery("#gm_actions #select_theme>select").on('change', function(){28 setThemeEditor( jQuery(this).val());29 changePar("theme", jQuery(this).val());30 THEME_EDITOR = jQuery(this).val();26 THEME_EDITOR = $("#filedit").data("theme"); 27 28 $("#gm_actions #select_theme>select").on('change', function(){ 29 setThemeEditor($(this).val()); 30 changePar("theme", $(this).val()); 31 THEME_EDITOR = $(this).val(); 31 32 }); 32 jQuery("#gm_actions input[name='wrapping']").on('change', function(){33 changePar("wrapping", jQuery(this).prop("checked"));33 $("#gm_actions input[name='wrapping']").on('change', function(){ 34 changePar("wrapping", $(this).prop("checked")); 34 35 }); 35 jQuery("#gm_actions input[name='printMargin']").on('change', function(){36 changePar("printMargin", jQuery(this).prop("checked"));36 $("#gm_actions input[name='printMargin']").on('change', function(){ 37 changePar("printMargin", $(this).prop("checked")); 37 38 }); 38 jQuery("#gm_actions input[name='linePos']").on('change', function(){39 if( jQuery(this).val()>editors[getID()].session.getLength())40 jQuery(this).val(editors[getID()].session.getLength());41 editors[getID()].gotoLine( jQuery(this).val());39 $("#gm_actions input[name='linePos']").on('change', function(){ 40 if($(this).val()>editors[getID()].session.getLength()) 41 $(this).val(editors[getID()].session.getLength()); 42 editors[getID()].gotoLine($(this).val()); 42 43 }); 43 44 44 45 var interval; 45 46 interval=setInterval(function(){ 46 jQuery(".filedit #gm_hotbar .full_mode").on('click',function(){47 jQuery(".filedit").prop("class","filedit_2");47 $(".filedit #gm_hotbar .full_mode").on('click',function(){ 48 $(".filedit").prop("class","filedit_2"); 48 49 changePar("resize"); 49 50 }); 50 jQuery(".filedit_2 #gm_hotbar .full_mode").on('click',function(){51 jQuery(".filedit_2").prop("class","filedit");51 $(".filedit_2 #gm_hotbar .full_mode").on('click',function(){ 52 $(".filedit_2").prop("class","filedit"); 52 53 changePar("resize"); 53 54 }); 54 55 55 jQuery(".gm_success:hidden, .gm_error:hidden").stop().slideDown(350);56 jQuery(".gm_success, .gm_error").on('click',function(){57 jQuery(this).slideUp(350,function(){jQuery(this).remove();});56 $(".gm_success:hidden, .gm_error:hidden").stop().slideDown(350); 57 $(".gm_success, .gm_error").on('click',function(){ 58 $(this).slideUp(350,function(){$(this).remove();}); 58 59 }); 59 60 },100); … … 61 62 editors[0] = addEditor(); 62 63 63 jQuery("#gm_hotbar .font_size_big").on('click',function(){64 $("#gm_hotbar .font_size_big").on('click',function(){ 64 65 if(fontSize<=24) 65 jQuery("#gm_editors>div").css("font-size", (fontSize++));66 $("#gm_editors>div").css("font-size", (fontSize++)); 66 67 }); 67 jQuery("#gm_hotbar .font_size_small").click(function(){68 $("#gm_hotbar .font_size_small").click(function(){ 68 69 if(fontSize>=10) 69 jQuery("#gm_editors>div").css("font-size", (fontSize--));70 $("#gm_editors>div").css("font-size", (fontSize--)); 70 71 }); 71 72 72 73 getFileOfList(); 73 74 74 jQuery("input[value='Сохранить']").on('click',function(){75 $("input[value='Сохранить']").on('click',function(){ 75 76 e=getID(); 76 77 writeToFile(dir[e]+file[e],editors[e]); 77 78 }); 78 jQuery("#gm_hotbar .new_window_editor").on('click',function(){79 $("#gm_hotbar .new_window_editor").on('click',function(){ 79 80 createNewWindow(); 80 }); 81 }); 82 function getFileOfList(){ 83 jQuery("ul.scandir_ul li.scandir_span").on('click', function(e){ 84 if(jQuery(this).parent().children('ul').css('display')=='none') 85 jQuery(this).parent().children('ul').slideDown(); 86 else 87 jQuery(this).parent().children('ul').slideUp(); 88 e.preventDefault(); 89 }); 90 jQuery("ul.scandir_ul li a").mousedown(function(e){ 91 e.preventDefault(); 92 if(e.which == 2){ 93 jQuery(this).mouseup(function(e){ 94 if(e.which == 2) 95 createNewWindow(jQuery(this).parent().parent("ul").data("dir-folder")+"/", jQuery(this).html()); 81 }); 82 83 function getFileOfList(){ 84 $("ul.scandir_ul li.scandir_span").off(); 85 $("ul.scandir_ul li a").off(); 86 $("ul.scandir_ul li").off(); 87 88 $("ul.scandir_ul li.scandir_span").on('click', function(e){ 89 if($(this).parent().children('ul').css('display')=='none') 90 $(this).parent().children('ul').slideDown(); 91 else 92 $(this).parent().children('ul').slideUp(); 93 e.preventDefault(); 94 }); 95 $("ul.scandir_ul li a").mousedown(function(e){ 96 e.preventDefault(); 97 if(e.which == 2){ 98 $(this).mouseup(function(e){ 99 if(e.which == 2) 100 createNewWindow($(this).parent().parent("ul").data("dir-folder")+"/", $(this).html()); 101 }); 102 }else if(e.which == 1){ 103 changeFile(getID(), $(this)); 104 } 105 }); 106 $("ul.scandir_ul li").on("contextmenu", function(e){ 107 if($(this).children("span").html()!=undefined){ 108 var type = "folder"; 109 var name = $(this).children("span").html(); 110 }else{ 111 var type = "file"; 112 var name = $(this).children("a").html(); 113 } 114 var dir = $(this).parents("ul").data("dir-folder"); 115 if(!e.shiftKey){ 116 openPropertyFile(e.pageY, e.pageX, name, dir, type, $(this)); 117 return false; 118 } 119 e.preventDefault(); 120 }); 121 } 122 function getFileOfTab(){ 123 $("#gm_slider>div>p[clicking='true']").css("background", submenuColor); 124 $("a.close_editor").mousedown(function(e){ 125 closeEditor($(this).parent("p.tab_editor")); 126 }); 127 $("p.tab_editor").mousedown(function(e){ 128 e.preventDefault(); 129 if(e.which == 2){ 130 $(this).mouseup(function(e){ 131 if(e.which == 2) 132 closeEditor($(this)); 133 }); 134 }else if(e.which == 1){ 135 var id = $(this).prop("id")-1+2,e = $(this); 136 $("#gm_editors>div:visible").fadeOut(100,function(){ 137 $("#gm_slider>div>p").css("background", "").attr("clicking","false"); 138 e.css("background", submenuColor).attr("clicking","true"); 139 $("#gm_editors>div#text_file_"+id).fadeIn(100); 140 }); 141 } 142 }); 143 } 144 function getID(){ 145 var id = $("#gm_editors>div:visible").prop("id"); 146 id = id.substring(id.indexOf("_")+1).substring(id.substring(id.indexOf("_")+1).indexOf("_")+1)-1; 147 return id; 148 } 149 function addEditor(dir_f, file_f){ 150 dir[editors.length]=!dir_f?"/":dir_f; 151 file[editors.length]=!file_f?"index.php":file_f; 152 readOnly[editors.length] = false; 153 var name_tab = (file[editors.length] && file[editors.length].length>15)? 154 file[editors.length].substr(0,12)+"..." 155 :file[editors.length]; 156 $("#gm_slider>div").append("<p title='"+file[editors.length]+"' clicking='true' id='"+editors.length+"' class='tab_editor'>"+name_tab+"<a title='Закрыть' class='close_editor'>X</a></p>"); 157 $("#gm_editors").append("<div id='text_file_"+(editors.length-1+2)+"'></div>"); 158 var editor_r = ace.edit("text_file_"+(editors.length-1+2)); 159 160 editor_r.setTheme("ace/theme/"+THEME_EDITOR); 161 editor_r.getSession().setMode("ace/mode/php"); 162 editor_r.setShowPrintMargin(false); 163 editor_r.getSession().setUseWrapMode(true); 164 editor_r.getSession().setUseSoftTabs(false); 165 166 editor_r.commands.addCommand({ 167 name:'save', // название команды 168 bindKey:{win: 'Ctrl-S', mac: 'Command-S'}, // вызов на PC и Mac 169 exec: function(editor){ 170 e = getID(); 171 writeToFile(dir[e]+file[e],editor); 172 } 173 }); 174 editor_r.commands.addCommand({ 175 name:'newwindow', // название команды 176 bindKey:{win: 'Ctrl-Q', mac: 'Command-Q'}, // вызов на PC и Mac 177 exec: function(editor){ 178 createNewWindow(); 179 } 180 }); 181 editor_r.commands.addCommand({ 182 name:'block', // название команды 183 bindKey:{win: 'Ctrl-B', mac: 'Command-B'}, // вызов на PC и Mac 184 exec: function(editor){ 185 e = getID(); 186 if(readOnly[e]){ 187 editor.setReadOnly(false); 188 readOnly[e]=false; 189 }else{ 190 editor.setReadOnly(true); 191 readOnly[e]=true; 192 } 193 }, 194 readOnly: true 195 }); 196 editor_r.getSession().selection.on('changeCursor', function(e){ 197 $("#gm_actions input[name='linePos']").val(editors[getID()].getCursorPosition().row + 1); 198 }); 199 readFromFile(dir[editors.length]+file[editors.length],editor_r); 200 getFileOfTab(); 201 return editor_r; 202 } 203 function fnShowProps(obj, objName){ 204 var result = ""; 205 for (var i in obj) // обращение к свойствам объекта по индексу 206 result += objName + "." + i + " = " + obj[i] + "<br />\n"; 207 document.write(result); 208 } 209 function getDirBack(){ 210 dir_back = $("#filedit").data("back-dir"); 211 } 212 function readFromFile(filedir, editor){ 213 jQuery.post(ajaxurl, { 214 action: 'gmace_action_read', 215 get_file: filedir 216 }, function(response) { 217 setModeEditor(editor, filedir); 218 editor.setValue(response); 219 editor.gotoLine(0); 220 }); 221 } 222 function writeToFile(filedir,editor){ 223 jQuery.post(ajaxurl, { 224 action: 'gmace_rewrite_file', 225 refile:filedir, 226 content:editor.getValue() 227 }, function(response) { 228 $("#messages").html("<div class='gm_success'>Файл <i>"+filedir+"</i> перезаписан.</div>"); 229 }); 230 } 231 function setThemeEditor(value){ 232 jQuery.post(ajaxurl, { 233 action: 'gmace_change_theme', 234 change_theme:value 235 }); 236 } 237 function changePar(par, val){ 238 for(var i=0; i<editors.length; i++){ 239 switch(par){ 240 case "theme": 241 editors[i].setTheme("ace/theme/"+val); 242 break; 243 case "wrapping": 244 editors[i].getSession().setUseWrapMode(val); 245 editors[i].resize(); 246 break; 247 case "resize": 248 editors[i].resize(); 249 break; 250 case "printMargin": 251 editors[i].setShowPrintMargin(val); 252 editors[i].resize(); 253 break; 254 } 255 } 256 } 257 function createNewWindow(dir_f, file_f){ 258 $("#gm_slider>div>p").css("background", "").attr("clicking","false"); 259 $("#gm_editors>div:visible").fadeOut(100,function(){ 260 editors[editors.length] = addEditor(dir_f, file_f); 261 }); 262 } 263 function setModeEditor(editor, filedir){ 264 if(filedir.substr(filedir.length-3,3)=='css'){ 265 editor.getSession().setMode("ace/mode/css"); 266 }else if(filedir.substr(filedir.length-2,2)=='js'){ 267 editor.getSession().setMode("ace/mode/javascript"); 268 }else if(filedir.substr(filedir.length-4,4)=='html'){ 269 editor.getSession().setMode("ace/mode/html"); 270 }else if(filedir.substr(filedir.length-8,8)=='htaccess'){ 271 editor.getSession().setMode("ace/mode/apache_conf"); 272 }else if(filedir.substr(filedir.length-4,4)=='java'){ 273 editor.getSession().setMode("ace/mode/java"); 274 }else if(filedir.substr(filedir.length-2,2)=='py'){ 275 editor.getSession().setMode("ace/mode/python"); 276 }else{ 277 editor.getSession().setMode("ace/mode/php"); 278 } 279 } 280 function changeFile(id, element){ 281 dir[id] = element.parent().parent("ul").data("dir-folder")+"/"; 282 file[id] = element.html(); 283 readFromFile(dir[id]+file[id],editors[id]); 284 var name_tab = file[id].length>15?file[id].substr(0,12)+"...":file[id]; 285 $("#gm_slider p#"+id).prop("title",file[id]).html(name_tab+"<a title='Закрыть' class='close_editor'>X</a>"); 286 getFileOfTab(); 287 } 288 function closeEditor(element){ 289 if($("p.tab_editor").length==1) 290 return; 291 var id = element.prop("id")-1+2; 292 if(element.attr("clicking")=="true"){ 293 $("#gm_editors>div#text_file_"+(id)).fadeOut(100,function(){ 294 element.remove(); 295 $("#gm_editors>div#text_file_"+(id)).remove(); 296 $("#gm_editors>div:eq(0)").fadeIn(100); 297 $("p.tab_editor:eq(0)").attr("clicking","true"); 298 getFileOfTab(); 96 299 }); 97 }else if(e.which == 1){ 98 changeFile(getID(), jQuery(this)); 300 }else{ 301 element.remove(); 302 $("#gm_editors>div#text_file_"+(id)).remove(); 303 getFileOfTab(); 99 304 } 100 }); 101 jQuery("ul.scandir_ul li").on("contextmenu", function(e){ 102 if(jQuery(this).children("span").html()!=undefined){ 103 var type = "folder"; 104 var name = jQuery(this).children("span").html(); 105 }else{ 106 var type = "file"; 107 var name = jQuery(this).children("a").html(); 305 } 306 function openPropertyFile(y, x, fileName, fileDir, type_obj, elementFile){ 307 $("<div>", { 308 "id" : "property_menu", 309 "data-file" : fileName, 310 "data-dir" : fileDir 311 }).css({"left": x, "top": y}).append($("<span>",{ 312 text : fileName 313 })).append($("<p>",{ 314 "class" : "copy", 315 text : "Копировать" 316 })).append($("<p>",{ 317 "class" : "cut", 318 text : "Вырезать" 319 })).append($("<p>",{ 320 "class" : "paste", 321 text : "Вставить", 322 "buffered" : "false" 323 })).append($("<p>",{ 324 "class" : "rename", 325 text : "Переименовать" 326 })).append($("<p>",{ 327 "class" : "delete", 328 text : "Удалить" 329 })).append($("<p>",{ 330 "class" : "new_file", 331 text : "Создать файл" 332 })).append($("<p>",{ 333 "class" : "new_folder", 334 text : "Создать папку" 335 })).append($("<p>",{ 336 "class" : "property", 337 text : "Свойства" 338 })).appendTo("#filedit"); 339 340 if(dirNameAction!=null && dirAction!=null){ 341 $("#property_menu .paste").attr("buffered", true); 108 342 } 109 var dir = jQuery(this).parents("ul").data("dir-folder"); 110 if(!e.shiftKey){ 111 openPropertyFile(e.pageY, e.pageX, name, dir, type, jQuery(this)); 112 return false; 343 344 if(x+$("#property_menu").width()>$(document).width()) 345 $("#property_menu").css({"left": "auto", "right": 0}); 346 if(y+$("#property_menu").height()>$(document).height()) 347 $("#property_menu").css({"top": "auto", "bottom": 0}); 348 349 if(fileName == "www"){ 350 $("#property_menu .copy").remove(); 351 $("#property_menu .cut").remove(); 352 $("#property_menu .rename").remove(); 353 $("#property_menu .delete").remove(); 113 354 } 114 e.preventDefault(); 115 }); 116 } 117 function getFileOfTab(){ 118 jQuery("#gm_slider>div>p[clicking='true']").css("background", submenuColor); 119 jQuery("a.close_editor").mousedown(function(e){ 120 closeEditor(jQuery(this).parent("p.tab_editor")); 121 }); 122 jQuery("p.tab_editor").mousedown(function(e){ 123 e.preventDefault(); 124 if(e.which == 2){ 125 jQuery(this).mouseup(function(e){ 126 if(e.which == 2) 127 closeEditor(jQuery(this)); 355 if(type_obj == "file"){ 356 $("#property_menu .paste").remove(); 357 $("#property_menu .new_folder").remove(); 358 $("#property_menu .new_file").remove(); 359 } 360 361 $(".filedit_2 #file").width("40%"); 362 363 // Deleting property menu 364 $(document).on("mousedown", function(e){ 365 if($(e.target).attr("id")!="property_menu" && $(e.target).parents("#property_menu").attr("id")!="property_menu"){ 366 $("#property_menu").remove(); 367 $(".filedit_2 #file").attr("style", ""); 368 } 369 }); 370 $("#property_menu p.property").on("click", function(){ 371 var element = $(this).parent(); 372 jQuery.post(ajaxurl, { 373 action: 'gmace_get_property_file', 374 file_dir: fileDir, 375 file_name: fileName 376 }, function(response){ 377 $("#property_menu").addClass("info_run").html(response); 128 378 }); 129 }else if(e.which == 1){ 130 var id = jQuery(this).prop("id")-1+2,e = jQuery(this); 131 jQuery("#gm_editors>div:visible").fadeOut(100,function(){ 132 jQuery("#gm_slider>div>p").css("background", "").attr("clicking","false"); 133 e.css("background", submenuColor).attr("clicking","true"); 134 jQuery("#gm_editors>div#text_file_"+id).fadeIn(100); 135 }); 136 } 137 }); 138 } 139 function getID(){ 140 var id = jQuery("#gm_editors>div:visible").prop("id"); 141 id = id.substring(id.indexOf("_")+1).substring(id.substring(id.indexOf("_")+1).indexOf("_")+1)-1; 142 return id; 143 } 144 function addEditor(dir_f, file_f){ 145 dir[editors.length]=!dir_f?"/":dir_f; 146 file[editors.length]=!file_f?"index.php":file_f; 147 readOnly[editors.length]=false; 148 var name_tab = file[editors.length].length>15? 149 file[editors.length].substr(0,12)+"..." 150 :file[editors.length]; 151 jQuery("#gm_slider>div").append("<p title='"+file[editors.length]+"' clicking='true' id='"+editors.length+"' class='tab_editor'>"+name_tab+"<a title='Закрыть' class='close_editor'>X</a></p>"); 152 jQuery("#gm_editors").append("<div id='text_file_"+(editors.length-1+2)+"'></div>"); 153 var editor_r = ace.edit("text_file_"+(editors.length-1+2)); 154 155 editor_r.setTheme("ace/theme/"+THEME_EDITOR); 156 editor_r.getSession().setMode("ace/mode/php"); 157 editor_r.setShowPrintMargin(false); 158 editor_r.getSession().setUseWrapMode(true); 159 editor_r.getSession().setUseSoftTabs(false); 160 161 editor_r.commands.addCommand({ 162 name:'save', // название команды 163 bindKey:{win: 'Ctrl-S', mac: 'Command-S'}, // вызов на PC и Mac 164 exec: function(editor){ 165 e = getID(); 166 writeToFile(dir[e]+file[e],editor); 167 } 168 }); 169 editor_r.commands.addCommand({ 170 name:'newwindow', // название команды 171 bindKey:{win: 'Ctrl-Q', mac: 'Command-Q'}, // вызов на PC и Mac 172 exec: function(editor){ 173 createNewWindow(); 174 } 175 }); 176 editor_r.commands.addCommand({ 177 name:'block', // название команды 178 bindKey:{win: 'Ctrl-B', mac: 'Command-B'}, // вызов на PC и Mac 179 exec: function(editor){ 180 e = getID(); 181 if(readOnly[e]){ 182 editor.setReadOnly(false); 183 readOnly[e]=false; 184 }else{ 185 editor.setReadOnly(true); 186 readOnly[e]=true; 187 } 188 }, 189 readOnly: true 190 }); 191 editor_r.getSession().selection.on('changeCursor', function(e){ 192 jQuery("#gm_actions input[name='linePos']").val(editors[getID()].getCursorPosition().row + 1); 193 }); 194 readFromFile(dir[editors.length]+file[editors.length],editor_r); 195 getFileOfTab(); 196 return editor_r; 197 } 198 function fnShowProps(obj, objName){ 199 var result = ""; 200 for (var i in obj) // обращение к свойствам объекта по индексу 201 result += objName + "." + i + " = " + obj[i] + "<br />\n"; 202 document.write(result); 203 } 204 function getDirBack(){ 205 dir_back = jQuery("#filedit").data("back-dir"); 206 } 207 function readFromFile(filedir,editor){ 208 jQuery.ajax({ 209 type:"POST", 210 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 211 dataType:"html", 212 data:{ 213 get_file:filedir, 214 is_gmace: true 215 }, 216 success:function(html){ 217 setModeEditor(editor, filedir); 218 editor.setValue(html); 219 editor.gotoLine(0); 220 } 221 }); 222 } 223 function writeToFile(filedir,editor){ 224 jQuery.ajax({ 225 type:"POST", 226 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 227 dataType:"html", 228 data:{ 229 refile:filedir, 230 content:editor.getValue(), 231 is_gmace: true 232 }, 233 success:function(html){ 234 jQuery("#messages").html("<div class='gm_success'>Файл <i>"+filedir+"</i> перезаписан.</div>"); 235 }, 236 error:function(html){ 237 jQuery("#messages").html("<div class='gm_error'>Ошибка перезаписи файла <i>"+filedir+"</i> !</div>"); 238 } 239 }); 240 } 241 function setThemeEditor(value){ 242 jQuery.ajax({ 243 type:"POST", 244 url:jQuery("#filedit").data("dir")+"/includes/settings.php", 245 dataType:"html", 246 data:{ 247 change_theme:value 248 } 249 }); 250 } 251 function changePar(par, val){ 252 for(var i=0; i<editors.length; i++){ 253 switch(par){ 254 case "theme": 255 editors[i].setTheme("ace/theme/"+val); 256 break; 257 case "wrapping": 258 editors[i].getSession().setUseWrapMode(val); 259 editors[i].resize(); 260 break; 261 case "resize": 262 editors[i].resize(); 263 break; 264 case "printMargin": 265 editors[i].setShowPrintMargin(val); 266 editors[i].resize(); 267 break; 268 } 269 } 270 } 271 function createNewWindow(dir_f, file_f){ 272 jQuery("#gm_slider>div>p").css("background", "").attr("clicking","false"); 273 jQuery("#gm_editors>div:visible").fadeOut(100,function(){ 274 editors[editors.length] = addEditor(dir_f, file_f); 275 }); 276 } 277 function setModeEditor(editor, filedir){ 278 if(filedir.substr(filedir.length-3,3)=='css'){ 279 editor.getSession().setMode("ace/mode/css"); 280 }else if(filedir.substr(filedir.length-2,2)=='js'){ 281 editor.getSession().setMode("ace/mode/javascript"); 282 }else if(filedir.substr(filedir.length-4,4)=='html'){ 283 editor.getSession().setMode("ace/mode/html"); 284 }else if(filedir.substr(filedir.length-8,8)=='htaccess'){ 285 editor.getSession().setMode("ace/mode/apache_conf"); 286 }else if(filedir.substr(filedir.length-4,4)=='java'){ 287 editor.getSession().setMode("ace/mode/java"); 288 }else if(filedir.substr(filedir.length-2,2)=='py'){ 289 editor.getSession().setMode("ace/mode/python"); 290 }else{ 291 editor.getSession().setMode("ace/mode/php"); 292 } 293 } 294 function changeFile(id, element){ 295 dir[id] = element.parent().parent("ul").data("dir-folder")+"/"; 296 file[id] = element.html(); 297 readFromFile(dir[id]+file[id],editors[id]); 298 var name_tab = file[id].length>15?file[id].substr(0,12)+"...":file[id]; 299 jQuery("#gm_slider p#"+id).prop("title",file[id]).html(name_tab+"<a title='Закрыть' class='close_editor'>X</a>"); 300 getFileOfTab(); 301 } 302 function closeEditor(element){ 303 if(jQuery("p.tab_editor").length==1) 304 return; 305 var id = element.prop("id")-1+2; 306 if(element.attr("clicking")=="true"){ 307 jQuery("#gm_editors>div#text_file_"+(id)).fadeOut(100,function(){ 308 element.remove(); 309 jQuery("#gm_editors>div#text_file_"+(id)).remove(); 310 jQuery("#gm_editors>div:eq(0)").fadeIn(100); 311 jQuery("p.tab_editor:eq(0)").attr("clicking","true"); 312 getFileOfTab(); 313 }); 314 }else{ 315 element.remove(); 316 jQuery("#gm_editors>div#text_file_"+(id)).remove(); 317 getFileOfTab(); 318 } 319 } 320 function openPropertyFile(y, x, fileName, fileDir, type_obj, elementFile){ 321 jQuery("<div>", { 322 "id" : "property_menu", 323 "data-file" : fileName, 324 "data-dir" : fileDir 325 }).css({"left": x, "top": y}).append(jQuery("<span>",{ 326 text : fileName 327 })).append(jQuery("<p>",{ 328 "class" : "copy", 329 text : "Копировать" 330 })).append(jQuery("<p>",{ 331 "class" : "cut", 332 text : "Вырезать" 333 })).append(jQuery("<p>",{ 334 "class" : "paste", 335 text : "Вставить", 336 "buffered" : "false" 337 })).append(jQuery("<p>",{ 338 "class" : "rename", 339 text : "Переименовать" 340 })).append(jQuery("<p>",{ 341 "class" : "delete", 342 text : "Удалить" 343 })).append(jQuery("<p>",{ 344 "class" : "new_file", 345 text : "Создать файл" 346 })).append(jQuery("<p>",{ 347 "class" : "new_folder", 348 text : "Создать папку" 349 })).append(jQuery("<p>",{ 350 "class" : "property", 351 text : "Свойства" 352 })).appendTo("#filedit"); 353 354 if(dirNameAction!=null && dirAction!=null){ 355 jQuery("#property_menu .paste").attr("buffered", true); 356 } 357 358 if(x+jQuery("#property_menu").width()>jQuery(document).width()) 359 jQuery("#property_menu").css({"left": "auto", "right": 0}); 360 if(y+jQuery("#property_menu").height()>jQuery(document).height()) 361 jQuery("#property_menu").css({"top": "auto", "bottom": 0}); 362 363 if(fileName == "www"){ 364 jQuery("#property_menu .copy").remove(); 365 jQuery("#property_menu .cut").remove(); 366 jQuery("#property_menu .rename").remove(); 367 jQuery("#property_menu .delete").remove(); 368 } 369 if(type_obj == "file"){ 370 jQuery("#property_menu .paste").remove(); 371 jQuery("#property_menu .new_folder").remove(); 372 jQuery("#property_menu .new_file").remove(); 373 } 374 375 jQuery(".filedit_2 #file").width("25%"); 376 377 // Deleting property menu 378 jQuery(document).on("mousedown", function(e){ 379 if(jQuery(e.target).attr("id")!="property_menu" && jQuery(e.target).parents("#property_menu").attr("id")!="property_menu"){ 380 jQuery("#property_menu").remove(); 381 jQuery(".filedit_2 #file").attr("style", ""); 382 } 383 }); 384 jQuery("#property_menu p.property").on("click", function(){ 385 var element = jQuery(this).parent(); 386 jQuery.ajax({ 387 type:"POST", 388 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 389 dataType:"html", 390 data:{ 391 property_file: "please", 392 file_dir: fileDir, 393 file_name: fileName, 394 is_gmace: true 395 }, 396 success: function(html){ 397 jQuery("#property_menu").addClass("info_run").html(html); 398 } 399 }); 400 }); 401 402 jQuery("#property_menu p.rename").on("click", function(){ 403 var element = jQuery(this).parent(); 404 jQuery("#property_menu").addClass("info_run").css({ 405 "width":"280px", 406 "height":"65px" 407 }).html("<input type='text' value='"+fileName+"'><input type='button' class='button button-primary' value='Применить'>"); 408 jQuery("#property_menu input.button-primary").on("click", function(){ 409 jQuery.ajax({ 410 type:"POST", 411 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 412 dataType:"html", 413 data:{ 379 }); 380 381 $("#property_menu p.rename").on("click", function(){ 382 var element = $(this).parent(); 383 $("#property_menu").addClass("info_run").css({ 384 "width":"280px", 385 "height":"65px" 386 }).html("<input type='text' value='"+fileName+"'><input type='button' class='button button-primary' value='Применить'>"); 387 $("#property_menu input.button-primary").on("click", function(){ 388 jQuery.post(ajaxurl, { 389 action: 'gmace_rename_and_delete_file', 414 390 rename_delete_action: "rename", 415 rename_file: jQuery("#property_menu input[type='text']").val(),391 rename_file: $("#property_menu input[type='text']").val(), 416 392 file_dir: fileDir, 417 file_name: fileName, 418 is_gmace: true 419 }, 420 success: function(html){ 421 if(html != "error"){ 393 file_name: fileName 394 }, function(response){ 395 if(response != "error"){ 422 396 if(type_obj == "file"){ 423 397 var par = elementFile.parent("ul").parent(); … … 426 400 } 427 401 par.children("ul").remove(); 428 par.append( html);429 jQuery("#property_menu").html("<bold><p>Успешно переименован!</p></bold>");402 par.append(response); 403 $("#property_menu").html("<bold><p>Успешно переименован!</p></bold>"); 430 404 getFileOfList(); 431 }else alert( html);432 } 405 }else alert(response); 406 }); 433 407 }); 434 408 }); 435 }); 436 437 jQuery("#property_menu p.delete").on("click", function(){ 438 var element = jQuery(this).parent(); 439 jQuery.ajax({ 440 type:"POST", 441 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 442 dataType:"html", 443 data:{ 409 410 $("#property_menu p.delete").on("click", function(){ 411 var element = $(this).parent(); 412 if(confirm("Вы действительно хотите удатить объект "+fileName+"?")) 413 jQuery.post(ajaxurl, { 414 action: 'gmace_rename_and_delete_file', 444 415 rename_delete_action: "delete", 445 416 file_dir: fileDir, 446 file_name: fileName, 447 is_gmace: true 448 }, 449 success: function(html){ 450 if(html != "error"){ 417 file_name: fileName 418 }, function(response){ 419 if(response != "error"){ 451 420 if(type_obj == "file"){ 452 421 var par = elementFile.parent("ul").parent(); … … 455 424 } 456 425 par.children("ul").remove(); 457 par.append( html);458 jQuery("#property_menu").addClass("info_run").css({426 par.append(response); 427 $("#property_menu").addClass("info_run").css({ 459 428 "width":"280px", 460 429 "height":"65px" 461 430 }).html("<bold><p>Успешно удален!</p></bold>"); 462 431 getFileOfList(); 463 }else alert(html); 464 } 465 }); 466 }); 467 468 jQuery("#property_menu p.new_folder, #property_menu p.new_file").on("click", function(){ 469 var element = jQuery(this).parent(); 470 if(jQuery(this).hasClass("new_file")){ 471 type_c = "file"; 472 }else{ 473 type_c = "folder"; 474 } 475 jQuery("#property_menu").addClass("info_run").css({ 476 "width":"280px", 477 "height":"65px" 478 }).html("<input type='text'><input type='button' class='button button-primary' value='Создать'>"); 479 jQuery("#property_menu input.button-primary").on("click", function(){ 480 jQuery.ajax({ 481 type:"POST", 482 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 483 dataType:"html", 484 data:{ 432 }else alert(response); 433 }); 434 }); 435 436 $("#property_menu p.new_folder, #property_menu p.new_file").on("click", function(){ 437 var element = $(this).parent(); 438 if($(this).hasClass("new_file")){ 439 type_c = "file"; 440 }else{ 441 type_c = "folder"; 442 } 443 $("#property_menu").addClass("info_run").css({ 444 "width":"280px", 445 "height":"65px" 446 }).html("<input type='text'><input type='button' class='button button-primary' value='Создать'>"); 447 $("#property_menu input.button-primary").on("click", function(){ 448 jQuery.post(ajaxurl, { 449 action: 'gmace_create_file', 485 450 action_for_file: type_c, 486 451 dir: fileDir+"/"+fileName, 487 name: jQuery("#property_menu input[type='text']").val(), 488 is_gmace: true 489 }, 490 success: function(html){ 491 if(html != "error"){ 452 name: $("#property_menu input[type='text']").val() 453 }, function(response){ 454 if(response != "error"){ 492 455 elementFile.parent().children("ul").remove(); 493 elementFile.parent().append( html);494 jQuery("#property_menu").html("<bold><p>Успешно созданно!</p></bold>");456 elementFile.parent().append(response); 457 $("#property_menu").html("<bold><p>Успешно созданно!</p></bold>"); 495 458 getFileOfList(); 496 }else alert(html); 459 }else alert(response); 460 }); 461 }); 462 }); 463 464 $("#property_menu p.copy, #property_menu p.cut").on("click", function(){ 465 if($(this).hasClass("copy")){ 466 dirAction = "copy"; 467 }else{ 468 if(type_obj == "file"){ 469 unlinkUl = elementFile; 470 }else if(type_obj == "folder"){ 471 unlinkUl = elementFile.parent(); 497 472 } 498 }); 499 }); 500 }); 501 502 jQuery("#property_menu p.copy, #property_menu p.cut").on("click", function(){ 503 if(jQuery(this).hasClass("copy")){ 504 dirAction = "copy"; 505 }else{ 506 if(type_obj == "file"){ 507 unlinkUl = elementFile; 508 }else if(type_obj == "folder"){ 509 unlinkUl = elementFile.parent(); 510 } 511 dirAction = "cut"; 512 } 513 dirNameAction = fileDir+"/"+fileName; 514 jQuery("#property_menu").remove(); 515 jQuery(".filedit_2 #file").attr("style", ""); 516 }); 517 518 jQuery("#property_menu p.paste[buffered='true']").on("click", function(){ 519 var element = jQuery(this).parent(); 520 jQuery.ajax({ 521 type:"POST", 522 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 523 dataType:"html", 524 data:{ 473 dirAction = "cut"; 474 } 475 dirNameAction = fileDir+"/"+fileName; 476 $("#property_menu").remove(); 477 $(".filedit_2 #file").attr("style", ""); 478 }); 479 480 $("#property_menu p.paste[buffered='true']").on("click", function(){ 481 var element = $(this).parent(); 482 jQuery.post(ajaxurl, { 483 action: 'gmace_paste_file', 525 484 action_paste: dirAction, 526 485 file_dir: fileDir+"/"+fileName, 527 obj_to_paste: dirNameAction, 528 is_gmace: true 529 }, 530 success: function(html){ 531 if(html != "error"){ 486 obj_to_paste: dirNameAction 487 }, function(response){ 488 if(response != "error"){ 532 489 elementFile.parent().children("ul").remove(); 533 elementFile.parent().append( html);534 jQuery("#property_menu").addClass("info_run").css({490 elementFile.parent().append(response); 491 $("#property_menu").addClass("info_run").css({ 535 492 "width":"280px", 536 493 "height":"65px" … … 544 501 545 502 getFileOfList(); 546 }else alert(html); 547 } 548 }); 549 }); 550 } 551 552 553 554 555 556 503 }else alert(response); 504 }); 505 }); 506 } 507 }); 508 })(jQuery) -
gmace/trunk/gmace.php
r1064647 r1087454 4 4 Plugin URI: http://wordpress.org/plugins/gmace/ 5 5 Description: Свободный PHP-редактор кода Wordpress 6 Version: 1.3. 26 Version: 1.3.3 7 7 Author: German Mesky 8 8 Author URI: http://vk.com/false_coder … … 11 11 define('GMACE_URL', plugin_dir_url(__FILE__)); 12 12 13 include(GMACE_DIR."includes/settings.php"); 14 15 $settings = new Settings(); 13 global $ace; 14 $ace = new GMAce(get_editor_theme()); 15 16 function gmace_reg_scripts(){ 17 wp_register_script("gmace-ace-js", 18 GMACE_URL."assets/js/ace/ace.js" 19 ); 20 wp_register_script("gmace-head-js", 21 GMACE_URL."assets/js/scripts.js", 22 array('jquery') 23 ); 24 25 wp_register_style("gmace-head-styles", GMACE_URL."assets/css/style.css"); 26 }add_action('admin_init', 'gmace_reg_scripts'); 16 27 17 if(is_admin()) 18 add_action('admin_menu', array($settings,'ConfigureMenu')); 28 function gmace_add_to_menu(){ 29 $page = add_menu_page("GMAce Editor", "GMAce", 8, "gmace-editor", "gmace_spread_page", "dashicons-editor-code"); 30 add_action('admin_print_scripts-'.$page, 'gmace_enqueue_script'); 31 }add_action('admin_menu', 'gmace_add_to_menu'); 32 33 function gmace_enqueue_script(){ 34 wp_enqueue_script("gmace-ace-js"); 35 wp_enqueue_script("gmace-head-js"); 36 37 wp_enqueue_style("gmace-head-styles"); 38 } 39 function gmace_spread_page(){ 40 global $ace; 41 include(GMACE_DIR."inc/editor.php"); 42 } 43 function get_editor_theme(){ 44 if(file_exists(GMACE_DIR."gm_theme")) 45 $mode = "r"; 46 else 47 $mode = "w"; 48 $file = fopen(GMACE_DIR."gm_theme", $mode); 49 if($mode=="w"){ 50 define("GMACE_THEME", "dreamweaver"); 51 fputs($file, GMACE_THEME); 52 }else{ 53 define("GMACE_THEME", fgets($file)); 54 } 55 fclose($file); 56 return GMACE_THEME; 57 } 58 59 function gmace_change_theme_callback(){ 60 $file = fopen(GMACE_DIR."gm_theme", "w"); 61 fputs($file, $_POST['change_theme']); 62 fclose($file); 63 }add_action('wp_ajax_gmace_change_theme', 'gmace_change_theme_callback'); 64 65 function gmace_read_file_callback(){ 66 fpassthru(fopen(ABSPATH.$_POST['get_file'],'r')); 67 wp_die(); 68 }add_action('wp_ajax_gmace_action_read', 'gmace_read_file_callback'); 69 70 function gmace_rewrite_file_callback(){ 71 $file = fopen(ABSPATH.$_POST['refile'],'w'); 72 fputs($file, stripslashes($_POST['content'])); 73 wp_die(); 74 }add_action('wp_ajax_gmace_rewrite_file', 'gmace_rewrite_file_callback'); 75 76 function gmace_get_property_file_callback(){ 77 78 $dir = ABSPATH.($_POST['file_dir']?substr($_POST['file_dir'], 1)."/":"").$_POST['file_name']; 79 $href = $_POST['file_dir']."/".$_POST['file_name']; 80 if(filetype($dir) == "dir"){ 81 $size = dirsize($dir); 82 }else{ 83 $size = filesize($dir); 84 } 85 if($size>=1024){ 86 $size/=1024; 87 if($size>=1024){ 88 $size/=1024; 89 if($size>=1024){ 90 $size/=1024; 91 if($size>=1024) 92 $size/=1024; 93 else $size = round($size, 1)." гб"; 94 }else $size = round($size, 1)." мб"; 95 }else $size = round($size, 1)." кб"; 96 }else $size = round($size, 1)." б"; 97 if(filetype($dir) == "dir"){ 98 print("<p><b>Директория: </b>$href</p>"); 99 print("<p><b>Размер каталога: </b>".$size."</p>"); 100 print("<p><b>Тип объекта: </b><span>Папка с файлами</span></p>"); 101 }else{ 102 print("<p> 103 <b>Директория файла: </b> 104 <a target='_blank' href='$href'>$href</a> 105 </p>\n"); 106 print("<p><b>Размер файла: </b>".$size."</p>"); 107 print("<p class='date'><b>Время последней модификации файла: </b>".date("j F Y (l) h:i:s", filemtime($dir))."</p>"); 108 print("<p class='date'><b>Время последнего обращения к файлу: </b>".date("j F Y (l) h:i:s", fileatime($dir))."</p>"); 109 print("<p><b>Тип объекта: </b><span>".filetype($dir)."</span></p>"); 110 } 111 wp_die(); 112 }add_action('wp_ajax_gmace_get_property_file', 'gmace_get_property_file_callback'); 113 114 function gmace_rename_and_delete_file_callback(){ 115 global $ace; 116 $dir = $_POST['file_dir']."/"; 117 if($_POST['rename_delete_action']=="rename" && rename(ABSPATH.$dir.$_POST['file_name'], ABSPATH.$dir.$_POST['rename_file'])){ 118 print($ace->scaning_dir($_POST['file_dir'], false)); 119 }elseif($_POST['rename_delete_action']=="delete"){ 120 if(filetype(ABSPATH.$dir.$_POST['file_name'])=="dir"){ 121 if(dir_unlink(ABSPATH.$dir.$_POST['file_name'])) 122 print($ace->scaning_dir($_POST['file_dir'], false)); 123 else print("error"); 124 }else{ 125 if(unlink(ABSPATH.$dir.$_POST['file_name'])) 126 print($ace->scaning_dir($_POST['file_dir'], false)); 127 else print("error"); 128 } 129 }else print("error"); 130 wp_die(); 131 }add_action('wp_ajax_gmace_rename_and_delete_file', 'gmace_rename_and_delete_file_callback'); 132 133 function gmace_create_file_callback(){ 134 global $ace; 135 136 $dir = ABSPATH.substr($_POST['dir'], 1)."/".$_POST['name']; 137 if(($_POST['action_for_file']=="folder" && mkdir($dir)) || ($_POST['action_for_file']=="file" && fopen($dir, "w"))) 138 print($ace->scaning_dir($_POST['dir'], false)); 139 else print("error"); 140 wp_die(); 141 }add_action('wp_ajax_gmace_create_file', 'gmace_create_file_callback'); 142 143 function gmace_paste_file_callback(){ 144 global $ace; 145 $dirFrom = $_POST['obj_to_paste']; 146 $dirTo = $_POST['file_dir']; 147 148 if(filetype(ABSPATH.$dirFrom)=="dir"){ 149 if(dir_move(ABSPATH.$dirFrom, ABSPATH.$dirTo, $_POST['action_paste']=="cut")) 150 print($ace->scaning_dir($dirTo, false)); 151 else print("error"); 152 }else{ 153 if(copy(ABSPATH.$dirFrom, ABSPATH.$dirTo."/".basename($dirFrom))){ 154 if($_POST['action_paste']=="cut") 155 unlink(ABSPATH.$dirFrom); 156 print($ace->scaning_dir(ABSPATH.$_POST['file_dir'], false)); 157 } 158 else print("error"); 159 } 160 wp_die(); 161 }add_action('wp_ajax_gmace_paste_file', 'gmace_paste_file_callback'); 162 163 class GMAce 164 { 165 public $TYPE; 166 public $THEME; 167 public $SCANDIR; 168 169 function GMAce($theme){ 170 $this->TYPE = "ul"; 171 $this->THEME = $theme; 172 $this->SCANDIR = ABSPATH; 173 } 174 175 function scaning_dir($dir, $flag){ 176 if($dir == "/") 177 $dir = ""; 178 $fd="<ul class='scandir_ul' data-dir-folder='".str_replace("/www", "", $dir)."'>"; 179 $folders; 180 $folder_id = 0; 181 $files; 182 $file_id = 0; 183 foreach(scandir($this->SCANDIR.substr($dir, 1)) as $index=>$val){ 184 if(filetype($this->SCANDIR.substr($dir, 1)."/".$val)=="dir"){ 185 if($val!="."&$val!=".."){ 186 $folders[$folder_id]=$val; 187 $folder_id++; 188 } 189 }else{ 190 $files[$file_id]=$val; 191 $file_id++; 192 } 193 } 194 195 //------ SORT -------// 196 for($i=0;$i<$folder_id;$i++){ 197 $fd.="<div><li class='scandir_span'><span>".$folders[$i]."</span></li>"; 198 $fd.=$this->scaning_dir($dir."/".$folders[$i], true); 199 } 200 for($i=0;$i<$file_id;$i++){ 201 $bg=$this->get_type_file($files[$i]); 202 $fd.="<li class='icon' type='$bg'><a>".$files[$i]."</a></li>"; 203 } 204 $fd.="</ul>"; 205 if($flag) 206 $fd.="</div>"; 207 208 return $fd; 209 } 210 function file_format($filename,$file_formats){ 211 $format=substr($filename,strrpos($filename,".")+1); 212 for($j=0;$j<count($file_formats);$j++) 213 if($format==$file_formats[$j]) 214 return true; 215 return false; 216 } 217 function get_type_file($file){ 218 if($this->file_format($file,array("jpg","jpeg","png","gif","ico"))){ 219 $bg="img"; 220 }elseif($this->file_format($file,array("js","json"))){ 221 $bg="js"; 222 }elseif($this->file_format($file,array("php"))){ 223 $bg="php"; 224 }elseif($this->file_format($file,array("html","htm"))){ 225 $bg="html"; 226 }elseif($this->file_format($file,array("css"))){ 227 $bg="css"; 228 }elseif($this->file_format($file,array("mp3","ogg","mp4","aac","wav"))){ 229 $bg="voice"; 230 }elseif($this->file_format($file,array("txt","htaccess"))){ 231 $bg="text"; 232 }elseif($this->file_format($file,array("java"))){ 233 $bg="java"; 234 }elseif($this->file_format($file,array("py"))){ 235 $bg="python"; 236 }elseif($this->file_format($file,array("zip","rar","7z","gzip","iso"))){ 237 $bg="archive"; 238 }else{ 239 $bg="unknown"; 240 } 241 return $bg; 242 } 243 } 244 function dir_move($dirFrom, $dirTo, $flag){ 245 $errors = 0; 246 $dirTo.="/".basename($dirFrom)."/"; 247 if(!file_exists($dirTo)) 248 mkdir($dirTo); 249 foreach(scandir($dirFrom) as $index=>$val){ 250 if(filetype($dirFrom."/".$val)=="dir"){ 251 if($val!="." & $val!=".."){ 252 dir_move($dirFrom."/".$val, $dirTo, $flag); 253 } 254 }else{ 255 copy($dirFrom."/".$val, $dirTo.$val); 256 } 257 } 258 if($flag) 259 dir_unlink($dirFrom); 260 return $errors==0; 261 } 262 function dir_unlink($dir){ 263 $errors = 0; 264 foreach(scandir($dir) as $index=>$val){ 265 if(filetype($dir."/".$val)=="dir"){ 266 if($val!="." & $val!=".."){ 267 dir_unlink($dir."/".$val); 268 } 269 }else{ 270 if(!unlink($dir."/".$val)) 271 $errors++; 272 } 273 } 274 if(!rmdir($dir)) 275 $errors++; 276 return $errors==0; 277 } 278 function dirsize($dir){ 279 $total_size; 280 foreach(scandir($dir) as $index=>$val){ 281 if(filetype($dir."/".$val)=="dir"){ 282 if($val!="." & $val!=".."){ 283 $total_size+=dirsize($dir."/".$val); 284 } 285 }else{ 286 $total_size+=filesize($dir."/".$val); 287 } 288 } 289 return $total_size; 290 } 19 291 ?> -
gmace/trunk/readme.txt
r1064647 r1087454 33 33 34 34 == Changelog == 35 36 = 1.3.3 = 37 * Reworked treatment system files 38 * Fixed some bugs 35 39 36 40 = 1.3.2 =
Note: See TracChangeset
for help on using the changeset viewer.