Changeset 1628720
- Timestamp:
- 04/03/2017 10:34:28 PM (9 years ago)
- Location:
- keep-in-touch/trunk
- Files:
-
- 2 added
- 2 edited
-
class-keep-in-touch-db.php (modified) (1 diff)
-
class-keep-in-touch-schedule.php (added)
-
class-keep-in-touch-settings.php (added)
-
keep-in-touch.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
keep-in-touch/trunk/class-keep-in-touch-db.php
r1628704 r1628720 15 15 16 16 $sql = "CREATE TABLE $table_name ( 17 full_name TINYTEXT DEFAULT '' NOT NULL, 17 18 email TINYTEXT DEFAULT '' NOT NULL, 18 19 status SET('pending_activation','active','pending_removal') DEFAULT 'pending_activation' NOT NULL, -
keep-in-touch/trunk/keep-in-touch.php
r1628704 r1628720 62 62 } 63 63 64 static private function is_null_or_empty_string($string) 65 { 66 return (!isset($string) || trim($string)===''); 67 } 68 69 static private function return_same_page() 70 { 71 if (wp_get_referer()) 72 wp_safe_redirect(wp_get_referer()); 73 else 74 wp_safe_redirect(get_home_url()); 75 } 76 64 77 static private function handle_virtual_page() 65 78 { 66 if (isset($_POST['keep_in_touch_submit']) and isset($_POST['keep_in_touch_email'])) 67 self::handle_subscribe(sanitize_email($_POST['keep_in_touch_email']), isset($_POST['keep_in_touch_email_reference']) ? sanitize_text_field($_POST['keep_in_touch_email_reference']) : NULL); 68 //else if (isset($_GET['subscribe'])) 69 // self::handle_subscribe_first_step(sanitize_text_field($_GET['subscribe'])); 79 if (isset($_POST['keep_in_touch_submit'])) 80 self::handle_submit(); 70 81 else if (isset($_GET['unsubscribe'])) 71 82 self::handle_unsubscribe(sanitize_text_field($_GET['unsubscribe'])); … … 73 84 self::handle_confirmation_code(sanitize_text_field($_GET['confirmation_code'])); 74 85 } 86 87 static private function handle_submit() 88 { 89 if (self::is_null_or_empty_string($_POST['keep_in_touch_email'])) 90 self::return_same_page(); 91 92 $email = sanitize_email($_POST['keep_in_touch_email']); 93 if (!isset($_POST['keep_in_touch_email_reference'])) 94 self::handle_subscribe_first_step($email); 95 else if (sanitize_email($_POST['keep_in_touch_email_reference']) == $email) 96 self::handle_subscribe_second_step($email); 97 else 98 Keep_In_Touch_Msg::emit_invalid_anti_robot_check($email, $email_reference); 99 } 75 100 76 static private function handle_subscribe ($email, $email_reference)101 static private function handle_subscribe_first_step($email) 77 102 { 78 if (!isset($email_reference)) 79 { 80 Keep_In_Touch_Msg::emit_subscription_anti_robot($email); 81 } 103 Keep_In_Touch_Msg::emit_subscription_anti_robot($email); 104 } 105 106 static private function handle_subscribe_second_step($email) 107 { 108 $confirmation_code = Keep_In_Touch_Utils::generate_unique_id(20); 109 if (Keep_In_Touch_Db::register_subscription_request($email, $confirmation_code)) 110 Keep_In_Touch_Msg::emit_confirm_subscription($email, $confirmation_code); 82 111 else 83 { 84 $confirmation_code = Keep_In_Touch_Utils::generate_unique_id(20); 85 86 if ($email != $email_reference) 87 Keep_In_Touch_Msg::emit_invalid_anti_robot_check($email, $email_reference); 88 else if (Keep_In_Touch_Db::register_subscription_request($email, $confirmation_code)) 89 Keep_In_Touch_Msg::emit_confirm_subscription($email, $confirmation_code); 90 else 91 Keep_In_Touch_Msg::emit_subscription_request_failed($email); 92 } 112 Keep_In_Touch_Msg::emit_subscription_request_failed($email); 93 113 } 94 114
Note: See TracChangeset
for help on using the changeset viewer.