| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | require_once( './inc/header.inc.php' );
|
|---|
| 4 | require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' );
|
|---|
| 5 | require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
|
|---|
| 6 | require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolProfileFields.php' );
|
|---|
| 7 | require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolProfilesController.php' );
|
|---|
| 8 | require_once( BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/scripts/BxTemplFormView.php" );
|
|---|
| 9 |
|
|---|
| 10 | //aa blya join nah!
|
|---|
| 11 |
|
|---|
| 12 | $_page['name_index'] = 3;
|
|---|
| 13 | $_page['css_name'] = 'join.css';
|
|---|
| 14 | $_page['extra_js'] .= '<script type="text/javascript" language="JavaScript" src="' . $site['plugins'] . 'jquery/ui.datepicker.js"></script>';
|
|---|
| 15 | $_page['extra_js'] .= '<script type="text/javascript" language="JavaScript" src="' . $site['plugins'] . 'jquery/jquery.form.js"></script>';
|
|---|
| 16 | $_page['extra_js'] .= '<script type="text/javascript" language="JavaScript" src="inc/js/join.js"></script>';
|
|---|
| 17 |
|
|---|
| 18 | //init datepicker
|
|---|
| 19 | $iMinAge = (int)getParam( 'search_start_age' );
|
|---|
| 20 | $iMaxAge = (int)getParam( 'search_end_age' );
|
|---|
| 21 | $iCurYear = (int)date('Y');
|
|---|
| 22 | $iMinYear = $iCurYear - $iMaxAge - 1;
|
|---|
| 23 | $iMaxYear = $iCurYear - $iMinAge;
|
|---|
| 24 |
|
|---|
| 25 | $iSelectedRel = ceil( $iMinAge * 365.25 ); //get relative days number for default date
|
|---|
| 26 |
|
|---|
| 27 | $sDatepickerInit = $oTemplConfig -> customize['join']['datepickerInit'];
|
|---|
| 28 |
|
|---|
| 29 | $sDatepickerInit = str_replace( '{min_year}', $iMinYear, $sDatepickerInit );
|
|---|
| 30 | $sDatepickerInit = str_replace( '{max_year}', $iMaxYear, $sDatepickerInit );
|
|---|
| 31 | $sDatepickerInit = str_replace( '{dfl_days}', $iSelectedRel, $sDatepickerInit );
|
|---|
| 32 |
|
|---|
| 33 | $_page['extra_js'] .= '
|
|---|
| 34 | <script type="text/javascript" language="JavaScript">
|
|---|
| 35 | $( document ).ready( function(){
|
|---|
| 36 | ' . $sDatepickerInit . '
|
|---|
| 37 | } );
|
|---|
| 38 | </script>';
|
|---|
| 39 |
|
|---|
| 40 | check_logged();
|
|---|
| 41 |
|
|---|
| 42 | $_page['header'] = _t( '_JOIN_H' );
|
|---|
| 43 | $_page['header_text'] = _t( '_JOIN_H' );
|
|---|
| 44 |
|
|---|
| 45 | if( $logged['member'] )
|
|---|
| 46 | {
|
|---|
| 47 | $_page['name_index'] = 0;
|
|---|
| 48 | $_page_cont[0]['page_main_code'] = _t( '_Sorry, you\'re already joined' );
|
|---|
| 49 | PageCode();
|
|---|
| 50 | exit;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | if ( getParam('reg_by_inv_only') == 'on' && getID($_COOKIE['idFriend'])==0 ) {
|
|---|
| 54 | $_page['name_index'] = 0;
|
|---|
| 55 | $_page_cont[0]['page_main_code'] = MsgBox(_t('registration by invitation only'));
|
|---|
| 56 | PageCode();
|
|---|
| 57 | exit;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | $oJoinProc = new BxDolJoinProcessor();
|
|---|
| 61 |
|
|---|
| 62 | $_ni = $_page['name_index'];
|
|---|
| 63 | $_page_cont[$_ni]['page_main_code'] = $oJoinProc -> process();
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | PageCode();
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | class BxDolJoinProcessor {
|
|---|
| 72 |
|
|---|
| 73 | var $oPF; //profile fields
|
|---|
| 74 | var $iPage; //currently shown page
|
|---|
| 75 | var $aPages; //available pages
|
|---|
| 76 | var $aValues; //inputted values
|
|---|
| 77 | var $aErrors; //errors generated on page
|
|---|
| 78 | var $bAjaxMode; // defines if the script were requested by ajax
|
|---|
| 79 |
|
|---|
| 80 | var $bCoupleEnabled;
|
|---|
| 81 | var $aCoupleMutualItems;
|
|---|
| 82 | var $bCouple;
|
|---|
| 83 |
|
|---|
| 84 | function BxDolJoinProcessor() {
|
|---|
| 85 | $this -> aValues = array( 0 => array(), 1 => array() ); // double arrays (for couples)
|
|---|
| 86 | $this -> aErrors = array( 0 => array(), 1 => array() );
|
|---|
| 87 |
|
|---|
| 88 | /* @var $this->oPF BxDolProfileFields */
|
|---|
| 89 | $this -> oPF = new BxDolProfileFields(1);
|
|---|
| 90 |
|
|---|
| 91 | $this -> bAjaxMode = ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' );
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | function process() {
|
|---|
| 95 | if( !$this -> oPF -> aArea )
|
|---|
| 96 | return 'Profile Fields cache not loaded. Cannot continue.';
|
|---|
| 97 |
|
|---|
| 98 | $this -> aPages = array_keys( $this -> oPF -> aArea );
|
|---|
| 99 |
|
|---|
| 100 | $this -> iPage = ( isset( $_POST['join_page'] ) ) ? $_POST['join_page'] : 0; // get current working page from POST
|
|---|
| 101 |
|
|---|
| 102 | if( $this -> iPage !== 'done' )
|
|---|
| 103 | $this -> iPage = (int)$this -> iPage;
|
|---|
| 104 |
|
|---|
| 105 | $this -> getCoupleOptions();
|
|---|
| 106 |
|
|---|
| 107 | $this -> processPostValues();
|
|---|
| 108 |
|
|---|
| 109 | if( $this -> bAjaxMode ) {
|
|---|
| 110 | $this -> showErrorsJson();
|
|---|
| 111 | exit;
|
|---|
| 112 | } else {
|
|---|
| 113 | ob_start();
|
|---|
| 114 |
|
|---|
| 115 | if( $this -> iPage === 'done' ) { //if all pages are finished and no errors found
|
|---|
| 116 | list( $iMemID, $sStatus ) = $this -> registerMember();
|
|---|
| 117 |
|
|---|
| 118 | if( !$iMemID )
|
|---|
| 119 | $this -> showFailPage();
|
|---|
| 120 | else
|
|---|
| 121 | $this -> showFinishPage( $iMemID, $sStatus );
|
|---|
| 122 | } else
|
|---|
| 123 | $this -> showJoinForm();
|
|---|
| 124 |
|
|---|
| 125 | return ob_get_clean();
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | function getCoupleOptions() {
|
|---|
| 130 | //find Couple item
|
|---|
| 131 | $aCoupleItem = false;
|
|---|
| 132 | foreach ($this -> aPages as $iPageInd => $iPage) { //cycle pages
|
|---|
| 133 | $aBlocks = $this -> oPF -> aArea[ $iPage ];
|
|---|
| 134 | foreach ($aBlocks as $iBlockID => $aBlock) { //cycle blocks
|
|---|
| 135 | $aItems = $aBlock['Items'];
|
|---|
| 136 | foreach ($aItems as $iItemID => $aItem) { //cycle items
|
|---|
| 137 | if( $aItem['Name'] == 'Couple' ) { // we found it!
|
|---|
| 138 | $aCoupleItem = $aItem;
|
|---|
| 139 | break;
|
|---|
| 140 | }
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | if( $aCoupleItem ) // we already found it
|
|---|
| 144 | break;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | if( $aCoupleItem ) // we already found it
|
|---|
| 148 | break;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | if( $aCoupleItem ) {
|
|---|
| 152 | $this -> bCoupleEnabled = true;
|
|---|
| 153 | $this -> bCouple = ( isset( $_REQUEST['Couple'] ) and $_REQUEST['Couple'] == 'yes' ) ? true : false;
|
|---|
| 154 | } else {
|
|---|
| 155 | $this -> bCoupleEnabled = false;
|
|---|
| 156 | $this -> bCouple = false;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | $this -> aCoupleMutualItems = $this -> oPF -> getCoupleMutualFields();
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | function processPostValues() {
|
|---|
| 163 |
|
|---|
| 164 | foreach ($this -> aPages as $iPage) { //cycle pages
|
|---|
| 165 |
|
|---|
| 166 | if( $this -> iPage !== 'done' and $iPage >= $this -> iPage ) {
|
|---|
| 167 | $this -> iPage = $iPage; // we are on the current page. dont process these values, dont go further, just show form.
|
|---|
| 168 | break;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | // process post values by Profile Fields class
|
|---|
| 172 | $this -> oPF -> processPostValues( $this -> bCouple, $this -> aValues, $this ->aErrors, $iPage );
|
|---|
| 173 |
|
|---|
| 174 | if( !empty( $this -> aErrors[0] ) or ( $this -> bCouple and !empty( $this -> aErrors[1] ) ) ) { //we found errors on previous page
|
|---|
| 175 | // do not process further values, just go to erroneous page.
|
|---|
| 176 | $this -> iPage = $iPage;
|
|---|
| 177 | break;
|
|---|
| 178 | }
|
|---|
| 179 | }
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | function showErrorsJson() {
|
|---|
| 183 | header('Content-Type:text/javascript');
|
|---|
| 184 |
|
|---|
| 185 | echo $this -> oPF -> genJsonErrors( $this -> aErrors, $this -> bCouple );
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | function showJoinForm() {
|
|---|
| 189 |
|
|---|
| 190 | //echoDbg( $this -> aValues );exit;
|
|---|
| 191 |
|
|---|
| 192 | $aFormAttrs = array(
|
|---|
| 193 | 'id' => 'join_form',
|
|---|
| 194 | 'onsubmit' => 'return validateJoinForm(this);'
|
|---|
| 195 | );
|
|---|
| 196 |
|
|---|
| 197 | $aTableAttrs = array(
|
|---|
| 198 | 'id' => 'join_form_table'
|
|---|
| 199 | );
|
|---|
| 200 |
|
|---|
| 201 | $aFormParams = array(
|
|---|
| 202 | 'hidden' => $this -> genHiddenFieldsArray()
|
|---|
| 203 | );
|
|---|
| 204 |
|
|---|
| 205 | $aTableParams = array(
|
|---|
| 206 | 'double' => $this ->bCoupleEnabled,
|
|---|
| 207 | 'second_enabled' => $this -> bCouple
|
|---|
| 208 | );
|
|---|
| 209 |
|
|---|
| 210 | $aTableParams['headers'] = array( '', _t( '_First Person' ), _t( '_Second Person' ) );
|
|---|
| 211 | $aTableParams['headers_add'] = 'class="header form_second_col"' . ( $this -> bCouple ? '' : ' style="display: none;"' );
|
|---|
| 212 |
|
|---|
| 213 | $aButtons = array(
|
|---|
| 214 | array(
|
|---|
| 215 | 'type' => 'submit',
|
|---|
| 216 | 'value' => _t( '_Submit' ),
|
|---|
| 217 | 'class' => 'input_submit'
|
|---|
| 218 | )
|
|---|
| 219 | );
|
|---|
| 220 |
|
|---|
| 221 | /* @var $oForm BxTemplFormView */
|
|---|
| 222 | $oForm = new BxTemplFormView( 'join_form' );
|
|---|
| 223 | $oForm -> begin( $aFormAttrs, $aTableAttrs, $aFormParams, $aTableParams );
|
|---|
| 224 |
|
|---|
| 225 | $aBlocks = $this -> oPF -> aArea[ $this -> iPage ];
|
|---|
| 226 | foreach( $aBlocks as $aBlock ) {
|
|---|
| 227 | $oForm -> beginBlock( _t( $aBlock['Caption'] ) );
|
|---|
| 228 |
|
|---|
| 229 | foreach( $aBlock['Items'] as $aItem ) {
|
|---|
| 230 |
|
|---|
| 231 | $aCol0 = array();
|
|---|
| 232 |
|
|---|
| 233 | $aCol0['Type'] = $aItem['Type'];
|
|---|
| 234 | $aCol0['Name'] = ( $aItem['Type'] == 'system' ) ? $aItem['Name'] : ( $aItem['Name'] . '[0]' );
|
|---|
| 235 | $aCol0['Mandatory'] = $aItem['Mandatory'];
|
|---|
| 236 | $aCol0['Control'] = $aItem['Control'];
|
|---|
| 237 | $aCol0['Values'] = $aItem['Values'];
|
|---|
| 238 | $aCol0['UseLKey'] = $aItem['UseLKey'];
|
|---|
| 239 |
|
|---|
| 240 | $aCol0['Caption'] = _t( $aItem['Caption'] );
|
|---|
| 241 | $aCol0['Desc'] = _t( $aItem['Desc'], $aItem['Min'], $aItem['Max'] );
|
|---|
| 242 | if( $aCol0['Desc'] == $aItem['Desc'] )
|
|---|
| 243 | $aCol0['Desc'] = '';
|
|---|
| 244 |
|
|---|
| 245 | // set value
|
|---|
| 246 | if( isset( $this -> aValues[0][ $aItem['Name'] ] ) )
|
|---|
| 247 | $aCol0['Value'] = $this -> aValues[0][ $aItem['Name'] ];
|
|---|
| 248 | elseif ( $aItem['Name'] == 'Couple' )
|
|---|
| 249 | $aCol0['Value'] = $this -> bCouple;
|
|---|
| 250 |
|
|---|
| 251 | // set error
|
|---|
| 252 | if( isset( $this -> aErrors[0][ $aItem['Name'] ] ) )
|
|---|
| 253 | $aCol0['Error'] = $this -> aErrors[0][ $aItem['Name'] ];
|
|---|
| 254 |
|
|---|
| 255 | // check second person's field
|
|---|
| 256 | if( $this -> bCoupleEnabled and !in_array( $aItem['Name'], $this -> aCoupleMutualItems ) ) {
|
|---|
| 257 | $aCol1 = array();
|
|---|
| 258 |
|
|---|
| 259 | $aCol1['Type'] = $aItem['Type'];
|
|---|
| 260 | $aCol1['Name'] = $aItem['Name'] . '[1]';
|
|---|
| 261 | $aCol1['Control'] = $aItem['Control'];
|
|---|
| 262 | $aCol1['Values'] = $aItem['Values'];
|
|---|
| 263 | $aCol1['UseLKey'] = $aItem['UseLKey'];
|
|---|
| 264 |
|
|---|
| 265 | // set value
|
|---|
| 266 | if( isset( $this -> aValues[1][ $aItem['Name'] ] ) )
|
|---|
| 267 | $aCol1['Value'] = $this -> aValues[1][ $aItem['Name'] ];
|
|---|
| 268 |
|
|---|
| 269 | // set error
|
|---|
| 270 | if( isset( $this -> aErrors[1][ $aItem['Name'] ] ) )
|
|---|
| 271 | $aCol1['Error'] = $this -> aValues[1][ $aItem['Name'] ];
|
|---|
| 272 |
|
|---|
| 273 | $oForm -> addRow( $aCol0, $aCol1 );
|
|---|
| 274 | } else
|
|---|
| 275 | $oForm -> addRow( $aCol0 );
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | $oForm -> endBlock();
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | $oForm -> end( $aButtons );
|
|---|
| 282 |
|
|---|
| 283 | echo $oForm -> getCode();
|
|---|
| 284 |
|
|---|
| 285 | //boonex id
|
|---|
| 286 | /* if( getParam( 'enable_get_boonex_id' ) )
|
|---|
| 287 | {
|
|---|
| 288 | global $tmpl;
|
|---|
| 289 |
|
|---|
| 290 | echo "<div class=\"import_boonex_id\">";
|
|---|
| 291 | $action = "boonex";
|
|---|
| 292 | $text = '<div class="boonex_id">' . _t( '_Import BoonEx ID' ) . '</div>';
|
|---|
| 293 | $table = "Profiles";
|
|---|
| 294 | $login_page = "{$site['url']}member.php";
|
|---|
| 295 | $join_page = "{$site['url']}join_form.php";
|
|---|
| 296 | $forgot_page = '';
|
|---|
| 297 | $template = BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/join_login_form.html";
|
|---|
| 298 |
|
|---|
| 299 | echo LoginForm( $text,$action,$table,$login_page,$forgot_page,$template );
|
|---|
| 300 |
|
|---|
| 301 | echo "</div>";
|
|---|
| 302 | } */
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | function genHiddenFieldsArray() {
|
|---|
| 306 | $aHiddenFields = array();
|
|---|
| 307 |
|
|---|
| 308 | //retrieve next page
|
|---|
| 309 | $iPageInd = (int)array_search( $this -> iPage, $this -> aPages );
|
|---|
| 310 | $iNextInd = $iPageInd + 1;
|
|---|
| 311 |
|
|---|
| 312 | if( array_key_exists( $iNextInd, $this -> aPages ) )
|
|---|
| 313 | $sNextPage = $this -> aPages[ $iNextInd ];
|
|---|
| 314 | else
|
|---|
| 315 | $sNextPage = 'done';
|
|---|
| 316 |
|
|---|
| 317 | // insert next page
|
|---|
| 318 | $aHiddenFields['join_page'] = $sNextPage;
|
|---|
| 319 |
|
|---|
| 320 | //echoDbg( $this -> aValues );
|
|---|
| 321 |
|
|---|
| 322 | // insert entered values
|
|---|
| 323 | $iHumans = $this -> bCouple ? 2 : 1;
|
|---|
| 324 | for( $iHuman = 0; $iHuman < $iHumans; $iHuman ++ ) {
|
|---|
| 325 | foreach( $this -> aPages as $iPage ) {
|
|---|
| 326 | if( $iPage == $this -> iPage )
|
|---|
| 327 | break; // we are on this page
|
|---|
| 328 |
|
|---|
| 329 | $aBlocks = $this -> oPF -> aArea[ $iPage ];
|
|---|
| 330 | foreach( $aBlocks as $aBlock ) {
|
|---|
| 331 | foreach( $aBlock['Items'] as $aItem ) {
|
|---|
| 332 | $sItemName = $aItem['Name'];
|
|---|
| 333 |
|
|---|
| 334 | if( isset( $this -> aValues[$iHuman][ $sItemName ] ) ) {
|
|---|
| 335 | $mValue = $this -> aValues[$iHuman][ $sItemName ];
|
|---|
| 336 |
|
|---|
| 337 | switch( $aItem['Type'] ) {
|
|---|
| 338 | case 'pass':
|
|---|
| 339 | $aHiddenFields[ $sItemName . '_confirm[' . $iHuman . ']' ] = $mValue;
|
|---|
| 340 | case 'text':
|
|---|
| 341 | case 'area':
|
|---|
| 342 | case 'date':
|
|---|
| 343 | case 'select_one':
|
|---|
| 344 | case 'num':
|
|---|
| 345 | $aHiddenFields[ $sItemName . '[' . $iHuman . ']' ] = $mValue;
|
|---|
| 346 | break;
|
|---|
| 347 |
|
|---|
| 348 | case 'select_set':
|
|---|
| 349 | foreach( $mValue as $iInd => $sValue )
|
|---|
| 350 | $aHiddenFields[ $sItemName . '[' . $iHuman . '][' . $iInd . ']' ] = $sValue;
|
|---|
| 351 | break;
|
|---|
| 352 |
|
|---|
| 353 | case 'range':
|
|---|
| 354 | $aHiddenFields[ $sItemName . '[' . $iHuman . '][0]' ] = $mValue[0];
|
|---|
| 355 | $aHiddenFields[ $sItemName . '[' . $iHuman . '][1]' ] = $mValue[1];
|
|---|
| 356 | break;
|
|---|
| 357 |
|
|---|
| 358 | case 'bool':
|
|---|
| 359 | $aHiddenFields[ $sItemName . '[' . $iHuman . ']' ] = $mValue ? 'yes' : '';
|
|---|
| 360 | break;
|
|---|
| 361 |
|
|---|
| 362 | case 'system':
|
|---|
| 363 | switch( $aItem['Name'] ) {
|
|---|
| 364 | case 'Couple':
|
|---|
| 365 | case 'TermsOfUse':
|
|---|
| 366 | $aHiddenFields[ $sItemName ] = $mValue ? 'yes' : '';
|
|---|
| 367 | break;
|
|---|
| 368 |
|
|---|
| 369 | case 'Captcha':
|
|---|
| 370 | $aHiddenFields[ $sItemName ] = $mValue;
|
|---|
| 371 | break;
|
|---|
| 372 | }
|
|---|
| 373 | break;
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 | }
|
|---|
| 377 | }
|
|---|
| 378 | }
|
|---|
| 379 | }
|
|---|
| 380 | return $aHiddenFields;
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | function registerMember() {
|
|---|
| 384 | $bEnAff = ( getParam('enable_aff') == 'on' );
|
|---|
| 385 |
|
|---|
| 386 | $oPC = new BxDolProfilesController();
|
|---|
| 387 |
|
|---|
| 388 | //convert to profile
|
|---|
| 389 | $aProfile = $this -> oPF -> getProfileFromValues( $this -> aValues[0] );
|
|---|
| 390 | //create it
|
|---|
| 391 | list( $iMemID, $sStatus ) = $oPC -> createProfile( $aProfile );
|
|---|
| 392 |
|
|---|
| 393 | if( !$iMemID )
|
|---|
| 394 | return array( false, 'Fail' );
|
|---|
| 395 |
|
|---|
| 396 | if( $this -> bCouple ) {
|
|---|
| 397 | //convert
|
|---|
| 398 | $aProfile = $this -> oPF -> getProfileFromValues( $this -> aValues[1] );
|
|---|
| 399 | //create
|
|---|
| 400 | list( $iMem1ID, $sStatus1 ) = $oPC -> createProfile( $aProfile, false, $iMemID );
|
|---|
| 401 |
|
|---|
| 402 | if( !$iMem1ID ) {
|
|---|
| 403 | $oPC -> deleteProfile( $iMemID );
|
|---|
| 404 | return array( false, 'Fail' );
|
|---|
| 405 | }
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | //send new user notification
|
|---|
| 409 | if( getParam('newusernotify') == 'on' )
|
|---|
| 410 | if( getParam('autoApproval_ifNoConfEmail') == 'on' )
|
|---|
| 411 | $oPC -> sendNewUserNotify( $iMemID );
|
|---|
| 412 |
|
|---|
| 413 | // Affiliate and friend checking
|
|---|
| 414 | if ( $bEnAff && $_COOKIE['idAff'] ) {
|
|---|
| 415 | $vRes = db_res("SELECT `ID` FROM `aff` WHERE `ID` = {$_COOKIE['idAff']} AND `Status` = 'active'");
|
|---|
| 416 | if ( mysql_num_rows( $vRes ) ) {
|
|---|
| 417 | $vRes = db_res("INSERT INTO `aff_members` (`idAff`,`idProfile`) VALUES ('{$_COOKIE['idAff']}', '{$iMemID}')");
|
|---|
| 418 | }
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | if ( $bEnAff && $_COOKIE['idFriend'] ) {
|
|---|
| 422 | $iFriendID = getID( $_COOKIE['idFriend'] );
|
|---|
| 423 | if ( $iFriendID ) {
|
|---|
| 424 | $vRes = db_res( "UPDATE `Profiles` SET `aff_num` = `aff_num` + 1 WHERE `ID` = '{$iFriendID}'" );
|
|---|
| 425 | createUserDataFile( $iFriendID );
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | reparseObjTags( 'profile', $iMemID );
|
|---|
| 430 |
|
|---|
| 431 | return array( $iMemID, $sStatus );
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | function showFailPage() {
|
|---|
| 435 | echo _t( '_Join failed' );
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | function showFinishPage( $iMemID, $sStatus ) {
|
|---|
| 439 | switch( $sStatus ) {
|
|---|
| 440 | case 'Active': $sStatusText = ('_USER_ACTIVATION_SUCCEEDED'); break; //activated automatically
|
|---|
| 441 | case 'Approval': $sStatusText = ('_USER_CONF_SUCCEEDED'); break; //automatically confirmed
|
|---|
| 442 | case 'Unconfirmed': $sStatusText = ('_EMAIL_CONF_SENT'); break; //conf mail succesfully sent
|
|---|
| 443 | case 'NotSent': $sStatusText = ('_EMAIL_CONF_NOT_SENT'); break; //failed to send conf mail
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | echo _t( '_Join complete' );
|
|---|
| 447 | echo '<br />';
|
|---|
| 448 | echo _t( $sStatusText );
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | function LoginForm( $text, $action, $table, $login_page, $forgot_page, $template = '' )
|
|---|
| 454 | {
|
|---|
| 455 | global $site;
|
|---|
| 456 | global $tmpl;
|
|---|
| 457 |
|
|---|
| 458 | $aFormReplace = array();
|
|---|
| 459 |
|
|---|
| 460 | $name_label = _t("_Nickname");
|
|---|
| 461 |
|
|---|
| 462 | $aFormReplace['header_text'] = $site['title'] . ' ' . $mem . ' Login';
|
|---|
| 463 | if( $action == "login" )
|
|---|
| 464 | {
|
|---|
| 465 | $aFormReplace['warning_text'] = $text;
|
|---|
| 466 | $aFormReplace['submit_label'] = _t("_Log In");
|
|---|
| 467 | $aFormReplace['form_onsubmit'] = 'return true;';
|
|---|
| 468 | }
|
|---|
| 469 | elseif( $action == 'boonex' )
|
|---|
| 470 | {
|
|---|
| 471 | $aFormReplace['warning_text'] = $text .
|
|---|
| 472 | '<div class="id">' .
|
|---|
| 473 | '<a href="javascript:void(0);"
|
|---|
| 474 | onclick="window.open(\'http://www.boonex.com/unity/express/XML.php?module=form&action=joinForm&community=3\', \'Boonex_Sign_Up\', \'width=400,height=593,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0\');">' .
|
|---|
| 475 | _t( '_Get BoonEx ID' ) .
|
|---|
| 476 | '</a>'.
|
|---|
| 477 | '</div>';
|
|---|
| 478 |
|
|---|
| 479 | $aFormReplace['submit_label'] = _t("_Import");
|
|---|
| 480 |
|
|---|
| 481 | $aFormReplace['form_onsubmit'] = 'getBoonexId( this, document.forms.join_form ); return false;';
|
|---|
| 482 | }
|
|---|
| 483 | $aFormReplace['action_url'] = $login_page;
|
|---|
| 484 | $aFormReplace['relocate_url'] = $_SERVER['PHP_SELF'];
|
|---|
| 485 | $aFormReplace['name_label'] = $name_label;
|
|---|
| 486 | $aFormReplace['password_label'] = _t("_Password");
|
|---|
| 487 |
|
|---|
| 488 | if( $forgot_page )
|
|---|
| 489 | {
|
|---|
| 490 | $aFormReplace['forgot_page_url'] = $forgot_page;
|
|---|
| 491 | $aFormReplace['forgot_label'] = _t("_forgot_your_password") . '?';
|
|---|
| 492 | }
|
|---|
| 493 | else
|
|---|
| 494 | {
|
|---|
| 495 | $aFormReplace['forgot_page_url'] = '';
|
|---|
| 496 | $aFormReplace['forgot_label'] = '';
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | if( !strlen( $template ) )
|
|---|
| 500 | $template = BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/join_login_form.html";
|
|---|
| 501 |
|
|---|
| 502 | $ret = file_get_contents( $template );
|
|---|
| 503 |
|
|---|
| 504 | foreach( $aFormReplace as $key => $val )
|
|---|
| 505 | $ret = str_replace( "__{$key}__", $val, $ret );
|
|---|
| 506 |
|
|---|
| 507 | return $ret;
|
|---|
| 508 | } |
|---|