I want to make showprofile.php check to see if the user is logged in. I've done this in the past and cannot find my notes.. ugh.. any ideas..?
perhaps something using
// ----------------------------------------------------------------------
// If we are not logged in, then present a log on form, otherwise present
// a menu of options.
if(($user['U_Username'] == ''))
{
$html -> not_right ("{$ubbt_lang['ADMOD_ONLY']}",$Cat);
}
Actually showprofile.php is a bit funky - it uses the $thisuser array rather than the $user array - so the if might need to look like this:
if (!$thisuser['U_Username']) {
Bingo, thankie.
I needed both suggestions. I think I was trying user instead of thisuser.
This is good thing to remember when running a board with pages that can be indexed. Some people do not wnat their profiles indexed across the web, especially with email ids present.
Well it works, but no message. When I put it after $userob, it shows the "Sorry you must be..." (And I'm logged in), and no error at all if logged out.
<br />// ---------------------<br />// Grab this user's info<br /> $userob = new user;<br /> $thisuser = $userob -> authenticate("U_PictureView,U_Number,U_TimeOffset,U_TimeFormat,U_Ignored,U_OC_Userid");<br /><br /> isset($thisuser['U_PictureView']) && $picview = $thisuser['U_PictureView'];<br /> isset($thisuser['U_TimeOffset']) && $toffset = $thisuser['U_TimeOffset'];<br /> !isset($thisuser['U_TimeFormat']) && $thisuser['U_TimeFormat'] = $theme['timeformat'];<br /> !isset($thisuser['U_Ignored']) && $thisuser['U_Ignored'] = "";<br /><br /> $Username = $thisuser['U_Username'];<br /><br /> $html = new html;<br /> <br />// If we are not logged in, then present a log on form, otherwise present<br />// a menu of options.<br /> if((!$thisuser['U_Username'] == ''))<br /> {<br /> $html -> not_right ("{$ubbt_lang['show_profile']}",$Cat);<br /> } <br />
[]JoshPet said:
if (!$thisuser['U_Username']) { [/]
Your code is still wrong- look at the "if" statement I posted - you've still got it incorrect.
Thankie Guys
Wouldn't adding this to your robots.txt be easier?
User-agent: *
Disallow: /pathtothreads/showprofile.php
While this would keep the legit search engines from indexing them, it wouldn't block any agents that ignore the robots.txt file, which is usually the case for email harvesters, etc.
In a pefect world yes, but as Rick said it's not fool proof.
[:"black"] To translate the threads above into Queen's English (you need to use small words with me). . the following code can be cut and pasted into showprofile.php in 6.3.2. Is this correct? Since I've never done this before, what part of showprofile.php do I paste this stuff? [/]
// ---------------------
// Grab this user's info
$userob = new user;
$thisuser = $userob -> authenticate("U_PictureView,U_Number,U_TimeOffset,U_TimeFormat,U_Ignored,U_OC_Userid");
isset($thisuser['U_PictureView']) && $picview = $thisuser['U_PictureView'];
isset($thisuser['U_TimeOffset']) && $toffset = $thisuser['U_TimeOffset'];
!isset($thisuser['U_TimeFormat']) && $thisuser['U_TimeFormat'] = $theme['timeformat'];
!isset($thisuser['U_Ignored']) && $thisuser['U_Ignored'] = "";
$Username = $thisuser['U_Username'];
$html = new html;
// If we are not logged in, then present a log on form, otherwise present
// a menu of options.
if (!$thisuser['U_Username']) {
$html -> not_right ("{$ubbt_lang['show_profile']}",$Cat);
}
In showprofile.php
Somewhere after this line:
$html = new html;
Paste this:
// Block them if they aren't logged in.
if (!$thisuser['U_Username']) {
$html -> not_right ("You must be logged in to view profiles.",$Cat);
}
I hate that this sounds like such a remedial question. . but exactly WHERE in showprofile.php do I paste this information?? I tried to paste in a section called "add new language string" in the box called "string". .I did not paste anything in the box called "key". Regardless, no action! Suggestions???
Oh I think I figured it out. . please excuse my ignorance. I'm now getting "you must be logged in to view profile". However, I'm also getting the following error above that information which says:
SQL ERROR: Database error only visible to forum administrators
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /export/etc. etc. etc.
Warning: Cannot modify header information - headers already sent by (output started at etc. etc. etc.
Suggestions as to what I did wrong?
Thanks
Did you use the admin panel editor? If so there is a bug that puts whitespace after the end of the script that can result in the headers already sent error. Pull down the file and edit it with a text editor like notepad.exe or some such thing. You will likely find white space after the closing php tag:
?>
Delete the whitespace and reupload. That should fix your problem.
This is exactly what I have in the showprofile.php as edited in notepad. I don't think there is any whitespace. . .other than that whitespace between my greyspace! HELP
<?
$ubbt_lang['RATING'] = "Rating";
$ubbt_lang['T_RATES'] = "Total Rates";
$ubbt_lang['RATE_USER'] = "Rate this user";
$ubbt_lang['STAR1'] = "1 star";
$ubbt_lang['STAR2'] = "2 stars";
$ubbt_lang['STAR3'] = "3 stars";
$ubbt_lang['STAR4'] = "4 stars";
$ubbt_lang['STAR5'] = "5 stars";
$ubbt_lang['DORATE'] = "Submit rating";
$ubbt_lang['YOURATED'] = "You rated this user a ";
$ubbt_lang['PROF_FOR'] = "Profile for";
$ubbt_lang['TEXT_NAME'] = "Name";
$ubbt_lang['USER_TITLE'] = "Title";
$ubbt_lang['TOTAL_POSTS'] = "Total Posts";
$ubbt_lang['TEXT_HOME'] = "Homepage";
$ubbt_lang['TEXT_OCCU'] = "Occupation";
$ubbt_lang['TEXT_HOBBY'] = "Hobbies";
$ubbt_lang['TEXT_LOC'] = "Location";
$ubbt_lang['TEXT_BIO'] = "Bio";
$ubbt_lang['PROF_ICQ'] = "ICQ Number";
$ubbt_lang['REGGED_ON'] = "Registered on";
$ubbt_lang['EDIT_T_U'] = "Edit this user";
$ubbt_lang['ADD_BOOK'] = "Add to address book";
$ubbt_lang['SHOW_ALL_P'] = "Show all user's posts";
$ubbt_lang['NO_LONGER'] = "This user is no longer in our database.";
// ---------------------
// Grab this user's info
$userob = new user;
$thisuser = $userob -> authenticate("U_PictureView,U_Number,U_TimeOffset,U_TimeFormat,U_Ignored,U_OC_Userid");
isset($thisuser['U_PictureView']) && $picview = $thisuser['U_PictureView'];
isset($thisuser['U_TimeOffset']) && $toffset = $thisuser['U_TimeOffset'];
!isset($thisuser['U_TimeFormat']) && $thisuser['U_TimeFormat'] = $theme['timeformat'];
!isset($thisuser['U_Ignored']) && $thisuser['U_Ignored'] = "";
$Username = $thisuser['U_Username'];
$html = new html;
// Block them if they aren't logged in.
if (!$thisuser['U_Username']) {
$html -> not_right ("You must be logged in to view profiles.",$Cat);
}
?>
He means right after the last
?>
at the very end of the file, if you have a blank space after that, remove it.
Roger that. . I don't believe that there is blank space after the last
?>
Sorry. Didn't intend for this to be a crash course in php but I'm guessing the error is someplace else. Does anyone see the error in above script
Okay, here's the best way to find out, just to be sure
Place your cursor just after the ?> and then use your
arrow keys to see if it moves forward or down. If it does either of those, back space all the way back. It's just that this is a typical error when there is a blank space (at least the second part). I haven't gone over this hack though so I'm not sure what else could be causing it.
No space. . .must be something with "the hack"
OK - you're editing the language file - wrong file. Remove that stuff from the language file. Edit the showprofile.php script (in the ubbthreads directory).
Somewhere near the top of the script, you'll have a line like this:
<br />$html = new html;<br />
AFTER that, Paste this:
<br />// Block them if they aren't logged in.<br />if (!$thisuser['U_Username']) {<br />$html -> not_right ("You must be logged in to view profiles.",$Cat);<br />}
That should do it.
nice catch Josh
I'll be dipped. .that did it! I appreciate your patience and insight. Once again you've helped me out of jam.
For 6.5.1 you can simply use the following mod and set the group to "3" (so only users can view profiles):
https://www.ubbdev.com/forum/showflat.php/Number/122155