Previous Thread
Next Thread
Print Thread
Rate Thread
Storing and Reading Post Count to/from Cookies #183961 12/08/2004 1:50 PM
Joined: Dec 2004
Posts: 6
Rainman Offline OP
Junior Member
OP Offline
Junior Member
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
Re: Storing and Reading Post Count to/from Cookies #183962 12/08/2004 2:32 PM
Joined: Jan 2000
Posts: 5,073
Charles Capps Offline
Admin Emeritus
Offline
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.
Re: Storing and Reading Post Count to/from Cookies #183963 12/08/2004 4:32 PM
Joined: Dec 2004
Posts: 6
Rainman Offline OP
Junior Member
OP Offline
Junior Member
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.

Re: Storing and Reading Post Count to/from Cookies #183964 12/08/2004 4:58 PM
Joined: Nov 2001
Posts: 745
Ron M Offline
Admin Emeritus
Offline
Admin Emeritus
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.

Re: Storing and Reading Post Count to/from Cookies #183965 12/08/2004 5:34 PM
Joined: Dec 2004
Posts: 6
Rainman Offline OP
Junior Member
OP Offline
Junior Member
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
Re: Storing and Reading Post Count to/from Cookies #183966 12/08/2004 5:46 PM
Joined: Jan 2003
Posts: 3,456
Ian Spence Offline
Master Hacker
Offline
Master Hacker
Joined: Jan 2003
Posts: 3,456
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

Re: Storing and Reading Post Count to/from Cookies #183967 12/08/2004 6:19 PM
Joined: Jan 2000
Posts: 5,073
Charles Capps Offline
Admin Emeritus
Offline
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.
Re: Storing and Reading Post Count to/from Cookies #183968 12/08/2004 7:27 PM
Joined: Dec 2004
Posts: 6
Rainman Offline OP
Junior Member
OP Offline
Junior Member
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

Re: Storing and Reading Post Count to/from Cookies #183969 12/09/2004 4:46 AM
Joined: Dec 2004
Posts: 6
Rainman Offline OP
Junior Member
OP Offline
Junior Member
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.

Re: Storing and Reading Post Count to/from Cookies #183970 12/09/2004 7:16 AM
Joined: May 2001
Posts: 1,042
Brett Offline
Moderator
Offline
Moderator
Joined: May 2001
Posts: 1,042
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
Re: Storing and Reading Post Count to/from Cookies #183971 12/09/2004 2:57 PM
Joined: Dec 2004
Posts: 6
Rainman Offline OP
Junior Member
OP Offline
Junior Member
Joined: Dec 2004
Posts: 6
Thank you!

It worked laugh


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
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,490
Posts293,665
Members13,828
Most Online5,166
Sep 15th, 2019
Top Posters(All Time)
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,786
Greg Hard 4,625
Top Posters(30 Days)
isaac 4
Today's Statistics
Currently Online 1426
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 21
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2019 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Snapshot build 20191013.dev)
Responsive Width:

PHP: 5.4.45 Page Time: 0.040s Queries: 14 (0.012s) Memory: 3.2789 MB (Peak: 3.4650 MB) Data Comp: Zlib Server Time: 2019-10-21 15:29:18 UTC
Valid HTML 5 and Valid CSS