Gossamer Forum
Home : Products : DBMan : Installation :

Just Start my project "People Matching"

(Page 1 of 2)
> >
Quote Reply
Just Start my project "People Matching"
Hi,
I spent a week and tried out a lot of diff. CGI ( non SQL )database program. now the nice one i have found!"dbman"
At first time i just install it and i LOVED it, coz so powerful.i have already rated it at 10 of 10 Smile
m...I just started my project "People Matching"
but I have some problems to Match it in my project. I'm a beginner who just started to use Perl language.
Plz help

Q1. I wanna make it have a REGISTERATION system with a password email back notify and Free email domain filter function (Exp. block hotmial or any i don't want's address...)

Q2 just get the user's birthday then automatic display him/her's recent age / graphic horoscope in the user list in html format (html.pl)
as i know it should take a date from the server and count it....but i don't know how...

Q3 i think its the same way as Q2
count the time to show how long about the user's membership started.

Q4 how can i get the user's IP and store up into the user's data?
Quote Reply
Re: Just Start my project "People Matching" In reply to
more Q2
Q2 just get the user's birthday then automatic display him/her's recent age / graphic horoscope in the user list
in html format (html.pl)
as i know it should take a date from the server and count it..and then get the Counted Number by $RecentAge..but i don't know how...

Q5 i wanna give a surprise to my users
when the day is matched the user's birthday
it can display a diff. graphic(jpg/gif) in him/her own user list.

i'll install dbman in a free hosting company (virtualacve.com) so i hope that it can be work on this server.

Sorry about i have asked a lot of questions to you...and Sorry about my lowest english skill level which makes you hard to understand it.

------------------
Quote Reply
Re: Just Start my project "People Matching" In reply to
I'm not sure what you want with the "password email back notify" feature. Do you want to allow users to be able to enter their email addresses and have their passwords mailed to them? If that's what you want, there is a modification at

http://www.jpdeni.com/dbman/lookup.txt

which will give you instructions on how to do it.

If you use the password lookup mod, you would be able to check for the unwanted email addresses when users sign up for a password (assuming you want them to be able to sign up). I'll help you with that later.

The birthday and horoscope features are a little complicated, but can be done. You will have to have separate fields for the day, month and year, and it would be easier if you also had a field for the day of the year the birthday falls on.

To compute the length of time the user has been a member is a little tricky. It's easier to just say "A member since 21-May-1999." It probably can be done, though, to say "A member for 323 days" or "A member for 1 year, 4 months and 10 days."

The user's IP address can probably be retrieved from $ENV{'HTTP_REFERER'}, but I'm not completely sure about that.

Quote:
Q4 how can i get the user's IP and store up into the user's data? when the user logged in.

I'm not sure what you mean by that. I think you can get the IP when the user adds a record. And you can probably get the IP printed in the log file every time the user logs in.

My suggestion is that before you do any of the above you first install the demo script on your site to make sure that it works.

Next, create your own fields for your database. Set
$db_auto_generate = 1;
in the default.cfg file so you don't have to worry about making your own forms and record displays.

If you have any problem understanding how to do the steps above, you might try checking out a little tutorial I have started to write. Go to http://www.jpdeni.com/dbman/tutorial.html and follow the steps there.

Once you have your fields configured correctly, you can start making your own modifications to the database. I would suggest that you add any new features one at a time. We'll help you with them as you go.



------------------
JPD





Quote Reply
Re: Just Start my project "People Matching" In reply to
Hi Carol, Benben,

Just to clear up one thing that Carol said there, to get the users IP address you'll need to use $ENV{'REMOTE_ADDR'} or if you want their remote host (the name of that server), use $ENV{'REMOTE_HOST'}. HTTP_REFERER is the page that the user came from.

Cheers,
His Nosiness,
adam
Quote Reply
Re: Just Start my project "People Matching" In reply to
Q4 again
Q4 how can i get the user's IP and store up into the user's data? when the user logged in.

Thx : )

------------------
Quote Reply
Re: Just Start my project "People Matching" In reply to
Dahmasta so how can i display the ip adress or host in dbman i want it in add_success
and main menu .
Quote Reply
Re: Just Start my project "People Matching" In reply to
Thanks Adam. That's the sort of thing I'm still pretty sketchy on.


------------------
JPD





Quote Reply
Re: Just Start my project "People Matching" In reply to
Classic,

Do you just want to display the remote_host, or do you want to add it to records or wha? Sorry, it just seems pointless to me to just display the users remote_host? I can't see them being interested in what server they dialled in from. However, mine is not to reason why... Smile

Anyway, if that's all you want, something like this would do it:

Code:
if ($ENV{'REMOTE_HOST'}) {
print "$ENV{'REMOTE_HOST'}";
}

You would of course have to close off any print qq statements first, and then reopen them.

If you could be more specific about what you want, I might be able to help more...

Cheers,
adam

