/** * Function check_attempts * Description: Check Script usage attempts and returns false if attempts reach max allowed * Requirements: Sessions * * @author Raheel Hasan * @version 1.2 * * @example * #/ Check Attempts * include_once('includes/check_attempts.php'); * if(check_attempts(10)==false) * { * return_back('resend-activation', true); exit; * } * * // return_back() function must call update_attempt_counts(); * **/ function check_attempts($allowed = 10, $sess_msg_key = 'CUSA_MSG_GLOBAL') { ###/ Check Attempts if (isset($_SESSION["au_wrongtry"]) && $_SESSION["au_wrongtry"] >= $allowed) { $last_time = (int) $_SESSION['au_last_attempt']; $now = time(); $stop_tm = rand(120, 220); if ($now - $last_time > $stop_tm) { //$_SESSION["au_wrongtry"] = 0; //$_SESSION['au_last_attempt'] = 0; reset_attempt_counts(); } else { $_SESSION[$sess_msg_key] = array(false, '<strong class="red-txt">Too Many Attempts!</strong><br />Please try again after a few minutes.'); $_SESSION['au_last_attempt'] = time(); return false; } } //end if attempt check.... return true; }
function process_signup_3($POST, $FILES, $user_id) { global $seo_tag, $consts; if ($user_id > 0) { ##/ Process Profile Pic include_once '../includes/resize_images.php'; $up_path = "user_files/prof/{$user_id}/"; if (!is_dir($up_path)) { mkdir($up_path, 0705, true); } $sql_prt = $profile_pic = ''; if (is_uploaded_file(@$_FILES['profile_pic']['tmp_name'])) { $copy_data = array(0 => array('i_part' => '_th', 'size_w' => 35, 'size_h' => 35)); $profile_pic = upload_img_rs('profile_pic', 250, 250, $up_path, 'Profile Pic', '', 250, 'CUSA_MSG_GLOBAL', false, $copy_data); if ($profile_pic != '') { $sql_prt .= ", profile_pic='{$profile_pic}'"; } } //die('x'); # #/save users $sql_users = "UPDATE users SET\n screen_name='{$POST['screen_name']}', identify_by='{$POST['identify_by']}' {$sql_prt}\n WHERE id = '{$user_id}'"; @mysql_exec($sql_users, 'save'); #/save user_info $sql_user_info = "UPDATE user_info SET\n country_code = '{$POST['country_code']}', state = '{$POST['state']}', city = '{$POST['city']}',\n \taddress_ln_1 = '{$POST['address_ln_1']}', address_ln_2 = '{$POST['address_ln_2']}',\n \tzip = '{$POST['zip']}', phone_number = '{$POST['phone_number']}'\n WHERE user_id = '{$user_id}'"; @mysql_exec($sql_user_info, 'save'); //die('x'); $_SESSION['signup_success'] = '2'; $_SESSION['signup_stage'] = 'signup-details'; reset_attempt_counts(); redirect_me('signup-details/success'); } else { $_SESSION["CUSA_MSG_GLOBAL"] = array(false, 'Unable to process your request at this moment! Please try again later.'); redirect_me($seo_tag); } }
#/ update user_info $sql_user_info = "UPDATE user_info SET country_code='{$_POST['country_code']}', state='{$_POST['state']}',\n city='{$_POST['city']}', address_ln_1='{$_POST['address_ln_1']}', address_ln_2='{$_POST['address_ln_2']}',\n \tzip='{$_POST['zip']}', phone_number='{$_POST['phone_number']}'\n WHERE user_id='{$user_id}'"; @mysql_exec($sql_user_info, 'save'); #/ update user_permissions $fields_perm = implode(',', $_POST['user_perm']); $sql_user_permissions = "UPDATE user_permissions SET fields_perm='{$fields_perm}'\n WHERE user_id='{$user_id}'"; @mysql_exec($sql_user_permissions, 'save'); #/ Update Session foreach ($_POST as $POSTk => $POSTv) { if (array_key_exists($POSTk, $_SESSION['CUSA_Main_usr_info'])) { $_SESSION['CUSA_Main_usr_info'][$POSTk] = $POSTv; } } //var_dump("<pre>", $_SESSION['CUSA_Main_usr_info']); die(); #/ Redirect reset_attempt_counts(); $_SESSION["CUSA_MSG_GLOBAL"] = array(true, "Your Profile data has been successfully Updated.."); redirect_me($seo_tag); exit; } else { $fv_msg = 'Please clear the following Error(s):<br /><br />- '; $fv_msg_ar = array(); foreach ($fv_errors as $fv_k => $fv_v) { $fv_msg_ar = array_merge($fv_msg_ar, $fv_v); } $fv_msg .= @implode('<br />- ', $fv_msg_ar); $_SESSION["CUSA_MSG_GLOBAL"] = array(false, $fv_msg); update_attempt_counts(); } } //end if form post..