require_once 'includes/init.php'; require_once 'classes/PHPMailer/src/Exception.php'; require_once 'classes/PHPMailer/src/PHPMailer.php'; require_once 'classes/PHPMailer/src/SMTP.php'; use PHPMailer\PHPMailer\PHPMailer; $varnum = 1; $countries = getCountries(); if ( isset( $_POST[ 'signupform' ] ) ) { $_SESSION[ 'first_name' ] = $_POST[ 'first_name' ]; $_SESSION[ 'last_name' ] = $_POST[ 'last_name' ]; $_SESSION[ 'countryid' ] = $_POST[ 'countryid' ]; $_SESSION[ 'stateid' ] = $_POST[ 'stateid' ]; $_SESSION[ 'email' ] = $_POST[ 'email' ]; $_SESSION[ 'phone' ] = $_POST[ 'phone' ]; $_SESSION[ 'address' ] = $_POST[ 'address' ]; $_SESSION[ 'city' ] = $_POST[ 'city' ]; $_SESSION[ 'zip' ] = $_POST[ 'zip' ]; } if ( isset( $_SESSION[ 'cts_flash' ] ) ) { require_once $docroot . '/includes/security.php'; $varnum = 2; } else { $user[ 'first_name' ] = $_SESSION[ 'first_name' ]; $user[ 'last_name' ] = $_SESSION[ 'last_name' ]; $user[ 'countryid' ] = $_SESSION[ 'countryid' ]; $user[ 'stateid' ] = $_SESSION[ 'stateid' ]; $user[ 'email' ] = $_SESSION[ 'email' ]; $user[ 'phone' ] = $_SESSION[ 'phone' ]; $user[ 'address' ] = $_SESSION[ 'address' ]; $user[ 'city' ] = $_SESSION[ 'city' ]; $user[ 'zip' ] = $_SESSION[ 'zip' ]; } if ( isset( $_POST[ 'signupform' ] ) ) { $badField = 0; // Petit checkup des champs if ( $_POST[ 'first_name' ] == "" )$badField = 1; if ( $_POST[ 'last_name' ] == "" )$badField = 1; if ( ( $_POST[ 'email' ] == "" ) && ( !isset( $_SESSION[ 'cts_flash' ] ) ) )$badField = 1; // if ( $_POST[ 'address' ] == "" )$badField = 1; // if ( $_POST[ 'city' ] == "" )$badField = 1; // if ( $_POST[ 'zip' ] == "" )$badField = 1; if ( isset( $_POST[ 'activation_serial' ] ) ) { $badserial = 0; $badserial = checkSerialExist( $_POST[ 'activation_serial' ], 0 ); if ( $badserial == 1 ) { header( "Location: sign_up.php?badserial=1" ); exit; } } if ( $badField == 1 ) { header( "Location: sign_up.php?badfield=1" ); exit; } // Petit checkup de province $badState = validateState( $_POST[ 'countryid' ], $_POST[ 'stateid' ] ); if ( $badState == 1 ) { header( "Location: sign_up.php?badstate=1" ); exit; } if ( !isset( $_SESSION[ 'cts_flash' ] ) ) { $url = 'https://www.google.com/recaptcha/api/siteverify'; $response = file_get_contents( $url . "?secret=" . $captcha_google_secret . "&response=" . $_POST[ 'g-recaptcha-response' ] . "&remoteip=" . $_SERVER[ 'REMOTE_ADDR' ] ); $data = json_decode( $response ); if ( isset( $data->success )AND $data->success == false ) { header( "Location: sign_up.php?captcha=1" ); exit; } } $securitycode = substr( rand(), 0, 12 ); $pzip_code = make_safe( $_POST[ 'zip' ] ); $pcountryid = make_safe( $_POST[ 'countryid' ] ); if ( list( $latitude, $longitude ) = getGeocode( $pzip_code . ", " . $pcountryid ) ) if ( !isset( $_SESSION[ 'cts_flash' ] ) ) { $loginpath = "index.php?newsuccess=1"; $reqCheck = "SELECT email FROM users "; $reqCheck .= "WHERE email = '" . $_POST[ 'email' ] . "' LIMIT 1"; $check = mysqli_query( $db_website, $reqCheck )or die( mysqli_error( $db_website ) ); $checkInfo = mysqli_fetch_assoc( $check ); $checknum = mysqli_num_rows( $check ); if ( $checknum > 0 ) { header( "Location: sign_up.php?exist=1" ); exit; } $insertSQL = sprintf( "INSERT INTO users (first_name, last_name, langid, countryid, stateid, email, phone, address, city, zip, password, last_ip, level_id, longitude, latitude, securitycode, creation_date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NOW())", GetSQLValue( $_POST[ 'first_name' ], "text" ), GetSQLValue( $_POST[ 'last_name' ], "text" ), GetSQLValue( $langid, "int" ), GetSQLValue( $_POST[ 'countryid' ], "text" ), GetSQLValue( $_POST[ 'stateid' ], "text" ), GetSQLValue( $_POST[ 'email' ], "text" ), GetSQLValue( $_POST[ 'phone' ], "text" ), GetSQLValue( $_POST[ 'address' ], "text" ), GetSQLValue( $_POST[ 'city' ], "text" ), GetSQLValue( str_replace( " ", "", strtoupper( $_POST[ 'zip' ] ) ), "text" ), GetSQLValue( md5( $_POST[ 'password' ] ), "text" ), GetSQLValue( $_SERVER[ 'REMOTE_ADDR' ], "text" ), GetSQLValue( 3, "int" ), GetSQLValue( $longitude, "text" ), GetSQLValue( $latitude, "text" ), GetSQLValue( $securitycode, "text" ) ); mysqli_query( $db_website, $insertSQL )or die( mysqli_error( $db_website ) ); $userid = mysqli_insert_id( $db_website ); $msgvar = $a_newemail3 . $clientName; if ( isset( $_POST[ 'activation_serial' ] ) ) { $insertSQL = sprintf( "INSERT INTO cables (userid, serial, status, origin) VALUES (%s, %s, %s, %s)", GetSQLValue( $userid, "int" ), GetSQLValue( $_POST[ 'activation_serial' ], "text" ), GetSQLValue( 0, "int" ), GetSQLValue( 1, "int" ) ); mysqli_query( $db_website, $insertSQL )or die( mysqli_error( $db_website ) ); } // Email html header inclusion require_once $docroot . "/includes/email_header.php"; // Email content $body .= "
" . $a_newemail5 . " : " . $_POST[ 'first_name' ] . " " . $_POST[ 'last_name' ] . "
\n";
// $body .= "" . $cts_email . " : " . $_POST[ 'email' ] . "
\n";
// $body .= "" . $cts_pass . " : " . $_POST[ 'password' ] . "
" . $a_newemail1 . "
\n"; $body .= "" . $a_newemail2 . "
\n";
$body .= "";
$body .= "https://" . $clientUrl . "/scripts/validation.php?id=";
$body .= $userid . "&code=" . $securitycode . "