[This message has been edited by dahamsta (edited May 22, 1999).]
Quote Reply
Re: Just Start my project "People Matching" In reply to
Yes i mean i want the ip to be locked in database and to display to the people so they do not put crap in to my database
but do i need to create a new field in default.cfg to do that or what Thanks for the reply.
Quote Reply
Re: Just Start my project "People Matching" In reply to
If you want to relate an IP address to each record, yes, you will need to create a field in your database to hold the IP address.


------------------
JPD







[This message has been edited by JPDeni (edited May 25, 1999).]
Quote Reply
Re: Just Start my project "People Matching" In reply to
Just a couple of points to note about associating a users IP with a record.

First, you won't always get an IP address. Some people will be behind complicated firewalls, and of course there'll be people who don't *want* you to know their IP address (anonymizer surfers for instance). And second, and more important, it's illogical to associate a users IP with a record, because most dial-up providers will assign a different IP to a user each time they dial in.

Cheers,
adam
Quote Reply
Re: Just Start my project "People Matching" In reply to
OK so if i only want to display incomming ip where should i put the script?
Quote Reply
Re: Just Start my project "People Matching" In reply to
Thx all,
i have already installed on the virtualave.net working well ah Smile
now i tring set-it-up to fit to my project

i understand it, to count out a day for how long my user has been started the membership is little bit hardly...but count out the age of my user who has been filled with month,year and only display "you're 3 month 18 years ago" should be easier
coz a month can be have 28,29,30,31 days, so if i really wanna do it, then i think i have to create a dbase for it. Exp i need to create a from "1999 to 2001"'s calendar in my db.

from Q1:but how about only count the month and year then display it on the db list with birthday and how long my user has been started the membership?
Quote Reply
Re: Just Start my project "People Matching" In reply to
clearly
my db is for store my user's info
format is...

fist name abc
last name cde
.
birth day 15
month 10
year 19xx
.
.
bababa..

i put the day of registeraton in hide type
if it gets 25-05-1999
so how can i count 'user's age' & 'how long the user has been started the membership'?

Q6 how can i make a preview feature, let my user can be do 'duble check' before 'to add a record'?

Please show me some codes

Thank's lot
Quote Reply
Re: Just Start my project "People Matching" In reply to
First of all, it seems that you want your dates in the format of "25-05-1999" instead of "25-May-1999." Is that correct? If so, you'll need to replace the following subroutines in the db.cgi script.

Code:
sub get_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.

$time = $_[0];
($time) | | ($time = time());
# be sure to remove the space between the two | characters in the line above.

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
++$mon;
($mon < 10) and ($mon = "0$mon");
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day-$mon-$year";
}

Code:
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }

