"; // --------------- GET/POST actions $page = (int)$_POST['page']; // create number of current page and additional sql conditions for join page $page = (!$page) ? '1' : $page + 1; // if user select 'couple' then show him fields for couple profile .. $profile_type_add = ('couple' != $_GET['ProfileType'] && 'couple' != $_POST['ProfileType']) ? " AND profile_type != 'couple' " : ""; // determine maximum number of join page parts $query = "SELECT MAX( FLOOR( `join_page` / 1000 ) ) FROM `ProfilesDesc` WHERE `visible` & 2 AND (FIND_IN_SET('0',`show_on_page`) OR FIND_IN_SET('3',`show_on_page`))"; $row = db_arr($query); $join_pages_num = $row[0]; // make last page of join form if ( $page > $join_pages_num ) $page = 'done'; // check fields from previous page if ( 'done' != $page ) $join_page_check_limit = " AND `join_page` < '". ($page * 1000) . "' AND `join_page` >= 1000"; else $join_page_check_limit = ''; //----------------------------------------------------------- // --------------- [ END ] GET/POST actions // --------------- page components $_ni = $_page['name_index']; $_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode(); // --------------- [END] page components PageCode(); // --------------- page components functions /** * page code function */ function PageCompPageMainCode() { global $content_w; global $page; global $profile_type_add; global $join_page_check_limit; global $join_pages_num; global $p_arr; global $_page; global $en_aff; $enable_security_image = getParam('enable_security_image'); ob_start(); session_start(); /* echo '
';*/ switch ( $page ) { // fill inputs with values from precede join pages case ( $page > 1 ) : $hidden_vals = ''; // inputs with POST values $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('".(int)$_page['name_index']."',show_on_page)) $join_page_check_limit $profile_type_add ORDER BY `order` ASC"); while ( $arrpd = mysql_fetch_array($respd) ) { $fname = get_input_name( $arrpd ); switch ( $arrpd['type'] ) { case 'set': // set of checkboxes $vals = preg_split ("/[,\']+/", $arrpd[extra], -1, PREG_SPLIT_NO_EMPTY); $p_arr[$fname] = ''; foreach ( $vals as $v ) { if ( strlen(trim($v)) <= 0 ) continue; $hidden_vals .= ''; $p_arr[$fname."&".$v] = process_pass_data($_POST[$fname."&".$v]); if ( $_POST[$fname."&".$v] == 'on' ) { if ( strlen($p_arr[$fname]) ) $p_arr[$fname] .= ",$v"; else $p_arr[$fname] .= $v; } } break; default: if ( $arrpd['get_value'] ) { $funcbody = $arrpd['get_value']; $func = create_function('$arg0', $funcbody); $hidden_vals .= ''; $p_arr[$fname] = process_pass_data($func($_POST)); } else { $hidden_vals .= ''; $p_arr[$fname] = process_pass_data($_POST[$fname]); } break; } } // check values $query = "SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('".(int)$_page['name_index']."',show_on_page)) $join_page_check_limit $profile_type_add ORDER BY `join_page` ASC"; $respd = db_res($query); while ( $arrpd = mysql_fetch_array($respd) ) { if ( !strlen($arrpd['check']) ) continue; $fname = get_input_name ( $arrpd ); $funcbody = $arrpd[check]; $func = create_function('$arg0', $funcbody); if ( !$func($p_arr[$fname])) { $add_on .= report_err( _t($arrpd['because'], $arrpd['min_length'],$arrpd['max_length']) ); } } $page = (!$add_on) ? $page : $page-1; break; break; case 'done': // fill array with POST values $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('".(int)$_page['name_index']."',show_on_page)) $join_page_check_limit $profile_type_add ORDER BY `order` ASC"); while ( $arrpd = mysql_fetch_array($respd) ) { $fname = get_input_name( $arrpd ); switch ( $arrpd['type'] ) { case 'set': // set of checkboxes $vals = preg_split ("/[,\']+/", $arrpd['extra'], -1, PREG_SPLIT_NO_EMPTY); $p_arr[$fname] = ''; foreach ( $vals as $v ) { if ( strlen(trim($v)) <= 0 ) continue; $hidden_vals .= ''; $p_arr[$fname."&".$v] = process_pass_data($_POST[$fname."&".$v]); if ( $_POST[$fname."&".$v] == 'on' ) { if ( strlen($p_arr[$fname]) ) $p_arr[$fname] .= ",$v"; else $p_arr[$fname] .= $v; } } break; default: if ( $arrpd['get_value'] ) { $funcbody = $arrpd['get_value']; $func = create_function('$arg0',$funcbody); $hidden_vals .= ''; $p_arr[$fname] = process_pass_data($func($_POST)); } else { $hidden_vals .= ''; $p_arr[$fname] = process_pass_data($_POST[$fname]); } break; } } // check values if ( $enable_security_image ) { if (!isset($_POST['securityImageValue']) || !isset($_SESSION['strSec']) || md5($_POST['securityImageValue']) != $_SESSION['strSec']) { $page = $join_pages_num; $add_on .= report_err ( _t("_SIMG_ERR") ); } } $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('".(int)$_page['name_index']."',show_on_page)) $join_page_check_limit $profile_type_add ORDER BY `order` ASC"); while ( $arrpd = mysql_fetch_array($respd) ) { if ( !strlen(trim($arrpd['check'])) ) continue; $fname = get_input_name ( $arrpd ); $funcbody = $arrpd['check']; $func = create_function('$arg0', $funcbody); if ( !$func($p_arr[$fname])) { $page = floor($arrpd['join_page'] / 1000); $add_on .= report_err( _t($arrpd['because'], $arrpd['min_length'], $arrpd['max_length']) ); } } break; default: break; } switch( $page ) { default: $page_text = _t( "_JOIN1", $page ) . $add_on; break; } switch ( $page ) { case 'done': // new profile creation $cl_values = "INSERT INTO Profiles SET "; $cl_first = 0; $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND `to_db` = 1 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('".(int)$_page['name_index']."',show_on_page)) $join_page_check_limit $profile_type_add ORDER BY `order` ASC"); while ( $arrpd = mysql_fetch_array($respd) ) { $fname = get_input_name ( $arrpd ); $dbname = get_field_name ( $arrpd ); $fval = $p_arr[$fname]; if ($dbname == 'zip') $fval = strtoupper($fval); switch ( $arrpd['type'] ) { case 'set': // set of checkboxes $cl_values .= " `$dbname` = '$fval'"; $cl_values .= ", "; break; case 'r': // reference to array for combo box $cl_values .= " `$dbname` = ".(int)$fval; $cl_values .= ", "; break; case 'a': // text Area case 'c': // input box case 'p': // input box password case 'rb': // radio buttons case 'e': // enum combo box case 'en': // enum combo box with numbers case 'eny': // enum combo box with numbers $fval = process_db_input( $fval, 0, 1 ); $cl_values .= " `$dbname` = '$fval'"; $cl_values .= ", "; break; } } $cl_values .= " `LastReg` = NOW(),"; $seed = rand(); $cl_values .= " `seed` = ".$seed; $create_result = db_res($cl_values); $IDnormal = db_arr ("SELECT ID FROM Profiles WHERE `seed` = $seed"); $IDnormal = $IDnormal[ID]; db_res ("UPDATE Profiles SET `seed` = 0 WHERE `ID` = $IDnormal"); $IDcrypt = crypt( $IDnormal, "secret_string" ); // encrypted ID for security purposes setcookie( "IDc", $IDcrypt, 0 , "/" ); $_COOKIE['IDc'] = $IDcrypt; // Affiliate and friend checking if ( $en_aff && $_COOKIE['idAff'] ) { $res = db_res("SELECT `ID` FROM `aff` WHERE `ID` = {$_COOKIE['idAff']} AND `Status` = 'active'"); if ( mysql_num_rows( $res ) ) { $res = db_res("INSERT INTO `aff_members` (`idAff`,`idProfile`) VALUES ({$_COOKIE['idAff']}, $IDnormal)"); } } if ( $en_aff && $_COOKIE['idFriend'] ) { $idFriend = getID( $_COOKIE['idFriend'] ); if ( $idFriend ) { $res = db_res( "UPDATE `Profiles` SET `aff_num` = `aff_num` + 1 WHERE `ID` = '$idFriend'" ); } } if ( strcmp( crypt( $IDnormal, 'secret_string' ), $_COOKIE['IDc'] ) != 0 ) { ob_end_clean(); $_page['header'] = _t( "_Error" ); $ret = "
"; $ret .= _t( "_MUST_HAVE_COOKIES" ); $ret .= "
"; return $ret; } $page_text = _t( "_JOIN3" ) . $add_on; $page_text .= activation_mail( $IDnormal ); $page_text .= "



