NYCPHP Meetup

NYPHP.org

GNUbie // Need help with coding problem

Web Page webpage at ureach.com
Fri Apr 11 21:20:12 EDT 2003


Hello!

I am trying to learn PHP and attended the "GNUbies" meeting on
Wednesday, April 9th on the "Introduction to PHP".  I am using 

phpNuke for a web site I am working on.  It was suggested that I
post a problem I am having on the NewYorkPHP mailing list.

I would like to get the login boxes to change to Private
Messages when a member logs in.

I attempled to do this at the bottom of the header, under where,
I have "Create an Account" change to "Welcome 
(MemberName)[Logout] after a Member logs into the site.

I have not been able to get it to work.  Please see the phpNuke
v6.0 site located at,
http://members.lycos.co.uk/testmenow/nuke/index.php

The code that would control the present display and change I am
trying to get is in two files.  The "theme.php" and "header.php"
files.

I placed the working "header.php" code back (that is the code on
the site presently) just so the site would look better.

Because I do not know the policy of the mailing list about
attachments, I am placing the code inside of this e-mail below
.
theme.php
header.php (This is the "header.php" code on the site now)
header2.php (What I tried and did not work)

I have also created a login so you can see what I am talking
about.
UserID:  sitetester
Password:  sitetester

If you look at the block titled "User Info" on the top right of
the page, you will see the login boxes have changed into a 

"Private Messages" area after you login.  I just want to get the
login boxes on the top of the page to change into the  the 

"Private Messages" portion  that you see on this block.  I do
not want the rest of the information on the block.  

Thanks in advance for any and all help you can give me.

New Member,

WP
Webbing Along ;):)


===============================================================
THEME.PHP code
-----------------------------------------
<?php

$bgcolor1 = "#ADADAD";
$bgcolor2 = "#ADADAD";
$bgcolor3 = "#D4D4D4";
$bgcolor4 = "#D4D4D4";
$textcolor1 = "#000000";
$textcolor2 = "#000000";

include("themes/subSystem/tables.php");

/************************************************************/
/* Function themeheader()                                   */
/*                                                          */
/* Control the header for your site. You need to define the */
/* BODY tag and in some part of the code call the blocks    */
/* function for left side with: blocks(left);               */
/************************************************************/

