8 require_once( CH_DIRECTORY_PATH_INC .
'design.inc.php' );
9 require_once( CH_DIRECTORY_PATH_INC .
'admin.inc.php' );
10 require_once( CH_DIRECTORY_PATH_INC .
'db.inc.php' );
30 $this -> aErrors = array( 0 => array(), 1 => array() );
34 $this -> aValues = array();
35 $this -> aValues[0] = $this -> aValues[1] = $this -> oPF -> getDefaultValues();
37 $this -> bAjaxMode = ( isset( $_SERVER[
'HTTP_X_REQUESTED_WITH'] )
and $_SERVER[
'HTTP_X_REQUESTED_WITH'] ==
'XMLHttpRequest' );
42 if(!$this->oPF->aArea)
43 return 'Profile Fields cache not loaded. Cannot continue.';
45 $this->aPages = array_keys($this->oPF->aArea);
47 $this->iPage = isset($_POST[
'join_page']) ? $_POST[
'join_page'] : 0;
48 if($this->iPage !==
'done' )
49 $this->iPage = (int)$this->iPage;
55 if($this->bAjaxMode &&
ch_get(
'join_page_validate') !==
false) {
61 if($this->iPage ===
'done' ) {
76 foreach ($this -> aPages
as $iPageInd =>
$iPage) {
77 $aBlocks = $this -> oPF -> aArea[
$iPage ];
78 foreach ($aBlocks
as $iBlockID => $aBlock) {
79 $aItems = $aBlock[
'Items'];
80 foreach ($aItems
as $iItemID => $aItem) {
81 if( $aItem[
'Name'] ==
'Couple' ) {
82 $aCoupleItem = $aItem;
96 $this -> bCoupleEnabled =
true;
99 $this -> bCoupleEnabled =
false;
100 $this -> bCouple =
false;
106 foreach ($this -> aPages
as $iPage) {
108 if( $this -> iPage !==
'done' and $iPage >= $this -> iPage ) {
116 if( !
empty( $this -> aErrors[0] )
or ( $this -> bCouple
and !
empty( $this -> aErrors[1] ) ) ) {
126 header(
'Content-Type:text/javascript; charset=utf-8');
127 return $this -> oPF -> genJsonErrors( $this -> aErrors, $this -> bCouple );
132 $aJoinFormParams = array(
133 'dynamic' => $this->bAjaxMode,
134 'couple_enabled' => $this->bCoupleEnabled,
135 'couple' => $this->bCouple,
136 'page' => $this->iPage,
138 'errors' => $this->aErrors,
139 'values' => $this->aValues,
142 return $this->oPF->getFormCode($aJoinFormParams);
148 $iPageInd = (int)array_search( $this -> iPage, $this -> aPages );
149 $iNextInd = $iPageInd + 1;
151 if( array_key_exists( $iNextInd, $this -> aPages ) )
152 $sNextPage = $this -> aPages[ $iNextInd ];
157 $aHiddenFields[
'join_page'] = $sNextPage;
162 $iHumans = $this -> bCouple ? 2 : 1;
163 for( $iHuman = 0; $iHuman < $iHumans; $iHuman ++ ) {
164 foreach( $this -> aPages
as $iPage ) {
165 if(
$iPage == $this -> iPage )
168 $aBlocks = $this -> oPF -> aArea[
$iPage ];
169 foreach( $aBlocks
as $aBlock ) {
170 foreach( $aBlock[
'Items']
as $aItem ) {
171 $sItemName = $aItem[
'Name'];
173 if( isset( $this -> aValues[$iHuman][ $sItemName ] ) ) {
174 $mValue = $this -> aValues[$iHuman][ $sItemName ];
176 switch( $aItem[
'Type'] ) {
178 $aHiddenFields[ $sItemName .
'_confirm[' . $iHuman .
']' ] = $mValue;
186 $aHiddenFields[ $sItemName .
'[' . $iHuman .
']' ] = $mValue;
190 foreach( $mValue
as $iInd => $sValue )
191 $aHiddenFields[ $sItemName .
'[' . $iHuman .
'][' . $iInd .
']' ] = $sValue;
195 $aHiddenFields[ $sItemName .
'[' . $iHuman .
'][0]' ] = $mValue[0];
196 $aHiddenFields[ $sItemName .
'[' . $iHuman .
'][1]' ] = $mValue[1];
200 $aHiddenFields[ $sItemName .
'[' . $iHuman .
']' ] = $mValue ?
'yes' :
'';
204 switch( $aItem[
'Name'] ) {
207 $aHiddenFields[ $sItemName ] = $mValue ?
'yes' :
'';
211 $aHiddenFields[ $sItemName ] = $mValue;
215 $aHiddenFields[
'ProfilePhoto_tmp'] = $mValue;
225 return $aHiddenFields;
232 $oZ =
new ChWsbAlerts(
'profile',
'before_join', 0, 0, $this->aValues[0]);
235 $aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]);
236 if (
empty($aProfile1[
'NickName']))
237 $aProfile1[
'NickName'] =
uriGenerate((
empty($aProfile1[
'FirstName']) ?
genRndPwd(10,
false) : $aProfile1[
'FirstName']),
'Profiles',
'NickName');
240 $aProfile1[
'endtime'] = (int)
time();
241 $aProfile1[
'timediff'] = $aProfile1[
'endtime'] - $aProfile1[
'starttime'];
242 $bBotCheck = (
'on' ==
getParam(sys_antispam_bot_check) ?
true :
false);
246 if (isset($aProfile1[
'youremail']) && !
empty($aProfile1[
'youremail'])) {
249 if (isset($aProfile1[
'reg_email']) && !
empty($aProfile1[
'reg_email'])) {
252 if (isset($aProfile1[
'reg_name']) && !
empty($aProfile1[
'reg_name'])) {
255 if (isset($aProfile1[
'reg_nickname']) && !
empty($aProfile1[
'reg_nickname'])) {
260 if (strpos($aProfile1[
'DescriptionMe'],
'<img src=') !==
false) {
263 if (strpos($aProfile1[
'DescriptionMe'],
'<a href=') !==
false) {
266 if (strpos($aProfile1[
'DescriptionMe'],
'https://') !==
false) {
269 if (strpos($aProfile1[
'DescriptionMe'],
'http://') !==
false) {
274 if ((
int)$aProfile1[
'timediff'] <= 5) {
281 $o->onPositiveDetection (
getVisitorIP(
false),
'Bot blocked on join.',
'botdetection');
283 return array(
false,
'Fail');
288 unset($aProfile1[
'endtime']);
289 unset($aProfile1[
'timediff']);
290 unset($aProfile1[
'starttime']);
291 unset($aProfile1[
'youremail']);
292 unset($aProfile1[
'reg_email']);
293 unset($aProfile1[
'reg_name']);
294 unset($aProfile1[
'reg_nickname']);
298 list($iId1, $sStatus1) = $oPC->createProfile($aProfile1);
302 if(isset($aProfile1[
'ProfilePhoto']) && !
empty($aProfile1[
'ProfilePhoto']))
303 @unlink(
$GLOBALS[
'dir'][
'tmp'] . $aProfile1[
'ProfilePhoto']);
305 return array(
false,
'Fail');
310 $aProfile2 = $this->oPF->getProfileFromValues($this -> aValues[1]);
311 list($iId2, $sStatus2) = $oPC->createProfile($aProfile2,
false, $iId1);
314 $oPC->deleteProfile($iId1);
315 return array(
false,
'Fail');
323 if(isset($aProfile1[
'ProfilePhoto']) && !
empty($aProfile1[
'ProfilePhoto'])) {
333 'medTitle' =>
_t(
'_sys_member_thumb_avatar'),
334 'medDesc' =>
_t(
'_sys_member_thumb_avatar'),
335 'medTags' =>
_t(
'_ProfilePhotos'),
336 'Categories' => array(
_t(
'_ProfilePhotos')),
337 'album' => str_replace(
'{nickname}',
getUsername($iId1),
getParam(
'ch_photos_profile_album_name')),
338 'albumPrivacy' => $oPrivacy->getDefaultValueModule(
'photos',
'album_view'),
340 ChWsbService::call(
'photos',
'perform_photo_upload', array(
$GLOBALS[
'dir'][
'tmp'] . $aProfile1[
'ProfilePhoto'], $aFileInfo,
false),
'Uploader');
349 $oZ =
new ChWsbAlerts(
'profile',
'join', $iId1, 0, array(
'status_text' => &$sStatus1));
352 return array($iId1, $sStatus1);
357 return '<div class="dbContentHtml">' .
_t(
'_Join failed' ) .
'</div>';
363 case 'Active':
$sStatusText = (
'_USER_ACTIVATION_SUCCEEDED');
break;
364 case 'Approval':
$sStatusText = (
'_USER_CONF_SUCCEEDED');
break;
365 case 'Unconfirmed':
$sStatusText = (
'_EMAIL_CONF_SENT');
break;
366 case 'NotSent':
$sStatusText = (
'_EMAIL_CONF_NOT_SENT');
break;
373 return '<div class="dbContentHtml ch-def-font-large">' .
_t(
'_Join complete' ) .
'<br />' .
_t(
$sStatusText ) .
'</div>';