use Time::Local;
eval {
$day = int($day); $mon = int($mon) - 1 ; $year = int($year) - 1900;
$time = timelocal(0,0,0,$day,$mon,$year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}

Replace the subroutines above with the matching subroutines in the db.cgi file. Run your database to make sure it works correctly before you make any more changes.

You will need to make the changes above in order for the subroutine below to work.

To compute the user's age, to the nearest year, add the following subroutine to db.cgi

Code:
sub get_age {
# --------------------------------------------------------
my ($bday,$bmon,$byear) = @_;

my ($date) = &get_date();
my ($day, $mon, $year) = split(/-/, $date);

my ($age) = $year - $byear;
if ($mon < $bmon) {
--$age;
}
elsif (($mon == $bmon) && ($day < $bday)) {
--$age;
}
return $age;
}

If your fields are BirthDay, BirthMonth and BirthYear, to print out the age of the user, in sub html_record (in the html.pl file) just after

my (%rec) = @_;

add

$current_age = &get_age($rec{'BirthDay'},$rec{'BirthMonth'},$rec{'BirthYear'});

In the place where you want to print out the age, use $current_age.

If your field names for the elements of the birthdate are different, be sure to change the names above.

Let's get this part working before we try anything else.


------------------
JPD







[This message has been edited by JPDeni (edited May 26, 1999).]
Quote Reply
Re: Just Start my project "People Matching" In reply to
after i replace those codes
get_date
date_to_unix
get_age

then it got '500 Internal Server Error'
the server is using Apache 1.2.6

here is my setting..

'current_age' => [20, 'numer', 3, 3, 1, '', '' ],
'BirthDay' => [21, 'numer', 0, 10, 1, '', '' ],
'BirthMonth' => [22, 'numer', 0, 10, 1, '', '' ],
'BirthYear' => [23, 'numer', 4, 4, 1, '19', '' ],

i'd try only replace with...
date_to_unix
get_age

then i can go back to the main menu
so, i guest is problem in get_date's codes
Quote Reply
Re: Just Start my project "People Matching" In reply to
Did you take out the space between the two | characters in the get_date subroutine?

The line

($time) &#0124; &#0124; ($time = time());

should have two | characters next to each other, with no space between them. The forum script adds a space for some reason, so there isn't anything I can do to change it. You need to delete the space.

That's the only thing I can think of that might be a problem. I have tested all of these subroutines extensively and I know there are no syntax errors.


------------------
JPD





Quote Reply
Re: Just Start my project "People Matching" In reply to
Thx JPDeni so much
i have removed the 'space'
and replace/add all codes
i can get back to main menu and add info on it.

'current_age' => [20, 'numer', -2, 4, 0, $get_age, '' ],
'BirthDay' => [21, 'numer', 2, 2, 1, '', '' ],
'BirthMonth' => [22, 'numer', 2, 2, 1, '', '' ],
'BirthYear' => [23, 'numer', 4, 4, 1, '', '' ],

so how can i get the 'current_age' and view on the DB list?

Quote Reply
Re: Just Start my project "People Matching" In reply to
The current age is not a field in your database. Since it will change, you don't want it to be saved to the record. Take out field 20. And be sure to renumber the other fields so you aren't missing a number.

Are you using autogenerate for your display? If so, you will need to create your own html_record subroutine with your own fields in it. Autogenerate only makes the simplest of displays.

Once you get your display created, in sub html_record (in the html.pl file) just after

my (%rec) = @_;

add

$current_age = &get_age($rec{'BirthDay'},$rec{'BirthMonth'},$rec{'BirthYear'});

In the place where you want to print out the age, use $current_age.

For example, you might want to have a row in a table where the age is printed.

Code:
<TR><TD>Current age:</TD>
<TD>$current_age years</TD></TR>





------------------
JPD





Quote Reply
Re: Just Start my project "People Matching" In reply to
I got the astrology thing figured out. It won't be 100% accurate, but it's as close as you can come with only the birth date.

You'll need to add a field to your database -- I'll call it Astro, but you can name it whatever you want, as long as you change it in the code below.

You'll need to add another subroutine to db.cgi. (You probably guessed that. Smile )

Code:
sub get_astro {
@astro_dates = (120,219,321,420,521,621,723,823,923,1023,1122,1222);
@astro_signs = (Aquarius,Pisces,Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scoripo,Sagittarius,Capricorn);

$astro_date = "$in{'BirthMonth'}$in{'BirthDay'}";
$astro_date = int($astro_date);

if ($astro_date < 120) {
$astro_date =1222;
}

for ($i=0; $i<11; ++$i) {
if ($astro_date < $astro_dates[$i+1]) {
last;
}
}

return $astro_signs[$i];
}

In sub add_record, after

($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

add

$in{'Astro'} = $get_astro;

Also, in case the user changes his birthdate (he made a mistake the first time), in sub modify_record, after

my ($status, $line, @lines, @data, $output, $found, $restricted);

add

$in{'Astro'} = $get_astro;

To print it out, use the same type of syntax for printing other $rec variables -- $rec{'Astro'}.



------------------
JPD





Quote Reply
Re: Just Start my project "People Matching" In reply to
its same thing, i wanna display it on the db list.
Quote Reply
Re: Just Start my project "People Matching" In reply to
Sorry, forgot about ya! If you want to display a users IP the best thing to do is add a line like:

$ip = $ENV{'REMOTE_ADDR'};

to your config file, and you can access this at any time by putting $ip in any of your subroutines. To get a little more sophisticated, you could have something like:

if ($ENV{'REMOTE_ADDR'}) { $ip = $ENV{'REMOTE_ADDR'}; }
else { $ip = "UNAVAILABLE"; }

If you want to use the server name, use REMOTE_HOST instead of REMOTE_ADDR.

Cheers,
adam
Quote Reply
Re: Just Start my project "People Matching" In reply to
There are several ways you can print out the length of membership. You can have

"a member for 387 days"

or

"a member for 1 year(s), 22 day(s)"

I'll give you the code for both and you can decide for yourself.

It's really hard to work out something like "2 years 5 months and 3 days" since months vary in length.

Just after your &get_age line in html_record, add

Code:
$total_days_joined = int((&date_to_unix(&get_date()) - &date_to_unix($rec{'DateAdded'}))/86400);
$years_joined = int($total_days_joined/365.25);
$days_this_year_joined = $total_days_joined % 365.25;

This assumes that your field that holds the date is called DateAdded. If you have named it something else, change the code above.

When you are ready to print it out, use the variables. You can either have something like

Code:
<TR><TD>Member for:</TD>
<TD>$total_days_joined days</TD></TR>


or

Code:
<TR><TD>Member for:</TD>
<TD>$years_joined year(s), $days_this_year_joined day(s)</TD></TR>

Just pick which one you want.

I'm still thinking about the astrology thing. That's a little tougher.


------------------
JPD





Quote Reply
Re: Just Start my project "People Matching" In reply to
Thank to all nice guys ( special thanks to JPDeni and dahamsta Smile )
now i just started the next step...
Quote Reply
Re: Just Start my project "People Matching" In reply to
yeaaaaaah ! Thank Thank Thanks

got it Smile Smile Smile! so how can i do the next step...

to count how long has been started the membership after the registeration?
> >