<?php
error_reporting(E_ALL ^ E_NOTICE);
//Here we check if any field was missed / left empty and act accordingly
if ($_POST['domain'] && $_POST['username'] && $_POST['pass'] && !($_GET['failed'] == "1"))
{
    switch ($_POST['login_option'])
    {
        case "2082":    $port = "2082";
                $protocol = "http://";
                break;
        case "2083":    $port = "2083";
                $protocol = "https://";
                break;
        case "2086":    $port = "2086";
                $protocol = "http://";
                break;
        case "2087":    $port = "2087";
                $protocol = "https://";
                break;
        case "2095":    $port = "2095";
                $protocol = "http://";
                break;
        case "2096":    $port = "2096";
                $protocol = "https://";
                break;
    }
            
    $redirectlocation = $protocol.$_POST['domain'].":".$port."/login/?user=".$_POST['username']."&pass=".$_POST['pass']."&failurl=".$_POST['failurl'];
     header ("Location: ".$redirectlocation);
}
else
{
    $error = 1;
    header ("Location: ".$_POST['failurl']);
}
?>
