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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.