1
wishcraft
Compiled Classes - PHP Extensions

I am thinking about taking on a new refactorisation project with xoops, see over time the subroutines have been altered some functions aren't where at least my understanding of coding, for example routines that where in the register.php are meant to belong in authfactory which hadn't had any functions added to some parts of it since 2006.

Seeming the registration process is part of a policy of the authentication.... anyway.

I have been looking at PHP Compilers following their development most of the ones I have tried seem to work, and I am thinking about working on a performance boost in XOOPS as building an extension library for XOOPS in php and compiling it in php..

ie.. php.ini

[extensions]
extension=xoops_authfactory.dll
extension=xoops_mail.dll

.. and so on..

This would maximize performance of xoops, it is just an idea. But you would have large performance improvements to people wanting to run massive systems.

This way at the moment in the refactory of the code, we will have to start developing code that Explicitily use the class_exists and function_exists..

ie.

le="color: #000000"><?php if (!class_exists('foo'){ class foo { function bar($fubar){ return $fubar; } } }


then in an outside clause function that is not call inside a class it should be

le="color: #000000"><?php if (!function_exists('foobar'){ function foobar($fubar){ return $fubar; } }


this way if an extension is loaded with the same function then when it installed it does not error and throw errors.
vCard (*.vcf): Dr. Simon Antony Roberts.vcf
Follow, Like & Read:-

x.com/EmpressFX
facebook.com/DrAntonyRoberts

2
wishcraft
Re: Compiled Classes - PHP Extensions

Well there is 279 classes in 2.3.1 and 254 external functions contained within the complete XOOPS system..

I wrote a tool in vb6 to convert it to contain all the function_exists and class_exists..

Here is the code for it - in final

cFindFile.cls
le="color: #000000"><?php Dim colInPaths As Collection Dim colOutpaths As Collection Dim sInputPath As String Dim sOutputPath As String Dim sInputPath2 As String Dim sOutputPath2 As String Dim lTotalProcess As Long Dim SearchPath As String, FindStr As String Dim FileSize As Long Dim NumFiles As Integer, NumDirs As Integer Dim AppStringName As String Dim cTempCollection As Collection Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long Const MAX_PATH = 260 Const MAXDWORD = &HFFFF Const INVALID_HANDLE_VALUE = -1 Const FILE_ATTRIBUTE_ARCHIVE = &H20 Const FILE_ATTRIBUTE_DIRECTORY = &H10 Const FILE_ATTRIBUTE_HIDDEN = &H2 Const FILE_ATTRIBUTE_NORMAL = &H80 Const FILE_ATTRIBUTE_READONLY = &H1 Const FILE_ATTRIBUTE_SYSTEM = &H4 Const FILE_ATTRIBUTE_TEMPORARY = &H100 Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Enum ListPaths PathsAndFilenames = 1 FilenamesOnly = 2 PathsOnly = 3 End Enum Dim ListSelected As ListPaths Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14 End Type Function StripNulls(OriginalStr As String) As String If (InStr(OriginalStr, Chr(0)) > 0) Then OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1) End If StripNulls = OriginalStr End Function Function FindFilesAPI(ByVal Path As String, ByVal SearchStr As String, ByVal FileCount As Integer, ByVal DirCount As Integer) Dim FileName As String ' Walking filename variable... Dim DirName As String ' SubDirectory Name Dim dirNames() As String ' Buffer for directory name entries Dim nDir As Integer ' Number of directories in this path Dim i As Integer ' For-loop counter... Dim hSearch As Long ' Search Handle Dim WFD As WIN32_FIND_DATA Dim Cont As Integer If Right(Path, 1) <> "" Then Path = Path & "" ' Search for subdirectories. nDir = 0 ReDim dirNames(nDir) Cont = True hSearch = FindFirstFile(Path & "*", WFD) If hSearch <> INVALID_HANDLE_VALUE Then Do While Cont DirName = StripNulls(WFD.cFileName) ' Ignore the current and encompassing directories. If (DirName <> ".") And (DirName <> "..") Then ' Check for directory with bitwise comparison. If GetFileAttributes(Path & DirName) And FILE_ATTRIBUTE_DIRECTORY Then If InStr(1, Path & DirName, "Processed") = 0 Then dirNames(nDir) = DirName DirCount = DirCount + 1 nDir = nDir + 1 ReDim Preserve dirNames(nDir) End If End If End If Cont = FindNextFile(hSearch, WFD) 'Get next subdirectory. Loop Cont = FindClose(hSearch) End If ' Walk through this directory and sum file sizes. hSearch = FindFirstFile(Path & SearchStr, WFD) Cont = True If hSearch <> INVALID_HANDLE_VALUE Then While Cont FileName = StripNulls(WFD.cFileName) If (FileName <> ".") And (FileName <> "..") Then FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * MAXDWORD) + WFD.nFileSizeLow FileCount = FileCount + 1 If InStr(1, Path & FileName, "SYSTEM FILES") <> 0 Then '// SYSTEM FILES DIRECTORY Else '// OTHER DIRECTORIES cTempCollection.Add Path & FileName End If End If Cont = FindNextFile(hSearch, WFD) ' Get next file Wend Cont = FindClose(hSearch) End If ' If there are sub-directories... If nDir > 0 Then ' Recursively walk into them... For i = 0 To nDir - 1 FindFilesAPI = FindFilesAPI + FindFilesAPI(Path & dirNames(i) & "", SearchStr, FileCount, DirCount) Next i End If End Function Public Function DoFileSystemSearch(ByVal sPath As String, ByVal sFilter As String, ByVal ListAction As ListPaths) As Collection ListSelected = ListAction Set cTempCollection = New Collection FindFilesAPI sPath, sFilter, NumFiles, NumDirs Set DoFileSystemSearch = cTempCollection End Function


form1.frm
le="color: #000000"><?php Private Sub ConvertFile( _ ByVal strInFileName As String, _ ByVal strOutFileName As String _ ) Dim strInFileContent As String Dim strOutFileContent As String Dim i As Long, j As Long Open strInFileName For Input As #1 Open strOutFileName For Output As #2 Do Until EOF(1) Line Input #1, strInFileContent strOutFileContent = "" j = 1 For i = 1 To Len(strInFileContent) If Asc(Mid(strInFileContent, i, 1)) = 10 Then strOutFileContent = strOutFileContent & vbCrLf j = j + 2 Else strOutFileContent = strOutFileContent & Mid(strInFileContent, i, 1) j = j + 1 End If Next Print #2, strOutFileContent Loop Close #2 Close #1 End Sub Private Sub Command1_Click() Dim cFind As New cFindFiles Dim cfList As New Collection Set cfList = cFind.DoFileSystemSearch(Text1.Text, "*.php", PathsAndFilenames) For Each Item In cfList Me.Caption = "editing: " & Mid(Item, Len((Text1.Text)) + 1, Len(Item) - Len(Text1.Text)) Open Item For Input As #1 Line Input #1, tmp Close #1 If InStr(1, tmp, Chr(10)) Then ConvertFile Item, "tmp2.php" FileCopy "tmp2.php", Item Kill "tmp2.php" End If Open "tmp.php" For Output As #2 Open Item For Input As #1 'If InStr(1, Item, "auth.php") Then Stop prenth = 0 While Not EOF(1) addme = String(step, Chr(9)) Line Input #1, tmp skipend = False If InStr(1, tmp, "/*") Then incomment = 2 End If If InStr(1, tmp, "*/") And incomment = 2 Then incomment = False End If If incomment = 1 Then incomment = 0 End If If InStr(1, tmp, "//") > 1 And incomment = 0 Then incomment = 1 End If If incomment = False And InStr(1, " " & tmp, "class ") > 0 And InStr(1, tmp, "=") = 0 And Len(tmp) <> 0 And prenth = 0 Then inclass = True Counts = True prenth = 0 firstprenth = InStr(1, tmp, "{") extends = InStr(1, tmp, "extends") classname = Trim(Mid(tmp, InStr(1, tmp, "class ") + 6, IIf(extends > 0, extends - (InStr(1, tmp, "function ") + 8), IIf(firstprenth > 0, firstprenth - (InStr(1, tmp, "function ") + 8), Len(tmp) - (InStr(1, tmp, "function ") + 1))))) If firstprenth > 5 Then prenth = prenth + 1 addme = addme & "if (!class_exists('" & classname & "')) {" & vbCrLf & vbTab step = step + 1 classes = classes + 1 skipend = True ElseIf incomment = False And InStr(1, " " & tmp, "function ") > 0 And Len(tmp) <> 0 And inclass = False And prenth = 0 Then infunction = True Counts = True prenth = 0 firstbrack = InStr(1, tmp, "(") firstprenth = InStr(1, tmp, "{") functionname = Trim(Mid(tmp, InStr(1, tmp, "function ") + 9, firstbrack - (InStr(1, tmp, "function ") + 9))) If firstprenth > 9 Then prenth = prenth + 1 addme = addme & "if (!function_exists('" & functionname & "')) {" & vbCrLf & vbTab step = step + 1 functions = functions + 1 skipend = True ElseIf incomment = False And Counts = True And (inclass = True Or infunction = True) Then For y = 1 To Len(tmp) Select Case Mid(tmp, y, 1) Case "{" prenth = prenth + 1 Case "}" prenth = prenth - 1 End Select Next End If If skipend = False Then If (infunction = True And prenth = 0) Or (tmp = "}" And inclass = True) Then infunction = False inclass = False addme = Chr(9) & "}" & vbCrLf Label1(0).Caption = "Classes: " & classes Label1(2).Caption = "Functions: " & functions Counts = False step = 0 End If End If Print #2, addme & tmp Wend Close #2 Close #1 FileCopy "tmp.php", Item Kill "tmp.php" DoEvents Next End Sub
vCard (*.vcf): Dr. Simon Antony Roberts.vcf
Follow, Like & Read:-

x.com/EmpressFX
facebook.com/DrAntonyRoberts

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits