12 if ( !isset($_GET[
'code']) ){
15 df_translate(
'actions.activate.MESSAGE_MISSING_CODE_PARAMETER',
16 'The code parameter is missing from your request. Validation cannot take place. Please check your url and try again.'
26 if ( isset($_SESSION[
'--redirect']) ) $url = $_SESSION[
'--redirect'];
27 else if ( isset($_SESSION[
'-redirect']) ) $url = $_SESSION[
'-redirect'];
28 else if ( isset($_REQUEST[
'--redirect']) ) $url = $_REQUEST[
'--redirect'];
29 else if ( isset($_REQUEST[
'-redirect']) ) $url = $_REQUEST[
'-redirect'];
30 else $url =
$app->url(
'-action='.
$app->_conf[
'default_action']);
34 $time_limit = 24*60*60;
35 if ( isset($params[
'time_limit']) ){
36 $time_limit = intval($params[
'time_limit']);
40 "delete from dataface__registrations
41 where registration_date < '".addslashes(date(
'Y-m-d H:i:s', time()-$time_limit)).
"'",
45 error_log(mysql_error(df_db()));
46 throw new Exception(
"Failed to delete registrations due to an SQL error. See error log for details.", E_USER_ERROR);
53 "select registration_data from dataface__registrations
54 where registration_code = '".addslashes($_GET[
'code']).
"'",
59 error_log(mysql_error(df_db()));
60 throw new Exception(
"Failed to load registration information due to an SQL error. See error log for details.", E_USER_ERROR);
64 if ( mysql_num_rows($res) == 0 ){
69 'actions.activate.MESSAGE_REGISTRATION_NOT_FOUND',
70 'No registration information could be found to match this code. Please try registering again.'
72 $app->redirect($url.
'&--msg='.urlencode($msg));
79 list($raw_data) = mysql_fetch_row($res);
80 $values = unserialize($raw_data);
81 $appdel =
$app->getDelegate();
82 if ( isset($appdel) and method_exists($appdel,
'validateRegistrationForm') ){
83 $res = $appdel->validateRegistrationForm($values);
85 $msg = $res->getMessage();
86 $app->redirect($url.
'&--msg='.urlencode($msg));
89 $res = mysql_query(
"select count(*) from
90 `".str_replace(
'`',
'',
$app->_conf[
'_auth'][
'users_table']).
"`
91 where `".str_replace(
'`',
'',
$app->_conf[
'_auth'][
'username_column']).
"` = '".addslashes($values[
$app->_conf[
'_auth'][
'username_column']]).
"'
94 error_log(mysql_error(df_db()));
95 throw new Exception(
"Failed to find user records due to an SQL error. See error log for details.", E_USER_ERROR);
98 list($num) = mysql_fetch_row($res);
101 'actions.activate.MESSAGE_DUPLICATE_USER',
102 'Registration failed because a user already exists by that name. Try registering again with a different name.'
104 $app->redirect($url.
'&--msg='.urlencode($msg));
111 $record->setValues($values);
112 $res = $record->save();
114 $app->redirect($url.
'&--msg='.urlencode($res->getMessage()));
117 "delete from dataface__registrations
118 where registration_code = '".addslashes($_GET[
'code']).
"'",
123 error_log(mysql_error(df_db()));
124 throw new Exception(
"Failed to clean up old registrations due to an SQL error. See error log for details.", E_USER_ERROR);
128 'actions.activate.MESSAGE_REGISTRATION_COMPLETE',
129 'Registration complete. You are now logged in.');
130 $_SESSION[
'UserName'] = $record->strval(
$app->_conf[
'_auth'][
'username_column']);
133 import(
'Dataface/Utilities.php');
137 $app->redirect($url.
'&--msg='.urlencode($msg));