BetaArchive Logo
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 3d, 6h, 4m | CPU: 21% | MEM: 2490MB of 5809MB used
{The community for beta collectors}

Forum rules


Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it


Post new topic Reply to topic  [ 18 posts ] 
Author Message
 PostPost subject: Help on a project I'm working on...        Posted: Fri Nov 02, 2007 5:16 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
Hello all,

I currently have a problem that I need to solve.

$lpop[4] displays the day in the year the comment was written, and $day displays the current day of the year, so how can I calculate how many days ago the comment was written?

I've tried the following:

1.
Code:
$m1 = round("$lpop[4]");
$m2 = round("$day");
$days = round("$m1-$m2");

Thus $days is supposed to display how many days the comment was written, but was unsuccessful. Also I know the date("Z"); which is used doesn't display the numbers in decimals, so there wasn't much point in rounding them, also it needs the second value, which is to interpret the number of decimal places it should be rounded to.

2.
Code:
$days = "$lpop[4]-$day";

Obviously $days is supposed to display how many days ago the comment was written but was again unsuccessful. This just displayed the sum the computer needed to do but it didn't actually do it.

All help is appriciated. Oh yes also the "project" is teen4m, if you haven't already guessed, and commenting is for user profiles. The overall point of this thing on the comments is to create something like YouTube comments where it will tell you how long ago the comment was posted.

Thanks,
Callum


Top  Profile  WWW
 PostPost subject:        Posted: Sat Nov 03, 2007 5:45 pm 
Reply with quote
Donator
User avatar
Offline

Joined
Mon Sep 04, 2006 1:06 pm

Posts
1004

Location
USA
I'm not that good at PHP, but I'd suggest when submitting the comment, creating a variable for each part of the date (Year, Month (written using numbers), Day, Minute, Second). Then, when you query your database and receive the info, just do the math with each different thing.

Code:
$finalyear = ($yearfromcomment-$thisyear);
echo 'Comment posted:';
if ($finalyear == '0') echo '';
else { echo $finalyear;
echo ' Years Ago,'; }

Then repeat that code for the month, day, ect.

I don't know if this would work, and it would require a bit of recoding in your database and profile page, but you could still try.

Hope this helps! :wink:

_________________
Old-Computer
BetaArchive VIP | Ex-OSBA Member


Top  Profile
 PostPost subject:        Posted: Sat Nov 03, 2007 6:46 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
I'm only really bothered about displaying how many days ago it was posted, and not too much about converting to years if it reaches 365.

It might also be helpful to know that I'm not using a database, the information is written to a text file in a folder, and each file is called $temp[0].txt, which means it'll be called the name of the profile, e.g. if someone posted a comment on a profile called thedude, it'll be written to /commentfolder/thedude.txt - also /commentfolder/ isn't the actual name of the folder.

A little bit of the code of the comment system is here:

Code:
$lpop = explode("|~|",$lines_review[$cv]);
$m1 = round("$lpop[4]");
$m2 = round("$day");
$days = round("$m1+$m2");
echo "<tr><td>Comment by <a>$lpop[1]</a> on $lpop[3], which was $days days ago.</td></tr><tr><td> $lpop[2] </td></tr><tr><td>&nbsp;</td></tr>";


The |~| part separates the different parts of the comment, like the date, poster, actual comment, ect, all from each other.

Also, Jeff, where you put you're IF statement and echo '';, for your reference, you don't need to put the echo, for example:

Code:
if ($number1=="1") {
}
else {
echo "Something about number 1";
}


Again, thanks for all of your help!


Top  Profile  WWW
 PostPost subject:        Posted: Sun Nov 04, 2007 8:39 am 
Reply with quote
Donator
Offline

Joined
Sat Aug 19, 2006 1:25 am

Posts
590

Location
Israel
PHP, like most UNIX-derived languages, uses UNIX timestamps (the number of seconds since 1/1/1970 00:00:00 GMT) to store date/time. By storing the output of the time() function, you can get the number of seconds between some date in the past and now, and by dividing it by 86400, you can get the number of days passed. For example:
Code:
// $past_date is a variable containing a standard UNIX timestamp of some date in the past
$seconds_passed = time() - $past_date;
$days_passed = $seconds_passed / 86400;


