/*************************************************************************** * Dolphin Smart Community Builder * ----------------- * begin : Mon Mar 23 2006 * copyright : (C) 2006 BoonEx Group * website : http://www.boonex.com/ * This file is part of Dolphin - Smart Community Builder * * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License. * http://creativecommons.org/licenses/by/3.0/ * * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the Creative Commons Attribution 3.0 License for more details. * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin, * see license.txt file; if not, write to marketing@boonex.com ***************************************************************************/ require_once( 'inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'profile_disp.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' ); // --------------- page variables and login $_page['name_index'] = 3; $_page['css_name'] = 'join_form.css'; if ( !( $logged['admin'] = member_auth( 1, false ) ) ) if ( !( $logged['member'] = member_auth( 0, false ) ) ) if ( !( $logged['aff'] = member_auth( 2, false )) ) $logged['moderator'] = member_auth( 3, false ); $_page['header'] = _t( "_JOIN_H" ); $_page['header_text'] = _t( "_JOIN_H" ); if( $logged['member'] ) { $_page['name_index'] = 0; $_page_cont[0]['page_main_code'] = _t( '_Sorry, you\'re already joined' ); PageCode(); exit; } // --------------- GET/POST actions $page = (int)htmlspecialchars_adv($_POST['page']); // create number of current page and additional sql conditions for join page $page = (!$page) ? '1' : $page + 1; // 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 $site; global $dir; global $tmpl; global $page; global $join_page_check_limit; global $join_pages_num; global $p_arr; global $_page; global $en_aff; global $oTemplConfig; global $newusernotify; $enable_security_image = getParam('enable_security_image'); $autoApproval_ifJoin = isAutoApproval('join'); ob_start(); session_start(); 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 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; case 'date': $p_arr[$fname] = sprintf("%04d-%02d-%02d", (int)$_POST[$fname . '_year'], (int)$_POST[$fname . '_month'], (int)$_POST[$fname . '_day'] ); $hidden_vals .= ''; $hidden_vals .= ''; $hidden_vals .= ''; 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 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 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; case 'date': $p_arr[$fname] = sprintf("%04d-%02d-%02d", (int)$_POST[$fname . '_year'], (int)$_POST[$fname . '_month'], (int)$_POST[$fname . '_day'] ); $hidden_vals .= ''; $hidden_vals .= ''; $hidden_vals .= ''; 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 AND `join_page` > 0 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: global $tmpl; if( $oTemplConfig -> customize['join_page']['showPageText'] ) $page_text = _t( "_JOIN1", $page ); echo $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 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( str_replace(' ', '', $fval) ); switch ( $arrpd['type'] ) { case 'set': // set of checkboxes case 'r': // reference to array for combo box case 'a': // text Area case 'c': // input box case 'rb': // radio buttons case 'e': // enum combo box case 'en': // enum combo box with numbers case 'eny': // enum combo box with numbers case 'date': // date $fval = process_db_input( $fval, 0, 1 ); $cl_values .= " `$dbname` = '$fval'"; $cl_values .= ", "; break; case 'p': $fval = md5( process_pass_data( $fval ) ); $cl_values .= " `$dbname` = '$fval'"; $cl_values .= ", "; break; } } $cl_values .= " `LastReg` = NOW()"; db_res($cl_values); $IDnormal = mysql_insert_id(); $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'" ); createUserDataFile( $idFriend ); } } if ( strcmp( crypt( $IDnormal, 'secret_string' ), $_COOKIE['IDc'] ) != 0 ) { ob_end_clean(); $_page['header'] = _t( "_Error" ); $ret = "
| "; $ret .= _t( "_MUST_HAVE_COOKIES" ); $ret .= " |
| ";
echo " $page_text ";
break;
default:
echo "";
echo " ";
echo "
";
echo " ";
$ret = ob_get_clean();
return $ret;
}
/**
* print error message
*/
function report_err( $str )
{
return "" . _t( "_Error" ) . ": $str";
$action = "login";
$text = _t( '_Member Login' );
$table = "Profiles";
$login_page = "{$site['url']}member.php";
$join_page = "{$site['url']}join_form.php";
$forgot_page = "{$site['url']}forgot.php";
$template = "{$dir['root']}templates/tmpl_{$tmpl}/join_login_form.html";
echo LoginForm( $text,$action,$table,$login_page,$forgot_page,$template );
echo " ";
if( getParam( 'enable_get_boonex_id' ) )
{
echo "";
$action = "boonex";
$text = ' ";
}
echo "' . _t( '_Import BoonEx ID' ) . ' ';
$table = "Profiles";
$login_page = "{$site['url']}member.php";
$join_page = "{$site['url']}join_form.php";
$forgot_page = '';
$template = "{$dir['root']}templates/tmpl_{$tmpl}/join_login_form.html";
echo LoginForm( $text,$action,$table,$login_page,$forgot_page,$template );
echo ""; } function LoginForm( $text, $action, $table, $login_page, $forgot_page, $template = '' ) { global $site; global $dir; global $tmpl; $aFormReplace = array(); $name_label = _t("_Nickname"); $aFormReplace['header_text'] = $site['title'] . ' ' . $mem . ' Login'; if( $action == "login" ) { $aFormReplace['warning_text'] = $text; $aFormReplace['submit_label'] = _t("_Log In"); $aFormReplace['form_onsubmit'] = 'return true;'; } elseif( $action == 'boonex' ) { $aFormReplace['warning_text'] = $text . ' ' .
'' .
_t( '_Get BoonEx ID' ) .
''.
' ';
$aFormReplace['submit_label'] = _t("_Import");
$aFormReplace['form_onsubmit'] = 'getBoonexId( this, document.forms.jform ); return false;';
}
$aFormReplace['action_url'] = $login_page;
$aFormReplace['relocate_url'] = $_SERVER['PHP_SELF'];
$aFormReplace['name_label'] = $name_label;
$aFormReplace['password_label'] = _t("_Password");
if( $forgot_page )
{
$aFormReplace['forgot_page_url'] = $forgot_page;
$aFormReplace['forgot_label'] = _t("_forgot_your_password") . '?';
}
else
{
$aFormReplace['forgot_page_url'] = '';
$aFormReplace['forgot_label'] = '';
}
if( !strlen( $template ) )
$template = "{$dir['root']}templates/tmpl_{$tmpl}/join_login_form.html";
$ret = file_get_contents( $template );
foreach( $aFormReplace as $key => $val )
$ret = str_replace( "__{$key}__", $val, $ret );
return $ret;
}
?> |