function themeheader() {
    global $user, $banners, $sitename, $slogan, $cookie,
$prefix, $name, $dbi;
    cookiedecode($user);
    $username = $cookie[1];
    if ($username == "") {
        $username = "Anonymous";
    }
    echo "<body bgcolor=\\"#ADADAD\\" text=\\"#000000\\"
leftmargin=\\"10\\" topmargin=\\"10\\" marginwidth=\\"10\\" 

marginheight=\\"10\\">";
    if ($banners == 1) {
	include("banners.php");}
	
    $topics_list = "<select name=\\"new_topic\\"
onChange='submit()'>\
";
    $topics_list .= "<option value=\\"\\">All Topics</option>\
";
    $toplist = sql_query("select topicid, topictext from
".$prefix."_topics order by topictext", $dbi);
    while(list($topicid, $topics) = sql_fetch_row($toplist,
$dbi)) {
    if ($topicid==$topic) { $sel = "selected "; }
	$topics_list .= "<option $sel
value=\\"$topicid\\">$topics</option>\
";
	$sel = "";
    }
    if ($username == "Anonymous") {
	$theuser = "  <a
href=\\"modules.php?name=Your_Account&op=new_user\\">Create an
account";
    } else {
	   $theuser = "  <B>Welcome $username!</B> <a 

href=\\"modules.php?name=Your_Account&op=logout\\"><B>[<I>Logout</I>]</B></a>";

    }
	$public_msg = public_message();
    include("themes/subSystem/header.php"); 
    blocks(left); 
    $tmpl_file = "themes/subSystem/left_center.html"; 
    $thefile = implode("", file($tmpl_file)); 
    $thefile = addslashes($thefile); 
    $thefile = "\\$r_file=\\"".$thefile."\\";"; 
    eval($thefile); 
    print $r_file;}

/************************************************************/
/* Function themefooter()                                   */
/*                                                          */
/* Control the footer for your site. You don't need to      */
/* close BODY and HTML tags at the end. In some part call   */
/* the function for right blocks with: blocks(right);       */
/* Also, $index variable need to be global and is used to   */
/* determine if the page your're viewing is the Homepage or */
/* and internal one.                                        */
/************************************************************/

function themefooter() {
    global $index, $foot1, $foot2, $foot3, $foot4, $copyright,
$totaltime, $footer_message;
    if ($index == 1) {
	$tmpl_file = "themes/subSystem/center_right.html";
	$thefile = implode("", file($tmpl_file));
	$thefile = addslashes($thefile);
	$thefile = "\\$r_file=\\"".$thefile."\\";";
	eval($thefile);
	print $r_file;
	blocks(right);
    }	
    $tmpl_file = "themes/subSystem/footer.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\\$r_file=\\"".$thefile."\\";";
    eval($thefile);
    print $r_file;
                echo "<center>\
";
        $footer_message = footmsg();
            echo "</center>\
";
        echo "<center><br><font class=\\"small\\">:: subSystem
phpbb2 style by <a href=\\"http://www.systemcorp.net\\">azure</a>


:: PHP-Nuke theme by <a
href=\\"http://www.nukemods.com\\">www.nukemods.com</a>
::</font></center>";  
	echo "<br>\
";
}

/************************************************************/
/* Function themeindex()                                    */
/*                                                          */
/* This function format the stories on the Homepage         */
/************************************************************/

function themeindex ($aid, $informant, $time, $title, $counter,
$topic, $thetext, $notes, $morelink, $topicname, $topicimage, 

$topictext) {
    global $anonymous, $tipath;
    if ($notes != "") {
	$notes = "<br><br><b>"._NOTE."</b> <i>$notes</i>\
";
    } else {
	$notes = "";
    }
    if ("$aid" == "$informant") {
	$content = "$thetext$notes\
";
    } else {
	if($informant != "") {
	    $content = "<a
href=\\"modules.php?name=Your_Account&op=userinfo&uname=$informant\\">$informant</a>
";
	} else {
	    $content = "$anonymous ";
	}
	$content .= ""._WRITES." <i>\\"$thetext\\"</i>$notes\
";
    }
    $posted = ""._POSTEDBY." ";
    $posted .= get_author($aid);
    $posted .= " "._ON." $time $timezone ($counter
"._READS.")";
    $tmpl_file = "themes/subSystem/story_home.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\\$r_file=\\"".$thefile."\\";";
    eval($thefile);
    print $r_file;
}

/************************************************************/
/* Function themearticle()                                  */
/*                                                          */
/* This function format the stories on the story page, when */
/* you click on that "Read More..." link in the home        */
/************************************************************/

function themearticle ($aid, $informant, $datetime, $title,
$thetext, $topic, $topicname, $topicimage, $topictext) {
    global $admin, $sid, $tipath;
    $posted = ""._POSTEDON." $datetime "._BY." ";
    $posted .= get_author($aid);
    if ($notes != "") {
	$notes = "<br><br><b>"._NOTE."</b> <i>$notes</i>\
";
    } else {
	$notes = "";
    }
    if ("$aid" == "$informant") {
	$content = "$thetext$notes\
";
    } else {
	if($informant != "") {
	    $content = "<a
href=\\"modules.php?name=Your_Account&op=userinfo&uname=$informant\\">$informant</a>
";
	} else {
	    $content = "$anonymous ";
	}
	$content .= ""._WRITES." <i>\\"$thetext\\"</i>$notes\
";
    }
    $tmpl_file = "themes/subSystem/story_page.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\\$r_file=\\"".$thefile."\\";";
    eval($thefile);
    print $r_file;
}

/************************************************************/
/* Function themesidebox()                                  */
/*                                                          */
/* Control look of your blocks. Just simple.                */
/************************************************************/