I hope it helps.


Top  Profile
 PostPost subject:        Posted: Sun Nov 04, 2007 3:12 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
ppc_digger wrote:
PHP, like most UNIX-derived languages, uses UNIX timestamps (the number of seconds since 1/1/1970 00:00:00 GMT) to store date/time. By storing the output of the time() function, you can get the number of seconds between some date in the past and now, and by dividing it by 86400, you can get the number of days passed. For example:
Code:
// $past_date is a variable containing a standard UNIX timestamp of some date in the past
$seconds_passed = time() - $past_date;
$days_passed = $seconds_passed / 86400;


I hope it helps.


Thanks! Yeah that has helped!

Dividing by 86400 was the key, although I haven't implemented it yet in the comment system, I've put it to test in a separate file. I'll give it a go later on the comment system.

Also, I noticed it has a number of decimal places, so I fixed this with a round() statement:
Code:
$thedays = round("$days_passed, 0");

Obviously the 0 indicates how many decimal places to round it to.

Again, thanks to everyone who has helped,
Callum


Top  Profile  WWW
 PostPost subject:        Posted: Mon Nov 05, 2007 7:54 pm 
Reply with quote
Donator
User avatar
Offline

Joined
Mon Sep 04, 2006 1:06 pm

Posts
1004

Location
USA
A couple things I found out about your system: the files folder in your older system is completely accessible, therefore I gained access to your message inbox, your profile info, and some other things. Even though this was in the older version, you carried over the file format and naming ways into the newer version. This may be a problem in the future when you get more members. Just in case, here's one of your messages
Quote:
new2|~~|mark|~~|Re: Re: Re: hi|~~|nice - like smileys, what about MSN or 16-bit MSN ones lol I love them|~~|6|~~|Fri 31-Aug-2007|~~|
(presumably from mark)

I know it's still in beta, and you would probably make it different in the final version, but you may want to consider renaming the files folder and adding a random number to each of those files you have in that folder, to prevent someone from randomly guessing a members pm box (and data, mood, ect) file.

Also, you may want to consider blacking out the url bar on some of your screenshots better next time...

If you want me to remove this stuff from the post, feel free to ask, I'll do it asap. (And I dunno if you have a newer dev version, so this stuff might be irrelevant)

_________________
Old-Computer
BetaArchive VIP | Ex-OSBA Member


Top  Profile
 PostPost subject:        Posted: Mon Nov 05, 2007 8:31 pm 
Reply with quote
Donator
Offline

Joined
Sat Aug 19, 2006 1:25 am

Posts
590

Location
Israel
If the system is so easy to hack, you might have bigger problems once it's public. I'd say switch to SQL completely. It's not so hard to learn, you can pick the basics up in an hour or so (great tutorial here), and the PHP bindings are also very simple (MySQL support is usually built-in, tutorial here). In addition to added security, it's much faster.


Top  Profile
 PostPost subject:        Posted: Tue Nov 06, 2007 4:23 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
Jeff wrote:
A couple things I found out about your system: the files folder in your older system is completely accessible, therefore I gained access to your message inbox, your profile info, and some other things. Even though this was in the older version, you carried over the file format and naming ways into the newer version. This may be a problem in the future when you get more members. Just in case, here's one of your messages
Quote:
new2|~~|mark|~~|Re: Re: Re: hi|~~|nice - like smileys, what about MSN or 16-bit MSN ones lol I love them|~~|6|~~|Fri 31-Aug-2007|~~|
(presumably from mark)

I know it's still in beta, and you would probably make it different in the final version, but you may want to consider renaming the files folder and adding a random number to each of those files you have in that folder, to prevent someone from randomly guessing a members pm box (and data, mood, ect) file.

Also, you may want to consider blacking out the url bar on some of your screenshots better next time...

If you want me to remove this stuff from the post, feel free to ask, I'll do it asap. (And I dunno if you have a newer dev version, so this stuff might be irrelevant)


Thanks for that!

No need to remove the message, it wasn't that private (well no messages are).

The content of the directory you found the information in will not be directly accessible, when the site goes live.

