Indigo Rose Software
  #1  
Old 09-08-2006
Mikhail Mikhail is offline
Forum Member
 
Join Date: Aug 2004
Location: Rio de Janeiro, Brasil
Posts: 61
Lightbulb HTML/PHP cleanner

Code:
function trans(string_um, string_dois, numero)
str_contento = String.Replace(str_contento, string_um, string_dois, numero);
end


function fErros(problematico)
problema = Application.GetLastError();

if (problematico == nil) then
problematico = "---";
end

if (problema ~= 0) then
TextFile.WriteFromString(_SourceFolder .. "\\problemas.txt", "\r\n" .. System.GetTime(0) .. ": " .. _tblErrorMessages[problema] .. "(" .. problematico .. ")", true);
problema = 0;
end
end


function rekhoder(temp)
str_contento = temp;
str_contento = String.TrimLeft(str_contento, nil);
str_contento = String.TrimRight(str_contento, nil);

trans("\r", "\n", false);
trans("\t", " ", false);
trans("\v", " ", false);

while String.Find(str_contento, "\n" .. " ", 1, false) >= 0 do
trans("\n" .. " ", "\n", false);
end

while String.Find(str_contento, " " .. "\n", 1, false) >= 0 do
trans(" " .. "\n", "\n", false);
end

while String.Find(str_contento, "\n\n", 1, false) >= 0 do
trans("\n\n", "\n", false);
end

while String.Find(str_contento, " " .. " ", 1, false) >= 0 do
trans(" " .. " ", " ", false);
end

trans(" />", "/>", false);

trans("<strong>", "<b>", false);
trans("</strong>", "</b>", false);


trans("<br>", "<br/>", false);
trans("<hr>", "<hr/>", false);
trans("<table", "<table", false);
trans("table>", "table>", false);

trans("<tr", "<tr", false);
trans("tr>", "tr>", false);

trans("<td", "<td", false);
trans("td>", "td>", false);


if File.DoesExist(_SourceFolder .. "\\rodox23.lua") then
Application.RunScriptFile(_SourceFolder .. "\\rodox23.lua");
else
--
end

end


if (source_path == "") or (source_path == nil) or not Folder.DoesExist(source_path) then
source_path = Dialog.FolderBrowse("The source folder...", "");
else
--
end

if (source_path ~= "CANCEL") or (source_path ~= "") or (source_path ~= nil) then
Dialog.Message("You choose the following folder", source_path);
rekhoder(source_path);
strDestinoA = str_contento;
strDestinoB = strDestinoA .. "_" .. System.GetDate(DATE_FMT_ISO) .. "_" .. String.Replace(System.GetTime(0), ":", "", false);
Folder.Create(strDestinoB);

function CallbackFunction(CurrentPath)
if (String.Find(CurrentPath, "CVS", 1, true) == -1) and (String.Find(CurrentPath, ".svn", 1, true) == -1) then
rekhoder(CurrentPath);
str_novepath = String.Replace(str_contento, strDestinoA, strDestinoB, true);

if not Folder.DoesExist(str_novepath) then
Folder.Create(str_novepath);
end

end
return true;
end

function FileFoundCallbackFunction(strCaminho)
File.SetAttributes(strCaminho, {ReadOnly=false, System=false, Hidden=false, Normal=true});
tPath = String.SplitPath(strCaminho);
sF = String.Lower(tPath.Filename);
sE = String.Lower(tPath.Extension);
strDrive = tPath.Drive;
strFolder = tPath.Folder;


if (String.Find(strCaminho, "CVS", 1, true) >= 1) and (String.Find(strCaminho, ".svn", 1, true) >= 1) then
--
elseif

(sE == ".php") or -- php = aparece 40.675 nos mais de 100.000 arquivos do xoops
(sE == ".html") or -- .html = 13174
(sE == ".css") or -- .css = 2244
(sE == ".txt") or -- .txt = 1885
(sE == ".htm") or -- .htm = 782
(sE == ".sql") or -- .sql = 368
(sE == ".js") or -- .js = 1615
(sE == ".xsl") or
(sE == ".log") or
(sE == ".cfg") or
(sE == ".inc") or
(sE == ".xml") then -- .xml = 137

problema = 0;
contents = TextFile.ReadToString(strCaminho);
problema = Application.GetLastError();
if (problema ~= 0) then
fErros(strCaminho);
else
rekhoder(contents);
new_contents = str_contento;
rekhoder(strCaminho);
str_contento = String.Replace(str_contento, strDestinoA, strDestinoB, true);
TextFile.WriteFromString(str_contento, new_contents, false);
fErros(str_contento);
end
else
--
end
return true;
end
StatusDlg.Show();
File.Find(source_path, "*", true, true, CallbackFunction, FileFoundCallbackFunction);
StatusDlg.Hide();
File.ExploreFolder(strDestinoB, SW_MAXIMIZE);
end
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software