Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Aug 2000
Posts: 1,290
Addict
Addict
Offline
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..?


- Custom Web Development
http://www.JCSWebDev.com
Sponsored Links
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
Offline
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.


- Custom Web Development
http://www.JCSWebDev.com
Joined: Aug 2000
Posts: 1,290
Addict
Addict
Offline
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.

Code
<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 />


- Custom Web Development
http://www.JCSWebDev.com
Sponsored Links
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
Offline
Joined: Aug 2000
Posts: 1,290
Doh, got it.. no == etc


- Custom Web Development
http://www.JCSWebDev.com
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
Offline
Joined: Aug 2000
Posts: 1,290
Yup caught it..


- Custom Web Development
http://www.JCSWebDev.com
Joined: Aug 2000
Posts: 1,290
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,290
Thankie Guys


- Custom Web Development
http://www.JCSWebDev.com
Sponsored Links
Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
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
Offline
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
Offline
Joined: Aug 2000
Posts: 1,290
In a pefect world yes, but as Rick said it's not fool proof.


- Custom Web Development
http://www.JCSWebDev.com
Joined: Dec 2003
Posts: 7
Lurker
Lurker
Offline
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
Offline
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
Offline
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
Offline
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
Offline
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
Offline
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
Offline
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
Offline
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
Offline
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:

Code
<br />$html = new html;<br />

AFTER that, Paste this:

Code
<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
Offline
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.

Joined: Jan 2003
Posts: 263
Member
Member
Joined: Jan 2003
Posts: 263
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


Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)