" . _t( "_UPLOAD_WHILE_WAITING", $site['url'] ) . "
"; modules_add($IDnormal); if (! getParam('enable_auto_aproval')) modules_block($IDnormal); // ---------------------------------------------------------- echo "
"; echo "
$page_text
"; break; default: echo "
"; //----------------------------------------------------------- if ( !$p_arr['ProfileType'] && $_GET['ProfileType'] ) $p_arr['ProfileType'] = $_GET['ProfileType']; do { $join_page_limit = ('done' == $page ) ? " AND join_page > '" . ($join_pages_num * 1000) . "' $profile_type_add " : " AND join_page > '" . ($page * 1000) . "' AND join_page < '" . (($page + 1) * 1000) . "' $profile_type_add "; $query = "SELECT COUNT(*) FROM `ProfilesDesc` WHERE `visible` & 2 $join_page_limit AND (FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('3',show_on_page))"; $res = db_res($query); $item_num = mysql_fetch_row($res); if ($item_num[0] <=0 && $page < $join_pages_num) $page++; } while ( $item_num[0] <= 0 && $page < $join_pages_num ); $join_page_limit = ('done' == $page ) ? " AND join_page > '" . ($join_pages_num * 1000) . "' $profile_type_add " : " AND join_page > '" . ($page * 1000) . "' AND join_page < '" . (($page + 1) * 1000) . "' $profile_type_add "; $hidden_vals .= ""; //----------------------------------------------------------- echo "
" : ">") . " $hidden_vals
$page_text


