Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 2004
Posts: 6
Junior Member
Junior Member
Offline
Joined: Dec 2004
Posts: 6
Hello everyone!
This board is a great resource!

I've looked at all the posts about cookies I could find...too many haha and I was wondering if you all could help me.

I want to store the user's post count on log-in to the cookie file.

Then I want to be able to read that post count from the cookie using javascript.

I have this for reading the cookie:
Code
<script language="Javascript1.1" type="text/javascript">
<!--

var session_cookie = getCookie('sessionBOARDSESSIONNUMBERREMOVED');
if (session_cookie == null) {
var session_dt = "0";
var session_j = "0";
} else {
var session_array = session_cookie.split("&");
var session_dt = session_array[0];
var session_j = session_array[1];
}

function getCookie(name) {
var cname = name + "=";
var dc = document.cookie;

if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) {
end = dc.length;
} // end if
return (dc.substring(begin, end));
} // end if
} // end if
return null;
}

//-->
</script>
and I've also looked through the ultimatebb.cgi where it stores cookies, but I keep doing something wrong.

Any help is appreciated. I am running version 6.7.

Thank you!
smile

Sponsored Links
Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
Why do you need this info in a cookie? Can't you read the user number from the cookie server-side and get their profile information from that?


UBB.classic: Love it or hate it, it was mine.
Joined: Dec 2004
Posts: 6
Junior Member
Junior Member
Offline
Joined: Dec 2004
Posts: 6
I agree what you said makes more sense. I am very familiar with ASP and ASP.NET but not so much with this perl/cgi integration I'm seeing in the ubb. This was the ghetto easy way I dreamed up haha.

I would just call the file open command where that file equaled the user number, then parse through that file for the post count? Is the post count stored in a variable location elsewhere that I could call?

I'm very new to modding a bulletin board of this size.

Any insight you have is helpful.

Thank you for replying.

Joined: Nov 2001
Posts: 745
Admin Emeritus
Admin Emeritus
Offline
Joined: Nov 2001
Posts: 745
Take a look at https://www.ubbdev.com/ubb/ultimatebb.php/topic/8/3690.html

There is a list of the member profile fields. Using PHP, you can just parse the file into an array and grab the appropriate field. I'm guessing you could file open and fetch the proper line in the file. Keep in mind that each of those fields in that list is a separate line.

Joined: Dec 2004
Posts: 6
Junior Member
Junior Member
Offline
Joined: Dec 2004
Posts: 6
Thanks for the link, ok I'm thinking of sticking with javascript to do all this.

I'm having trouble finding a good javascript "open the file and parse through it" tutorial...familiar obviously with how to parse the text once inside.

Anyone have a quick code they could share to open say user 0000001.cgi parse through it for line 7 then store that in a variable?

Sorry to sound so naive, but I learn best by example.

Thank you.

Sponsored Links
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
https://www.ubbdev.com/ubb/ultimatebb.php/topic/17/1031.html

The script in that thread does something similar, you'd only need to modify it slightly

Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
Javascript is client side, no file opening there. smile


UBB.classic: Love it or hate it, it was mine.
Joined: Dec 2004
Posts: 6
Junior Member
Junior Member
Offline
Joined: Dec 2004
Posts: 6
ugh this is what i get for trying to do this at work...*puts a dunce cap on.

i'm just going to do it with perl...im extremely rusty with it - ill post up what i get...

thanks again ya'll

smile

Joined: Dec 2004
Posts: 6
Junior Member
Junior Member
Offline
Joined: Dec 2004
Posts: 6
Ok I've parsed the post count.

Anyone got a plain php way to read the board cookie for user name without using any includes...just straight up read the cookie, grab the display name...etc. no noncgi paths, var_config includes...just straight up reading it and displaying it.

Basically the PHP equivalent of this:

Code
 <script language="Javascript1.1" type="text/javascript">
<!--

var session_cookie = getCookie('session2453335.1958');
if (session_cookie == null) {
var session_dt = "0";
var session_j = "0";
} else {
var session_array = session_cookie.split("&");
var session_dt = session_array[0];
var session_j = session_array[1];
}

function getCookie(name) {
var cname = name + "=";
var dc = document.cookie;

if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) {
end = dc.length;
} // end if
return (dc.substring(begin, end));
} // end if
} // end if
return null;
}

//-->
</script>

<script language="Javascript" type="text/javascript">
<!--
var user_cookie = getCookie('ubber2453335.1958');
if(''==user_cookie &#0124;&#0124; null==user_cookie) {
document.writeln('You are not logged in.' , ' <a class="top" href="http://www.poorreflection.com/cgi-bin/ultimatebb.cgi?ubb=login">Login</a> or <a class="top" href="http://www.poorreflection.com/cgi-bin/ultimatebb.cgi?ubb=agree">register</a>')
} else {

var user_array=user_cookie.split("&");
user_array[2] = unescape(user_array[2]);
document.writeln('Hello, ', user_array[2]);
document.writeln('[ <a class="top" href="http://www.poorreflection.com/cgi-bin/ultimatebb.cgi?ubb=logoff">'
,'<acronym title="Click here to log out.">'
,'log out</acronym></a> ]');

}
//-->
</script>

I've tried several ways and it keeps displaying nothing.

Thanks everyone - a lot of good posts in this forum - i think i've worn out the search button.

Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
Code
<?php

if(!isset($_COOKIE["ubber2453335_1958"])) {
echo 'You are not logged in. <a class="top" href="http://www.poorreflection.com/cgi-bin/ultimatebb.cgi?ubb=login">Login</a> or <a class="top" href="http://www.poorreflection.com/cgi-bin/ultimatebb.cgi?ubb=agree">register</a>';
} else {
$user_array = explode("&", $_COOKIE["ubber2453335_1958"]);

echo "Hello, $user_array[2] [ <a href='top' href='http://www.poorreflection.com/cgi-bin/ultimatebb.cgi?ubb=logoff'><acronym title='Click here to log out.'>log out</acronym></a> ]";
} // end if

?>
This one worked for me.

Sponsored Links
Joined: Dec 2004
Posts: 6
Junior Member
Junior Member
Offline
Joined: Dec 2004
Posts: 6
Thank you!

It worked laugh


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
Posts: 70
Joined: January 2007
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
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)