Also, since you registered, I've noticed that your profile wasn't automatically created, which could be another potential bug, and I've found out why the profiles are saying there not found (insufficient files created on registration), but I'll have to dig deep into the code to find out why the required files aren't being created. Did you notice any sort of PHP errors on registration?

Yeah, we don't have a newer developer version just yet, but PM me if you want the URL to a somewhat more stable version.

What images were you refering to when you said about blocking URL out more?

ppc_digger wrote:
If the system is so easy to hack, you might have bigger problems once it's public. I'd say switch to SQL completely. It's not so hard to learn, you can pick the basics up in an hour or so (great tutorial here), and the PHP bindings are also very simple (MySQL support is usually built-in, tutorial here). In addition to added security, it's much faster.


Thanks again for that. A lot of people have asked me why I haven't used SQL for it. To be honest, at my current level of PHP, I feel more comfortable with just flat-files, but I may well use it.


Top  Profile  WWW
 PostPost subject:        Posted: Tue Nov 06, 2007 5:03 pm 
Reply with quote
Donator
User avatar
Offline

Joined
Mon Sep 04, 2006 1:06 pm

Posts
1004

Location
USA
I'll continue this discussion in PMs with you! :)

_________________
Old-Computer
BetaArchive VIP | Ex-OSBA Member


Top  Profile
 PostPost subject:        Posted: Sat Nov 10, 2007 1:23 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
I'm working on version 4 of teen4m, which is SQL based. Only myself and Mark (who currently doesn't know about it as of this post) can access this demo currently, as it is highly private, since its unstable.

Image

Thanks,
Callum :D


Top  Profile  WWW
 PostPost subject:        Posted: Thu Nov 15, 2007 4:59 am 
Reply with quote
Donator
Offline

Joined
Fri Oct 26, 2007 5:12 pm

Posts
2461
If thats going to be your logo.. I don't like it. To tell you the truth, it looks like crap.


Top  Profile
 PostPost subject:        Posted: Thu Nov 15, 2007 12:50 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
Dude, no way! That's not going to be the logo, that was a quick image I put together in less than, say 3 minutes, if that. I have to say, I don't like the colours.


Top  Profile  WWW
 PostPost subject:        Posted: Thu Nov 15, 2007 5:07 pm 
Reply with quote
Donator
Offline

Joined
Fri Oct 26, 2007 5:12 pm

Posts
2461
callumh wrote:
Dude, no way! That's not going to be the logo, that was a quick image I put together


THANK GOD! :P


Top  Profile
 PostPost subject:        Posted: Fri Nov 16, 2007 10:45 am 
Reply with quote
FTP Access
User avatar
Offline

Joined
Wed Oct 04, 2006 11:02 pm

Posts
514
callumh wrote:
Image here


Xara 3D?


Top  Profile
 PostPost subject:        Posted: Fri Nov 16, 2007 10:49 am 
Reply with quote
Donator
User avatar
Offline

Joined
Thu Aug 31, 2006 2:45 pm

Posts
1432

Location
UK

Favourite OS
Longhorn 4074
moonlit wrote:
callumh wrote:
Image here


Xara 3D?
lol, i also thought it's xara 3d or xara webstyle...


Top  Profile  WWW
 PostPost subject:        Posted: Fri Nov 16, 2007 5:39 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
Yep Xara 3D 6.0 Pro... my favorite for 3D text.

I have a non-installing copy on my USB flash drive, just in case :wink:


Top  Profile  WWW
 PostPost subject:        Posted: Sat Nov 17, 2007 2:54 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Wed Oct 04, 2006 11:02 pm

Posts
514
Portable apps ftw!


Top  Profile
 PostPost subject:        Posted: Sat Nov 17, 2007 5:29 pm 
Reply with quote
User avatar
Offline

Joined
Tue Jul 24, 2007 10:15 pm

Posts
197

Location
teen4m.net

Favourite OS
Windows 7 Ultimate x64
Yeah, but not portableapps.com, which I get quite a lot of portable software off. I recompiled the installer, and just modified a few app files to make it portable :)


Top  Profile  WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 




Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2018

 

Sitemap | XML | RSS