boemboem Posted February 23, 2009 Share Posted February 23, 2009 Hello all, I have two gaming websites. One is our main website, where everyone logs in. Now I have a other website (a ladder) wich has it's own login / password. I would like to edit my ladder login so it uses the database of the main website. I really don't know how to do this, so can somebody help me with this?? This is the login check of the main page (http://www.coldcharlie.nl) <?php /* ######################################################################## # # # Version 4 / / / # # -----------__---/__---__------__----__---/---/- # # | /| / /___) / ) (_ ` / ) /___) / / # # _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ # # Free Content / Management System # # / # # # # # # Copyright 2005-2006 by webspell.org # # # # visit webSPELL.org, webspell.info to get webSPELL for free # # - Script runs under the GNU GENERAL PUBLIC LICENSE # # - It's NOT allowed to remove this copyright-tag # # -- http://www.fsf.org/licensing/licenses/gpl.html # # # # Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), # # Far Development by Development Team - webspell.org # # # # visit webspell.org # # # ######################################################################## */ //settings $sleep = 1; //idle status for script if password is wrong? //settings end $ws_pwd=md5($_POST['pwd']); include("_mysql.php"); include("_settings.php"); $ws_user = $_POST['ws_user']; $check = safe_query("SELECT * FROM ".PREFIX."user WHERE username='$ws_user'"); $anz = mysql_num_rows($check); if($anz) { $check = safe_query("SELECT * FROM ".PREFIX."user WHERE username='$ws_user' AND activated='1'"); if(mysql_num_rows($check)) { $ds=mysql_fetch_array($check); // check password $login = 0; if($ws_pwd == $ds[password]) { //session session_name('ws_session'); session_start(); $_SESSION['ws_auth'] = $ds['userID'].":".$ws_pwd; $_SESSION['ws_lastlogin'] = $ds[lastlogin]; $_SESSION['referer'] = $_SERVER['HTTP_REFERER']; //cookie setcookie("ws_auth", $ds['userID'].":".$ws_pwd, time()+($sessionduration*60*60)); $login = 1; } elseif(!($ws_pwd == $ds[password])) { if($sleep) sleep(5); $error='Je hebt een ongeldig wachtwoord gebruikt.<br><br><a href="javascript:history.back()">Ga terug en probeer het nog eens!</a>'; } } else $error='Jouw account is nog niet geactiveerd<br><br> <a href="javascript:history.back()">Ga terug en probeer het nog eens!</a>'; } else $error='Geen gebruiker met gebruikersnaam <b>'.htmlspecialchars($ws_user).'</b> geregistreerd.<br><br> <a href="javascript:history.back()">Ga terug en probeer het nog eens!</a>'; ?> <html> <head> <title><? echo PAGETITLE; ?></title> <link href="_stylesheet.css" rel="stylesheet" type="text/css"> <?php if($login) { echo '<meta http-equiv="refresh" content="3;URL=index.php?site=loginoverview">';$error = 'Inloggen is gelukt!!'; } ?> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body { background-color: #000000; font-color: ffffff; } --> </style></head> <body> <table width="100%" height="100%"> <tr> <td align="center" valign="top"><p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p><img src="style/rd.gif"><br> </p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="center"><font color="#FFFFFF" size="2"><? echo $error; ?></font></div></td> </tr> </table></td> </tr> </table> </body> </html> Here is the code of the ladder site wich should be edited: (http://ladders.coldcharlie.nl) <? /*======================================================================*\ || #################################################################### || || # Elite Gaming Ladder v2 || # ---------------------------------------------------------------- # || || # Copyright ©2007-2008 Elite Gaming Ladder LLC. All Rights Reserved. || || # This file may not be redistributed in whole or significant part. # || || # ------------------- EGL IS NOT FREE SOFTWARE ------------------- # || || # http://www.eliteladders.com # || || #################################################################### || \*======================================================================*/ session_start(); include("./includes/incglobal.php"); if ($login[id] && !is_numeric($login[id])) { error("You have specified an Invalid Login ID!"); } switch($act){ case "setlogin": set($login); break; case "refresh": refresh(); break; case "logout": lout(); break; default: login($mes); break; } function login($mes){ global $config; if (isset($_COOKIE["user"])){ $out[body].="<br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Login</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> <b>You are already logged in!</center></td></tr> </table> </center><br /><br /><br /><br />"; }else{ $out[body].=" <br /> <center> <table width='400' border='0' cellspacing='1' bgcolor='#000000' cellpadding='1'> <form method='post'> <tr bgcolor='$config[altcolor]'> <td background='$config[bg]' width='100%' valign='center' align='left' colspan='2'> <strong>Login</strong>"; if(isset($mes)){ $out[body].="<font color='red'>(Incorrect Login)</red>"; } $out[body].=" </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Username</td> <td width='60%' valign='center' align='center'><input type='text' name='login[name]' class='input' value='$login[name]' size='32' maxlength='15'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Password</td> <td width='60%' valign='center' align='center'><input type='password' class='input' name='login[pass]' value='' size='32' maxlength='20'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Login Length</td> <td width='60%' valign='center' align='center'> <select class='button' name='login[clength]'> <option value='60'>1 Hour</option> <option value='1440'>1 Day</option> <option value='10080'>1 Week</option> <option value='43200'>1 Month</option> <option value='83200' selected='selected'>Forever</option> </select></td> </tr> <tr bgcolor='$config[altcolorb]'> <td><a href='./register.php'>Register Now!</a></td> <td width='100%' valign='top' align='right'> <input type='hidden' name='act' value='setlogin'> <input type='submit' class='button' name='submit' value='Login >>'></td> </form> </tr> </table> <br /><br /> <table width='400' border='0' cellspacing='1' cellpadding='2' bgcolor='#000000'> <form method='post' action='./forgotpw.php'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Forgot Password?</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'>Username</td> <td width='60%' valign='center' align='center'><input type='text' name='login[name]' class='input' value='' size='25' maxlength='10'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='40%' valign='center' align='left'><img src='./includes/captcha.php' /></td> <td width='60%' valign='center' align='center'>Enter the text you see in the image.<br /> <input class='input' type='text' name='login[capt]' value='' size='40' maxlength='13'></td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='top' align='right' colspan='2'> <input type='submit' class='button' name='submit' value='Resend >>'></td> </form> </tr> </table> </center><br /><br />"; } include("$config[html]"); } function set($login){ global $config; $login[pass] = md5(md5($login[pass])); if(!mysql_num_rows(mysql_query("SELECT id FROM members WHERE name='$login[name]' AND password='$login[pass]'"))){ $mes="1"; login($mes); exit; } $getid=mysql_query("SELECT id,act FROM members WHERE name='$login[name]'"); $getid=mysql_fetch_array($getid); if($getid[act] == 0){ error("Your account is not activated yet, you must click the link provided in your welcome email."); } //Set Cookies setcookie("tid",$getid[id], time()+60 * $login[clength]); setcookie("user",$login[name], time()+60 * $login[clength]); setcookie("pass",$login[pass], time()+60 * $login[clength]); $out[body].="<META HTTP-EQUIV='refresh' content='0;URL=$config[scripturl]/index.php?action=myhome'> <br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Login</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> Logging in..... </center></td></tr> </table> </center><br /><br /><br /><br /><br /><br />"; include("$config[html]"); } function lout(){ global $config; setcookie('tid','', time()-60 * 999999); setcookie('user','', time()-60 * 999999); setcookie('pass','', time()-60 * 999999); $out[body].="<META HTTP-EQUIV='refresh' content='0;URL=$config[scripturl]/login.php?act=refresh&type=logout'> <br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Logout.</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> Logging out........ </center></td></tr> </table> </center><br /><br /><br /><br /><br /><br />"; include("$config[html]"); } function refresh(){ global $config; $out[body].=" <br /> <center> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'> <tr bgcolor='$config[altcolora]'> <td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'> <strong>Logout.</strong> </td> </tr> <tr bgcolor='$config[altcolorb]'> <td width='100%' valign='center' align='left'><center> You have been sucessfully logged out. We hope you visit again! </center></td></tr> </table> </center><br /><br /><br /><br /><br /><br />"; include("$config[html]"); } ?> Quote Link to comment Share on other sites More sharing options...
Goafer Posted February 23, 2009 Share Posted February 23, 2009 can you not just have the ladder website access the main database instead of it's own? Quote Link to comment Share on other sites More sharing options...
boemboem Posted February 23, 2009 Author Share Posted February 23, 2009 it should indeed, but I need the ladder website login page fit to do that, so a few lines should be edited, maybe somebody here knows what to edit to make it do that. this is from the main page $ws_pwd=md5($_POST['pwd']); include("_mysql.php"); include("_settings.php"); $ws_user = $_POST['ws_user']; $check = safe_query("SELECT * FROM ".PREFIX."user WHERE username='$ws_user'"); $anz = mysql_num_rows($check); if($anz) { $check = safe_query("SELECT * FROM ".PREFIX."user WHERE username='$ws_user' AND activated='1'"); if(mysql_num_rows($check)) { $ds=mysql_fetch_array($check); // check password $login = 0; if($ws_pwd == $ds[password]) { this is from the ladder: function set($login){ global $config; $login[pass] = md5(md5($login[pass])); if(!mysql_num_rows(mysql_query("SELECT id FROM members WHERE name='$login[name]' AND password='$login[pass]'"))){ $mes="1"; login($mes); exit; } $getid=mysql_query("SELECT id,act FROM members WHERE name='$login[name]'"); $getid=mysql_fetch_array($getid); if($getid[act] == 0){ error("Your account is not activated yet, you must click the link provided in your welcome email."); } a part of the first code (the select from database part) should be editted so looks in the right tables. For both websites I use the same database, only other tables, and also different tables with username and password so there shouldn't be a problem with login in to the database. Quote Link to comment Share on other sites More sharing options...
boemboem Posted February 24, 2009 Author Share Posted February 24, 2009 can anyone help me with this please Quote Link to comment Share on other sites More sharing options...
blacksharkmedia Posted March 12, 2009 Share Posted March 12, 2009 just edit the config file from the ladder site and add the access data from the first site Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.