2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-21 11:07:58 +00:00
* e107 website system
*
2012-06-13 04:58:43 +00:00
* Copyright ( C ) 2008 - 2012 e107 Inc ( e107 . org )
2008-12-21 11:07:58 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* User signup
*
2011-09-14 11:30:58 +00:00
* $URL $
* $Id $
*
*/
2006-12-02 04:36:16 +00:00
2008-12-21 22:17:05 +00:00
2006-12-02 04:36:16 +00:00
require_once ( " class2.php " );
2009-08-28 15:30:25 +00:00
2012-05-31 06:07:33 +00:00
2006-12-02 04:36:16 +00:00
$qs = explode ( " . " , e_QUERY );
2009-08-28 15:30:25 +00:00
2008-12-21 22:17:05 +00:00
if ( $qs [ 0 ] != 'activate' )
2008-06-13 20:20:23 +00:00
{ // multi-language fix.
2009-08-28 15:30:25 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE );
2008-12-28 22:37:43 +00:00
// include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_usersettings.php"); Shouldn't need this now
2006-12-02 04:36:16 +00:00
}
2009-08-28 15:30:25 +00:00
2008-12-21 11:07:58 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_user.php' ); // Generic user-related language defines
2008-12-21 22:17:05 +00:00
define ( 'SIGNUP_DEBUG' , FALSE );
2006-12-02 04:36:16 +00:00
2008-12-21 22:17:05 +00:00
include_once ( e_HANDLER . 'user_extended_class.php' );
2009-01-04 16:00:19 +00:00
$usere = new e107_user_extended ;
2008-12-21 22:17:05 +00:00
require_once ( e_HANDLER . 'calendar/calendar_class.php' );
2006-12-02 04:36:16 +00:00
$cal = new DHTML_Calendar ( true );
2008-12-21 22:17:05 +00:00
require_once ( e_HANDLER . 'validator_class.php' );
2009-11-22 14:10:09 +00:00
// require_once(e_HANDLER.'user_handler.php');
2010-10-26 07:41:20 +00:00
$userMethods = e107 :: getUserSession ();
2008-12-21 22:17:05 +00:00
$userMethods -> deleteExpired (); // Delete time-expired partial registrations
2006-12-02 04:36:16 +00:00
2010-02-10 21:53:56 +00:00
require_once ( e107 :: coreTemplatePath ( 'signup' )); //correct way to load a core template.
2006-12-02 04:36:16 +00:00
2012-05-31 06:07:33 +00:00
//include_once(e_CORE.'shortcodes/batch/signup_shortcodes.php');
$signup_shortcodes = e107 :: getScBatch ( 'signup' );
$facebook_shortcodes = e107 :: getScBatch ( 'facebook' , TRUE );
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$signup_imagecode = ( $pref [ 'signcode' ] && extension_loaded ( 'gd' ));
2008-06-13 20:20:23 +00:00
$text = '' ;
2008-12-29 09:31:36 +00:00
$extraErrors = array ();
$error = FALSE ;
2006-12-02 04:36:16 +00:00
2007-12-15 15:06:40 +00:00
2007-12-09 16:42:23 +00:00
//-------------------------------
2009-08-28 15:30:25 +00:00
// Resend Activation Email
2007-12-09 16:42:23 +00:00
//-------------------------------
2009-11-18 20:45:20 +00:00
if (( e_QUERY == 'resend' ) && ! USER && ( $pref [ 'user_reg_veri' ] == 1 ))
2006-12-02 04:36:16 +00:00
{
require_once ( HEADERF );
2008-12-21 22:17:05 +00:00
$clean_email = $tp -> toDB ( $_POST [ 'resend_email' ]);
if ( ! check_email ( $clean_email ))
2006-12-02 04:36:16 +00:00
{
$clean_email = " xxx " ;
}
2008-12-21 22:17:05 +00:00
$new_email = $tp -> toDB ( varset ( $_POST [ 'resend_newemail' ], '' ));
if ( ! check_email ( $new_email ))
2006-12-02 04:36:16 +00:00
{
$new_email = FALSE ;
}
if ( $_POST [ 'submit_resend' ])
2008-12-21 11:07:58 +00:00
{ // Action user's submitted information
// 'resend_email' - user name or email address actually used to sign up
// 'resend_newemail' - corrected email address
// 'resend_password' - password (required if changing email address)
2008-06-13 20:20:23 +00:00
2008-12-21 22:17:05 +00:00
if ( $_POST [ 'resend_email' ] && ! $new_email && $clean_email && $sql -> db_Select_gen ( " SELECT * FROM #user WHERE user_ban=0 AND user_sess='' AND (`user_loginname`= ' " . $clean_email . " ' OR `user_name` = ' " . $clean_email . " ' OR `user_email` = ' " . $clean_email . " ' ) " ))
2008-12-21 11:07:58 +00:00
{ // Account already activated
2006-12-02 04:36:16 +00:00
$ns -> tablerender ( LAN_SIGNUP_40 , LAN_SIGNUP_41 . " <br /> " );
require_once ( FOOTERF );
2011-04-12 21:11:16 +00:00
exit ();
2006-12-02 04:36:16 +00:00
}
2008-06-13 20:20:23 +00:00
2008-12-21 11:07:58 +00:00
// Start by looking up the user
2008-12-21 22:17:05 +00:00
if ( ! $sql -> db_Select ( " user " , " * " , " (`user_loginname` = ' " . $clean_email . " ' OR `user_name` = ' " . $clean_email . " ' OR `user_email` = ' " . $clean_email . " ' ) AND `user_ban`= " . USER_REGISTERED_NOT_VALIDATED . " AND `user_sess` !='' LIMIT 1 " ))
2006-12-02 04:36:16 +00:00
{
2008-12-21 11:07:58 +00:00
require_once ( e_HANDLER . " message_handler.php " );
2008-12-21 22:17:05 +00:00
message_handler ( " ALERT " , LAN_SIGNUP_64 . ': ' . $clean_email ); // email (or other info) not valid.
2011-04-12 21:11:16 +00:00
require_once ( FOOTERF );
exit ();
2008-12-21 11:07:58 +00:00
}
$row = $sql -> db_Fetch ();
// We should have a user record here
2009-08-28 15:30:25 +00:00
2008-12-21 11:07:58 +00:00
if ( trim ( $_POST [ 'resend_password' ]) != " " && $new_email )
{ // Need to change the email address - check password to make sure
2008-12-21 22:17:05 +00:00
if ( $userMethods -> CheckPassword ( $_POST [ 'resend_password' ], $row [ 'user_loginname' ], $row [ 'user_password' ]) === TRUE )
2008-12-21 11:07:58 +00:00
{
2011-04-12 21:11:16 +00:00
if ( $sql -> db_select ( 'user' , 'user_id, user_email' , " user_email=' " . $new_email . " ' " ))
{ // Email address already used by someone
require_once ( e_HANDLER . " message_handler.php " );
message_handler ( " ALERT " , LAN_SIGNUP_106 ); // Duplicate email
require_once ( FOOTERF );
exit ();
}
2008-12-21 11:07:58 +00:00
if ( $sql -> db_Update ( " user " , " user_email=' " . $new_email . " ' WHERE user_id = ' " . $row [ 'user_id' ] . " ' LIMIT 1 " ))
2006-12-02 04:36:16 +00:00
{
2008-12-21 11:07:58 +00:00
$row [ 'user_email' ] = $new_email ;
2006-12-02 04:36:16 +00:00
}
}
else
{
2008-12-21 11:07:58 +00:00
require_once ( e_HANDLER . " message_handler.php " );
message_handler ( " ALERT " , LAN_SIGNUP_52 ); // Incorrect Password.
2011-04-12 21:11:16 +00:00
require_once ( FOOTERF );
exit ();
2006-12-02 04:36:16 +00:00
}
}
2009-08-28 15:30:25 +00:00
2008-12-21 11:07:58 +00:00
// Now send the email - got some valid info
2008-12-21 22:17:05 +00:00
$row [ 'user_password' ] = 'xxxxxxx' ; // Don't know the real one
$eml = render_email ( $row );
2009-11-18 20:45:20 +00:00
$eml [ 'e107_header' ] = $row [ 'user_id' ];
require_once ( e_HANDLER . 'mail.php' );
$mailer = new e107Email ();
if ( ! $mailer -> sendEmail ( USEREMAIL , USERNAME , $eml , FALSE ))
2006-12-02 04:36:16 +00:00
2008-12-21 11:07:58 +00:00
$do_log [ 'signup_action' ] = LAN_SIGNUP_63 ;
if ( ! sendemail ( $row [ 'user_email' ], $eml [ 'subject' ], $eml [ 'message' ], $row [ 'user_name' ], " " , " " , $eml [ 'attachments' ], $eml [ 'cc' ], $eml [ 'bcc' ], $returnpath , $returnreceipt , $eml [ 'inline-images' ]))
{
2008-12-21 22:17:05 +00:00
$ns -> tablerender ( LAN_ERROR , LAN_SIGNUP_42 );
$do_log [ 'signup_result' ] = LAN_SIGNUP_62 ;
2008-12-21 11:07:58 +00:00
}
else
{
$ns -> tablerender ( LAN_SIGNUP_43 , LAN_SIGNUP_44 . " " . $row [ 'user_email' ] . " - " . LAN_SIGNUP_45 . " <br /><br /> " );
2008-12-21 22:17:05 +00:00
$do_log [ 'signup_result' ] = LAN_SIGNUP_61 ;
2008-12-21 11:07:58 +00:00
}
// Now log this (log will ignore if its disabled)
$admin_log -> user_audit ( USER_AUDIT_PW_RES , $do_log , $row [ 'user_id' ], $row [ 'user_name' ]);
require_once ( FOOTERF );
exit ;
}
2006-12-02 04:36:16 +00:00
elseif ( ! $_POST [ 'submit_resend' ])
2008-12-21 11:07:58 +00:00
{ // Display form to get info from user
2006-12-02 04:36:16 +00:00
$text .= " <div style='text-align:center'>
2010-01-30 21:27:31 +00:00
< form method = 'post' action = '".e_SELF."?resend' id = 'resend_form' >
2006-12-02 04:36:16 +00:00
< table style = '".USER_WIDTH."' class = 'fborder' >
< tr >
< td class = 'forumheader3' style = 'text-align:right' > " .LAN_SIGNUP_48. " </ td >
< td class = 'forumheader3' >
< input type = 'text' name = 'resend_email' class = 'tbox' size = '50' style = 'max-width:80%' value = '' maxlength = '80' />
</ td >
</ tr >
< tr >
< td class = 'forumheader3' colspan = '2' > " .LAN_SIGNUP_49. " </ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'text-align:right;width:30%' > " .LAN_SIGNUP_50. " </ td >
2010-02-11 22:12:09 +00:00
< td class = 'forumheader3' >< input type = 'text' name = 'resend_newemail' class = 'tbox' size = '50' style = 'max-width:80%' value = '' maxlength = '80' /></ td >
2006-12-02 04:36:16 +00:00
</ tr >
< tr >
< td class = 'forumheader3' style = 'text-align:right' > " .LAN_SIGNUP_51. " </ td >
2010-02-11 22:12:09 +00:00
< td class = 'forumheader3' >< input type = 'text' name = 'resend_password' class = 'tbox' size = '50' style = 'max-width:80%' value = '' maxlength = '80' /></ td >
2006-12-02 04:36:16 +00:00
</ tr >
" ;
$text .= " <tr style='vertical-align:top'>
< td colspan = '2' style = 'text-align:center' class = 'forumheader' > " ;
$text .= " <input class='button' type='submit' name='submit_resend' value= \" " . LAN_SIGNUP_47 . " \" /> " ; // resend activation email.
$text .= " </td>
</ tr >
</ table >
</ form >
</ div > " ;
$ns -> tablerender ( LAN_SIGNUP_47 , $text );
require_once ( FOOTERF );
exit ;
}
exit ;
}
// ------------------------------------------------------------------
2008-12-21 11:07:58 +00:00
if ( ! $_POST )
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
$error = '' ;
$text = ' ' ;
$password1 = '' ;
$password2 = '' ;
$email = '' ; // Used in shortcodes
$loginname = '' ;
$realname = '' ;
$image = '' ;
$avatar_upload = '' ;
$photo_upload = '' ;
$_POST [ 'ue' ] = '' ;
$signature = '' ;
2006-12-02 04:36:16 +00:00
}
2012-06-13 04:58:43 +00:00
2012-06-13 05:02:43 +00:00
2012-06-13 04:58:43 +00:00
2009-11-18 20:45:20 +00:00
if ( ADMIN && ( e_QUERY == 'preview' || e_QUERY == 'test' || e_QUERY == 'preview.aftersignup' ))
2006-12-02 04:36:16 +00:00
{
if ( e_QUERY == " preview.aftersignup " )
{
require_once ( HEADERF );
2009-03-21 22:59:29 +00:00
2009-03-22 21:07:33 +00:00
$allData [ 'data' ][ 'user_email' ] = " example@email.com " ;
$allData [ 'data' ][ 'user_loginname' ] = " user_loginname " ;
2009-03-21 22:59:29 +00:00
2009-03-22 21:07:33 +00:00
$after_signup = render_after_signup ( $error_message );
$ns -> tablerender ( $after_signup [ 'caption' ], $after_signup [ 'text' ]);
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
2008-12-21 22:17:05 +00:00
$temp = array ();
$eml = render_email ( $temp , TRUE ); // It ignores the data, anyway
2006-12-02 04:36:16 +00:00
echo $eml [ 'preview' ];
2009-11-18 20:45:20 +00:00
if ( e_QUERY == 'test' )
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
require_once ( e_HANDLER . 'mail.php' );
$mailer = new e107Email ();
if ( ! $mailer -> sendEmail ( USEREMAIL , USERNAME , $eml , FALSE ))
2006-12-02 04:36:16 +00:00
{
echo " <br /><br /><br /><br > >> " . LAN_SIGNUP_42 ; // there was a problem.
}
else
{
echo " <br /><br /> >> " . LAN_SIGNUP_43 . " [ " . USEREMAIL . " ] - " . LAN_SIGNUP_45 ;
}
}
exit ;
}
if ( $pref [ 'membersonly_enabled' ])
{
$HEADER = " <div style='text-align:center; width:100%;margin-left:auto;margin-right:auto;text-align:center'><div style='width:70%;text-align:center;margin-left:auto;margin-right:auto'><br /> " ;
if ( file_exists ( THEME . " images/login_logo.png " ))
{
2009-11-18 20:45:20 +00:00
$HEADER .= " <img src=' " . THEME_ABS . " images/login_logo.png' alt='' /> \n " ;
2006-12-02 04:36:16 +00:00
}
else
{
2009-11-18 20:45:20 +00:00
$HEADER .= " <img src=' " . e_IMAGE_ABS . " logo.png' alt='' /> \n " ;
2006-12-02 04:36:16 +00:00
}
2009-11-18 20:45:20 +00:00
$HEADER .= '<br />' ;
$FOOTER = '</div></div>' ;
2006-12-02 04:36:16 +00:00
}
if ( $signup_imagecode )
{
require_once ( e_HANDLER . " secure_img_handler.php " );
$sec_img = new secure_image ;
}
2009-11-22 23:36:23 +00:00
2012-05-31 06:07:33 +00:00
if (( USER || ( $pref [ 'user_reg' ] == 0 ) || ( vartrue ( $pref [ 'auth_method' ], 'e107' ) != 'e107' )) && ! getperms ( '0' ))
2010-02-10 21:53:56 +00:00
{
2012-05-31 06:07:33 +00:00
header ( 'location: ' . e_HTTP . 'index.php' );
}
if ( getperms ( '0' ))
{
//$mes = e107::getMessage();
//$mes->debug("You are currently logged in.");
$SIGNUP_BEGIN = " <div class='s-message' style='background-color:red;text-align:center;padding:30px;'> You are currently logged in.</div> " . $SIGNUP_BEGIN ;
2006-12-02 04:36:16 +00:00
}
2007-12-09 16:42:23 +00:00
//----------------------------------------
2009-08-28 15:30:25 +00:00
// After clicking the activation link
2007-12-09 16:42:23 +00:00
//----------------------------------------
2006-12-02 04:36:16 +00:00
if ( e_QUERY )
{
2009-11-18 20:45:20 +00:00
$qs = explode ( '.' , e_QUERY );
if ( $qs [ 0 ] == 'activate' && ( count ( $qs ) == 3 || count ( $qs ) == 4 ) && $qs [ 2 ])
2006-12-02 04:36:16 +00:00
{
2009-08-28 15:30:25 +00:00
//TODO use generic multilanguage selection
// return the message in the correct language.
2007-12-15 15:06:40 +00:00
if ( isset ( $qs [ 3 ]) && strlen ( $qs [ 3 ]) == 2 )
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
require_once ( e_HANDLER . 'language_class.php' );
2009-08-09 08:39:27 +00:00
$slng = new language ;
$the_language = $slng -> convert ( $qs [ 3 ]);
2009-08-28 15:30:25 +00:00
if ( is_readable ( e_LANGUAGEDIR . $the_language . '/lan_' . e_PAGE ))
2006-12-02 04:36:16 +00:00
{
2009-08-28 15:30:25 +00:00
include ( e_LANGUAGEDIR . $the_language . '/lan_' . e_PAGE );
2006-12-02 04:36:16 +00:00
}
else
{
2009-08-28 15:30:25 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE );
}
2006-12-02 04:36:16 +00:00
}
else
{
2009-08-28 15:30:25 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE );
2006-12-02 04:36:16 +00:00
}
$e107cache -> clear ( " online_menu_totals " );
if ( $sql -> db_Select ( " user " , " * " , " user_sess=' " . $tp -> toDB ( $qs [ 2 ], true ) . " ' " ))
{
2008-12-17 20:26:57 +00:00
if ( $row = $sql -> db_Fetch ())
2006-12-02 04:36:16 +00:00
{
2009-06-12 20:41:35 +00:00
$dbData = array ();
$dbData [ 'WHERE' ] = " user_sess=' " . $tp -> toDB ( $qs [ 2 ], true ) . " ' " ;
$dbData [ 'data' ] = array ( 'user_ban' => '0' , 'user_sess' => '' );
2008-12-17 20:26:57 +00:00
// Set initial classes, and any which the user can opt to join
2009-06-12 20:41:35 +00:00
if ( $userMethods -> userClassUpdate ( $row , 'userveri' ))
2008-12-17 20:26:57 +00:00
{
2009-06-12 20:41:35 +00:00
$dbData [ 'data' ][ 'user_class' ] = $row [ 'user_class' ];
2008-12-17 20:26:57 +00:00
}
2009-06-12 20:41:35 +00:00
$userMethods -> addNonDefaulted ( $dbData );
validatorClass :: addFieldTypes ( $userMethods -> userVettingInfo , $dbData );
$newID = $sql -> db_Update ( 'user' , $dbData );
if ( $newID === FALSE )
{
$admin_log -> e_log_event ( 10 , debug_backtrace (), 'USER' , 'Verification Fail' , print_r ( $row , TRUE ), FALSE , LOG_TO_ROLLING );
require_once ( HEADERF );
$ns -> tablerender ( LAN_SIGNUP_75 , LAN_SIGNUP_101 );
require_once ( FOOTERF );
exit ;
}
2008-12-17 20:26:57 +00:00
// Log to user audit log if enabled
$admin_log -> user_audit ( USER_AUDIT_EMAILACK , $row );
2009-06-12 20:41:35 +00:00
$e_event -> trigger ( 'userveri' , $row ); // Legacy event
$e_event -> trigger ( 'userfull' , $row ); // 'New' event
2009-01-04 16:00:19 +00:00
if ( varset ( $pref [ 'autologinpostsignup' ]))
{
require_once ( e_HANDLER . 'login.php' );
2011-09-14 11:30:58 +00:00
$usr = new userlogin ();
$usr -> login ( $row [ 'user_loginname' ], md5 ( $row [ 'user_name' ] . $row [ 'user_password' ] . $row [ 'user_join' ]), 'signup' , '' );
2009-01-04 16:00:19 +00:00
}
2008-12-17 20:26:57 +00:00
require_once ( HEADERF );
2008-12-21 22:17:05 +00:00
$text = LAN_SIGNUP_74 . " <a href='index.php'> " . LAN_SIGNUP_22 . " </a> " . LAN_SIGNUP_23 . " <br /> " . LAN_SIGNUP_24 . " " . SITENAME ;
$ns -> tablerender ( LAN_SIGNUP_75 , $text );
2008-12-17 20:26:57 +00:00
require_once ( FOOTERF );
exit ;
2006-12-02 04:36:16 +00:00
}
}
else
2007-12-09 16:42:23 +00:00
{ // Invalid activation code
2006-12-02 04:36:16 +00:00
header ( " location: " . e_BASE . " index.php " );
exit ;
}
}
}
2007-12-09 16:42:23 +00:00
//----------------------------------------
// Initial signup (registration)
//----------------------------------------
2012-06-13 04:58:43 +00:00
2006-12-02 04:36:16 +00:00
if ( isset ( $_POST [ 'register' ]))
2012-06-13 04:58:43 +00:00
{
2006-12-02 04:36:16 +00:00
$e107cache -> clear ( " online_menu_totals " );
require_once ( e_HANDLER . " message_handler.php " );
2010-09-07 17:03:30 +00:00
if ( isset ( $_POST [ 'rand_num' ]) && $signup_imagecode )
2012-06-13 04:58:43 +00:00
{
if ( $badCodeMsg = e107 :: getSecureImg () -> invalidCode ( $_POST [ 'rand_num' ], $_POST [ 'code_verify' ])) // better: allows class to return the error.
2006-12-02 04:36:16 +00:00
{
2012-06-13 04:58:43 +00:00
//$extraErrors[] = LAN_SIGNUP_3."\\n";
$extraErrors [] = $badCodeMsg . " \\ n " ;
2008-12-21 22:17:05 +00:00
$error = TRUE ;
2006-12-02 04:36:16 +00:00
}
}
2008-07-16 22:19:57 +00:00
if ( $invalid = $e_event -> trigger ( " usersup_veri " , $_POST ))
{
2008-12-29 09:31:36 +00:00
$extraErrors [] = $invalid . " \\ n " ;
2008-07-16 22:19:57 +00:00
$error = TRUE ;
}
2008-12-21 22:17:05 +00:00
if ( ! $error )
2006-12-02 04:36:16 +00:00
{
2008-12-21 22:17:05 +00:00
if ( varsettrue ( $pref [ 'predefinedLoginName' ]))
2006-12-02 04:36:16 +00:00
{
2008-12-21 22:17:05 +00:00
$_POST [ 'loginname' ] = $userMethods -> generateUserLogin ( $pref [ 'predefinedLoginName' ]);
2006-12-02 04:36:16 +00:00
}
2009-08-28 15:30:25 +00:00
2012-05-31 06:07:33 +00:00
if ( ! isset ( $_POST [ 'hideemail' ])) // For when it is disabled - default is to hide-email.
{
$_POST [ 'hideemail' ] = 1 ;
}
if ( ! isset ( $_POST [ 'email_confirm' ]))
{
$_POST [ 'email_confirm' ] = $_POST [ 'email' ];
}
2008-12-21 22:17:05 +00:00
// Use LoginName for DisplayName if restricted
if ( ! check_class ( $pref [ 'displayname_class' ], e_UC_PUBLIC . ',' . e_UC_MEMBER ))
2006-12-02 04:36:16 +00:00
{
2008-12-21 22:17:05 +00:00
$_POST [ 'username' ] = $_POST [ 'loginname' ];
2006-12-02 04:36:16 +00:00
}
2009-08-28 15:30:25 +00:00
2008-12-21 22:17:05 +00:00
// Now validate everything
$allData = validatorClass :: validateFields ( $_POST , $userMethods -> userVettingInfo , TRUE ); // Do basic validation
validatorClass :: checkMandatory ( 'user_name,user_loginname' , $allData ); // Check for missing fields (email done in userValidation() )
validatorClass :: dbValidateArray ( $allData , $userMethods -> userVettingInfo , 'user' , 0 ); // Do basic DB-related checks
$userMethods -> userValidation ( $allData ); // Do user-specific DB checks
2008-12-29 09:31:36 +00:00
if ( ! isset ( $allData [ 'errors' ][ 'user_password' ]))
{ // No errors in password - keep it outside the main data array
2009-01-11 21:06:52 +00:00
$savePassword = $allData [ 'data' ][ 'user_password' ];
unset ( $allData [ 'data' ][ 'user_password' ]); // Delete the password value in the output array
2007-12-09 16:42:23 +00:00
}
2008-12-28 22:37:43 +00:00
unset ( $_POST [ 'password1' ]); // Restrict the scope of this
unset ( $_POST [ 'password2' ]);
2009-08-28 15:30:25 +00:00
2012-01-02 22:06:22 +00:00
$allData [ 'user_ip' ] = e107 :: getIPHandler () -> getIP ( FALSE );
2009-08-28 15:30:25 +00:00
2009-11-18 20:45:20 +00:00
// check for multiple signups from the same IP address. But ignore localhost
2009-11-24 16:41:10 +00:00
if ( $allData [ 'user_ip' ] != e107 :: LOCALHOST_IP )
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
if ( $ipcount = $sql -> db_Select ( 'user' , '*' , " user_ip=' " . $allData [ 'user_ip' ] . " ' and user_ban !='2' " ))
2008-12-21 22:17:05 +00:00
{
2009-11-18 20:45:20 +00:00
if ( $ipcount >= $pref [ 'signup_maxip' ] && trim ( $pref [ 'signup_maxip' ]) != " " )
{
$allData [ 'errors' ][ 'user_email' ] = ERR_GENERIC ;
$allData [ 'errortext' ][ 'user_email' ] = LAN_SIGNUP_71 ;
2012-01-02 22:06:22 +00:00
$admin_log -> log_event ( 'USET_15' , LAN_SIGNUP_103 . e107 :: getIPHandler () -> getIP ( FALSE ), 4 );
2009-11-18 20:45:20 +00:00
}
2006-12-02 04:36:16 +00:00
}
2008-12-21 22:17:05 +00:00
}
2009-08-28 15:30:25 +00:00
2008-12-21 22:17:05 +00:00
// Email address confirmation.
if ( ! isset ( $allData [ 'errors' ][ 'user_email' ]))
{ // Obviously nothing wrong with the email address so far (or maybe its not required)
if ( $_POST [ 'email' ] != $_POST [ 'email_confirm' ])
2006-12-02 04:36:16 +00:00
{
2008-12-21 22:17:05 +00:00
$allData [ 'errors' ][ 'user_email' ] = ERR_GENERIC ;
$allData [ 'errortext' ][ 'user_email' ] = LAN_SIGNUP_38 ;
2009-01-11 21:06:52 +00:00
unset ( $allData [ 'data' ][ 'user_email' ]);
2008-12-21 22:17:05 +00:00
}
}
2009-08-28 15:30:25 +00:00
2008-12-21 22:17:05 +00:00
// Verify Custom Signup options if selected - need specific loop since the need for them is configuration-dependent
2008-12-28 22:37:43 +00:00
$signup_option_title = array ( LAN_USER_63 , LAN_USER_71 , LAN_USER_72 , LAN_USER_73 , LAN_USER_74 );
$signup_option_names = array ( 'realname' , 'signature' , 'image' , 'class' , 'customtitle' );
2009-08-28 15:30:25 +00:00
2008-12-21 22:17:05 +00:00
foreach ( $signup_option_names as $key => $value )
{
2009-01-11 21:06:52 +00:00
if ( $pref [ 'signup_option_' . $value ] == 2 && ! isset ( $alldata [ 'data' ][ 'user_' . $value ]) && ! isset ( $alldata [ 'errors' ][ 'user_' . $value ]))
2008-12-21 22:17:05 +00:00
{
$alldata [ 'errors' ][ 'user_' . $value ] = ERR_GENERIC ;
2008-12-28 22:37:43 +00:00
$alldata [ 'errortext' ][ 'user_' . $value ] = str_replace ( '--SOMETHING--' , $signup_option_title [ $key ], LAN_USER_75 );
2008-12-21 22:17:05 +00:00
}
}
2009-08-28 15:30:25 +00:00
2008-12-28 22:37:43 +00:00
// Validate Extended User Fields.
2008-12-21 22:17:05 +00:00
$eufVals = array ();
2012-06-02 14:36:22 +00:00
//if (isset($_POST['ue']))
2008-12-21 22:17:05 +00:00
{
2012-06-02 14:36:22 +00:00
$eufVals = $usere -> userExtendedValidateAll ( varset ( $_POST [ 'ue' ], array ()), varset ( $_POST [ 'hide' ], array ()), TRUE ); // Validate the extended user fields
2006-12-02 04:36:16 +00:00
}
2008-12-28 22:37:43 +00:00
// Determine whether we have an error
2008-12-29 09:31:36 +00:00
$error = (( isset ( $allData [ 'errors' ]) && count ( $allData [ 'errors' ])) || ( isset ( $eufVals [ 'errors' ]) && count ( $eufVals [ 'errors' ])) || count ( $extraErrors ));
2012-06-02 14:36:22 +00:00
2008-12-21 22:17:05 +00:00
// All validated here - handle any errors
2012-06-13 04:58:43 +00:00
if ( $error ) //FIXME - this ignores the errors caused by invalid image-code.
2008-12-21 22:17:05 +00:00
{
require_once ( e_HANDLER . " message_handler.php " );
2008-12-28 22:37:43 +00:00
$temp = array ();
2008-12-29 09:31:36 +00:00
if ( count ( $extraErrors ))
{
$temp [] = implode ( '<br />' , $extraErrors );
}
2008-12-28 22:37:43 +00:00
if ( count ( $allData [ 'errors' ]))
{
$temp [] = validatorClass :: makeErrorList ( $allData , 'USER_ERR_' , '%n - %x - %t: %v' , '<br />' , $userMethods -> userVettingInfo );
}
2012-06-02 14:36:22 +00:00
if ( varsettrue ( $eufVals [ 'errors' ]))
2008-12-28 22:37:43 +00:00
{
2012-06-02 14:36:22 +00:00
$temp [] = validatorClass :: makeErrorList ( $eufVals , 'USER_ERR_' , '%n - %t: %v' , '<br />' );
2008-12-28 22:37:43 +00:00
}
2012-06-02 14:36:22 +00:00
2008-12-28 22:37:43 +00:00
message_handler ( 'P_ALERT' , implode ( '<br />' , $temp ));
2008-12-21 22:17:05 +00:00
}
} // End of data validation
2012-06-13 04:58:43 +00:00
else
{
message_handler ( 'P_ALERT' , implode ( '<br />' , $extraErrors )); // Workaround for image-code errors.
}
2006-12-02 04:36:16 +00:00
2007-12-09 16:42:23 +00:00
// ========== End of verification.. ==============
// If no errors, we can enter the new member in the DB
2008-12-21 22:17:05 +00:00
// At this point we have two data arrays:
2009-01-11 21:06:52 +00:00
// $allData['data'] - the 'core' user data
// $eufVals['data'] - any extended user fields
2006-12-02 04:36:16 +00:00
if ( ! $error )
{
2008-12-29 09:31:36 +00:00
$error_message = '' ;
2006-12-02 04:36:16 +00:00
$fp = new floodprotect ;
if ( $fp -> flood ( " user " , " user_join " ) == FALSE )
{
header ( " location: " . e_BASE . " index.php " );
exit ;
}
2009-08-28 15:30:25 +00:00
if ( $_POST [ 'email' ] && $sql -> db_Select ( " user " , " * " , " user_email=' " . $_POST [ 'email' ] . " ' AND user_ban=' " . USER_BANNED . " ' " ))
2007-10-11 19:46:36 +00:00
{
2007-12-09 16:42:23 +00:00
exit ;
2006-12-02 04:36:16 +00:00
}
2008-12-28 22:37:43 +00:00
$u_key = md5 ( uniqid ( rand (), 1 )); // Key for signup completion
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_sess' ] = $u_key ; // Validation key
2008-12-21 22:17:05 +00:00
2009-06-12 20:41:35 +00:00
$userMethods -> userClassUpdate ( $allData [ 'data' ], 'usersup' );
2006-12-02 04:36:16 +00:00
2008-12-21 22:17:05 +00:00
if ( $pref [ 'user_reg_veri' ])
{
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_ban' ] = USER_REGISTERED_NOT_VALIDATED ;
2008-12-21 22:17:05 +00:00
}
else
{
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_ban' ] = USER_VALIDATED ;
2008-12-21 22:17:05 +00:00
}
// Work out data to be written to user audit trail
$signup_data = array ( 'user_name' , 'user_loginname' , 'user_email' , 'user_ip' );
2012-01-10 16:31:39 +00:00
// foreach (array() as $f)
foreach ( $signup_data as $f )
2008-12-21 22:17:05 +00:00
{
2009-01-11 21:06:52 +00:00
$signup_data [ $f ] = $allData [ 'data' ][ $f ]; // Just copy across selected fields
2008-12-21 22:17:05 +00:00
}
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_password' ] = $userMethods -> HashPassword ( $savePassword , $allData [ 'data' ][ 'user_loginname' ]);
2008-12-17 20:26:57 +00:00
if ( varsettrue ( $pref [ 'allowEmailLogin' ]))
{ // Need to create separate password for email login
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_prefs' ] = serialize ( array ( 'email_password' => $userMethods -> HashPassword ( $savePassword , $allData [ 'data' ][ 'user_email' ])));
2008-12-17 20:26:57 +00:00
}
2008-01-15 21:57:53 +00:00
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_join' ] = time ();
2012-01-10 16:31:39 +00:00
// The user_class, user_perms, user_prefs, user_realm fields don't have default value,
// so we put apropriate ones, otherwise - broken DB Insert
$allData [ 'data' ][ 'user_class' ] = '' ;
$allData [ 'data' ][ 'user_perms' ] = '' ;
$allData [ 'data' ][ 'user_prefs' ] = '' ;
$allData [ 'data' ][ 'user_realm' ] = '' ;
2008-12-21 22:17:05 +00:00
// Actually write data to DB
2009-01-11 21:06:52 +00:00
validatorClass :: addFieldTypes ( $userMethods -> userVettingInfo , $allData );
$nid = $sql -> db_Insert ( 'user' , $allData );
if ( isset ( $eufVals [ 'data' ]) && count ( $eufVals [ 'data' ]))
2008-12-21 22:17:05 +00:00
{
2009-01-11 21:06:52 +00:00
$usere -> addFieldTypes ( $eufVals ); // Add in the data types for storage
$eufVals [ 'WHERE' ] = '`user_extended_id` = ' . intval ( $nid );
//$usere->addDefaultFields($eufVals); // Add in defaults for anything not explicitly set (commented out for now - will slightly modify behaviour)
2008-12-21 22:17:05 +00:00
$sql -> db_Select_gen ( " INSERT INTO `#user_extended` (user_extended_id) values (' { $nid } ') " );
2009-01-11 21:06:52 +00:00
$sql -> db_Update ( 'user_extended' , $eufVals );
2008-12-21 22:17:05 +00:00
}
2009-01-11 21:06:52 +00:00
if ( SIGNUP_DEBUG ) $admin_log -> e_log_event ( 10 , debug_backtrace (), " DEBUG " , " Signup new user " , array_merge ( $allData [ 'data' ], $eufVals ) , FALSE , LOG_TO_ROLLING );
2008-01-15 21:57:53 +00:00
// Log to user audit log if enabled
2008-03-23 21:43:47 +00:00
$signup_data [ 'user_id' ] = $nid ;
2008-01-15 21:57:53 +00:00
$signup_data [ 'signup_key' ] = $u_key ;
2008-03-23 21:43:47 +00:00
$signup_data [ 'user_realname' ] = $tp -> toDB ( $_POST [ 'realname' ]);
2008-01-15 21:57:53 +00:00
$admin_log -> user_audit ( USER_AUDIT_SIGNUP , $signup_data );
2007-12-15 15:06:40 +00:00
2008-12-21 22:17:05 +00:00
if ( ! $nid )
2006-12-02 04:36:16 +00:00
{
require_once ( HEADERF );
$ns -> tablerender ( " " , LAN_SIGNUP_36 );
require_once ( FOOTERF );
}
2008-12-17 20:26:57 +00:00
$adviseLoginName = '' ;
2012-05-09 14:57:30 +00:00
if ( varsettrue ( $pref [ 'predefinedLoginName' ]) && ( integer ) $pref [ 'allowEmailLogin' ] === 0 )
2008-12-17 20:26:57 +00:00
{
2009-01-11 21:06:52 +00:00
$adviseLoginName = LAN_SIGNUP_65 . ': ' . $allData [ 'data' ][ 'user_loginname' ] . '<br />' . LAN_SIGNUP_66 . '<br />' ;
2008-12-17 20:26:57 +00:00
}
2008-06-13 20:20:23 +00:00
2006-12-02 04:36:16 +00:00
if ( $pref [ 'user_reg_veri' ])
2007-12-09 16:42:23 +00:00
{ // Verification required (may be by email or by admin)
2006-12-02 04:36:16 +00:00
// ========== Send Email =========>
2009-01-11 21:06:52 +00:00
if (( $pref [ 'user_reg_veri' ] != 2 ) && $allData [ 'data' ][ 'user_email' ]) // Don't send if email address blank - means that its not compulsory
2006-12-02 04:36:16 +00:00
{
2009-01-11 21:06:52 +00:00
$allData [ 'data' ][ 'user_id' ] = $nid ; // User ID
$allData [ 'data' ][ 'user_password' ] = $savePassword ; // Might need to send plaintext password in the email
$eml = render_email ( $allData [ 'data' ]);
2009-11-18 20:45:20 +00:00
$eml [ 'e107_header' ] = $eml [ 'userid' ];
require_once ( e_HANDLER . 'mail.php' );
$mailer = new e107Email ();
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
if ( ! $mailer -> sendEmail ( $allData [ 'data' ][ 'user_email' ], $allData [ 'data' ][ 'user_name' ], $eml , FALSE ))
2006-12-02 04:36:16 +00:00
{
$error_message = LAN_SIGNUP_42 ; // There was a problem, the registration mail was not sent, please contact the website administrator.
}
2009-11-18 20:45:20 +00:00
unset ( $allData [ 'data' ][ 'user_password' ]);
2006-12-02 04:36:16 +00:00
}
2009-06-12 20:41:35 +00:00
$e_event -> trigger ( 'usersup' , $_POST ); // Old trigger - send everything in the template, including extended fields.
$e_event -> trigger ( 'userpartial' , array_merge ( $allData [ 'data' ], $eufVals [ 'data' ])); // New trigger - send everything in the template, including extended fields.
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
2009-03-21 22:59:29 +00:00
2009-03-22 21:07:33 +00:00
$after_signup = render_after_signup ( $error_message );
$ns -> tablerender ( $after_signup [ 'caption' ], $after_signup [ 'text' ]);
2009-03-21 22:59:29 +00:00
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
else
2007-12-09 16:42:23 +00:00
{ // User can be signed up immediately
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
2009-01-11 21:06:52 +00:00
if ( ! $sql -> db_Select ( " user " , " user_id " , " user_loginname=' " . $allData [ 'data' ][ 'user_loginname' ] . " ' AND user_password=' " . $allData [ 'data' ][ 'user_password' ] . " ' " ))
2008-12-17 20:26:57 +00:00
{ // Error looking up newly created user
2006-12-02 04:36:16 +00:00
$ns -> tablerender ( " " , LAN_SIGNUP_36 );
require_once ( FOOTERF );
exit ;
}
2009-06-12 20:41:35 +00:00
$e_event -> trigger ( 'usersup' , $_POST ); // send everything in the template, including extended fields.
$e_event -> trigger ( 'userfull' , array_merge ( $allData [ 'data' ], $eufVals [ 'data' ])); // New trigger - send everything in the template, including extended fields.
2006-12-02 04:36:16 +00:00
2008-12-17 20:26:57 +00:00
if ( isset ( $pref [ 'signup_text_after' ]) && ( strlen ( $pref [ 'signup_text_after' ]) > 2 ))
2006-12-02 04:36:16 +00:00
{
2008-12-17 20:26:57 +00:00
$text = $tp -> toHTML ( str_replace ( '{NEWLOGINNAME}' , $loginname , $pref [ 'signup_text_after' ]), TRUE , 'parse_sc,defs' ) . " <br /> " ;
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-21 22:17:05 +00:00
$text = LAN_SIGNUP_76 . " " . SITENAME . " , " . LAN_SIGNUP_12 . " <br /><br /> " . LAN_SIGNUP_13 ;
2006-12-02 04:36:16 +00:00
}
$ns -> tablerender ( LAN_SIGNUP_8 , $text );
require_once ( FOOTERF );
exit ;
}
2008-12-21 22:17:05 +00:00
} // End - if (!$error)
else
{ // 'Recirculate' selected values so they are retained on the form when an error occurs
foreach ( array ( 'user_class' ) as $a )
{
2009-01-11 21:06:52 +00:00
$signupData [ $a ] = $tp -> toForm ( varset ( $allData [ 'data' ][ $a ], '' ));
2008-12-21 22:17:05 +00:00
}
2006-12-02 04:36:16 +00:00
}
}
2008-06-13 20:20:23 +00:00
// Disable the signup form - if either there was an error, or starting from scratch
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
$qs = ( $error ? " stage " : e_QUERY );
if ( $pref [ 'use_coppa' ] == 1 && strpos ( $qs , " stage " ) === FALSE )
{
$text = $tp -> parseTemplate ( $COPPA_TEMPLATE , TRUE , $signup_shortcodes );
2008-12-21 22:17:05 +00:00
$ns -> tablerender ( LAN_SIGNUP_78 , $text );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
2007-10-11 19:46:36 +00:00
if ( $qs == 'stage1' && $pref [ 'use_coppa' ] == 1 )
2006-12-02 04:36:16 +00:00
{
2007-10-11 19:46:36 +00:00
if ( isset ( $_POST [ 'newver' ]))
2006-12-02 04:36:16 +00:00
{
2007-10-11 19:46:36 +00:00
if ( ! varsettrue ( $_POST [ 'coppa' ]))
2006-12-02 04:36:16 +00:00
{
$text = $tp -> parseTemplate ( $COPPA_FAIL );
2008-12-21 22:17:05 +00:00
$ns -> tablerender ( LAN_SIGNUP_78 , $text );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
}
2007-10-11 19:46:36 +00:00
else
{
header ( 'Location: ' . e_BASE . 'signup.php' );
exit ;
}
2006-12-02 04:36:16 +00:00
}
require_once ( e_HANDLER . " form_handler.php " );
$rs = new form ;
$text = $tp -> parseTemplate ( $SIGNUP_BEGIN . $SIGNUP_BODY . $SIGNUP_END , TRUE , $signup_shortcodes );
2008-12-21 22:17:05 +00:00
$ns -> tablerender ( LAN_SIGNUP_79 , $text );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
2008-06-13 20:20:23 +00:00
//----------------------------------
2008-12-21 22:17:05 +00:00
// Function returns an image if a field is required.
2006-12-02 04:36:16 +00:00
function req ( $field )
{
return ( $field == 2 ? REQUIRED_FIELD_MARKER : " " );
}
2008-06-13 20:20:23 +00:00
//----------------------------------
2006-12-02 04:36:16 +00:00
function headerjs ()
{
$script_txt = "
< script type = \ " text/javascript \" >
function addtext3 ( sc ){
document . getElementById ( 'signupform' ) . image . value = sc ;
}
function addsig ( sc ){
document . getElementById ( 'signupform' ) . signature . value += sc ;
}
function help ( help ){
document . getElementById ( 'signupform' ) . helpb . value = help ;
}
</ script > \n " ;
global $cal ;
$script_txt .= $cal -> load_files ();
return $script_txt ;
}
2009-11-18 20:45:20 +00:00
/**
* Create email to send to user who just registered .
*
* @ param array $userInfo is the array of user - related DB variables
*
* @ return array of data for mailer - field names directly compatible
*/
2008-12-21 22:17:05 +00:00
function render_email ( $userInfo , $preview = FALSE )
2006-12-02 04:36:16 +00:00
{
// 1 = Body
// 2 = Subject
2008-12-21 22:17:05 +00:00
global $pref , $SIGNUPEMAIL_LINKSTYLE , $SIGNUPEMAIL_SUBJECT , $SIGNUPEMAIL_TEMPLATE ;
2006-12-02 04:36:16 +00:00
if ( $preview == TRUE )
{
2008-12-21 22:17:05 +00:00
$userInfo [ 'user_password' ] = " test-password " ;
$userInfo [ 'user_loginname' ] = " test-loginname " ;
$userInfo [ 'user_name' ] = " test-username " ;
2012-05-09 14:57:30 +00:00
$userInfo [ 'user_email' ] = " test-username@email " ;
2008-12-21 22:17:05 +00:00
$userInfo [ 'user_website' ] = " www.test-site.com " ; // This may not be defined
$userInfo [ 'user_id' ] = 0 ;
$userInfo [ 'user_sess' ] = " 1234567890ABCDEFGHIJKLMNOP " ;
2006-12-02 04:36:16 +00:00
}
2009-11-18 20:45:20 +00:00
define ( 'RETURNADDRESS' , ( substr ( SITEURL , - 1 ) == " / " ? SITEURL . " signup.php?activate. " . $userInfo [ 'user_id' ] . " . " . $userInfo [ 'user_sess' ] : SITEURL . " /signup.php?activate. " . $userInfo [ 'user_id' ] . " . " . $userInfo [ 'user_sess' ] . " . " . e_LAN ));
$pass_show = ( $pref [ 'user_reg_secureveri' ]) ? '*******' : $userInfo [ 'user_password' ];
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
if ( file_exists ( THEME . 'email_template.php' ))
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
require_once ( THEME . 'email_template.php' );
2006-12-02 04:36:16 +00:00
}
else
{
2009-11-18 20:45:20 +00:00
require_once ( e_THEME . 'templates/email_template.php' );
2006-12-02 04:36:16 +00:00
}
2009-11-18 20:45:20 +00:00
/* Inline images now handled automatically - just include in email template with an absolute link
$inlineImages = array ();
$inlineImages = explode ( " , " , $SIGNUPEMAIL_IMAGES );
if ( vartrue ( $SIGNUPEMAIL_BACKGROUNDIMAGE ))
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
$inlineImages [] = $SIGNUPEMAIL_BACKGROUNDIMAGE ;
2006-12-02 04:36:16 +00:00
}
2009-11-18 20:45:20 +00:00
if ( count ( $inlineImages )) { $ret [ 'mail_inline_images' ] = implode ( " , " , $inlineImages ); }
*/
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$ret [ 'mail_recipient_id' ] = $userInfo [ 'user_id' ];
if ( vartrue ( $SIGNUPEMAIL_CC )) { $ret [ 'mail_copy_to' ] = $SIGNUPEMAIL_CC ; }
if ( vartrue ( $SIGNUPEMAIL_BCC )) { $ret [ 'mail_bcopy_to' ] = $SIGNUPEMAIL_BCC ; }
if ( vartrue ( $SIGNUPEMAIL_ATTACHMENTS )) { $ret [ 'mail_attach' ] = $SIGNUPEMAIL_ATTACHMENTS ; }
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$style = ( $SIGNUPEMAIL_LINKSTYLE ) ? " style=' { $SIGNUPEMAIL_LINKSTYLE } ' " : " " ;
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$search [ 0 ] = '{LOGINNAME}' ;
2012-05-09 14:57:30 +00:00
$replace [ 0 ] = intval ( $pref [ 'allowEmailLogin' ]) === 0 ? $userInfo [ 'user_loginname' ] : $userInfo [ 'user_email' ];
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$search [ 1 ] = '{PASSWORD}' ;
2006-12-02 04:36:16 +00:00
$replace [ 1 ] = $pass_show ;
2009-11-18 20:45:20 +00:00
$search [ 2 ] = '{ACTIVATION_LINK}' ;
2008-12-21 22:17:05 +00:00
$replace [ 2 ] = " <a href=' " . RETURNADDRESS . " ' { $style } > " . RETURNADDRESS . " </a> " ;
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$search [ 3 ] = '{SITENAME}' ;
2006-12-02 04:36:16 +00:00
$replace [ 3 ] = SITENAME ;
2009-11-18 20:45:20 +00:00
$search [ 4 ] = '{SITEURL}' ;
2008-12-21 22:17:05 +00:00
$replace [ 4 ] = " <a href=' " . SITEURL . " ' { $style } > " . SITEURL . " </a> " ;
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$search [ 5 ] = '{USERNAME}' ;
2008-12-21 22:17:05 +00:00
$replace [ 5 ] = $userInfo [ 'user_name' ];
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
$search [ 6 ] = '{USERURL}' ;
2008-12-21 22:17:05 +00:00
$replace [ 6 ] = varsettrue ( $userInfo [ 'user_website' ]) ? $userInfo [ 'user_website' ] : " " ;
2006-12-02 04:36:16 +00:00
2009-11-18 20:45:20 +00:00
/* Inline images now handled automatically - just include in email template with an absolute link
2006-12-02 04:36:16 +00:00
$cnt = 1 ;
2009-11-18 20:45:20 +00:00
foreach ( $inlineImages as $img )
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
if ( is_readable ( $inlineImages [ $cnt - 1 ]))
2006-12-02 04:36:16 +00:00
{
$cid_search [] = " { IMAGE " . $cnt . " } " ;
2009-11-18 20:45:20 +00:00
$cid_replace [] = " <img alt= \" " . SITENAME . " \" src='cid: " . md5 ( $inlineImages [ $cnt - 1 ]) . " ' /> \n " ;
2006-12-02 04:36:16 +00:00
$path_search [] = " { IMAGE " . $cnt . " } " ;
2009-11-18 20:45:20 +00:00
$path_replace [] = " <img alt= \" " . SITENAME . " \" src= \" " . $inlineImages [ $cnt - 1 ] . " \" /> \n " ;
2006-12-02 04:36:16 +00:00
}
$cnt ++ ;
}
2009-11-18 20:45:20 +00:00
*/
2006-12-02 04:36:16 +00:00
$subject = str_replace ( $search , $replace , $SIGNUPEMAIL_SUBJECT );
2009-11-18 20:45:20 +00:00
$ret [ 'mail_subject' ] = $subject ;
$ret [ 'send_html' ] = TRUE ;
2006-12-02 04:36:16 +00:00
$HEAD = " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.1//EN \" \" http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd \" > \n " ;
$HEAD .= " <html xmlns='http://www.w3.org/1999/xhtml' > \n " ;
$HEAD .= " <head><meta http-equiv='content-type' content='text/html; charset=utf-8' /> \n " ;
$HEAD .= ( $SIGNUPEMAIL_USETHEME == 1 ) ? " <link rel= \" stylesheet \" href= \" " . SITEURL . THEME . " style.css \" type= \" text/css \" /> \n " : " " ;
2007-06-28 19:38:15 +00:00
$HEAD .= ( $preview ) ? " <title> " . LAN_SIGNUP_58 . " </title> \n " : " " ;
2006-12-02 04:36:16 +00:00
if ( $SIGNUPEMAIL_USETHEME == 2 )
{
$CSS = file_get_contents ( THEME . " style.css " );
$HEAD .= " <style> \n " . $CSS . " \n </style> " ;
}
$HEAD .= " </head> \n " ;
2009-11-18 20:45:20 +00:00
if ( vartrue ( $SIGNUPEMAIL_BACKGROUNDIMAGE ))
2006-12-02 04:36:16 +00:00
{
2009-11-18 20:45:20 +00:00
$HEAD .= " <body background= \" " . $SIGNUPEMAIL_BACKGROUNDIMAGE . " \" > \n " ;
2006-12-02 04:36:16 +00:00
}
else
{
$HEAD .= " <body> \n " ;
}
$FOOT = " \n </body> \n </html> \n " ;
2009-11-18 20:45:20 +00:00
$ret [ 'mail_body' ] = str_replace ( $search , $replace , $HEAD . $SIGNUPEMAIL_TEMPLATE . $FOOT );
$ret [ 'preview' ] = $ret [ 'mail_body' ]; // Non-standard field
2006-12-02 04:36:16 +00:00
return $ret ;
}
2009-03-22 21:07:33 +00:00
2009-11-18 20:45:20 +00:00
2009-03-22 21:07:33 +00:00
function render_after_signup ( $error_message )
{
global $pref , $allData , $adviseLoginName , $tp ;
$srch = array ( " [sitename] " , " [email] " , " { NEWLOGINNAME} " , " { EMAIL} " );
$repl = array ( SITENAME , " <b> " . $allData [ 'data' ][ 'user_email' ] . " </b> " , $allData [ 'data' ][ 'user_loginname' ], $allData [ 'data' ][ 'user_email' ]);
if ( isset ( $pref [ 'signup_text_after' ]) && ( strlen ( $pref [ 'signup_text_after' ]) > 2 ))
{
2009-07-08 01:28:55 +00:00
$text = str_replace ( $srch , $repl , $tp -> toHTML ( $pref [ 'signup_text_after' ], TRUE , 'parse_sc,defs' )) . " <br /> " ;
// keep str_replace() outside of toHTML to allow for search/replace of dynamic terms within 'defs'.
2009-03-22 21:07:33 +00:00
}
else
{
$text = ( $pref [ 'user_reg_veri' ] == 2 ) ? LAN_SIGNUP_37 : str_replace ( $srch , $repl , LAN_SIGNUP_72 );
$text .= " <br /><br /> " . $adviseLoginName ;
}
$caption_arr = array ();
$caption_arr [ 0 ] = LAN_SIGNUP_73 ; // Thank you! (No Approval).
$caption_arr [ 1 ] = LAN_SIGNUP_98 ; // Confirm Email (Email Confirmation)
$caption_arr [ 2 ] = LAN_SIGNUP_100 ; // Approval Pending (Admin Approval)
$caption = $caption_arr [ $pref [ 'user_reg_veri' ]];
if ( $error_message )
{
$text = " <br /><b> " . $error_message . " </b><br /> " ; // Just display the error message
$caption = LAN_SIGNUP_99 ; // Problem Detected
}
$ret [ 'text' ] = $text ;
$ret [ 'caption' ] = $caption ;
return $ret ;
}
2008-07-16 22:19:57 +00:00
?>