Starting Server
#1

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
Reply
#2

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.
Reply
#3

isn't everything except the html stuff in the delimiters?
Reply
#4

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

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?
Reply
#6

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
Reply
#7

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

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
Reply
#9

idk kk
Reply
#10

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>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)