Need some PHP help for this script
-
@obsolesce said in Need some PHP help for this script:
It's hard to work without having data to use. Could you copy all that data from your screenshot to a text file so I can copy / paste that to use?
Sorry I went offline after that to play a game of Life with the kids.
-
For anyone interested. Thanks to @Obsolesce this is progressing nicely.
Current code is on my github.
Have extensions being parsed into an array. Now just to wrap things into a pretty form.
-
I added AstMan.php to github and it contains all the connection stuff wrapped in functions with error handling. But I am having a hell of a time trying to use them.
https://github.com/sorvani/freepbx-helper-scripts/blob/master/AstMan.php@dafyre .........
-
@JaredBusch -- Check my pull request.
-
@dafyre said in Need some PHP help for this script:
@JaredBusch -- Check my pull request.
That worked, minus a syntax correction.
-
Added in @Obsolesce's last commit for the form.
Now to make the form actually submit.
-
next bit. I have this being returned by a function.
string(3771) "Asterisk Call Manager/4.0.3 Response: Success Message: Authentication accepted Event: FullyBooted Privilege: system,all Uptime: 151132 LastReload: 40568 Status: Fully Booted Response: Success EventList: start Message: Following are Events for each object associated with the Endpoint Event: EndpointDetail <snip not needed> Event: AuthDetail <snip not needed> Event: AorDetail <snip not needed> Event: ContactStatusDetail AOR: 5120 URI: sip:[email protected]:5060 UserAgent: Yealink SIP-T42G 29.83.0.35 RegExpire: 1532368885 ViaAddress: 10.202.0.150:5060 CallID: [email protected] Status: Reachable RoundtripUsec: 15857 EndpointName: 5120 ID: 5120;@9e6900eb84ddc2a05701b109000ae8e5 AuthenticateQualify: 0 OutboundProxy: Path: QualifyFrequency: 60 QualifyTimeout: 3.000 Event: EndpointDetailComplete EventList: Complete ListItems: 4 Response: Goodbye Message: Thanks for all the fish.
I do not need the
Event
responses except forContactStatusDetail
.
I want to get that section dropped into an array in PHP.if I am somehow getting each line of text in the variable $line, I can use explode I believe?
$split = explode(":",$line,2);
I would then need to add each line to an array?
-
Frustration and finally progress. Buttons do nothing yet, but @Obsolesce has been working on that in his spare time.
Currently requires 2 files from my github.
AstMan.php
andyealink.reload.php
-
@jaredbusch said in Need some PHP help for this script:
What you're building looks a little like what you have in 3CX. They also show ip address, mac address and the user name and some other minor stuff. As options besides reload (called reprovision) and reboot, they also "firmware update" and also a direct link to the phones webserver.
Maybe some of that would make sense to add to your php script?PS. Checking the input from the form is relatively easy. Make sure the form tag in the generated html uses post <form method="post"> . Then when you receive the values into the php script you can do print_r($_POST); and you'll see how everything looks. Then it's just a matter of going through the $_POST array and picking out the extensions you selected.
It's the name of the checkboxes in html that will appear in the $_POST array. So when the html table is generated use the extension number as name for the checkboxes, for instance ext_101, ext_102 etc.
-
This is now working at a basic level.
Code on GitHub.
-
github updated. files renamed a bit. Still a work in progress, but things working much better.