function themesidebox($title, $content) {
    $tmpl_file = "themes/subSystem/blocks.html";
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\\$r_file=\\"".$thefile."\\";";
    eval($thefile);
    print $r_file;
}

?>
----------------------------------------------------------------------------------------------

HEADER.PHP (CODE ON SITE NOW)
--------------------------------------------------------------
<?
echo ("<script src='themes/subSystem/fade.js'
language='Javascript'></script>");
echo ("<table class='bodyline' width='100%' cellspacing='0'
cellpadding='0' border='0'>");
echo ("<tr>");
echo ("<td align='center' valign='top'>");
echo ("<table width='100%' border='0' cellspacing='0'
cellpadding='0'>");
echo ("<tr>");
echo ("<td height='100' bgcolor='#ADADAD'
background='themes/subSystem/images/bg.gif'><a
href='index.php'><img src='themes/subSystem/images/logo.gif'
width='280' height='100'
border='0'></a></td>");
echo ("</tr>");
echo ("</table>");
echo ("<table width='100%' border='0' cellspacing='0'
cellpadding='0'>");
echo ("<tr>");
echo ("<td bgcolor='#ADADAD'><table width='100%' border='0'
cellspacing='0' cellpadding='4'>");
echo ("<tr>");
echo ("<td width='150' nowrap><font
class='content'>$theuser</font></td>");
echo ("<td nowrap><div align='center'><font
class='content'><B><strong>::</strong> 
<a href='index.php'>[Home]</a> <strong>::</strong>&nbsp;
<a
href='modules.php?name=Downloads'>[Downloads]</a>&nbsp;<strong>::</strong>&nbsp;
<a href='modules.php?name=Your_Account'>[Your
Account]</a>&nbsp;<strong>::</strong>&nbsp;
<a
href='modules.php?name=Forums'>[Forums]</a>&nbsp;<strong>::</strong></font></div></td>");
echo "<td width='150' nowrap><div align='center'><font
class='content'><B><script
type=\\"text/javascript\\">\
";
echo "<!--   // Array ofmonth Names\
";
echo "var monthNames = new Array(
\\"January\\",\\"February\\",\\"March\\",\\"April\\",\\"May\\",\\"June\\",\\"July\\",\\"August\\",\\"September\\",\\"October\\",\\"November\\",\\"De

cember\\");\
";
echo "var now = new Date();\
";
echo "thisYear = now.getYear();\
";
echo "if(thisYear < 1900) {thisYear += 1900}; // corrections if
Y2K display problem\
";
echo "document.write(monthNames[now.getMonth()] + \\" \\" +
now.getDate() + \\", \\" + thisYear);\
";
echo "// -->\
";
echo "</script>\
";
echo ("</B></font></div></td>");
echo ("</tr>");
echo ("</table></td>");
echo ("</tr>");
echo ("</table>");
echo ("<table width='100%' border='0' cellspacing='0'
cellpadding='0'>");
echo ("<tr>");
echo ("<td bgcolor='#ADADAD'><img
src='themes/subSystem/images/7px.gif' width='7'
height='7'></td>");
echo ("</tr>");
echo ("</table>");
echo ("<table width='100%' cellpadding='0' cellspacing='0'
border='0' align='center'>");
echo ("<tr valign='top'>");
echo ("<td>$public_msg<img
src='themes/NukeNews/images/pixel.gif' width='1' height='1'
border='0'
alt=''></td>");
echo ("</tr>");
echo ("");
echo ("<TR bgcolor='#ADADAD'><TD colspan='3'>");
echo ("<table cellpadding='0' cellspacing='0' width='100%'
border='0' align='center'
bgcolor='$bgcolor2'><tr>");
echo ("<form action='modules.php?name=Your_Account'
method='post'>");
echo ("<TD width='35%'><b>NICKNAME </b><input type='text'
name='uname' size='10' maxlength='25'>");
echo ("<b>PASSWORD</b> <input type='password' name='pass'
size='10' maxlength='20'>");
echo ("<input type='hidden' name='op' value='login'><input
type='submit' value='LOGIN'>");
echo ("</td>");
echo ("</form>");
echo ("<td width='30%' align='center'><FONT
class='title'><B>$slogan</FONT></B></td>");
echo ("<form action='modules.php?name=Search' method='post'>");
echo ("<td width='35%' align='right'>");
echo ("<font class='content'><b>Search</b> <input type='text'
size='15' name='query'>");
echo ("<b>in</b>  $topics_list</font>");
echo ("</select>");
echo ("</td></tr>");
echo ("</form>");
echo ("");
echo ("</table>");
echo ("</td></tr>");
echo ("");
echo ("</table>");
echo ("<table width='100%' cellpadding='0' cellspacing='0'
border='0' align='center'>");
echo ("<tr valign='top'>");
echo ("<td valign='top' width='1'
background='themes/subSystem/images/7px.gif'>");
?>
--------------------------------------------------------------------------------------

HEADER2.PHP (What I tried but did not work)
----------------------------------------------------------
<?
echo ("<script src='themes/subSystem/fade.js'
language='Javascript'></script>");
echo ("<table class='bodyline' width='100%' cellspacing='0'
cellpadding='0' border='0'>");
echo ("<tr>");
echo ("<td align='center' valign='top'>");
echo ("<table width='100%' border='0' cellspacing='0'
cellpadding='0'>");
echo ("<tr>");
echo ("<td height='100' bgcolor='#ADADAD'
background='themes/subSystem/images/bg.gif'><a
href='index.php'><img src='themes/subSystem/images/logo.gif'
width='280' height='100'
border='0'></a></td>");
echo ("</tr>");
echo ("</table>");
echo ("<table width='100%' border='0' cellspacing='0'
cellpadding='0'>");
echo ("<tr>");
echo ("<td bgcolor='#ADADAD'><table width='100%' border='0'
cellspacing='0' cellpadding='4'>");
echo ("<tr>");
echo ("<td width='150' nowrap><font
class='content'>$theuser</font></td>");
echo ("<td nowrap><div align='center'><font
class='content'><B><strong>::</strong> 
<a href='index.php'>[Home]</a> <strong>::</strong>&nbsp;
<a
href='modules.php?name=Downloads'>[Downloads]</a>&nbsp;<strong>::</strong>&nbsp;
<a href='modules.php?name=Your_Account'>[Your
Account]</a>&nbsp;<strong>::</strong>&nbsp;
<a
href='modules.php?name=Forums'>[Forums]</a>&nbsp;<strong>::</strong></font></div></td>");
echo "<td width='150' nowrap><div align='center'><font
class='content'><B><script
type=\\"text/javascript\\">\
";
echo "<!--   // Array ofmonth Names\
";
echo "var monthNames = new Array(
\\"January\\",\\"February\\",\\"March\\",\\"April\\",\\"May\\",\\"June\\",\\"July\\",\\"August\\",\\"September\\",\\"October\\",\\"November\\",\\"De

cember\\");\
";
echo "var now = new Date();\
";
echo "thisYear = now.getYear();\
";
echo "if(thisYear < 1900) {thisYear += 1900}; // corrections if
Y2K display problem\
";
echo "document.write(monthNames[now.getMonth()] + \\" \\" +
now.getDate() + \\", \\" + thisYear);\
";
echo "// -->\
";
echo "</script>\
";
echo ("</B></font></div></td>");
echo ("</tr>");
echo ("</table></td>");
echo ("</tr>");
echo ("</table>");
echo ("<table width='100%' border='0' cellspacing='0'
cellpadding='0'>");
echo ("<tr>");
echo ("<td bgcolor='#ADADAD'><img
src='themes/subSystem/images/7px.gif' width='7'
height='7'></td>");
echo ("</tr>");
echo ("</table>");
echo ("<table width='100%' cellpadding='0' cellspacing='0'
border='0' align='center'>");
echo ("<tr valign='top'>");
echo ("<td>$public_msg<img
src='themes/NukeNews/images/pixel.gif' width='1' height='1'
border='0'
alt=''></td>");
echo ("</tr>");
echo ("");
echo ("<TR bgcolor='#ADADAD'><TD colspan='3'>");
echo ("<table cellpadding='0' cellspacing='0' width='100%'
border='0' align='center'
bgcolor='$bgcolor2'><tr>");

$content .= "<form action=\\"modules.php?name=Your_Account\\"
method=\\"post\\">";

if (is_user($user)) {
    $content .= "<br><img src=\\"images/blocks/group-4.gif\\"
height=\\"14\\" width=\\"17\\"> "._BWEL.", 

<b>$username</b>.<br>\
<hr>\
";
    $result = sql_query("select uid from $user_prefix"._users."
where uname='$username'", $dbi);
    list($uid) = sql_fetch_row($result, $dbi);
    $result2 = sql_query("select to_userid from
$prefix"._priv_msgs." where to_userid='$uid' and read_msg='0'",
$dbi);
    $newpms = sql_num_rows($result2, $dbi);
    $result3 = sql_query("select to_userid from
$prefix"._priv_msgs." where to_userid='$uid' and read_msg='1'",
$dbi);
    $oldpms = sql_num_rows($result3, $dbi);
    $content .= "<img src=\\"images/blocks/email-y.gif\\"
height=\\"10\\" width=\\"14\\"> <a 

href=\\"modules.php?name=Private_Messages\\"><b>"._BPM."</b></a><br>\
";
    $content .= "<img src=\\"images/blocks/email-r.gif\\"
height=\\"10\\" width=\\"14\\"> "._BUNREAD.":
<b>$newpms</b><br>\
";
    $content .= "<img src=\\"images/blocks/email-g.gif\\"
height=\\"10\\" width=\\"14\\"> "._BREAD.":
<b>$oldpms</b><br>\
<hr>\
";
} else {
    $content .= "<img src=\\"images/blocks/group-4.gif\\"
height=\\"14\\" width=\\"17\\"> "._BWEL.",
<b>$anonymous</b>\
<hr>";
    $content .= ""._NICKNAME." <input type=\\"text\\"
name=\\"uname\\" size=\\"10\\" maxlength=\\"25\\"><br>";
    $content .= ""._PASSWORD." <input type=\\"password\\"
name=\\"pass\\" size=\\"10\\" maxlength=\\"20\\"><br>";
    $content .= "<input type=\\"hidden\\" name=\\"op\\"
value=\\"login\\">";
    $content .= "<input type=\\"submit\\" value=\\""._LOGIN."\\">\

(<a 

href=\\"modules.php?name=Your_Account&op=new_user\\">"._BREG."</a>)<hr>";
}
$content .= "</form>";

echo ("<form action='modules.php?name=Your_Account'
method='post'>");
echo ("<TD width='35%'><b>NICKNAME </b><input type='text'
name='uname' size='10' maxlength='25'>");
echo ("<b>PASSWORD</b> <input type='password' name='pass'
size='10' maxlength='20'>");
echo ("<input type='hidden' name='op' value='login'><input
type='submit' value='LOGIN'>");
echo ("</td>");
echo ("</form>");
echo ("<td width='30%' align='center'><FONT
class='title'><B>$slogan</FONT></B></td>");
echo ("<form action='modules.php?name=Search' method='post'>");
echo ("<td width='35%' align='right'>");
echo ("<font class='content'><b>Search</b> <input type='text'
size='15' name='query'>");
echo ("<b>in</b>  $topics_list</font>");
echo ("</select>");
echo ("</td></tr>");
echo ("</form>");
echo ("");
echo ("</table>");
echo ("</td></tr>");
echo ("");
echo ("</table>");
echo ("<table width='100%' cellpadding='0' cellspacing='0'
border='0' align='center'>");
echo ("<tr valign='top'>");
echo ("<td valign='top' width='1'
background='themes/subSystem/images/7px.gif'>");
?>
-------------------------------------------------------------------------------------

________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag



More information about the talk mailing list