#1  
Old 5th March 2006, 21:41
Glorfindel Glorfindel is offline
Junior Member
 
Join Date: Feb 2006
Posts: 26
Thanks: 0
Thanked 3 Times in 2 Posts
Default Simple HTML Login Form

Please look below for a more advanced login script

Heres a quick little tip to save some time looking at the ISPConfig login.php file, or for those who don't know php/html very well

HTML Code:
<form method="POST" action="http://YOUR_DOMAIN_HERE:81/login/login.php">
  Username: <input type="text" name="username" size="15" /><br />
  Password: <input type="password" name="passwort" size="15" /><br />
  <div align="center">
    <p><input type="submit" value="Login" /></p>
  </div>
</form>
This is just some simple HTML code that will log in to the ISPConfig panel from anywhere you want to put it. (It will redirect you to the port 81 server, of course, but it will skip the login screen... supposing you put in a valid username and password.)

Also, note that "passwort" is not a typo. ISPConfig seemingly was not coded in english.

Hope this helps someone,
Glorfindel

Last edited by Glorfindel; 8th March 2006 at 02:15.
Reply With Quote
Sponsored Links
  #2  
Old 7th March 2006, 20:03
Glorfindel Glorfindel is offline
Junior Member
 
Join Date: Feb 2006
Posts: 26
Thanks: 0
Thanked 3 Times in 2 Posts
Default

Ok, there are two things I really don't like about ISPConfig. One, there are a lot of passwords and usernames for each user to remeber. Two, there is a lack of remoting (can't wait for them to release the remoting plugin!! )

Here is a much more advanced login script in PHP. This script displays the most important parts of ISPConfig (in my opinion) based on the ISPConfig panel login username and password. Once the user uses this login, the login form will be replaced with a link to the ISPConfig panel, webmail, and phpMyAdmin for each of the databases that they have created. All these log in automatically in a new window.




As a disclaimer... I'm primarily a C++ coder, and I don't do much PHP, so there are surely many improvements to be made!

Connect.php
PHP Code:
<?php
// db info
$hostname="localhost";
$mysql_login="root";
$mysql_password="YOUR_ROOT_PASSWORD";
$database="THE_ISPCONFIG_DATABASE_NAME";

if (!(
$db mysql_connect($hostname$mysql_login $mysql_password))){
  die(
"Can't connect to mysql.");    
}else{
  if (!(
mysql_select_db("$database",$db)))  {
    die(
"Can't connect to db.");
  }
}
?>
This file simply sets up a connection to the ISPConfig database. Make sure to replace the root password, and ISPConfig database name with your own.

login.php
PHP Code:
<?php
/***************************************************************************
 ISP Config Login Interface
     Author: Glorfindel       
 ---------------------------------------------------------------------------
 Desc: Provides a unified log-in outside of the ISPConfig control panel.   
 This unified login checks the ISPConfig user tables, and provides links   
 to each of the ISPConfig panels with one, unified, password outside port  
 81.                                                                       
***************************************************************************/

// start session
session_start(); 

include(
"connect.php");

