|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
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..?
|
|
|
|
Joined: Oct 2003
Posts: 2,305
Old Hand
|
Old Hand
Joined: Oct 2003
Posts: 2,305 |
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); }
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
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']) {
|
|
|
|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
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.
|
|
|
|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
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 />
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
[]JoshPet said: if (!$thisuser['U_Username']) { [/]
|
|
|
|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
Your code is still wrong- look at the "if" statement I posted - you've still got it incorrect.
|
|
|
|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
|
|
|
|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
Thankie Guys 
|
|
|
|
Joined: Nov 2002
Posts: 554
Code Monkey
|
Code Monkey
Joined: Nov 2002
Posts: 554 |
Wouldn't adding this to your robots.txt be easier?
User-agent: * Disallow: /pathtothreads/showprofile.php
|
|
|
|
Joined: May 1999
Posts: 3,039
Guru
|
Guru
Joined: May 1999
Posts: 3,039 |
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.
UBB.threads Developer
|
|
|
|
Joined: Aug 2000
Posts: 1,290
Addict
|
Addict
Joined: Aug 2000
Posts: 1,290 |
In a pefect world yes, but as Rick said it's not fool proof.
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
[:"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); }
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
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); }
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
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???
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
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
|
|
|
|
Joined: Jun 2003
Posts: 1,025
Junior Member
|
Junior Member
Joined: Jun 2003
Posts: 1,025 |
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.
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
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); } ?>
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
He means right after the last ?> at the very end of the file, if you have a blank space after that, remove it.
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
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 
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
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.
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
No space. . .must be something with "the hack" 
|
|
|
|
Joined: Nov 2001
Posts: 10,369
I type Like navaho
|
I type Like navaho
Joined: Nov 2001
Posts: 10,369 |
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. 
|
|
|
|
Joined: Oct 2003
Posts: 2,305
Old Hand
|
Old Hand
Joined: Oct 2003
Posts: 2,305 |
nice catch Josh 
|
|
|
|
Joined: Dec 2003
Posts: 7
Lurker
|
Lurker
Joined: Dec 2003
Posts: 7 |
I'll be dipped. .that did it! I appreciate your patience and insight. Once again you've helped me out of jam. 
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 87
Joined: December 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|