Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:35:58+00:00 2026-06-11T21:35:58+00:00

I have used this script, but it is not serving me well anymore. I

  • 0

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:

$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 "<font color='red'>fail: unable to establish connection</font>\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);
        }
    }
}

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.

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.

Could someone help me with this case please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:36:00+00:00Added an answer on June 11, 2026 at 9:36 pm

    you can use a form to launch script only when pressing a button like :

    $ip = "ip";
    $user = "user";
    $pass = "password";
    
    if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
    echo '<form action="#" method="POST">';
    echo '<input type="submit" name="launch" value="1" />'
    echo '</form>';
    
    if($_POST['launch']==1){
        if(!($con = ssh2_connect($ip, 22))){
            echo "<font color='red'>fail: unable to establish connection</font>\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);
                }
            }
        }
    }
    

    and for password you can use “baba” class or if it is only a problem of source reading you can use a simple reversable encrypt function like a XOR encryption, BEWARE it is only to make the password not directly redable from source but it is not a perfect securisation

    example :

     function XORin($key='asimpletext', $text='pwd'){
         for($i=0;$i<strlen($text);$i++)
         {
             for($j=0;$j<strlen($key);$j++,$i++)
             {
                 $outText .= $text{$i} ^ $key{$j};
             }
         }
         return $outText;
     }
    
     function XORout($key='asimpletext', $text='pwd'){(){
         for($i=0;$i<strlen($text);$i++)
         {
             for($j=0;$j<strlen($key);$j++,$i++)
             {
                 $outText .= $key{$j} ^ $text{$i};
             }
         }
         return $outText;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tweaked this script that I used from JqueryUi and I have a problem.
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,
I have used this code for extracting urls from web page.But in the line
I have used MVC MVC 2.0 Client Side validation, but it does not work
I once used this wrong PHP script which created a 340 mode directories: <?php
I have a php script which generates an image, and is used (mainly) like
Well this is not the first time im asking these question here but I
I have used a for loop in my script like this ... for var
This seems like a common question but search is not returning anything. I have
I have used this website for testing http://www.webpagetest.org and among some suggestions for optimization

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.