$Today = getdate(); - UserInfo Block

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   $Today = getdate(); - UserInfo Block
VikG
CZ Newbie
VikG has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: May 25, 2005
0.00 posts per day
Posts: 4
Points: 186
   
Hey

I have reconfigured my table to store the date in a different format with the help of an online guide so that i could make phpbb standalone. However, i have one problem which is that the userinfo block is trying to look for new signups today and yesterday with the wrong SQL String as the database format is different. Currently it is looking for:

$Today = getdate();
//Formatting Current Date
$month = $Today['month'];
$mday = $Today['mday'];
$year = $Today['year'];
//Formatting Previous Date
$pmonth = $Today['month'];
$pmday = $Today['mday'];
$pmday = $mday-1;
$pyear = $Today['year'];
//Month conversion into numeric mode
if ($pmonth=="January") { $pmonth=1; } else
if ($pmonth=="February") { $pmonth=2; } else
if ($pmonth=="March") { $pmonth=3; } else
if ($pmonth=="April") { $pmonth=4; } else
if ($pmonth=="May") { $pmonth=5; } else
if ($pmonth=="June") { $pmonth=6; } else
if ($pmonth=="July") { $pmonth=7; } else
if ($pmonth=="August") { $pmonth=8; } else
if ($pmonth=="September") { $pmonth=9; } else
if ($pmonth=="October") { $pmonth=10; } else
if ($pmonth=="November") { $pmonth=11; } else
if ($pmonth=="December") { $pmonth=12; };
$test = mktime (0,0,0,$pmonth,$pmday,$pyear,1);

//Creating SQL parameter
$curDate2 = "%".$month[0].$month[1].$month[2]."%".$mday."%".$year."%";
$preday = strftime ("%d",$test);
$premonth = strftime ("%B",$test);
$preyear = strftime ("%Y",$test);
$curDateP = "%".$premonth[0].$premonth[1].$premonth[2]."%".$preday."%".$preyear."%";

//Executing SQL Today
$sql = "SELECT COUNT(user_id) AS userCount FROM $user_prefix"._users." WHERE user_regdate LIKE '$curDate2'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$userCount = $row[userCount];
//end

//Executing SQL Today
$sql = "SELECT COUNT(user_id) AS userCount FROM $user_prefix"._users." WHERE user_regdate LIKE '$curDateP'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$userCount2 = $row[userCount];
//end


However, the changes i made are i changed user_regdate from the phpNuke "pretty-print" ("MMM dd, YYYY) format to unixtime.


<?php

require_once("mainfile.php");
global $user_prefix,$db;

$months = array("abc","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

$result = $db->sql_query("SELECT user_id, username, user_regdate FROM ".$user_prefix."_users");

echo "Fetching information for ".$db->sql_numrows($result)." users...<br><br>";

while($row = $db->sql_fetchrow($result)) {
        $date = $row['user_regdate'];
        $tmp = explode(" ",$date);
        $day = substr($tmp[1],0,2);
        $month = $tmp[0];
        while($month_name = current($months)) {
                if($month_name == $month) {
                        $month = key($months);
                }
                next($months);
        }
        reset($months);
        $year = $tmp[2];
        $unixdate = mktime(0,0,0,$month,$day,$year);
        echo "Converting regdate for ".$row['username']."...";
        $result2 = $db->sql_query("UPDATE ".$user_prefix."_users SET user_regdate=".$unixdate." WHERE user_id=".$row['user_id']);
        if(!$result2) {
                echo "<font color=\"#ff0000\"><b>Error!</b></font><br>";
        }
        else {
                echo "<font color=\"#00ff00\"><b>Success!</b></font><br>";
        }
}

?>



How can i make the block update to search using unix time?

Thanks in advance

Regards

Vikas


Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.04 posts per day
Posts: 8089
Points: 494,430
   
Just change the unix time back before you do the query for users today and users yesterday.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: $Today = getdate(); - UserInfo Block
VikG
CZ Newbie
VikG has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: May 25, 2005
0.00 posts per day
Posts: 4
Points: 186
   
Interesting Idea. However, how would i do this?



Back to top Reply with quote
#4   
aUsTiN
CZ Active Member
usa.gif georgia.gif
Age: 41
Gender: Male
Website:
Status: Offline
Joined: Sep 09, 2003
0.02 posts per day
Posts: 142
Points: 57
  MSN Messenger 
$time_human = create_date($board_config['default_dateformat'], $unix_stamp_here, $board_config['board_timezone']);

That is a phpBB code, so as long as you have phpBB installed itll work. To change the date format, just change the first bit of the function to the format you need. You can simply change it to

date('Y-m-d');

or whatever format you need instead of $board_config['default_dateformat']



Back to top Reply with quote
#5   
VikG
CZ Newbie
VikG has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: May 25, 2005
0.00 posts per day
Posts: 4
Points: 186
   
Thanks,

I see what you mean, however, which file should i add the code you gave me. I dont know where i can edit the "$unix_stamp_here" as "$time_human" is not a function in the php i put above.

Please assist. Also, if possible could you add a modified script up so i can understand. Apologies if i sound rude, just not too good with php/sql.



Back to top Reply with quote
#6   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.04 posts per day
Posts: 8089
Points: 494,430
   
You would put it in the user block before the actual output.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
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
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum