Changeset 708540
- Timestamp:
- 05/06/2013 08:08:40 AM (13 years ago)
- Location:
- db-form
- Files:
-
- 21 added
- 5 edited
-
tags/1.1 (added)
-
tags/1.1/css (added)
-
tags/1.1/css/admin.css (added)
-
tags/1.1/css/basics.css (added)
-
tags/1.1/db_form_plugin.php (added)
-
tags/1.1/img (added)
-
tags/1.1/img/icon_alert.png (added)
-
tags/1.1/img/icon_submit.png (added)
-
tags/1.1/img/icon_submit_invert.png (added)
-
tags/1.1/img/icon_success.png (added)
-
tags/1.1/img/icon_warning.png (added)
-
tags/1.1/js (added)
-
tags/1.1/js/admin.js (added)
-
tags/1.1/php (added)
-
tags/1.1/php/admin.php (added)
-
tags/1.1/php/connector.php (added)
-
tags/1.1/php/shortcodes.php (added)
-
tags/1.1/readme.txt (added)
-
tags/1.1/screenshot-1.png (added)
-
tags/1.1/screenshot-2.png (added)
-
tags/1.1/screenshot-3.png (added)
-
trunk/db_form_plugin.php (modified) (1 diff)
-
trunk/php/admin.php (modified) (4 diffs)
-
trunk/php/connector.php (modified) (3 diffs)
-
trunk/php/shortcodes.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
db-form/trunk/db_form_plugin.php
r701492 r708540 1 1 <?php 2 2 /* 3 Plugin Name: db form3 Plugin Name: DB Form 4 4 Plugin URI: http://http://www.valentinalisch.de/dev_wp/db-form/ 5 5 Description: Simple plugIn to submit entries to a database. 6 Version: 1. 06 Version: 1.1 7 7 Author: Valentin Alisch 8 8 Author URI: http://www.valentinalisch.de -
db-form/trunk/php/admin.php
r701508 r708540 46 46 47 47 register_setting('dbf-settings-group', 'dbf-0-confirmation'); 48 register_setting('dbf-settings-group', 'dbf-0-confirmation-function'); 49 register_setting('dbf-settings-group', 'dbf-0-confirmation-recipient'); 48 50 register_setting('dbf-settings-group', 'dbf-0-confirmation-subject'); 49 51 register_setting('dbf-settings-group', 'dbf-0-confirmation-content'); … … 201 203 <?php 202 204 if(get_option('dbf-0-main-function') == 'mail'){ 203 $throwback = '<th scope="row"> E-Mail</th>'205 $throwback = '<th scope="row">DB Form E-Mail</th>' 204 206 . '<td>' 205 207 . '<input type="text" name="dbf-0-admin-mail" value="'.get_option('dbf-0-admin-mail').'" />' … … 208 210 else if(get_option('dbf-0-main-function') == 'data'){ 209 211 $throwback = '<tr valign="top">' 210 . '<th scope="row"> E-Mail</th>'212 . '<th scope="row">DB Form E-Mail</th>' 211 213 . '<td>' 212 214 . '<input type="text" name="dbf-0-admin-mail" value="'.get_option('dbf-0-admin-mail').'" />' … … 294 296 if(get_option('dbf-0-confirmation') == 'true'){ 295 297 $throwback = '<tr valign="top">' 298 . '<th scope="row">E-Mail Confirmation Recipient</th>' 299 . '<td>' 300 . '<select name="dbf-0-confirmation-function">' 301 . '<option value="admin" '.selected( get_option('dbf-0-confirmation-function'), 'admin').' >DB Form E-Mail (configured above)</option>' 302 . '<option value="custom" '.selected( get_option('dbf-0-confirmation-function'), 'custom').' >Custom E-Mail</option>' 303 . '</select>' 304 . '</td>' 305 . '</tr>'; 306 if(get_option('dbf-0-confirmation-function') == 'custom'){ 307 $throwback .= '<tr valign="top">' 308 . '<th scope="row"></th>' 309 . '<td>' 310 . '<input type="text" name="dbf-0-confirmation-recipient" value="'.get_option('dbf-0-confirmation-recipient').'" />' 311 . '<p class="description">You can use the name-attribute of your mail field here. <br /> Example: %form-mail%</p>' 312 . '</td>' 313 . '</tr>'; 314 } 315 $throwback .= '<tr valign="top">' 296 316 . '<th scope="row">E-Mail Confirmation Subject</th>' 297 317 . '<td>' -
db-form/trunk/php/connector.php
r701484 r708540 9 9 include_once($path); 10 10 11 //CONNECTOR DATEN 12 //__values sammeln&prüfen 13 $dbf_sec_fields = get_option('dbf-'.$_POST["dbf_submitted"].'-all-fields'); 14 $dbf_fields_wrong = array(); 15 foreach ($dbf_sec_fields as $field){ 16 if(isset($_POST[$field['name']])){ 17 //____leer&required = bad 18 if(str_replace(' ','',$_POST[$field['name']]) == '' && $field['required'] == 'true'){ 19 $dbf_fields_wrong[] = $field; 20 }else if($field['type'] == 'mail' && $field['required'] == 'true'){ 21 if(!check_email($_POST[$field['name']])){ 11 //FORM ABGESCHICKT 12 if(isset($_POST['dbf_submitted'])){ 13 //CONNECTOR DATEN 14 //__values sammeln&prüfen 15 $dbf_sec_fields = get_option('dbf-'.$_POST["dbf_submitted"].'-all-fields'); 16 $dbf_fields_wrong = array(); 17 foreach ($dbf_sec_fields as $field){ 18 if(isset($_POST[$field['name']])){ 19 //____leer&required = bad 20 if(str_replace(' ','',$_POST[$field['name']]) == '' && $field['required'] == 'true'){ 22 21 $dbf_fields_wrong[] = $field; 23 } 24 } 25 }else{ 26 //____undefined&required = bad 27 if($field['required'] == 'true'){ 28 $dbf_fields_wrong[] = $field; 29 } 30 } 31 } 32 //__backup Array bauen 33 $dbf_backup_array = ''; 34 foreach ($dbf_sec_fields as $field){ 35 if(isset($_POST[$field['name']])){ 36 $dbf_backup_array[$field['name']] = $_POST[$field['name']]; 37 }else{ 38 $dbf_backup_array[$field['name']] = ''; 39 } 40 } 41 update_option('dbf-'.$_POST["dbf_submitted"].'-last-fields', $dbf_backup_array); 42 43 //__weiter/zurück 44 if(count($dbf_fields_wrong) <= 0){ 45 //____mail 46 if(get_option('dbf-0-main-function') == 'mail'){ 47 //______ausdrücke ersetzen 48 $dbf_mail_content = nl2br(get_option('dbf-0-mail-content')); 49 preg_match_all('/%(.*)%/U', $dbf_mail_content , $matches); 50 foreach ($matches[0] as $match){ 51 if(isset($_POST[substr($match, 1, -1)])){ 52 $dbf_mail_content = str_replace($match, nl2br($_POST[substr($match, 1, -1)]), $dbf_mail_content); 53 } 54 } 55 //______mail bauen 56 $dbf_mail_header = "From: ".get_bloginfo('name')." < ".get_bloginfo('admin_email')." >\n"; 57 $dbf_mail_header .= "Content-Type: text/html\n"; 58 $dbf_mail_header .= "Content-Transfer-Encoding: 8bit\n"; 59 60 //______mail throw! 61 if(mail(get_option('dbf-0-admin-mail'), get_option('dbf-0-mail-subject'), $dbf_mail_content, $dbf_mail_header)){ 62 //________confirmation 63 if(get_option('dbf-0-confirmation') == 'true'){ 64 //________confirmation bauen 65 $dbf_confirmation_content = nl2br(get_option('dbf-0-confirmation-content')); 66 preg_match_all('/%(.*)%/U', $dbf_confirmation_content , $matches); 67 foreach ($matches[0] as $match){ 68 if(isset($_POST[substr($match, 1, -1)])){ 69 $dbf_confirmation_content = str_replace($match, nl2br($_POST[substr($match, 1, -1)]), $dbf_confirmation_content); 70 } 71 } 72 $dbf_confirmation_header = "From: ".get_bloginfo('name')." < ".get_bloginfo('admin_email')." >\n"; 73 $dbf_confirmation_header .= "Content-Type: text/html\n"; 74 $dbf_confirmation_header .= "Content-Transfer-Encoding: 8bit\n"; 75 76 //________confirmation throw! 77 if(mail(get_option('dbf-0-admin-mail'), get_option('dbf-0-confirmation-subject'), $dbf_confirmation_content, $dbf_confirmation_header)){ 78 //________zurück/woanders 79 if(get_option('dbf-0-redirect') != 'custom' ){ 80 $returns = array( 'message' => 'success' ); 81 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 82 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 83 exit; 84 }else{ 85 header("Location: ".get_option('dbf-0-redirect-url')); 86 exit; 87 } 88 }else{ 89 //________zurück+meldung 90 $returns = array( 'message' => 'alert-mailcon' ); 91 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 92 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 93 exit; 94 } 95 }else{ 96 //________zurück/woanders 97 if(get_option('dbf-0-redirect') != 'custom' ){ 98 $returns = array( 'message' => 'success' ); 99 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 100 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 101 exit; 102 }else{ 103 header("Location: ".get_option('dbf-0-redirect-url')); 104 exit; 22 }else if($field['type'] == 'mail' && $field['required'] == 'true'){ 23 if(!check_email($_POST[$field['name']])){ 24 $dbf_fields_wrong[] = $field; 105 25 } 106 26 } 107 27 }else{ 108 //________zurück+meldung 109 $returns = array( 'message' => 'warning-mail' ); 110 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 111 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 112 exit; 113 } 28 //____undefined&required = bad 29 if($field['required'] == 'true'){ 30 $dbf_fields_wrong[] = $field; 31 } 32 } 33 } 34 //__backup Array bauen 35 $dbf_backup_array = ''; 36 foreach ($dbf_sec_fields as $field){ 37 if(isset($_POST[$field['name']])){ 38 $dbf_backup_array[$field['name']] = $_POST[$field['name']]; 39 }else{ 40 $dbf_backup_array[$field['name']] = ''; 41 } 42 } 43 update_option('dbf-'.$_POST["dbf_submitted"].'-last-fields', $dbf_backup_array); 114 44 115 //____data 116 }elseif(get_option('dbf-0-main-function') == 'data'){ 117 //______datenbank connect 118 $dbf_db = new wpdb(get_option('dbf-0-db-user'),get_option('dbf-0-db-password'),get_option('dbf-0-db-name'),get_option('dbf-0-db-host')); 119 if($dbf_db){ 120 121 //______string vorbereiten 122 $dbf_insert = array(); 123 foreach($dbf_sec_fields as $field){ 124 $dbf_column = $field['name']; 125 if(isset($_POST[$dbf_column])){ 126 $dbf_insert[$dbf_column] = $_POST[$dbf_column]; 127 } 128 } 45 //__weiter/zurück 46 if(count($dbf_fields_wrong) <= 0){ 47 //____mail 48 if(get_option('dbf-0-main-function') == 'mail'){ 49 //______ausdrücke ersetzen 50 $dbf_mail_content = nl2br(get_option('dbf-0-mail-content')); 51 preg_match_all('/%(.*)%/U', $dbf_mail_content , $matches); 52 foreach ($matches[0] as $match){ 53 if(isset($_POST[substr($match, 1, -1)])){ 54 $dbf_mail_content = str_replace($match, nl2br($_POST[substr($match, 1, -1)]), $dbf_mail_content); 55 } 56 } 57 //______mail bauen 58 $dbf_mail_header = "From: ".get_bloginfo('name')." < ".get_bloginfo('admin_email')." >\n"; 59 $dbf_mail_header .= "Content-Type: text/html\n"; 60 $dbf_mail_header .= "Content-Transfer-Encoding: 8bit\n"; 129 61 130 //______ push!131 if( $dbf_db->insert(get_option('dbf-0-db-table'), $dbf_insert)){62 //______mail throw! 63 if(mail(get_option('dbf-0-admin-mail'), get_option('dbf-0-mail-subject'), $dbf_mail_content, $dbf_mail_header)){ 132 64 //________confirmation 133 65 if(get_option('dbf-0-confirmation') == 'true'){ 66 echo "hello"; 134 67 //________confirmation bauen 68 //__________recipient 69 if(get_option('dbf-0-confirmation-function') == 'custom'){ 70 preg_match_all('/%(.*)%/U', get_option('dbf-0-confirmation-recipient') , $matches); 71 if(count($matches[0]) == 1){$dbf_confirmation_recipient = $_POST[$matches[1][0]];}else{$dbf_confirmation_recipient = get_option('dbf-0-confirmation-recipient');} 72 }else{$dbf_confirmation_recipient = get_option('dbf-0-admin-mail');} 73 //__________content 135 74 $dbf_confirmation_content = nl2br(get_option('dbf-0-confirmation-content')); 136 75 preg_match_all('/%(.*)%/U', $dbf_confirmation_content , $matches); … … 145 84 146 85 //________confirmation throw! 147 if(mail( get_option('dbf-0-admin-mail'), get_option('dbf-0-confirmation-subject'), $dbf_confirmation_content, $dbf_confirmation_header)){86 if(mail($dbf_confirmation_recipient, get_option('dbf-0-confirmation-subject'), $dbf_confirmation_content, $dbf_confirmation_header)){ 148 87 //________zurück/woanders 149 88 if(get_option('dbf-0-redirect') != 'custom' ){ … … 176 115 } 177 116 }else{ 178 //______ zurück+meldung179 $returns = array( 'message' => 'warning- dbins' );117 //________zurück+meldung 118 $returns = array( 'message' => 'warning-mail' ); 180 119 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 181 120 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 182 121 exit; 183 122 } 123 124 //____data 125 }elseif(get_option('dbf-0-main-function') == 'data'){ 126 //______datenbank connect 127 $dbf_db = new wpdb(get_option('dbf-0-db-user'),get_option('dbf-0-db-password'),get_option('dbf-0-db-name'),get_option('dbf-0-db-host')); 128 if($dbf_db){ 184 129 185 }else{ 186 //______zurück+meldung 187 $returns = array( 'message' => 'warning-dbcon' ); 188 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 189 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 190 exit; 191 } 192 } 130 //______string vorbereiten 131 $dbf_insert = array(); 132 foreach($dbf_sec_fields as $field){ 133 $dbf_column = $field['name']; 134 if(isset($_POST[$dbf_column])){ 135 $dbf_insert[$dbf_column] = $_POST[$dbf_column]; 136 } 137 } 138 139 //______push! 140 if($dbf_db->insert(get_option('dbf-0-db-table'), $dbf_insert)){ 141 //________confirmation 142 if(get_option('dbf-0-confirmation') == 'true'){ 143 //________confirmation bauen 144 //__________recipient 145 if(get_option('dbf-0-confirmation-function') == 'custom'){ 146 preg_match_all('/%(.*)%/U', get_option('dbf-0-confirmation-recipient') , $matches); 147 if(count($matches[0]) == 1){$dbf_confirmation_recipient = $_POST[$matches[1][0]];}else{$dbf_confirmation_recipient = get_option('dbf-0-confirmation-recipient');} 148 }else{$dbf_confirmation_recipient = get_option('dbf-0-admin-mail');} 149 //__________content 150 $dbf_confirmation_content = nl2br(get_option('dbf-0-confirmation-content')); 151 preg_match_all('/%(.*)%/U', $dbf_confirmation_content , $matches); 152 foreach ($matches[0] as $match){ 153 if(isset($_POST[substr($match, 1, -1)])){ 154 $dbf_confirmation_content = str_replace($match, nl2br($_POST[substr($match, 1, -1)]), $dbf_confirmation_content); 155 } 156 } 157 $dbf_confirmation_header = "From: ".get_bloginfo('name')." < ".get_bloginfo('admin_email')." >\n"; 158 $dbf_confirmation_header .= "Content-Type: text/html\n"; 159 $dbf_confirmation_header .= "Content-Transfer-Encoding: 8bit\n"; 160 161 //________confirmation throw! 162 if(mail($dbf_confirmation_recipient, get_option('dbf-0-confirmation-subject'), $dbf_confirmation_content, $dbf_confirmation_header)){ 163 //________zurück/woanders 164 if(get_option('dbf-0-redirect') != 'custom' ){ 165 $returns = array( 'message' => 'success' ); 166 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 167 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 168 exit; 169 }else{ 170 header("Location: ".get_option('dbf-0-redirect-url')); 171 exit; 172 } 173 }else{ 174 //________zurück+meldung 175 $returns = array( 'message' => 'alert-mailcon' ); 176 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 177 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 178 exit; 179 } 180 }else{ 181 //________zurück/woanders 182 if(get_option('dbf-0-redirect') != 'custom' ){ 183 $returns = array( 'message' => 'success' ); 184 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 185 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 186 exit; 187 }else{ 188 header("Location: ".get_option('dbf-0-redirect-url')); 189 exit; 190 } 191 } 192 }else{ 193 //______zurück+meldung 194 $returns = array( 'message' => 'warning-dbins' ); 195 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 196 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 197 exit; 198 } 199 200 }else{ 201 //______zurück+meldung 202 $returns = array( 'message' => 'warning-dbcon' ); 203 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 204 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 205 exit; 206 } 207 } 208 }else{ 209 //____zurück+meldung 210 $returns = array( 'message' => 'warning-input', 211 'fields' => '' 212 ); 213 foreach ($dbf_fields_wrong as $field){ 214 $returns['fields'] .= $field['name'].';'; 215 } 216 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 217 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 218 exit; 219 } 220 //ODER NICHT? 193 221 }else{ 194 //____zurück+meldung 195 $returns = array( 'message' => 'warning-input', 196 'fields' => '' 197 ); 198 foreach ($dbf_fields_wrong as $field){ 199 $returns['fields'] .= $field['name'].';'; 200 } 201 $dbf_prev_url = get_permalink($_POST['dbf_'.$_POST['dbf_submitted'].'_post_id']); 202 header("Location: ".$dbf_prev_url.'?'.http_build_query($returns)); 222 echo 'Huh, what are you doing here? *PUNCH* <br />'; 223 header('Refresh: 1;url='.get_bloginfo('siteurl').''); 203 224 exit; 204 225 } -
db-form/trunk/php/shortcodes.php
r701484 r708540 364 364 add_shortcode( 'radio', 'dbf_field_radio'); 365 365 366 //SELECT 367 function dbf_field_select($atts, $content=null){ 368 global $dbf_foundouter, $dbf_outerid, $dbf_warning_radio, $dbf_warning_enclosure, $dbf_sec_option, $dbf_wrong_fields, $dbf_last_fields; 369 370 if($dbf_foundouter){ 371 //__values 372 extract( shortcode_atts( array( 373 'label' => '', 374 'name' => '', 375 'value' => '', 376 'required' => 'false', 377 'description' => '' 378 ), $atts ) ); 379 380 //__secure 381 $dbf_sec_value = get_option($dbf_sec_option); 382 $dbf_sec_value[] = array( "type" => "select", 383 "name" => $name, 384 "required" => $required 385 ); 386 update_option($dbf_sec_option, $dbf_sec_value); 387 388 //__workwork 389 $additional = ''; 390 if(in_array($name,$dbf_wrong_fields)){$additional .= ' dbf_field_error';} 391 $options = Array(); 392 $labels = explode(';', $label); 393 $values = explode(';', $value); 394 if(count($labels) == count($values)){ 395 $i = 0; 396 foreach ($labels as $label_single){ 397 $options[] = array( 'label' => $label_single, 398 'value' => $values[$i] 399 ); 400 $i++; 401 } 402 403 $throwback = '<div class="dbf_select_wrapper dbf_wrapper '.$additional.'">' 404 . '<div class="dbf_select_before dbf_label">' 405 . '<div class="dbf_select_description">'.$description.'</div>' 406 . '</div>' 407 . '<div class="dbf_select_main dbf_field">' 408 . '<select name="'.$name.'" data-required="'.$required.'" >'; 409 410 foreach ($options as $option){ 411 //____backup 412 $backup = ''; 413 if(isset($dbf_last_fields[$name])){if($dbf_last_fields[$name] == $option['value']){$backup='selected="selected"';}else{$backup='';}}else{$backup='';} 414 $throwback .= '<option value="'.$option['value'].'" '.$backup.' >'.$option['label'].'</option>'; 415 } 416 417 $throwback .= '</select>' 418 . '</div>' 419 . '<div class="dbf-cleaner"></div>' 420 . '</div>'; 421 }else{ 422 $throwback = $dbf_warning_radio; 423 } 424 }else{ 425 $throwback = $dbf_warning_enclosure; 426 } 427 428 //__throw! 429 return $throwback; 430 431 } 432 add_shortcode( 'select', 'dbf_field_select'); 433 366 434 //CHECKBOX 367 435 function dbf_field_checkbox($atts, $content=null){ -
db-form/trunk/readme.txt
r701510 r708540 4 4 Requires at least: 3.2 5 5 Tested up to: 3.5.1 6 Stable tag: 1. 0.16 Stable tag: 1.1 7 7 8 8 Simple plugIn to submit entries to a database. … … 58 58 == Changelog == 59 59 60 = 1.1 = 61 * Option to select confirmation mail recipient added 62 * `[select]` shortcode added (drop downs) 63 60 64 = 1.0.1 = 61 65 * Bug fixes … … 85 89 == Upgrade Notice == 86 90 91 = 1.1 = 92 Important Update! 93 Rewritten HTML output, rewritten configuration pages. 94 This requires you to update your settings and eventually completely change/rewrite your CSS files 95 which you use to style the plugIn. 96 Custom CSS stylesheet selection is not supported right now! (Will be available in 1.1.1 — May 7th) 97 87 98 = 1.0.1 = 88 99 Important Update!
Note: See TracChangeset
for help on using the changeset viewer.