xampp control panel equivalent(apachefriends.org)

Windows specific forum
culita
User
User
Posts: 29
Joined: Thu May 03, 2012 1:24 pm

xampp control panel equivalent(apachefriends.org)

Post by culita »

The ideea to switch on/off apache + mysql (the minimal you need to write php-mysql scripts on windows over apache server):
if is on will turn it off,if is off will turn it on ! the ideea is a switch
Compile it and/OR run it from anywhere of your computer ... theoretically must work ...
Here is the code ...

Code: Select all

DisableDebugger
Global resultnet=InitNetwork()
Global xampppath.s="c:\xampp\"
Global apachepath.s="c:\xampp\apache\bin\"
Global mysqlpath.s="c:\xampp\mysql\bin\"
Global mysql=0
Global apache=0

Global standbysw=0

 Procedure.l port(port)
  If (Con = OpenNetworkConnection("127.0.0.1", Port)) = 0
  ProcedureReturn 0
  Else
  ProcedureReturn 1
  EndIf
  CloseNetworkConnection(Con)
EndProcedure


;Debug port(80)
;Debug port(3306)



Procedure.l apache(state.l)
iserror=0;success
If(state=1)
  If(Not(port(80)))
    RunProgram("httpd.exe","--defaults-file="+Chr(34)+"..\conf\httpd.conf"+Chr(34)+"  --standalone",apachepath,#PB_Program_Hide)
    Delay(50)
  Else
    iserror=1;it's already running
  EndIf
  apache=1
Else
  If(port(80))
    RunProgram("taskkill","/f /im httpd.exe","",#PB_Program_Hide)
    Delay(50)
  Else
    iserror=2;nothing to stop
  EndIf
  apache=0
EndIf
Delay(10)
ProcedureReturn iserror
EndProcedure


Procedure.l mysql(state.l)
iserror=0;success
If(state=1)
  If(Not(port(3306)))
    RunProgram("mysqld.exe","--defaults-file="+Chr(34)+"my.ini"+Chr(34),mysqlpath,#PB_Program_Hide)
    Delay(50)
  Else
    iserror=1;it's already running
  EndIf
  mysql=1
Else
  If(port(3306))
    RunProgram("taskkill","/f /im mysqld.exe","",#PB_Program_Hide)
    Delay(50)
  Else
    iserror=2;nothing to stop
  EndIf
  mysql=0
EndIf
Delay(10)
ProcedureReturn iserror
EndProcedure


Procedure startserver()
  apache(1):Delay(700):mysql(1):Delay(1000)
  ;waituntilport(80,1):waituntilport(3306,1)
  Delay(500)
  standbysw=1
  End
EndProcedure

Procedure stopserver()
  Repeat
    apache(0):mysql(0)
    Delay(200)
    ;If(apache=0)And(mysql=0)
    If(Not(port(3306))) And (Not(port(3306)))
    ProcedureReturn
    EndIf
  Until 1
  Delay(500)
  standbysw=1
    ;waituntilport(80,0):waituntilport(3306,0)
EndProcedure



;Debug apache(1):Debug mysql(1):waituntilport(80,1):waituntilport(3306,1)
;Debug apache(1):Debug mysql(1):waituntilport(80,1):waituntilport(3306,1)
;Debug apache(0):Debug mysql(0):waituntilport(80,0):waituntilport(3306,0)






If(Not(port(3306))) And (Not(port(3306)))
thread = CreateThread(@startserver(), 500)
  If thread
        Delay(2000)
        Repeat
        Delay(5)
        Until standbysw=1
        KillThread(thread)
  EndIf
 
Else
thread = CreateThread(@stopserver(), 500)
    If thread
          Delay(2000)
          Repeat
          Delay(5)
          Until standbysw=1
          KillThread(thread)
    EndIf
EndIf
End
EnableDebugger

The spy,
TOVARISH GENERAL CULITA
Last edited by culita on Wed Jul 18, 2012 3:48 pm, edited 3 times in total.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: wamp(APACHEFRIENDS.ORG switch-cpanel for XAMPP)

Post by Kwai chang caine »

For information, i have an error, i think it's the fault of missing the mandatory parameter in the procedure threaded

Code: Select all

Procedure YourProcedure(*Value)
    ; the variable '*Value' equal 23
  EndProcedure

  CreateThread(@YourProcedure(), 23)
After i have again an error here

Code: Select all

KillThread(thread)
ImageThe happiness is a road...
Not a destination
culita
User
User
Posts: 29
Joined: Thu May 03, 2012 1:24 pm

Re: wamp(APACHEFRIENDS.ORG switch-cpanel for XAMPP)

Post by culita »

run it without debugger OR COMPILE A EXE
and one more think ... you must be able to run the .exe file from any part of your hardisk instread "c:\xampp"

i have update the code with automatic options to disable enable the debugger ....
lol
Post Reply