function 
checkLogin()
{
    
// convert username and password from _GET to _SESSION
    
if($_GET){
      
$_SESSION['username']=$_GET["username"];
      
$_SESSION['passwort']=$_GET["passwort"];  
    } 
    
    
$username $_SESSION['username'];
    
$passwort $_SESSION['passwort'];
    
    
$username addslashes($username);
    
$passwort addslashes($passwort);
    
    
$sql "SELECT * FROM sys_user WHERE username = '$username' AND (passwort = '".md5($passwort)."' OR passwort = PASSWORD('$passwort'))";
    
    
$result=mysql_query($sql);
    if (!
$_SESSION['verified'])
    {
        if (( 
$num mysql_num_rows($result) ) and ($passwort != ""))
        {
            if (
$num != 0)
            {
                
$_SESSION['ERROR'] = "";
                
$_SESSION['verified'] = 1;
                
                
// lets get their e-mail alias.
                
$sql "SELECT user_email FROM isp_isp_user WHERE user_name='$username'";
                
$result mysql_query($sql);
                
$_SESSION['email'] = mysql_result($result,0,"user_email");
            } 
        } 
        else 
        {
            
$_SESSION['ERROR'] = "login is WRONG!!";
        }
    }
    
    if (
$_SESSION['verified'] != 1$_SESSION['ERROR'] = "Login Failed. <br />";
}


//////////////////////////
// Main Bit Starts Here //
//////////////////////////
//
if ($_SESSION['verified'] != and $_GET['action'] == "login")
    
checkLogin(); 
    
if (
$_GET['action'] == "logout")
{
    
$_SESSION = array();
    
session_destroy();
    
$_SESSION['ERROR'] = "You have successfully logged out. <BR />";
}
    
if (
$_SESSION['verified'] != 1)
{
    
// User is NOT logged in, so lets give him a login form...
    
echo("<!--Begin Login -->");
    echo(
"<font color='red'>");
    echo(
$_SESSION['ERROR']);
    
$_SESSION['ERROR'] = ""// reset the error message if there is one.
    
echo("</font><br />");
    echo(
"<form method=\"GET\" action=\"");
    echo(
$_SERVER['PHP_SELF']);
    echo(
"\">");
    echo(
"Username: <br /><input type=\"text\" name=\"username\" size=\"15\" /><br />");
    echo(
"Password: <br /><input type=\"password\" name=\"passwort\" size=\"15\" /><br />");
    echo(
"<input type=\"hidden\" name=\"action\" value=\"login\" />");
    echo(
"<p><input type=\"submit\" value=\"Login\" /></p>");
    echo(
"</form>");
    echo(
"<!--End Login -->");
    } else {
    
// if the user IS logged in, give him options here.
    
    // Javascript to make POST data submittable thru link...
    // Web Admin Panel
    
echo("<script language='JavaScript' type='text/javascript'>\n");
    echo(
"<!--\n");
    echo(
"function submit()\n");
    echo(
"{\n");
    echo(
"document.loginform.submit();\n");
    echo(
"}\n");
    echo(
"-->\n");
    
    
// Mail
    //echo("<script language='JavaScript' type='text/javascript'>\n");
    
echo("<!--\n");
    echo(
"function submit1()\n");
    echo(
"{\n");
    echo(
"document.loginform1.submit();\n");
    echo(
"}\n");
    echo(
"-->\n");
    
    
// PhpMyAdmin
    //echo("<script language='JavaScript' type='text/javascript'>\n");
    
echo("<!--\n");
    echo(
"function submit2()\n");
    echo(
"{\n");
    echo(
"document.loginform2.submit();\n");
    echo(
"}\n");
    echo(
"-->\n");
    echo(
"</script>\n");
    
////////////////////////////////////////////////////////////////////
    // Note: Newlines are required, else it screws up the javascript  //
    ////////////////////////////////////////////////////////////////////
    
    
echo("<B>Control Panel: </B><BR />");
    
    echo(
"<form method='POST' target=_blank action='http://www.glorf.com:81/login/login.php' name='loginform'>\n");
    echo(
"<input type=\"hidden\" name=\"username\" value=\"");
    echo(
$_SESSION['username']);
    echo(
"\"><input type=\"hidden\" name=\"passwort\" value=\"");
    echo(
$_SESSION['passwort']);
    echo(
"\">");
    echo(
"</form>");
    echo(
"<a href='javascript: submit()'>Website Admin Panel</a>\n");

    echo(
"<form method='POST' target=_blank action='http://www.glorf.com:81/webmail/msglist.php' name='loginform1'>\n");
    echo(
"<input type=\"hidden\" name=\"f_email\" value=\"");
    echo(
$_SESSION['email']);
    echo(
"@glorfy.com\"><input type=\"hidden\" name=\"f_pass\" value=\"");
    echo(
$_SESSION['passwort']);
    echo(
"\">");
    echo(
"</form>");
    echo(
"<a href='javascript: submit1()'>Web Mail</a><br />\n");
    
    
    echo(
"<BR /><B>Databases: </B><BR />");
    
    
// Now lets get the database names...
    // first that means we need to link the username to a web_id.
    
$email $_SESSION['email'];
    
$sql "SELECT web_id FROM isp_fakt_record WHERE notiz= '$email'";
    
$result mysql_query($sql);
    
$_SESSION['web_id'] = mysql_result($result,0,"web_id");
    
$web_id $_SESSION['web_id'];
    
    
// now we need to use that to grab all the DB names for displaying.
    
$sql "SELECT datenbankuser FROM isp_isp_datenbank WHERE web_id = '$web_id'";
    
$result mysql_query($sql);
    
// now lets loop the results and store them into an array for later display purposes.
    
global $dbs$num_db;
    
$num_db mysql_num_rows($result);
    
$dbs = array(30); // a user can't have more than 30 databases :)
    
for ($i=0$i $num_db$i+=1)
    {
        
$dbs[$i] = mysql_result($result,$i,"datenbankuser");
        echo(
"<a href=\"http://");
        echo(
$dbs[$i]);
        echo(
":");
        echo(
$_SESSION['passwort']);
        echo(
"@www.glorf.com:81/phpmyadmin/index.php");
        echo(
"\">");
        echo(
$dbs[$i]);
        echo(
"</a><br />");
    }
    
    
///////////////////////////////////////
    
echo("<hr />");
    echo(
"<a href=\"");
    echo(
$_SERVER['PHP_SELF']);
    echo(
"?action=logout\">logout<br></a>");

mysql_close();
?>
This file is the meat of the script. You need to use a search and replace to replace all "glorf.com" with "your.com" DO NOT put a www. on that... I used www off and on throughout the script, so your find and replace would end up making some www.www. if you do that!

Now, wherever you would like to have the login, you need to add the code...
PHP Code:
<?php include("login.php"); ?>
I suggest you do this inside a table, as that is how I am using it.

Feel free to modify the code, but let me know if you make improvements, so that I can put them into my own version!!

Last edited by Glorfindel; 7th March 2006 at 20:17.
Reply With Quote
  #3  
Old 15th January 2011, 15:56
Green-Sky Green-Sky is offline
Junior Member
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Which mysql banks I have to make?
Reply With Quote
  #4  
Old 16th January 2011, 13:54
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
Default

Why do you mean with "mysql banks"?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to login root in GUI Mode in Suse10 saialkesh HOWTO-Related Questions 12 2nd May 2006 10:57
Problem with POP3 Login masterkain Installation/Configuration 6 15th January 2006 19:11
authdaemon LOGIN: REJECT dgradzik Tips/Tricks/Mods 2 22nd September 2005 01:09
authdaemon LOGIN: REJECT dgradzik Installation/Configuration 2 21st September 2005 19:03
Total Frustration-HELP palkat Installation/Configuration 17 3rd September 2005 18:28


All times are GMT +2. The time now is 20:56.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.