Jump to content

quick help


dantebeck

Recommended Posts

Hi,

 

I have the following code, which does implement "autologin" on the Pandora FMS monitoring solution

<?php

 

$pwd = "pandora";

 

$user = "admin";

$data = $user.$pwd;

$data = md5($data);

 

echo "DEBUG md5sum $data user $user Pass $pwd<br>";


echo '<input type="hidden" name="loginhash_data" value="'.$data.'">';

echo '<input type="hidden" name="loginhash_user" value="'.$user.'">';

echo '<input type="submit">';

echo '</form>';

 

Thats a sample code that comes with the Pandora FMS install, however, it displays a "Submit" button you have to hit in order to get to the URL, how can I get rid off that submit button and have it redirect me automatically?

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/283016-quick-help/
Share on other sites

Not sure of the "best" approach, but here is one that I use:

$url = 'http://10.1.10.10/pandora_console/index.php?loginhash=auto&sec=estado&sec2=operation/agentes/estado_agente&refr=60';
$data = array('loginhash_data'=>$data, 'loginhash_user'=>$user);
http_post_redirect($url, $data);

function http_post_redirect($url='', $data=array(), $doc=true) {

    $data = json_encode($data);

    if($doc) { echo "<html><head></head><body>"; }

    echo "
    <script type='text/javascript'>
        var data = eval('(' + '$data' + ')');
        var jsForm = document.createElement('form');

        jsForm.method = 'post';
        jsForm.action = '$url';

        for (var name in data) {
            var jsInput = document.createElement('input');
            jsInput.setAttribute('type', 'hidden');
            jsInput.setAttribute('name', name);
            jsInput.setAttribute('value', data[name]);
            jsForm.appendChild(jsInput);
        }
        document.body.appendChild(jsForm);
        jsForm.submit();
    </script>";

    if($doc) { echo "</body></html>"; }
    exit;
}
Link to comment
https://forums.phpfreaks.com/topic/283016-quick-help/#findComment-1454134
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.