"; // profile type radio buttons: if ( 1 == $page ) { if ( 'on' == getParam("enable_couple") ) { if ( 'couple' == $p_arr['ProfileType'] ) $cchecked = 'checked="checked"'; else $schecked = 'checked="checked"'; echo ' '; } else { echo " "; } } $first_row = 1; $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('".(int)$_page['name_index']."',show_on_page)) $join_page_limit $profile_type_add ORDER BY `join_page` ASC"); while ( $arrpd = mysql_fetch_array($respd) ) { $fname = get_input_name( $arrpd ); if ( $arrpd['get_value'] && $arrpd['to_db'] == 0 ) { $funcbody = $arrpd['get_value']; $func = create_function('$arg0',$funcbody); $p_arr[$fname] = $func($p_arr); } $not_first_row = 0; switch ($arrpd['type']) { case 'set': // set of checkboxes echo print_row_set ( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case 'rb': // radio buttons echo print_row_radio_button ( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case 'r': // reference to array for combo box echo print_row_ref ( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case '0': // divider echo print_row_delim( $first_row, $arrpd, "panel", 3 ); $not_first_row = 1; $first_row = 1; break; case 'e': // enum combo box // Don't show profile type in field list if ('ProfileType' == $arrpd['name']) break; // Cut 'couple' from choice list if ( 'Sex' == $fname || 'Sex2' == $fname ) $arrpd['extra'] = preg_replace("/(^|,|)'couple'($|,|)/", '', $arrpd['extra']); echo print_row_enum( $first_row, $arrpd, $p_arr[$fname], "table", $javascript ); break; case 'en': // enum combo box with numbers echo print_row_enum_n( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case 'eny': // enum combo box with years echo print_row_enum_years( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case 'a': // text Area echo print_row_area( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case 'c': // input box echo print_row_edit( $first_row, $arrpd, $p_arr[$fname], "table" ); break; case 'p': // input box password echo print_row_pwd( $first_row, $arrpd, $p_arr[$fname], "table" ); break; default: $not_first_row = 1; break; } if ( !$not_first_row && $first_row == 1 ) $first_row = 0; } echo "
'. _t("_ProfileType") .':   '. _t("_single") .'   '. _t("_couple") .'

 
"; // show on the last page of join form if ( $join_pages_num == $page ) { ?>