SA-MP Forums Archive
Starting Server - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Starting Server (/showthread.php?tid=492273)



Starting Server - Mattakil - 03.02.2014

Yes, I know this isnt pawn related, but it's still scripting related to samp. I'm trying to make a script to start/stop my server via PHP. I'm no PHP expert, so i'm trying to learn through this. And please, do not simply link me to another panel, I wanna do this myself.

The issue is the SSH, it doesn't start the server when the function is called.

PHP код:

<?php
if( isset( $_REQUEST['start'] )) 

    
StartServer();
    echo 
"<script type='text/javascript'>alert('Server Started');</script>";

function 
StartServer()
{
    
$connection ssh2_connect("178.63.193.38"22);
    
ssh2_auth_password($connection"purerp""teeheeilikepie");
    
shell_exec('cd /home/purerp/samp');
    
shell_exec('./samp03svr');
}
?>

<form>
<input type="submit" name="start" value="Start Server" />
<input type="submit" name="start" value="Stop Server" />
</form>
Yes, I know start and stop call the same function


Re: Starting Server - Wizz123 - 03.02.2014

The PHP interpreter only executes PHP code within its delimiters. Anything outside its delimiters is not processed, so you must let it execute so it gets processed and then it starts.


Re: Starting Server - Mattakil - 03.02.2014

isn't everything except the html stuff in the delimiters?


Re: Starting Server - Vince - 03.02.2014

Unless you're on a VPS or dedi, shell_exec will almost always be disabled due to the severe security risk it poses.


Re: Starting Server - Wizz123 - 03.02.2014

Quote:
Originally Posted by Vince
Посмотреть сообщение
Unless you're on a VPS or dedi, shell_exec will almost always be disabled due to the severe security risk it poses.
What you are saying is true but it got nothing to do with his case. As i stated above let it execute, or if its already executing and nothing is working then something else is wrong do you have any other functions perhaps?


Re: Starting Server - Mattakil - 03.02.2014

Quote:
Originally Posted by Wizz123
Посмотреть сообщение
What you are saying is true but it got nothing to do with his case. As i stated above let it execute, or if its already executing and nothing is working then something else is wrong do you have any other functions perhaps?
At the moment that is the whole script-

I'm running ubuntu 32 bit OS on a VPS


Re: Starting Server - Mattakil - 03.02.2014

im also a noob at php, so please use kindergarden language :P


Re: Starting Server - SchurmanCQC - 03.02.2014

PHP код:
<?php 
if( isset( $_REQUEST['start'] ))  
{  
    
StartServer(); 
    echo 
"<script type='text/javascript'>alert('Server Started');</script>"
}
function 
StartServer() 

    
$connection ssh2_connect("178.63.193.38"22); 
    
ssh2_auth_password($connection"purerp""teeheeilikepie"); 
    
ssh2_exec($connection'cd /home/purerp/samp'); 
    
ssh2_exec($connection'./samp03svr'); 

?> 
<form> 
<input type="submit" name="start" value="Start Server" /> 
<input type="submit" name="start" value="Stop Server" /> 
</form>
Try that


Re: Starting Server - San1 - 04.02.2014

idk kk


Re: Starting Server - Wizz123 - 04.02.2014

Quote:
Originally Posted by SchurmanCQC
Посмотреть сообщение
PHP код:
<?php 
if( isset( $_REQUEST['start'] ))  
{  
    
StartServer(); 
    echo 
"<script type='text/javascript'>alert('Server Started');</script>"
}
function 
StartServer() 

    
$connection ssh2_connect("178.63.193.38"22); 
    
ssh2_auth_password($connection"purerp""teeheeilikepie"); 
    
ssh2_exec($connection'cd /home/purerp/samp'); 
    
ssh2_exec($connection'./samp03svr'); 

?> 
<form> 
<input type="submit" name="start" value="Start Server" /> 
<input type="submit" name="start" value="Stop Server" /> 
</form>
Try that
Good job!, let me just correct you with a small thing

PHP код:
<?php  
if( isset( $_REQUEST['start'] ))   
{   
    
StartServer();  
    echo 
"<script type='text/javascript'>alert('Server Started');</script>";  

function 
StartServer()  
{  
    
$connection ssh_connect("178.63.193.38"22); // when you connect it should always be ssh even if its the same definition.
    
ssh2_auth_password($connection"purerp""teeheeilikepie");  
    
ssh2_exec($connection'cd /home/purerp/samp');  
    
ssh2_exec($connection'./samp03svr');  
}  
?>  
<form>  
<input type="submit" name="start" value="Start Server" />  
<input type="submit" name="start" value="Stop Server" />  
</form>