I'm pretty green when it comes to PHP so I would really appreciate your help as I've been fumbling around with this for a while now.
Here is the script that I need to install (I'll let you know what I've done after this):
<?
// ------------------------------------------
// INSTRUCTIONS
// 1. Edit the variable below.
// 2. Upload to your site, and thats it 🙂.
//
// OPTIONAL ( might be needed )
// editing the cookies.
// if your cookies have a prefix set to them you will need to change the $COOKIE
// to have a prefix. so if your prefix is ibf then to cookie thing would be
// $_COOKIE['ibf_member_id']; and so on.
//
//-------------------------------------------
// Variables
$members = "ibf_members"; // Name of the table where your members are
$groups = "ibf_groups"; // Name of the group table.
$url = ""; // The full URL to your forums
$short = "forums/admin.php"; // The link to the admin control pane
$db_host = "localhost"; // Should work 99% of the time.
$db_user = ""; // mySQL database "USER"
$db_pass = ""; // mySQL database "PASS"
$database = "ibf_database"; // mySQL "DATABASE" name
// langugage variables
// no need to change these.
$yourcp = "Your CP";
$gobyebye = "Go ByeBye";
$loggedin = "Logged In As:";
$login = "Login";
$register = "Register";
// ---------------
// Cookies... Yum.
// ---------------
if you have a prefix on your cookies add it in $_COOKIE['prefix_member_id'];. like that.
$ibf_member_id = $COOKIE['member_id']; // member name from the cookie.
$ibf_pass_hash = $COOKIE['pass_hash']; // password encripted from the cookie. using md5();
$ibf_session_id = $_COOKIE['session_id']; // session id for links and what not.
// connect to the database
$link = mysql_connect("$db_host","$db_user","$db_pass") or die("cannot connect");
mysql_select_db("$database");
function show_mlist() {
global $ibf_member_id, $ibf_pass_hash, $ibf_session_id, $members, $groups, $url, $short, $yourcp, $gobyebye, $loggedin, $login, $register, $pm;
// pm pop-up. new feature of 2.1
$show_popup = $pm['show_popup'];
if( $show_popup > 0 ) {
$query = "UPDATE ".$members." SET show_popup='0' WHERE id='{$pm[name]}' ";
$result = mysql_query($query) or die("A fatal MySQL error occured. <br />\nQuery: " . $query . "<br />\nError: " . mysql_error());
$kaboom = <<< EOF
<script language='JavaScript'>
<!--
window.open('".$url."?act=Msg&CODE=99&s={$ibf_session_id}','NewPM','width=500,height=250,resizable=yes,scrollbars=yes');
//-->
</script>";
EOF;
}
$rendered .= $kaboom;
// Selecting members from the database
$query = "SELECT m.id AS id, m.password AS password, m.name AS name, m.mgroup AS mgroup, m.new_msg AS new_msg, m.show_popup AS show_popup, g.g_id AS g_id, g.g_is_supmod AS g_is_supmod, g.g_access_cp AS g_access_cp FROM ".$members." m LEFT JOIN ".$groups." g ON ( g.g_id = m.mgroup) WHERE id='$ibf_member_id'";
$result = mysql_query($query) or die("A fatal MySQL error occured. <br />\nQuery: " . $query . "<br />\nError: " . mysql_error());
$pm = mysql_fetch_array($result);
// Starting making member bar
if( isset( $ibf_member_id ) && ( $ibf_pass_hash == "$pm[password]" ) ){
// log out link
$logout = "<a href='".$url."?s=$ibf_session_id&act=Login&CODE=03'>".$gobyebye."</a>";
// moderator control panel link.
if( $pm[g_is_supmod] == 1 ) {
$modcp = " | <a href='".$url."?act=modcp'>Mod CP</a>";
}
// admin control panel link.
if( $pm[g_access_cp] == 1 ) {
$admincp = " | <a href='".$short."'>Admin CP</a>";
}
// the formated look of the end of the logout, admin cp and mod cp. Change the format here if wanted.
$rendered .= "<a href='{$url}?showuser={$pm['id']}'>".$loggedin ."</a> <strong>{$pm[name]}</strong> ( {$logout} <strong>{$admincp}{$modcp} </strong>)";
} else {
// if not logged in will show this.
$rendered .= "Welcome <strong>Visitor</strong> <a href='".$url."?act=Login&CODE=00'>Login</a> | <a href='".$url."?&act=Reg&CODE=00'>Register</a>";
}
return $rendered;
}
?>
<!-- // add this section into your page wherever you want the login to be. -->
<script language='JavaScript'>
<!--
function buddy_pop()
{
window.open('<?php echo $url ?>?act=buddy&','BrowserBuddy','width=200,height=450,resizable=yes,scrollbars=yes');
}
//-->
</script>
<div style='padding: 5px; float:left;'>
<?php
$show_left = show_mlist();
echo $show_left;
?>
</div>
<div style='padding: 5px; float:right;'>
<?
// left side of the member bar.
if ( isset( $ibf_member_id ) && $ibf_pass_hash == "$pm[password]" ) {
$date = date("F d");
$render = <<<EOF
<!-- control panel link -->
<a href="$url?s=$ibf_session_id&act=UserCP&CODE=00">$yourcp</a> /
<!-- new messages thing. -->
<a href="{$url}?s=$ibf_session_id&act=Msg&CODE=01">{$pm['new_msg']} new messages</a> /
<!-- My Assistant Link -->
<a href='javascript:buddy_pop();'>My Assistant</a> /
<!-- gets latest post info from your boards. -->
<a href="{$url}?act=Search&CODE=getnew">{$date}</a>
EOF;
echo $render;
} else {
// shows the date.
echo "Today Is ".date("F d");
}
?>
</div>
<?
// ----------------------------
// DEBUG LINE
// remove this when you go live, this is just to test the cookies so you can see if they are working
// ----------------------------
echo " <br /><br />If these below are blank, go back to the script and check your cookies to make sure they are correct<br /><br />";
echo "MID: ".$ibf_member_id . "<br /> PASSWORD HASH: " . $ibf_pass_hash ." <br /> SESSION HASH:" . $ibf_session_id;
?>
<!-- end of the script. have fun! -->
I edited the variables (user/pw/db host/url) inserted the script from <!-- // add this section into your page wherever you want the login to be. --> and then uploaded the page I put this on.
I then uploaded the txt file above into the forums directory.
I've had a fiddle around but can't seem to get anywhere except:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'user@....' (Using password: YES) in /home/websitename/html/Templates/Templates/cdtemplate1.php on line 83
cannot connect
The password and username are correct so the only thing I can think of is that I keep putting the text file in the wrong place or the chmod permissions need changing? I really don't know.
in a squeaky voice help!