swish Posted May 3, 2008 Share Posted May 3, 2008 Luis, Coming to you for help. I am trying to Start/Stop/Restart using php or curl What would be the proper commands to send to tcadmin to allow this? Everything I have tried has restricted it due to asp.net permissions Thanks in advance Link to comment Share on other sites More sharing options...
LFA Posted May 4, 2008 Share Posted May 4, 2008 You need to create a page in asp.net and execute it from php with curl. start.aspx: <% Dim service As New TCAdminSDK.Objects.Service service.ServiceID = Request.QueryString("serviceid") If service.Find() Then If service.Start() Then Response.Write("Success!") End If End If %> start.php: <?php $start = curl_init("http://xxx.xxx.xxx.xxx/start.aspx?serviceid=TCXXXXXXXXXX"); curl_exec($start); curl_close($start); ?> In IIS you can restrict access to start.aspx only for local ips or your other web server's ip. Link to comment Share on other sites More sharing options...
swish Posted May 6, 2008 Author Share Posted May 6, 2008 Works like a charm as usual. Thanks much. Link to comment Share on other sites More sharing options...
swish Posted May 6, 2008 Author Share Posted May 6, 2008 Well strange things are goin on..lol Sometimes it works 100%.....then randomly I get "Access Denied" then after awhile it magically starts working again. Link to comment Share on other sites More sharing options...
swish Posted May 6, 2008 Author Share Posted May 6, 2008 Well after much playin by me and main coder we figured out that it needed session.logon So after that...it seems to work. Link to comment Share on other sites More sharing options...
BLAST3R Posted August 19, 2008 Share Posted August 19, 2008 Would you mind posting the 'working' code for the people also having a problem with it not working, swish? Thanks alot! Link to comment Share on other sites More sharing options...
BLAST3R Posted August 19, 2008 Share Posted August 19, 2008 Currently I have made this, named it stop.aspx and placed in a subfolder on the TCAdmin Web folder in the Webserver front-end, restricted IP access for security, but it doesn't work. Contents stop.aspx: <% Dim serviceid As String = Request.QueryString("serviceid") Dim service As New TCAdminSDK.Objects.Service service.ServiceID = serviceid If service.Find Then service.Stop() If service.CurrentStatus = TCAdminSDK.Objects.ServiceStatus.Running Then Response.Write("ERROR - Server niet gestopt!<br />") Response.Flush() End If If service.CurrentStatus = TCAdminSDK.Objects.ServiceStatus.Stopped Then Response.Write("Server gestopt.<br />") Response.Flush() End If End If %> The address I am trying this with is: stop.aspx?serviceid=TC64341511732211400735560 Which is an existing service. Also, when putting in a non-existing serviceid it gives an empty page. When I give this one, it results the message saying it is still running: ERROR - Server niet gestopt! Dutch for 'ERROR - Server is not stopped!'. It is meant to stop the service, but doesn't seem to. Is there anything I miss at the top part of stop.aspx or did I make an error somewhere? Please help! Link to comment Share on other sites More sharing options...
BLAST3R Posted August 21, 2008 Share Posted August 21, 2008 Anyone? We would like to proceed with our control panel. Link to comment Share on other sites More sharing options...
Salmus Posted August 26, 2008 Share Posted August 26, 2008 Doesn't work for me ... also need help ... Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 I've submitted a support ticket for this. I really need a working solution as we are forced to pause our development of our CP, thus delaying the launch of our business. Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 It seems to work now. Magically? Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 What do I have to add to the file to make it work all the time? As I have read the post by swish, I would have to add something for a session. Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 Ok, it only seems to work when an admin has issued a start/stop command before the script does. When the admin's session times out or disconnects, the scripts stop working. Link to comment Share on other sites More sharing options...
ECF Posted August 27, 2008 Share Posted August 27, 2008 I read your support ticket. You can find the SDK documentation in your C:\Program Files\TCAdmin Game Control Panel directory on your master server. The filename is SDK.CHM However, we cannot write code for you. If your devs can read the documentation and create a working system that is great. Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 Well, thats the problem. Our devs write PHP code, not ASP code. There has been an example posted here which thereafter does not work directly without getting a ASP dev looking at it? Hmm.. Link to comment Share on other sites More sharing options...
swish Posted August 27, 2008 Author Share Posted August 27, 2008 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, sprintf("http://YOURADDRESS/customcommands.aspx?cmd=restart&id=%s", $_GET['id'] )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch); curl_close ($ch); Then create a customcommands.aspx page in your tcadmin/web install folder... Put the following: **You need to edit the code to include your ADMINUSER and ADMINPASS in the place I put those two. You will also need to include your USERID <%@ Import Namespace="TCAdminSDK" %> <%@ Import Namespace="Web.billingapi" %> <% Dim cmds As ArrayList = New ArrayList(New String() {"status", "start", "stop", "restart", "suspend", "unsuspend", "user"}) Dim cmd As String = Request.QueryString("cmd") Dim service_id As String = Request.QueryString("id") If cmd = Nothing OrElse cmds.Contains(cmd) = False OrElse service_id = Nothing Then Response.Write("invalid id or cmd") Exit Sub End If Dim Session As TCAdminSDK.Web.Session = New TCAdminSDK.Web.Session() Session.LogOn("ADMINNAME", "ADMINPASSWORD") If cmd = "user" Then Dim u As New TCAdminSDK.Objects.User u.UserID = "USERID" If u.Find() Then For Each service As TCAdminSDK.Objects.Service In u.Services Response.Write(service.ServerIP & ":" & service.ServerPort & "<br/>") Next End If End If Dim svc As New TCAdminSDK.Objects.Service() svc.ServiceID = service_id If svc.Find Then If cmd = "status" Then Response.Write(svc.CurrentStatus.ToString.ToLower) ElseIf cmd = "suspend" Then If svc.StartupType = Objects.ServiceStartup.Disabled Then Response.Write("server is already suspended") Else Try svc.Suspend(False) Response.Write("service suspended") Catch ex As Exception Response.Write("could not suspend server: " & svc.GetLastError.Source & "<br/>" & svc.GetLastError.Message) End Try End If ElseIf cmd = "unsuspend" Then If svc.StartupType <> Objects.ServiceStartup.Disabled Then Response.Write("server is not suspended") Else Try svc.Enable(False) Response.Write("service unsuspended") Catch ex As Exception Response.Write("could not unsuspend server: " & svc.GetLastError.Source & "<br/>" & svc.GetLastError.Message) End Try End If ElseIf cmd = "start" Then If svc.CurrentStatus = Objects.ServiceStatus.Running Or svc.CurrentStatus = Objects.ServiceStatus.StartPending Then Response.Write("service is already started or starting") ElseIf svc.Start() Then Response.Write("service started") Else Dim ex As Exception = svc.GetLastError Response.Write(svc.GetLastError.Source & "<br/>" & svc.GetLastError.Message) End If ElseIf cmd = "stop" Then If svc.CurrentStatus = Objects.ServiceStatus.Stopped Or svc.CurrentStatus = Objects.ServiceStatus.StopPending Then Response.Write("service is already started or starting") ElseIf svc.Stop() Then Response.Write("service stopped") Else Response.Write(svc.GetLastError.Source & "<br/>" & svc.GetLastError.Message) End If ElseIf cmd = "restart" Then If svc.Stop() AndAlso svc.Start() Then Response.Write("service restarted") Else Response.Write(svc.GetLastError.Source & "<br/>" & svc.GetLastError.Message) End If End If End If %> You can love me later Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 I love you already <3. Link to comment Share on other sites More sharing options...
swish Posted August 27, 2008 Author Share Posted August 27, 2008 Haha I hope it helps atleast a little. Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 It did help a lot. Working like a charm now. Big thanks ! Link to comment Share on other sites More sharing options...
LFA Posted August 27, 2008 Share Posted August 27, 2008 You need to create a session. For example: Dim sess As New TCAdminSDK.Web.Session Try If Not sess.LogOn("admin", "password") Then Response.Write("Could not log in!") Response.End() End If ... ...your code here ... Finally sess.LogOff() End Try Link to comment Share on other sites More sharing options...
BLAST3R Posted August 27, 2008 Share Posted August 27, 2008 I think this will help a lot of people that aren't so advanced with ASP . Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.