Changeset 3149634
- Timestamp:
- 09/10/2024 09:01:10 PM (19 months ago)
- Location:
- kofc-state/trunk
- Files:
-
- 1 added
- 8 edited
-
admin.php (modified) (9 diffs)
-
helpers/filter_helper.php (added)
-
helpers/validation_helper.php (modified) (4 diffs)
-
kofc-state.php (modified) (7 diffs)
-
readme.txt (modified) (3 diffs)
-
type-assembly.php (modified) (2 diffs)
-
type-council.php (modified) (2 diffs)
-
type-knight.php (modified) (3 diffs)
-
views/admin/star_reqs.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kofc-state/trunk/admin.php
r2831418 r3149634 5 5 * @Author Chris Hood (http://chrishood.me) 6 6 * @Link http://onthegridwebdesign.com 7 * @copyright (c) 2016-202 2, On the Grid Web Design LLC7 * @copyright (c) 2016-2024, On the Grid Web Design LLC 8 8 * @created 7/21/2016 9 9 */ … … 22 22 $otgkofcs_Scores_Model = new otgkofcs_Scores_Model(); 23 23 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 24 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');24 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 25 25 26 26 $message_list = array(); … … 82 82 $Score_Model = new otgkofcs_Scores_Model(); 83 83 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 84 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');84 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 85 85 86 86 $message_list = array(); … … 168 168 $Recruiting_Model = new otgkofcs_Recruiting_Model(); 169 169 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 170 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');170 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 171 171 172 172 $message_list = array(); … … 223 223 // ***** Load Models, Helpers and Libraries ***** 224 224 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 225 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');225 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 226 226 227 227 $message_list = array(); … … 266 266 $otgkofcs_Star_Model = new otgkofcs_Star_Model(); 267 267 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 268 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');268 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 269 269 270 270 $message_list = array(); … … 325 325 $Messages_Model = new otgkofcs_Messages_Model(); 326 326 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 327 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');327 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 328 328 329 329 $message_list = array(); … … 367 367 require_once(OTGKOFCS_ROOT_PATH . 'models/messages_model.php'); 368 368 $otgkofcs_Messages_Model = new otgkofcs_Messages_Model(); 369 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');369 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 370 370 371 371 // ***** Check for Get Variables ***** … … 393 393 $otgkofcs_Star_Model = new otgkofcs_Star_Model(); 394 394 require_once(OTGKOFCS_ROOT_PATH . 'helpers/view_helper.php'); 395 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');395 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 396 396 397 397 $message_list = array(); -
kofc-state/trunk/helpers/validation_helper.php
r3096237 r3149634 1 1 <?php 2 /** Validation and Filters Helper3 * @Package Knights of Columbus State WP Plugin2 /** Submitted Data Validation Helper, OTG WP Plugins Common File 3 * @Package com.onthegridwebdesign.wpp-kofc-state 4 4 * @File helpers/validation_helper.php 5 5 * @Author Chris Hood (https://onthegridwebdesign.com) 6 * @Link http ://onthegridwebdesign.com7 * @copyright (c) 2018-202 2, On the Grid Web Design LLC8 * @created 2/24/20186 * @Link https://onthegridwebdesign.com/software 7 * @copyright (c) 2018-2024, On the Grid Web Design LLC 8 * @created 9/10/2024 9 9 */ 10 10 11 /** Gets and Cleans a Post Value 12 * @param string $field 13 * @param string $default 14 * @param boolean $allow_html 15 * @return string|null 16 */ 17 function otgkofcs_get_request_string ($field, $default=null, $allow_html=false) { 18 if (empty($_REQUEST[$field])) { 19 return $default; 20 } else { 21 if ($allow_html) 22 return trim(filter_var(stripslashes_deep($_REQUEST[$field]), FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW)); 23 else 24 return trim(filter_var(stripslashes_deep($_REQUEST[$field]), FILTER_SANITIZE_SPECIAL_CHARS)); 25 } 26 } 27 28 /** Checks the Variable and Returns It as an Integer or Null 29 * @param string $field 30 * @param int $default 31 * @return int|null 32 */ 33 function otgkofcs_get_request_int ($field, $default=null) { 34 if (empty($_REQUEST[$field]) || (!ctype_digit(trim($_REQUEST[$field])) && !is_int(trim($_REQUEST[$field])))) { 35 if (is_int($default) || ctype_digit($default)) 36 $out = $default; 37 else 38 $out = null; 39 } else { 40 $out = (int)trim($_REQUEST[$field]); 41 } 42 return $out; 43 } 44 45 /** Gets and Cleans a Email Post Value 46 * @param string $field 47 * @param string $default 48 * @return string|null 49 */ 50 function otgkofcs_get_request_email ($field, $default=null) { 51 if (empty($_REQUEST[$field])) { 52 return $default; 53 } else { 54 return filter_var(trim($_REQUEST[$field]), FILTER_SANITIZE_EMAIL); 55 } 56 } 57 58 /** Gets and Cleans a URL Value 59 * @param string $field 60 * @param string $default 61 * @return string|null 62 */ 63 function otgkofcs_get_request_link ($field, $default = null) { 64 if (empty($_REQUEST[$field])) { 65 return $default; 66 } else { 67 $link = trim(stripslashes_deep($_REQUEST[$field])); 68 if (0 != strncasecmp($link, 'http://', 7) && 0 != strncasecmp($link, 'https://', 8)) 69 $link = 'http://' . $link; 70 return filter_var($link, FILTER_SANITIZE_URL); 71 } 72 } 73 74 /** Gets and Cleans a Textarea Post 75 * @param string $field 76 * @param string $default 77 * @return string|null 78 */ 79 function otgkofcs_get_request_texarea ($field, $default = null) { 80 if (empty($_REQUEST[$field])) { 81 return $default; 82 } else { 83 return trim(filter_var(stripslashes_deep($_REQUEST[$field]), FILTER_SANITIZE_SPECIAL_CHARS)); 84 } 85 } 86 87 /** Get the Bulk Action List and Only Allows Integers in the List 11 /** Cleans and Checks an Email Address 12 * @param string $in 88 13 * @return array 89 14 */ 90 function otgkofcs_get_bulk_action_list () { 91 $bulk_action_list = array(); 92 if (!empty($_POST['bulk_action_list'])) foreach ($_POST['bulk_action_list'] as $id) { 93 if (is_int($id) || ctype_digit($id)) { 94 $bulk_action_list[] = (int)$id; 95 } 15 function otgkofcs_validate_email ($in) { 16 if (empty($in)) 17 return ['email' => '', 'valid' => false, 'message' => 'Email address needs to be submitted.']; 18 19 $valid = true; 20 $message = ''; 21 22 if (!$email_domain = stristr($in, '@')) { 23 $message = 'Email address needs a "@"!'; 24 $valid = false; 25 } elseif (!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-]).*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $in)) { 26 $message = 'Email address is missing something!'; 27 $valid = false; 28 } elseif (!stristr($email_domain, '.')) { 29 $message = 'Email address domain needs to be valid!'; 30 $valid = false; 31 } elseif (!filter_var($in, FILTER_VALIDATE_EMAIL)) { 32 $message = 'Email address needs to be valid!'; 33 $valid = false; 96 34 } 97 return $bulk_action_list;98 }99 35 100 /** Get the Bulk Action List and Only Allows Integers in the List 101 * @return array 102 */ 103 function otgkofcs_get_request_int_array ($field = 'bulk_action_list') { 104 $bulk_action_list = array(); 105 if (!empty($_POST[$field])) foreach ($_POST[$field] as $key => $value) { 106 if (is_int($value) || ctype_digit($value)) { 107 $bulk_action_list[$key] = (int)$value; 108 } 109 } 110 return $bulk_action_list; 111 } 112 113 /** Get the Bulk Action List and Only Allows Integers in the List 114 * @param string $field 115 * @return array 116 */ 117 function otgkofcs_get_request_str_array ($field) { 118 $field_array = array(); 119 if (!empty($_POST[$field])) foreach ($_POST[$field] as $key => $value) { 120 $field_array[trim(filter_var(stripslashes_deep($key), FILTER_SANITIZE_SPECIAL_CHARS))] = trim(filter_var(stripslashes_deep($value), FILTER_SANITIZE_SPECIAL_CHARS)); 121 } 122 return $field_array; 123 } 124 125 /** Replace Quotes with HTML Entity Names 126 * @param string $in 127 * @return string 128 */ 129 function otgkofcs_filter_quotes ($in) { 130 return trim(str_replace(['"', "'"], ['"', '''], $in)); 36 return ['valid' => $valid, 'message' => $message]; 131 37 } 132 38 … … 134 40 * @return boolean 135 41 */ 136 function otgkofcs_verify_hcaptcha () { 42 function otgkofcs_verify_hcaptcha () { 137 43 $post_data['secret'] = get_option('otgkofcs_hcaptcha_secret_key'); 138 44 if (empty($post_data['secret'])) return true; // hcaptcha is disabled … … 145 51 $response = curl_exec($curl); 146 52 $response_data = json_decode($response, true); 147 //$response = wp_remote_post('https://hcaptcha.com/siteverify', ['body' => $post_data]); 148 //$response_data = json_decode($response['body'], true); 149 53 150 54 /* ***** For Debugging ***** 151 55 $curl_error = curl_error($curl); … … 159 63 /**/ 160 64 161 if ( $response_data['success'])65 if ('true' == $response_data['success']) { 162 66 return true; 163 164 return false; 67 } else { 68 return false; 69 } 165 70 } -
kofc-state/trunk/kofc-state.php
r2908729 r3149634 5 5 Description: Functionality for State Councils Including Recruiting Scoreboards 6 6 Author: Chris Hood, On The Grid Web Design LLC 7 Version: 2. 4.37 Version: 2.5.0 8 8 Author URI: https://onthegridwebdesign.com 9 Updated: 12/8/2022Created: 7/21/20169 Updated: 9/10/2024 Created: 7/21/2016 10 10 */ 11 11 … … 55 55 56 56 /** Load CSS and JS Files 57 */ 57 */ 58 58 function otgkofcs_scripts () { 59 59 wp_register_style('otgkofcs_css', plugins_url('kofc-state.min.css', __FILE__)); … … 97 97 $table_messages = $wpdb->prefix . 'otgkofcs_messages'; 98 98 $charset_collate = $wpdb->get_charset_collate(); 99 99 100 100 // *** Knights Table *** 101 101 $sql_knights = "CREATE TABLE $table_knights ( … … 127 127 dbDelta($sql_district_scores); 128 128 if (!get_option('otgkofcs_number_of_districts')) update_option('otgkofcs_number_of_districts', 12); 129 129 130 130 // *** Star Council Requiments Table *** 131 131 $sql_star_requirements = "CREATE TABLE $table_star_requirements ( … … 136 136 ) $charset_collate;"; 137 137 dbDelta($sql_star_requirements); 138 138 139 139 // *** Star Council Requiments Met Table *** 140 140 $sql_star_reqs_met = "CREATE TABLE $table_star_reqs_met ( … … 144 144 ) $charset_collate;"; 145 145 dbDelta($sql_star_reqs_met); 146 146 147 147 // *** Messages Table *** 148 148 $sql_messages = "CREATE TABLE $table_messages ( … … 157 157 PRIMARY KEY (`message_id`) 158 158 ) $charset_collate;"; 159 dbDelta($sql_messages); 159 dbDelta($sql_messages); 160 160 } 161 161 -
kofc-state/trunk/readme.txt
r3096237 r3149634 4 4 Tags: knights of columbus, widget, shortcode, kofc 5 5 Requires at least: 4.0 6 Tested up to: 6. 56 Tested up to: 6.6 7 7 Requires PHP: 5.6 8 Stable tag: 2. 4.48 Stable tag: 2.5.0 9 9 License: GPLv3 10 10 … … 26 26 27 27 == Installation == 28 After activating go to the settings page. Here you can set the number of districts you have. To enable spam reduction on the email forms, Google reCaptcha keys are required. Links to the settings page are under Settings in the admin and on the plugins page. 28 After activating go to the settings page. Here you can set the number of districts you have. To enable spam reduction on the email forms, Google reCaptcha keys are required. Links to the settings page are under Settings in the admin and on the plugins page. 29 29 The admin menu will have the two new post types in the main admin menu along with the Scoreboard and Inbound Messages menu items. 30 30 … … 74 74 75 75 == Changelog == 76 2.5.0 (9/10/2024) 77 - Updated validation and filter helper functions, including splitting validation and filter functions into separate helper files. 78 76 79 2.4.4 (6/1/2024) 77 80 - Small tweaks -
kofc-state/trunk/type-assembly.php
r2831418 r3149634 174 174 } 175 175 176 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');176 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 177 177 178 178 $text_field_list = ['name', 'location', 'charter_date', 'faithful_navigator', 'faithful_comptroller', 'color_corps_commander', 'twitter', 'instagram']; … … 319 319 */ 320 320 function email_assembly_form () { 321 require_once(OTGKOFCS_ROOT_PATH . 'helpers/validation_helper.php');322 321 require_once('models/messages_model.php'); 323 322 $otgkofcs_Messages_Model = new otgkofcs_Messages_Model(); 323 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 324 require_once(OTGKOFCS_ROOT_PATH . 'helpers/validation_helper.php'); 324 325 325 326 // ***** Form Valdiation ***** -
kofc-state/trunk/type-council.php
r2831418 r3149634 189 189 } 190 190 191 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');191 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 192 192 193 193 $text_field_list = ['name', 'location', 'contact_email', 'grand_knight', 'district', 'assembly', 'charter_date', 'twitter', 'instagram']; … … 322 322 */ 323 323 function email_council_form () { 324 require_once(OTGKOFCS_ROOT_PATH . 'helpers/validation_helper.php');325 324 require_once('models/messages_model.php'); 326 325 $otgkofcs_Messages_Model = new otgkofcs_Messages_Model(); 326 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 327 require_once(OTGKOFCS_ROOT_PATH . 'helpers/validation_helper.php'); 327 328 328 329 // ***** Form Valdiation ***** -
kofc-state/trunk/type-knight.php
r2831418 r3149634 50 50 'description' => '', 51 51 'labels' => $labels, 52 'supports' => array('title', 'editor', 'thumbnail'),52 'supports' => ['title', 'editor', 'thumbnail'], 53 53 'hierarchical' => false, 54 54 'public' => true, … … 155 155 } 156 156 157 require_once(OTGKOFCS_ROOT_PATH . 'helpers/ validation_helper.php');157 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 158 158 159 159 $text_field_list = ['name_first', 'name_last', 'council', 'twitter', 'instagram']; … … 281 281 */ 282 282 function email_knight_form () { 283 require_once(OTGKOFCS_ROOT_PATH . 'helpers/validation_helper.php');284 283 require_once('models/messages_model.php'); 285 284 $otgkofcs_Messages_Model = new otgkofcs_Messages_Model(); 285 require_once(OTGKOFCS_ROOT_PATH . 'helpers/filter_helper.php'); 286 require_once(OTGKOFCS_ROOT_PATH . 'helpers/validation_helper.php'); 286 287 287 288 // ***** Form Valdiation ***** -
kofc-state/trunk/views/admin/star_reqs.php
r2831418 r3149634 28 28 </ul> 29 29 30 <input type="submit" >30 <input type="submit" value="Save Changes"> 31 31 <script> 32 32 jQuery(function($) { … … 43 43 <form id="otgkofcs_star_req_add_form" class="edit" method="post"> 44 44 <?php wp_nonce_field('star_reqs_add'); ?> 45 <h3>Add Requirement</h3>45 <h3>Add a Requirement</h3> 46 46 <input type="text" id="otgkofcs_title" name="new_name" placeholder="Requirement Name" required="required" maxlength="250" style="width: 400px;"> 47 <input type="submit" >47 <input type="submit" value="Add"> 48 48 </form> 49 49 </div>
Note: See TracChangeset
for help on using the changeset viewer.