php2connect, encrypt and workaround
<p>I have used this script, but it is not serving me well anymore. I have to visit mysite.com/serv.php to call the script. So, first here is the script:</p>

<pre><code>$ip = "ip";
$user = "user";
$pass = "password";

if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");

if(!($con = ssh2_connect($ip, 22))){
    echo "&lt;font color='red'&gt;fail: unable to establish connection&lt;/font&gt;\n";
} else {   

    if(!ssh2_auth_password($con, $user, $pass)) {
        echo "fail: unable to authenticate";
    } else {
        echo "Sucessful";
        if (!($stream = ssh2_exec($con, "/home/boza/serv.sh" ))) {
            echo "fail: unable to execute command";
        } else {
            stream_set_blocking($stream, true);
            $data = "";
            while ($buf = fread($stream,4096)) {
                $data .= $buf;
            }
            fclose($stream);
        }
    }
}
</code></pre>

<p>The script works well, but I want to have some changes in it.
1. I would like to add md5 hash into it, to make it more secure
2. I would like for the script to not be executed when visiting serv.php, but by pressing a button to make an ajax call.
3. I would like there to be user feedback, like "sucessful" or "fail"... like I did now, with live ajax or something without refreshing site.</p>

<p>I have googled and I have tried to put md5('xxxx') into the script, I have got a weird errors and I'm sure I was doing something wrong.</p>

<p>Could someone help me with this case please?</p>
