Registration Date is incorrect..

Solutions for other frequently encountered problems with running phpBB.

Moderator: Moderators

Registration Date is incorrect..

Postby UseLess on Fri Mar 24, 2006 12:50 am

Greetings,

To change the registration date of a user use the following little script, the script should be downloaded from here and saved as a PHP file (it should automatically be given the filename of 'update_regdate.php' but if not give the file a suitable name) and then uploaded to the root of your forum and then run it.

You run the file like so;

Code: Select all
http://www.yourdomain.com/path_to_forum/update_regdate.php?id=2&day=1&month=1&year=2006


where:

- id = the user id for the user you want to update the registration date for
- day = the day of the month
- month = the month of the year
- year = the year

Note: No checks are done on the user id or the date so an invalid day, month or year could produce unexpected results

[code filename="update_regdate.php"]<?php
/*
filename: update_regdate.php

author: UseLess

version: 1.0.2
*/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

if( $userdata['user_level'] != ADMIN )
{
message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}

// extract the user id from the URL
$user_id = ( isset($_GET['id']) ? intval($_GET['id']) : 0);

// extract the day, month and year from the URL
$the_day = ( isset($_GET['day']) ? intval($_GET['day']) : 0);
$the_month = ( isset($_GET['month']) ? intval($_GET['month']) : 0);
$the_year = ( isset($_GET['year']) ? intval($_GET['year']) : 0);

$the_hour = 0;
$the_minute = 0;
$the_second = 0;

if( $user_id != 0 && $the_day != 0 && $the_month != 0 && $the_year != 0 )
{
// create the unix timestamp
$the_date = mktime($the_hour, $the_minute, $the_second, $the_month, $the_day, $the_year);

// update the users table
$sql = "UPDATE " . USERS_TABLE . " SET user_regdate = " . $the_date . " WHERE user_id = " . $user_id;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not set user reg date.', '', __LINE__, __FILE__, $sql);
}

message_die(GENERAL_MESSAGE, 'Updated reg date for user: ' . $user_id . '<br /><br />Set date to: <b>' . $the_date . '</b> which is: ' . create_date($lang['DATE_FORMAT'], $the_date, $board_config['board_timezone']));
}
else
{
message_die(GENERAL_MESSAGE, 'One of the following happened:<br /><ul><li>no user id was supplied</li><li>no day of the month was supplied</li><li>no month of the year was supplied</li><li>no year was supplied</li></ul><br />You use the file like so:<br /><br />http://www.yourdomain.com/path_to_forum/update_regdate.php?id=2&day=1&month=1&year=2006<br /><br />which would give you a registration date for user 2 of 1 January 2006');
}

?>[/code]
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Return to Common Problems

Who is online

Users browsing this forum: No registered users and 1 guest

cron