8 require_once( CH_DIRECTORY_PATH_CLASSES .
'Thing.php' );
9 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbPFM.php' );
10 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbPrivacy.php' );
24 'join' => array(
'Country',
'Sex'),
39 $this -> aCache =
$oCache->getData(
$GLOBALS[
'MySQL']->genDbCacheKey(
'sys_profile_fields'));
40 if (
null === $this -> aCache || !is_array($this->aCache)) {
44 if (!$oPFM -> createCache())
53 $bBotCheck = (
'on' ==
getParam(sys_antispam_bot_check) ?
true :
false);
55 $iJoinBlock =
$GLOBALS[
'MySQL']->getOne(
"SELECT `JoinBlock` FROM `sys_profile_fields` WHERE `Name` = 'Password'");
56 if($this -> iAreaID == 1) {
57 $this -> aCache[1][0][$iJoinBlock][
'Items'][] = array(
58 'Name' =>
'starttime',
78 $this -> aCache[1][0][$iJoinBlock][
'Items'][] = array(
79 'Name' =>
'youremail',
99 $this -> aCache[1][0][$iJoinBlock][
'Items'][] = array(
100 'Name' =>
'reg_email',
114 'MandatoryMsg' =>
'',
120 $this -> aCache[1][0][$iJoinBlock][
'Items'][] = array(
121 'Name' =>
'reg_name',
135 'MandatoryMsg' =>
'',
141 $this -> aCache[1][0][$iJoinBlock][
'Items'][] = array(
142 'Name' =>
'reg_nickname',
156 'MandatoryMsg' =>
'',
163 $this -> aCache[100][0][
'Items'][] = array(
164 'Name' =>
'starttime',
170 $this -> aCache[100][0][
'Items'][] = array(
171 'Name' =>
'youremail',
177 $this -> aCache[100][0][
'Items'][] = array(
178 'Name' =>
'reg_email',
184 $this -> aCache[100][0][
'Items'][] = array(
185 'Name' =>
'reg_name',
191 $this -> aCache[100][0][
'Items'][] = array(
192 'Name' =>
'reg_nickname',
201 $this -> aArea = $this -> aCache[ $this -> iAreaID ];
204 $this -> aBlocks = $this -> aArea;
214 $aJsonErrors = array();
220 return json_encode( $aJsonErrors );
226 $iHumans = $bCouple ? 2 : 1;
228 if( $this -> iAreaID == 1 )
229 $this -> aBlocks = $this -> aArea[
$iPage];
231 foreach( $this -> aBlocks
as $iBlockID => $aBlock ) {
232 if ($iBlockOnly > 0
and $iBlockOnly != $iBlockID)
235 $aItems = $aBlock[
'Items'];
236 foreach ($aItems
as $iItemID => $aItem) {
237 $sItemName = $aItem[
'Name'];
239 for( $iHuman = 0; $iHuman < $iHumans; $iHuman ++ ) {
240 if( $iHuman == 1
and in_array( $sItemName, $this -> aCoupleMutual ) )
244 switch( $aItem[
'Type'] ) {
249 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] ) )
254 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] ) )
259 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] )
and $_POST[$sItemName][$iHuman] ==
'yes' )
266 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] )
and trim( $_POST[$sItemName][$iHuman] ) !==
'' )
267 $mValue = (int)trim( $_POST[$sItemName][$iHuman] );
271 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] )
and trim( $_POST[$sItemName][$iHuman] ) !==
'' ) {
272 list( $iYear, $iMonth, $iDay ) = explode(
'-', $_POST[$sItemName][$iHuman] );
274 $iDay = intval($iDay);
275 $iMonth = intval($iMonth);
276 $iYear = intval($iYear);
278 $mValue = sprintf(
"%04d-%02d-%02d", $iYear, $iMonth, $iDay);
284 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] )
and is_array( $_POST[$sItemName][$iHuman] ) ) {
285 foreach ($_POST[$sItemName][$iHuman]
as $sValue ) {
292 if( isset( $_POST[$sItemName] )
and isset( $_POST[$sItemName][$iHuman] ) ) {
293 if (is_array($_POST[$sItemName][$iHuman]))
294 $aRange = $_POST[$sItemName][$iHuman];
296 $aRange = explode(
'-', $_POST[$sItemName][$iHuman], 2);
298 $mValue = array(
null,
null );
300 $aRange[0] = isset( $aRange[0] ) ? trim( $aRange[0] ) :
'';
301 $aRange[1] = isset( $aRange[1] ) ? trim( $aRange[1] ) :
'';
303 if( $aRange[0] !==
'' )
304 $mValue[0] = (int)$aRange[0];
306 if( $aRange[1] !==
'' )
307 $mValue[1] = (int)$aRange[1];
312 switch( $aItem[
'Name'] ) {
316 if( isset( $_POST[$sItemName] )
and $_POST[$sItemName] ==
'yes' )
324 if( isset( $_POST[$sItemName] ) )
329 if (isset($_FILES[
'ProfilePhoto'])) {
330 if ($_FILES[
'ProfilePhoto'][
'error'] == UPLOAD_ERR_OK) {
331 $sTmpName = tempnam(
$GLOBALS[
'dir'][
'tmp'],
'pphot');
332 if (move_uploaded_file($_FILES[
'ProfilePhoto'][
'tmp_name'], $sTmpName))
333 $mValue = basename($sTmpName);
335 } elseif (isset($_POST[
'ProfilePhoto']) && trim($_POST[
'ProfilePhoto'])) {
336 $mValue = preg_replace(
'/[^a-zA-Z0-9\.]/',
'', $_POST[
'ProfilePhoto']);
343 $rRes = $this ->
checkPostValue( $iBlockID, $iItemID, $mValue, $iHuman, $iProfileID );
346 $aErrors[$iHuman][$sItemName] = $rRes;
349 if( $aItem[
'Type'] ==
'pass' and ( $this -> iAreaID == 2
or $this -> iAreaID == 3
or $this -> iAreaID == 4 ) ) {
351 $mValue = $aValues[$iHuman][$sItemName];
356 $aValues[$iHuman][$sItemName] = $mValue;
365 $aItem = $this -> aBlocks[$iBlockID][
'Items'][$iItemID];
367 return 'Item not found';
370 'text' => array(
'Mandatory',
'Min',
'Max',
'Unique',
'Check' ),
371 'area' => array(
'Mandatory',
'Min',
'Max',
'Unique',
'Check' ),
372 'html_area' => array(
'Mandatory',
'Min',
'Max',
'Unique',
'Check' ),
373 'pass' => array(
'Mandatory',
'Min',
'Max',
'Check',
'PassConfirm' ),
374 'date' => array(
'Mandatory',
'Min',
'Max',
'Check' ),
375 'select_one' => array(
'Min',
'Max',
'Mandatory',
'Values',
'Check' ),
376 'select_set' => array(
'Min',
'Max',
'Mandatory',
'Values',
'Check' ),
377 'num' => array(
'Mandatory',
'Min',
'Max',
'Unique',
'Check' ),
378 'range' => array(
'Mandatory',
'RangeCorrect',
'Min',
'Max',
'Check' ),
379 'system' => array(
'System' ),
380 'bool' => array(
'Mandatory' )
383 $aMyChecks = $aChecks[ $aItem[
'Type'] ];
387 foreach ($aMyChecks
as $sCheck ) {
388 $sFunc =
'checkPostValueFor' . $sCheck;
390 $mRes = $this -> $sFunc( $aItem, $mValue, $iHuman, $iProfileID );
392 if( $mRes !==
true ) {
393 if( is_bool( $mRes ) )
394 return _t( $aItem[ $sCheck .
'Msg' ], $aItem[$sCheck] );
406 if( $sConfPass != $mValue )
407 return _t(
'_Password confirmation failed' );
414 if( is_null($mValue[0])
or is_null($mValue[1]) )
417 if( $mValue[0] > $mValue[1] )
418 return _t(
'_First value must be bigger' );
425 $iMin = $aItem[
'Min'];
429 if(mb_strlen($mValue) == 0 && !$aItem[
'Mandatory'])
432 switch( $aItem[
'Type'] ) {
435 if( mb_strlen( $mValue ) < $iMin )
440 if( mb_strlen( strip_tags($mValue) ) < $iMin )
445 if( mb_strlen( $mValue ) > 0
and mb_strlen( $mValue ) < $iMin )
450 if( $mValue < $iMin )
455 if( $this ->
getAge($mValue) < $iMin )
460 if( $mValue[0] < $iMin || $mValue[1] < $iMin )
465 if( count( $mValue ) < $iMin )
475 $iMax = $aItem[
'Max'];
479 if(mb_strlen($mValue) == 0 && !$aItem[
'Mandatory'])
482 switch( $aItem[
'Type'] ) {
486 if( mb_strlen( $mValue ) > $iMax )
491 if( mb_strlen( strip_tags($mValue) ) > $iMax )
496 if( $mValue > $iMax )
501 if( $this ->
getAge($mValue) > $iMax )
506 if( $mValue[0] > $iMax || $mValue[1] > $iMax )
511 if( count( $mValue ) > $iMax )
523 if( !$aItem[
'Unique'] )
526 $iProfileID = (int)$iProfileID;
528 $sAdd =
"AND `ID` != $iProfileID";
532 $sQuery =
"SELECT COUNT(*) FROM `Profiles` WHERE `{$aItem['Name']}` = ? $sAdd";
533 if( (
int)
db_value( $sQuery, [$mValue] ) )
541 $sCheck = $aItem[
'Check'];
545 $sFunc =
function($arg0)
use ($sCheck) {
546 return eval($sCheck);
549 if( !$sFunc( $mValue ) )
557 if( !$aItem[
'Mandatory'] )
560 if( $aItem[
'Type'] ==
'num' ) {
561 if( is_null($mValue) )
563 } elseif( $aItem[
'Type'] ==
'range' ) {
564 if( is_null($mValue[0])
or is_null($mValue[1]) )
566 } elseif( $aItem[
'Type'] ==
'pass' ) {
567 if( $this -> iAreaID == 2
or $this -> iAreaID == 3
or $this -> iAreaID == 4 )
585 if( is_array( $aItem[
'Values'] ) )
586 $aValues = $aItem[
'Values'];
591 return 'Cannot find list';
593 if( $aItem[
'Type'] ==
'select_one' ) {
594 if( !in_array( $mValue, $aValues ) )
595 return 'Value not in list. Hack attempt!';
596 } elseif( $aItem[
'Type'] ==
'select_set' ) {
597 foreach( $mValue
as $sValue )
598 if( !in_array( $sValue, $aValues ) )
599 return 'Value not in list. Hack attempt!';
608 foreach($this -> aCache[100][0][
'Items']
as $aItem)
609 if(!
empty($aItem[
"Default"]))
610 $aItems[$aItem[
"Name"]] = $aItem[
"Default"];
618 if( substr( $sKey, 0, 2 ) == $this->sLinkPref )
619 $sKey = substr( $sKey, 2 );
621 return @array_keys( $aPreValues[$sKey] );
626 switch( $aItem[
'Name'] ) {
632 if( !in_array($mValue, $aItem[
'Values'] ) )
633 return 'Status hack attempt!';
641 return _t(
'_Sorry, your IP been banned');
643 return sprintf(
_t(
'_sys_spam_detected'), CH_WSB_URL_ROOT .
'contact.php');
645 return $aItem[
'Name'] !=
'TermsOfUse' || $mValue ?
true :
_t(
'_You must agree with terms of use' );
649 if ($aItem[
'Mandatory'] && is_null($mValue))
650 return _t(
'_Please specify image file' );
652 if (( isset( $_SERVER[
'HTTP_X_REQUESTED_WITH'] )
and $_SERVER[
'HTTP_X_REQUESTED_WITH'] ==
'XMLHttpRequest' ))
655 $sFileName =
$GLOBALS[
'dir'][
'tmp'] . $mValue;
657 if ($mValue && !file_exists($sFileName))
658 return 'No way! File not exists: ' . $sFileName;
660 $aSize = @getimagesize($sFileName);
661 if ($mValue && !$aSize) {
663 return _t(
'_Please specify image file' );
666 if ($mValue && $aSize[2] != IMAGETYPE_GIF && $aSize[2] != IMAGETYPE_JPEG && $aSize[2] != IMAGETYPE_PNG) {
668 return _t(
'_Please specify image of JPEG, GIF or PNG format' );
698 $bd = explode(
'-', $sBirthDate );
699 foreach ($bd
as $i => $v) $bd[$i] = intval($v);
701 if (intval(date(
'n')) > $bd[1] || (intval(date(
'n')) == $bd[1] && intval(date(
'j')) >= $bd[2]))
702 $age = intval(date(
'Y')) - $bd[0];
704 $age = intval(date(
'Y')) - $bd[0] - 1;
714 foreach( $this -> aBlocks
as $aBlock ) {
715 foreach( $aBlock[
'Items']
as $aItem ) {
716 $sItemName = $aItem[
'Name'];
717 if( !array_key_exists( $sItemName,
$aProfile ))
722 switch( $aItem[
'Type'] ) {
724 $mValue = explode(
',', $mValue );
728 $mValue = explode(
',', $mValue );
729 foreach( $mValue
as $iInd => $sValue )
730 $mValue[$iInd] = (int)$sValue;
734 $mValue = (bool)$mValue;
738 $mValue = (int)$mValue;
751 switch( $sItemName ) {
754 $mValue = (int)$mValue;
758 $mValue = (bool)$mValue;
764 $aValues[$sItemName] = $mValue;
777 if( $this -> iAreaID == 1 ) {
779 foreach( array_keys( $this -> aArea )
as $iPage )
785 foreach( $aBlock[
'Items']
as $aItem ) {
786 $sItemName = $aItem[
'Name'];
787 if( !array_key_exists( $sItemName, $aValues ) )
790 $mValue = $aValues[$sItemName];
814 $aAllItems = $this -> aCache[100][0][
'Items'];
816 $this -> aCoupleMutual = array(
'NickName',
'Password',
'Email',
'Country',
'City',
'zip',
'EmailNotify' );
817 $this -> aCoupleMutualCopy = array(
'Country',
'City',
'zip');
819 foreach( $aAllItems
as $aItem ) {
820 if( $aItem[
'Name'] ==
'Couple' ) {
821 $a = explode(
"\n", $aItem[
'Extra']);
822 array_walk($a,
function (&$sItem, $iKey) {
823 $sItem = trim($sItem);
825 $this -> aCoupleMutual = array_merge( $this -> aCoupleMutual, $a );
828 if( $aItem[
'Type'] ==
'system' &&
'Age' != $aItem[
'Name'])
829 $this -> aCoupleMutual[] = $aItem[
'Name'];
831 if( $aItem[
'Type'] ==
'pass' )
832 $this -> aCoupleMutual[] = $aItem[
'Name'] .
'_confirm';
839 return $this -> aCoupleMutual;
844 return $this -> aCoupleMutualCopy;
851 switch( $aItem[
'Type'] ) {
867 return _t( $sValue ?
'_Yes' :
'_No' );
872 if ($aItem[
'Name'] ==
'Country') {
873 $sFlagName = strtolower($sValue);
874 $sValueView =
'<img src="' .
$site[
'flags'] . $sFlagName .
'.gif" /> ' . $sValueView;
883 switch( $aItem[
'Name'] ) {
889 case 'DateLastLogin':
894 return _t(
"_$sValue" );
900 return _t( $sValue ?
'_Yes' :
'_No' );
922 $sViewableDate = $sDate !=
'0000-00-00 00:00:00' && $sDate !=
'0000-00-00'
926 return $sViewableDate;
933 if( is_string($mValues)
and substr($mValues, 0, 2) == $this->sLinkPref ) {
934 $sKey = substr($mValues, 2);
936 if( !isset( $aPreValues[$sKey][$sUseLKey] ) )
940 } elseif( is_array($mValues) ) {
941 if( in_array($sValue, $mValues) )
954 if( is_string($mValues)
and substr($mValues, 0, 2) == $this->sLinkPref ) {
955 $sKey = substr($mValues, 2);
956 if( !isset( $aPreValues[$sKey] ) )
959 $aValues = explode(
',', $sValue );
963 foreach( $aValues
as $sValue )
964 $aTValues[] =
_t( $aPreValues[$sKey][$sValue][$sUseLKey] );
967 } elseif( is_array($mValues) ) {
969 foreach( explode(
',', $sValue )
as $sValueOne )
970 $aValues[] =
_t(
"_FieldValues_{$sValueOne}" );
985 foreach( $this -> aBlocks
as $aBlock ) {
986 foreach( $aBlock[
'Items']
as $aItem ) {
987 $sItemName = $aItem[
'Name'];
990 switch( $aItem[
'Type'] ) {
1002 $mValue = explode(
'-',
$_REQUEST[$sItemName], 2);
1004 $mValue[0] = (int)$mValue[0];
1005 $mValue[1] = (int)$mValue[1];
1007 if( !$mValue[0]
and !$mValue[1] )
1015 if (is_array(
$_REQUEST[$sItemName] )) {
1021 $mValue[] = $sValue;
1037 switch( $sItemName ) {
1047 elseif( isset(
$_REQUEST[$sItemName][0] ) )
1049 elseif( isset(
$_REQUEST[$sItemName][1] ) )
1051 } elseif( isset(
$_REQUEST[$sItemName] ) ) {
1052 $mValue =
'yes' ==
$_REQUEST[$sItemName] ? 1 : 0;
1069 if( !is_null( $mValue ) )
1070 $aParams[ $sItemName ] = $mValue;
1079 if( !$this -> aArea )
1082 $aFields1 = $this -> aBlocks[0][
'Items'];
1083 $aFields2 = $this -> aCache[100][0][
'Items'];
1087 foreach( $aFields1
as $aField1 ) {
1088 $aField2 = $aFields2[ $aField1[
'MatchField'] ];
1092 $iTotalPercent += $aField1[
'MatchPercent'];
1094 $sVal1 = $aProf1[ $aField1[
'Name'] ];
1095 $sVal2 = $aProf2[ $aField2[
'Name'] ];
1097 if( !strlen($sVal1)
or !strlen($sVal2) )
1101 switch(
"{$aField1['Type']} {$aField1['Type']}" ) {
1102 case 'select_set select_one':
1103 $aVal1 = explode(
',', $sVal1 );
1105 if( in_array( $sVal2, $aVal1 ) )
1109 case 'select_one select_set':
1110 $aVal2 = explode(
',', $sVal2 );
1112 if( in_array( $sVal1, $aVal2 ) )
1116 case 'select_set select_set':
1117 $aVal1 = explode(
',', $sVal1 );
1118 $aVal2 = explode(
',', $sVal2 );
1121 foreach( $aVal1
as $sTempVal1 ) {
1122 if( in_array( $sTempVal1, $aVal2 ) )
1126 $iAddPart = $iFound / count( $aVal1 );
1130 $aVal1 = explode(
',', $sVal1 );
1131 $sVal2 = (int)$sVal2;
1133 if( (
int)$aVal1[0] <= $sVal2
and $sVal2 <= (int)$aVal1[0] )
1138 $aVal1 = explode(
',', $sVal1 );
1140 $aDate = explode(
'-', $sVal2 );
1144 if( (
int)$aVal1[0] <= $sVal2
and $sVal2 <= (
int)$aVal1[0] )
1149 if( $sVal1 == $sVal2 )
1153 $iMyPercent += round( $aField1[
'MatchPercent'] * $iAddPart );
1156 if( $iTotalPercent != 100 && $iTotalPercent != 0 )
1157 $iMyPercent = (int)( ( $iMyPercent / $iTotalPercent ) * 100 );
1164 switch ($this->iAreaID) {
1191 $sCustomHtmlBefore =
'';
1192 $sCustomHtmlAfter =
'';
1193 $oAlert =
new ChWsbAlerts(
'profile',
'show_profile_form', 0, 0, array(
'oProfileFields' => $this,
'oForm' =>
$oForm,
'sCustomHtmlBefore' => &$sCustomHtmlBefore,
'sCustomHtmlAfter' => &$sCustomHtmlAfter));
1196 return $sCustomHtmlBefore .
$oForm->getCode() . $sCustomHtmlAfter;
1201 $aShowModes = array(
'featured',
'birthdays',
'top_rated',
'popular',
'moderators');
1204 $aDefaultParams = $aParams[
'default_params'];
1206 $sSearchModeName = ($this->iAreaID == 10 ?
'quick' : ($this->iAreaID == 11 ?
'adv' :
'simple'));
1214 foreach ($this->aBlocks
as $iBlockId => $aBlock) {
1224 'name' =>
'search_mode',
1225 'value' => $sSearchModeName,
1229 $sSrmKey =
'search_result_mode';
1230 if(!
empty($aDefaultParams[$sSrmKey])) {
1234 'value' => $aDefaultParams[$sSrmKey],
1237 unset($aDefaultParams[$sSrmKey]);
1249 'type' =>
'block_header',
1250 'caption' =>
_t($aBlock[
'Caption']),
1254 foreach ($aBlock[
'Items']
as $iItemId => $aItem) {
1256 if ($iItemId == 1
or $iItemId == 2)
1260 $aFormInput = array(
1261 'name' => $aItem[
'Name'],
1262 'caption' => (
_t($aItem[
'Caption']) != $aItem[
'Caption']) ?
_t($aItem[
'Caption']) :
null,
1263 'info' => (
_t($aItem[
'Desc']) != $aItem[
'Desc']) ?
_t($aItem[
'Desc']) :
null,
1264 'value' =>
empty($aDefaultParams[$aItem[
'Name']]) ?
'' : $aDefaultParams[$aItem[
'Name']],
1267 switch ($aItem[
'Type']) {
1271 $aFormInput[
'type'] =
'text';
1275 $aFormInput[
'value'] =
'yes';
1276 $aFormInput[
'type'] =
'checkbox';
1282 switch($aItem[
'Control']) {
1284 $aFormInput[
'type'] =
'select_box';
1285 $aFormInput[
'attrs'][
'add_other'] =
'false';
1289 $aFormInput[
'type'] = $aItem[
'Name'] ==
'LookingFor' ?
'select' :
'checkbox_set';
1293 $aFormInput[
'type'] = $aItem[
'Name'] ==
'Sex' ?
'checkbox_set' :
'select';
1296 $aFormInput[
'values'] = $this->
convertValues4Input($aItem[
'Values'], $aItem[
'UseLKey'],
'search');
1297 if($aItem[
'Type'] ==
'select_one' && is_array($aFormInput[
'value'])) {
1298 $aFormInput[
'value'] = $aFormInput[
'value'][0];
1305 $aFormInput[
'type'] =
'doublerange';
1306 $aFormInput[
'attrs'] = array(
1307 'min' => $aItem[
'Min'],
1308 'max' => $aItem[
'Max'],
1313 switch ($aItem[
'Name']) {
1315 $aFormInput[
'type'] =
'number';
1316 $aFormInput[
'attrs'][
'min'] = 1;
1320 $aFormInput[
'type'] =
'text';
1324 $sLivingWithinC =
_t(
"_living within");
1325 $sMilesC =
_t(
"_miles");
1326 $sKmC =
_t(
"_kilometers");
1327 $sFromZipC =
_t(
"_from zip/postal code");
1329 $aFormInput[
'type'] =
'custom';
1331 $aFormInput[
'content'] = <<<EOF
1332 <div
class=
"location_wrapper">
1334 <input
type=
"text" name=
"distance" class=
"form_input_distance ch-def-round-corners-with-border ch-def-font" />
1335 <select
name=
"metric" class=
"form_input_select form_input_metric">
1336 <option selected=
"selected" value=
"miles">$sMilesC</option>
1337 <option
value=
"km">$sKmC</option>
1342 <input
type=
"text" name=
"zip" class=
"form_input_zip ch-def-round-corners-with-border ch-def-font" />
1349 if (
'on' ==
getParam(
'enable_global_couple')) {
1350 $aFormInput[
'type'] =
'select';
1351 $aFormInput[
'values'] = array(
1352 'no' =>
_t(
'_Single'),
1353 'yes' =>
_t(
'_Couple')
1356 $aFormInput[
'type'] =
'hidden';
1357 $aFormInput[
'value'] =
'no';
1364 $aInputs[] = $aFormInput;
1370 'type' =>
'checkbox',
1371 'name' =>
'online_only',
1372 'label' =>
_t(
'_online only'),
1373 'checked' => !
empty($aDefaultParams[
'online_only']) &&
1374 ($aDefaultParams[
'online_only'] ==
'on'),
1380 if($oMemberInfo->isAvatarSearchAllowed())
1382 'type' =>
'checkbox',
1383 'name' =>
'photos_only',
1384 'label' =>
_t(
'_With photos only'),
1385 'checked' => !
empty($aDefaultParams[
'photos_only']) &&
1386 $aDefaultParams[
'photos_only'] ==
'on',
1394 'value' =>
_t(
'_Search'),
1400 'form_attrs' => array(
1402 'action' =>
$GLOBALS[
'site'][
'url'] .
'search.php',
1403 'name' => $sSearchModeName .
'_search_form' . $iFormCounter,
1405 'inputs' => $aInputs,
1408 if (isset($aParams[
'form_attrs']) && is_array($aParams[
'form_attrs']))
1409 $aForm[
'form_attrs'] = array_merge (
$aForm[
'form_attrs'], $aParams[
'form_attrs']);
1411 if (isset($aParams[
'inputs']) && is_array($aParams[
'inputs']))
1412 $aForm[
'inputs'] = array_merge (
$aForm[
'inputs'], $aParams[
'inputs']);
1414 if(!$bReturnArray) {
1434 $bDynamic = !
empty($aParams[
'dynamic']) ? $aParams[
'dynamic'] :
false;
1435 $bCoupleEnabled = $aParams[
'couple_enabled'];
1436 $bCouple = $aParams[
'couple'];
1437 $aHiddenItems = $aParams[
'hiddens'];
1438 $iPage = $aParams[
'page'];
1440 $aValues = $aParams[
'values'];
1447 foreach ($aHiddenItems
as $sName => $sValue) {
1467 foreach( $this->aArea[
$iPage]
as $aBlock ) {
1470 'type' =>
'block_header',
1471 'caption' =>
_t( $aBlock[
'Caption'] ),
1474 $aAddInputs = array();
1477 foreach( $aBlock[
'Items']
as $aItem ) {
1479 $aInputParams = array(
1480 'dynamic' => $bDynamic,
1481 'couple' => $bCouple,
1483 0 => isset($aValues[0][$aItem[
'Name']]) ? $aValues[0][$aItem[
'Name']] :
null,
1484 1 => isset($aValues[1][$aItem[
'Name']]) ? $aValues[1][$aItem[
'Name']] :
null,
1487 0 => isset(
$aErrors[0][$aItem[
'Name']]) ?
$aErrors[0][$aItem[
'Name']] :
null,
1488 1 => isset(
$aErrors[1][$aItem[
'Name']]) ?
$aErrors[1][$aItem[
'Name']] :
null,
1492 $bBotCheck = (
'on' ==
getParam(sys_antispam_bot_check) ?
true :
false);
1495 if($aItem[
'Default'] ==
'spam') {
1496 $aInputsTemp[
'value'] =
'';
1497 $aInputsTemp[
'Default'] =
'';
1498 $aInputsTemp[
'tr_attrs'] = array(
'class' =>
'hidable');
1500 if($aItem[
'Name'] ==
'starttime') {
1501 $aInputsTemp[
'value'] = (int)
time();
1503 $aInputs[] = $aInputsTemp;
1508 if ($bCoupleEnabled && !in_array( $aItem[
'Name'], $this -> aCoupleMutual ))
1512 if ($aItem[
'Type'] ==
'pass') {
1513 $aItem_confirm = $aItem;
1515 $aItem_confirm[
'Name'] .=
'_confirm';
1516 $aItem_confirm[
'Caption'] =
'_Confirm password';
1517 $aItem_confirm[
'Desc'] =
'_Confirm password descr';
1521 if ($bCoupleEnabled && !in_array( $aItem[
'Name'], $this -> aCoupleMutual ))
1527 if (!
empty($aAddInputs)) {
1530 'type' =>
'block_header',
1531 'caption' =>
_t( $aBlock[
'Caption'] ) .
' - ' .
_t(
'_Second Person'),
1533 'class' =>
'hidable',
1534 'style' =>
'display: ' . ($bCouple ?
'table-row' :
'none'),
1538 $aInputs = array_merge($aInputs, $aAddInputs);
1545 'name' =>
'do_submit',
1546 'value' =>
_t(
'_Join_now' ),
1548 'class' =>
'ch-btn-primary'
1555 'form_attrs' => array(
1556 'name' =>
'join_form',
1557 'action' => CH_WSB_URL_ROOT .
'join.php',
1559 'onsubmit' =>
'return validateJoinForm(this);',
1560 'enctype' =>
'multipart/form-data',
1562 'table_attrs' => array(
1563 'id' =>
'join_form_table'
1566 'double' => $bCoupleEnabled,
1567 'second_enabled' => $bCouple
1569 'inputs' => $aInputs,
1582 $bCoupleEnabled = $aParams[
'couple_enabled'];
1583 $bCouple = $aParams[
'couple'];
1584 $aHiddenItems = $aParams[
'hiddens'];
1586 $iProfileID = $aParams[
'profile_id'];
1588 $aValues = $aParams[
'values'];
1595 foreach ($aHiddenItems
as $sName => $sValue) {
1617 foreach( $this->aBlocks
as $aBlock ) {
1620 'type' =>
'block_header',
1621 'caption' =>
_t( $aBlock[
'Caption'] ),
1624 $aAddInputs = array();
1627 foreach( $aBlock[
'Items']
as $aItem ) {
1629 $aInputParams = array(
1630 'couple' => $bCouple,
1632 0 => isset($aValues[0][$aItem[
'Name']]) ? $aValues[0][$aItem[
'Name']] :
null,
1633 1 => isset($aValues[1][$aItem[
'Name']]) ? $aValues[1][$aItem[
'Name']] :
null,
1636 0 => isset(
$aErrors[0][$aItem[
'Name']]) ?
$aErrors[0][$aItem[
'Name']] :
null,
1637 1 => isset(
$aErrors[1][$aItem[
'Name']]) ?
$aErrors[1][$aItem[
'Name']] :
null,
1639 'profile_id' => $iProfileID,
1644 if ($bCoupleEnabled && !in_array( $aItem[
'Name'], $this -> aCoupleMutual ))
1648 if ($aItem[
'Type'] ==
'pass') {
1649 $aItem_confirm = $aItem;
1651 $aItem_confirm[
'Name'] .=
'_confirm';
1652 $aItem_confirm[
'Caption'] =
'_Confirm password';
1653 $aItem_confirm[
'Desc'] =
'_Confirm password descr';
1657 if ($bCoupleEnabled && !in_array( $aItem[
'Name'], $this -> aCoupleMutual ))
1663 if (!
empty($aAddInputs)) {
1666 'type' =>
'block_header',
1667 'caption' =>
_t( $aBlock[
'Caption'] ) .
' - ' .
_t(
'_Second Person'),
1669 'class' =>
'hidable',
1670 'style' =>
'display: ' . ($bCouple ?
'table-row' :
'none'),
1674 $aInputs = array_merge($aInputs, $aAddInputs);
1681 'name' =>
'do_save',
1682 'value' =>
_t(
'_Save' ),
1688 'form_attrs' => array(
1689 'name' =>
'edit_form',
1690 'action' => CH_WSB_URL_ROOT .
'pedit.php?ID=' . $iProfileID,
1692 'onsubmit' =>
'return validateEditForm(this);',
1694 'table_attrs' => array(
1695 'id' =>
'edit_form_table'
1698 'double' => $bCoupleEnabled,
1699 'second_enabled' => $bCouple
1701 'inputs' => $aInputs,
1709 $bCouple = $aParams[
'couple'];
1710 $aValues = $aParams[
'values'];
1713 $iProfileID = $aParams[
'profile_id'];
1717 switch ($aItem[
'Type']) {
1718 case 'text': $aInput[
'type'] =
'text'; $aInput[
'value'] = $aValues[$iPerson];
break;
1719 case 'area': $aInput[
'type'] =
'textarea'; $aInput[
'value'] = $aValues[$iPerson];
break;
1720 case 'html_area': $aInput[
'type'] =
'textarea'; $aInput[
'html'] =
true; $aInput[
'value'] = $aValues[$iPerson];
break;
1721 case 'date': $aInput[
'type'] =
'date'; $aInput[
'value'] = $aValues[$iPerson];
break;
1722 case 'datetime': $aInput[
'type'] =
'datetime'; $aInput[
'value'] = $aValues[$iPerson];
break;
1723 case 'num': $aInput[
'type'] =
'number'; $aInput[
'value'] = $aValues[$iPerson];
break;
1724 case 'pass': $aInput[
'type'] =
'password';
break;
1726 $aInput[
'type'] =
'doublerange';
1727 $aInput[
'value'] = is_array($aValues[$iPerson]) ? $aValues[$iPerson][0] .
'-' . $aValues[$iPerson][1] : $aValues[$iPerson];
1730 $aInput[
'type'] =
'checkbox';
1731 $aInput[
'value'] =
'yes';
1732 $aInput[
'checked'] = (bool)(
int)$aValues[$iPerson];
1736 switch ($aItem[
'Control']) {
1737 case 'select': $aInput[
'type'] =
'select';
break;
1738 case 'radio': $aInput[
'type'] =
'radio_set';
break;
1740 default:
return false;
1743 $aInput[
'values'] = $this->
convertValues4Input($aItem[
'Values'], $aItem[
'UseLKey'],
'edit');
1745 $aInput[
'value'] = $aValues[$iPerson];
1749 switch ($aItem[
'Control']) {
1750 case 'select': $aInput[
'type'] =
'select_multiple';
break;
1751 case 'checkbox': $aInput[
'type'] =
'checkbox_set';
break;
1753 default:
return false;
1756 $aInput[
'values'] = $this->
convertValues4Input($aItem[
'Values'], $aItem[
'UseLKey'],
'edit');
1758 $aInput[
'value'] = $aValues[$iPerson];
1762 switch ($aItem[
'Name']) {
1765 'type' =>
'checkbox',
1767 'checked' => $aValues[0]
1774 'value' => $aValues[0],
1775 'values' => array(),
1778 foreach ($aItem[
'Values']
as $sValue) {
1779 $aInput[
'values'][$sValue] =
_t(
"_FieldValues_$sValue");
1785 case 'DateLastEdit':
1786 case 'DateLastLogin':
1792 default:
return false;
1796 default:
return false;
1799 $aInput[
'name'] = ( $aItem[
'Type'] ==
'system' ) ? $aItem[
'Name'] : ( $aItem[
'Name'] .
"[$iPerson]" );
1800 $aInput[
'caption'] =
_t( $aItem[
'Caption'] );
1801 $aInput[
'required'] = $aItem[
'Type'] ==
'pass' ?
false : $aItem[
'Mandatory'];
1803 ($sInfo =
_t( $aItem[
'Desc'], $aItem[
'Min'], $aItem[
'Max'] )) != $aItem[
'Desc'])
1806 if ($aItem[
'Type'] ==
'date') {
1807 $aInput[
'attrs'][
'min'] = $aItem[
'Max'] ? (date(
'Y') - $aItem[
'Max']) .
'-' . date(
'm') .
'-' . date(
'd') : (date(
'Y') - 100) .
'-' . date(
'm') .
'-' . date(
'd');
1808 $aInput[
'attrs'][
'max'] = $aItem[
'Min'] ? (date(
'Y') - $aItem[
'Min']) .
'-' . date(
'm') .
'-' . date(
'd') : (date(
'Y') + 100) .
'-' . date(
'm') .
'-' . date(
'd');
1810 $aInput[
'attrs'][
'min'] = $aItem[
'Min'];
1811 $aInput[
'attrs'][
'max'] = $aItem[
'Max'];
1814 $aInput[
'error'] =
$aErrors[$iPerson];
1816 if ($iPerson == 1) {
1817 $aInput[
'tr_attrs'] = array(
1818 'class' =>
'hidable',
1819 'style' =>
'display: ' . ($bCouple ?
'table-row' :
'none'),
1829 $bDynamic = $aParams[
'dynamic'];
1830 $bCouple = $aParams[
'couple'];
1831 $aValues = $aParams[
'values'];
1836 switch ($aItem[
'Type']) {
1837 case 'text': $aInput[
'type'] =
'text'; $aInput[
'value'] = $aValues[$iPerson];
break;
1838 case 'area': $aInput[
'type'] =
'textarea'; $aInput[
'value'] = $aValues[$iPerson];
break;
1840 $aInput[
'type'] =
'textarea';
1841 $aInput[
'html'] =
true;
1842 $aInput[
'dynamic'] = $bDynamic;
1843 $aInput[
'value'] = $aValues[$iPerson];
1845 case 'date': $aInput[
'type'] =
'date'; $aInput[
'value'] = $aValues[$iPerson];
break;
1846 case 'datetime': $aInput[
'type'] =
'datetime'; $aInput[
'value'] = $aValues[$iPerson];
break;
1847 case 'num': $aInput[
'type'] =
'number'; $aInput[
'value'] = $aValues[$iPerson];
break;
1849 $aInput[
'type'] =
'doublerange';
1850 $aInput[
'value'] = is_array($aValues[$iPerson]) ? $aValues[$iPerson][0] .
'-' . $aValues[$iPerson][1] : $aValues[$iPerson];
1852 case 'pass': $aInput[
'type'] =
'password';
break;
1854 $aInput[
'type'] =
'checkbox';
1855 $aInput[
'value'] =
'yes';
1856 $aInput[
'checked'] = (bool)(
int)$aValues[$iPerson];
1860 switch ($aItem[
'Control']) {
1861 case 'select': $aInput[
'type'] =
'select';
break;
1862 case 'radio': $aInput[
'type'] =
'radio_set';
break;
1865 $aInput[
'values'] = $this->
convertValues4Input($aItem[
'Values'], $aItem[
'UseLKey'],
'join');
1867 $aInput[
'value'] = $aValues[$iPerson];
1871 switch ($aItem[
'Control']) {
1872 case 'select': $aInput[
'type'] =
'select_multiple';
break;
1873 case 'checkbox': $aInput[
'type'] =
'checkbox_set';
break;
1876 $aInput[
'values'] = $this->
convertValues4Input($aItem[
'Values'], $aItem[
'UseLKey'],
'join');
1878 $aInput[
'value'] = $aValues[$iPerson];
1882 switch ($aItem[
'Name']) {
1885 'type' =>
'checkbox',
1886 'label' =>
_t($aItem[
'Caption']),
1890 $aItem[
'Caption'] =
'';
1894 if (
'on' ==
getParam(
'enable_global_couple')) {
1898 'no' =>
_t(
'_Single'),
1899 'yes' =>
_t(
'_Couple'),
1902 'onchange' =>
'doShowHideSecondProfile(this.value, this.form);',
1904 'value' => $bCouple ?
'yes' :
'no',
1915 $aInput[
'type'] =
'captcha';
1916 $aInput[
'dynamic'] = $bDynamic;
1919 case 'ProfilePhoto':
1920 $aInput[
'type'] =
'file';
1927 'content' =>
_t(
'_join_form_note', CH_WSB_URL_ROOT) .
'<input type="hidden" name="Agree" />',
1929 $aItem[
'Caption'] =
'';
1935 $aInput[
'name'] = ( $aItem[
'Type'] ==
'system' ) ? $aItem[
'Name'] : ( $aItem[
'Name'] .
"[$iPerson]" );
1936 $aInput[
'caption'] =
_t( $aItem[
'Caption'] );
1937 $aInput[
'required'] = $aItem[
'Mandatory'];
1939 ($sInfo =
_t( $aItem[
'Desc'], $aItem[
'Min'], $aItem[
'Max'] )) != $aItem[
'Desc'])
1942 if ($aItem[
'Type'] ==
'date') {
1943 $aInput[
'attrs'][
'min'] = $aItem[
'Max'] ? (date(
'Y') - $aItem[
'Max']) .
'-' . date(
'm') .
'-' . date(
'd') : (date(
'Y') - 100) .
'-' . date(
'm') .
'-' . date(
'd');
1944 $aInput[
'attrs'][
'max'] = $aItem[
'Min'] ? (date(
'Y') - $aItem[
'Min']) .
'-' . date(
'm') .
'-' . date(
'd') : (date(
'Y') + 100) .
'-' . date(
'm') .
'-' . date(
'd');
1946 $aInput[
'attrs'][
'min'] = $aItem[
'Min'];
1947 $aInput[
'attrs'][
'max'] = $aItem[
'Max'];
1950 $aInput[
'error'] =
$aErrors[$iPerson];
1952 if ($iPerson == 1) {
1953 $aInput[
'tr_attrs'] = array(
1954 'class' =>
'hidable',
1955 'style' =>
'display: ' . ($bCouple ?
'table-row' :
'none'),
1967 if (is_array($mValues)) {
1968 foreach ($mValues
as $sKey)
1969 $aValues[$sKey] =
_t(
'_FieldValues_' . $sKey);
1970 } elseif (is_string($mValues)
and !
empty($mValues)
and substr($mValues, 0, 2) == $this->sLinkPref) {
1971 $sKey = substr($mValues, 2);
1972 if (isset(
$GLOBALS[
'aPreValues'][$sKey]) ) {
1973 $aPValues =
$GLOBALS[
'aPreValues'][$sKey];
1975 foreach ($aPValues
as $k => $r) {
1976 if (!isset($r[$sUseLKey]))
1978 $aValues[$k] =
_t($r[$sUseLKey]);
1981 if (
'Country' == $sKey &&
$GLOBALS[
'oTemplConfig']->bForceSortCountries)
1984 if(!
empty($sFormName) && !
empty($this->aAddPleaseSelect[$sFormName]) && is_array($this->aAddPleaseSelect[$sFormName]) && in_array($sKey, $this->aAddPleaseSelect[$sFormName]))
1985 $aValues = array(
'' =>
_t(
'_Please_Select_')) + $aValues;