Changeset 690252
- Timestamp:
- 04/01/2013 06:45:52 PM (13 years ago)
- Location:
- mj-contact-us/trunk
- Files:
-
- 13 added
- 8 edited
-
.gitignore (added)
-
README.md (added)
-
css/mj.css (modified) (5 diffs)
-
css/mjCont.css (added)
-
files/captcha_code_file.php (added)
-
files/db.php (added)
-
files/includes.php (modified) (1 diff)
-
files/mj-class-functions.php (modified) (1 diff)
-
files/mj-class-html.php (modified) (3 diffs)
-
files/mj-class-process.php (modified) (12 diffs)
-
files/monofont.ttf (added)
-
index.php (modified) (1 diff)
-
js/mj.js (modified) (1 diff)
-
js/mjCon.js (added)
-
readme.txt (modified) (1 diff)
-
screenshot-4.jpg (added)
-
screenshot-5.jpg (added)
-
screenshot-6.jpg (added)
-
screenshot-7.jpg (added)
-
screenshot-8.jpg (added)
-
screenshot-9.jpg (added)
Legend:
- Unmodified
- Added
- Removed
-
mj-contact-us/trunk/css/mj.css
r659596 r690252 51 51 line-height: 1.4em; 52 52 } 53 #mailform input{ 53 .fieldBlock select, #mailform select{height:3em;} 54 .fieldBlock input, .fieldBlock select, #mailform input, #mailform select{ 54 55 width: 314px; 55 56 padding: 6px; … … 59 60 border: 1px solid #cecece; 60 61 } 61 #mailform input.error{62 .fieldBlock input.error , #mailform input.error{ 62 63 background: #f8dbdb; 63 64 border-color: #e77776; … … 121 122 } 122 123 /******* /FORM *******/ 124 #mailform input[type="checkbox"]{ 125 width:10px; 126 } 127 128 #mailform input[type="radio"]{ 129 width:20px; 130 } 131 123 132 input[type="text"], input[type="password"], textarea { 124 133 box-shadow:; … … 127 136 #mailform label.error { 128 137 129 bottom: - 13px;130 color: # 000000;138 bottom: -4px; 139 color: #dd514c; 131 140 font-size: 12px; 132 141 left: 3px; … … 138 147 #mailform .w-16{width: 16px;} 139 148 .p-12{padding: 12px;} 140 .h-43{ height:43px;}149 .h-43{min-height:43px;} 141 150 .h-100{min-height:100px;} 142 151 .f-13{font-size:13px;} 143 .error{background-color: #e77776; color: #f2f2f2} 152 .error{color: #dd514c; width:324px; display:block;} 153 label.error{text-align: right;} 154 .fr{float:right; clear:both;} 155 .fl{float:left; clear:both;} 156 .message{color: #000000;} 157 .fieldBlock{width: 53%;} -
mj-contact-us/trunk/files/includes.php
r656078 r690252 5 5 /* defined variables */ 6 6 $atn = (isset($_REQUEST['atn'])) ? $_REQUEST['atn'] : ''; 7 DEFINE('NAME', 'mj-contact-us'); 8 DEFINE('IMGPATH' , plugins_url('/'.NAME.'/images/')); 9 DEFINE('CSSPATH' , plugins_url('/'.NAME.'/css/mj.css')); 10 DEFINE('URL' , admin_url('admin.php?page=mj-mainpage')); 11 DEFINE('ACTION' , $atn); 7 define('NAME', 'mj-contact-us'); 8 define('IMGPATH' , plugins_url('/'.NAME.'/images/')); 9 define('CSSPATH' , plugins_url('/'.NAME.'/css/mj.css')); 10 define('URL' , admin_url('admin.php?page=mj-mainpage')); 11 define('FORMURL' , admin_url('admin.php?page=mj-contact-forms')); 12 define('ADDFORM' , add_query_arg(array('atn'=>'add'), admin_url('admin.php?page=mj-contact-forms'))); 13 define('EDITFORM' , add_query_arg(array('atn'=>'edit'), admin_url('admin.php?page=mj-contact-forms'))); 14 define('FIELDSURL' , admin_url('admin.php?page=mj-contact-fields')); 15 define('ADDFIELD' , add_query_arg(array('atn'=>'add'), admin_url('admin.php?page=mj-contact-fields'))); 16 define('EDITFIELD' , add_query_arg(array('atn'=>'edit'), admin_url('admin.php?page=mj-contact-fields'))); 17 define('STOREDDATAVIEW' , add_query_arg(array('atn'=>'view','id'=>''), admin_url('admin.php?page=mj-store-fields'))); 18 define('ACTION' , $atn); 19 define('WP_CAPTCHA_DIR_URL', plugin_dir_url(__FILE__)); 20 define('WP_CAPTCHA_DIR', dirname(__FILE__)); 12 21 13 include( plugin_dir_path( __FILE__ ) . '/simple-php-captcha.php');14 22 include( plugin_dir_path( __FILE__ ) . '/mj-class-functions.php'); 15 23 include( plugin_dir_path( __FILE__ ) . '/mj-class-process.php'); 16 24 include( plugin_dir_path( __FILE__ ) . '/mj-class-html.php'); 25 include( plugin_dir_path( __FILE__ ) . '/db.php'); 17 26 18 27 ?> -
mj-contact-us/trunk/files/mj-class-functions.php
r656078 r690252 1 <<<<<<< .mine 1 2 <?php 3 2 4 /** 5 3 6 * simple function file 7 4 8 */ 9 5 10 class MjFunctions{ 6 11 12 13 14 public static $fieldType = array( 15 16 1=>'Text', 17 18 2=>'Textarea', 19 20 3=>'Submit', 21 22 4=>'Radio', 23 24 5=>'Checkbox', 25 26 6=>'Dropdown', 27 28 //7=>'File', 29 30 8=>'Chapcha', 31 32 ); 33 34 public static $validationRules = array( 35 36 0=>'text', 37 38 1=>'email', 39 40 2=>'number', 41 42 3=>'url', 43 44 //5=>'Regular Expression', 45 46 ); 47 48 49 7 50 public static function MathCaptcha(){ 51 8 52 $rand_int1 = substr(mt_rand(),0,2); 53 9 54 $rand_int2 = substr(mt_rand(),0,1); 55 10 56 $rand_int3 = substr(mt_rand(),0,1); 57 11 58 $captcha_answer = $rand_int1 + $rand_int2 - $rand_int3; 59 12 60 $_SESSION['captcha_answer'] = $captcha_answer; 61 13 62 return $rand_int1.' + '.$rand_int2.' - '.$rand_int3." = ?"; 14 } 63 64 } 65 15 66 public static function BaseIncode(){ 67 16 68 return base64_encode($_SESSION['captcha_answer']); 17 } 69 70 } 71 18 72 public static function BaseDecode($value){ 73 19 74 return base64_decode($value); 20 } 21 22 23 24 } 75 76 } 77 78 79 80 public static function GetFormData(){ 81 82 global $wpdb; 83 84 $table_name = $wpdb->prefix . "mj_contact_forms"; 85 86 $active_rows = $wpdb->get_results( 87 88 "SELECT * FROM {$table_name}" 89 90 ); 91 92 return $active_rows; 93 94 } 95 96 97 98 public static function GetFormFielsData(){ 99 100 global $wpdb; 101 102 $table_name = $wpdb->prefix . "mj_contact_fields"; 103 104 $active_rows = $wpdb->get_results( 105 106 "SELECT * FROM {$table_name}" 107 108 ); 109 110 return $active_rows; 111 112 } 113 114 115 116 117 118 public static function message($code = ''){ 119 120 $MSG = (isset($_REQUEST['MSG'])) ? $_REQUEST['MSG']: $code; 121 122 switch($MSG){ 123 124 case 'A01BC': 125 126 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data saved Successfully</div></div>"; 127 128 break; 129 130 case 'AS091K23': 131 132 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data saved Successfully</div></div>"; 133 134 break; 135 136 case 'C02SC': 137 138 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data updated Successfully</div></div>"; 139 140 break; 141 142 case 'F02AF': 143 144 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data deleted Successfully</div></div>"; 145 146 break; 147 148 case 'S02AS': 149 150 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data status Changed Successfully</div></div>"; 151 152 break; 153 154 case 'AS091K24': 155 156 echo "<div class='error p-12' id='message'><div class='p-12'>Error : Error while saving data. Please try it later</div></div>"; 157 158 break; 159 160 # new message 161 162 case 'E-FRM-NAME': 163 164 echo "<div class='error p-12' id='message'><div class='p-12'>Error : Empty Form Name</div></div>"; 165 166 break; 167 168 case 'E-FRM-ID': 169 170 echo "<div class='error p-12' id='message'><div class='p-12'>Error : Empty Form ID</div></div>"; 171 172 break; 173 174 case 'E-FRM-INVALID': 175 176 echo "<div class='error p-12' id='message'><div class='p-12'>Error : Invalid Request</div></div>"; 177 178 break; 179 180 case 'E-FIELD-NAME': 181 182 echo "<div class='error p-12' id='message'><div class='p-12'>Error : Empty Field Name</div></div>"; 183 184 break; 185 186 case 'E-FIELD-ID': 187 188 echo "<div class='error p-12' id='message'><div class='p-12'>Error : Empty Field ID</div></div>"; 189 190 break; 191 192 case 'E-FIELD-TYPE': 193 194 echo "<div class='error p-12' id='message'><div class='p-12'>Error : No Field Type Selected</div></div>"; 195 196 break; 197 198 case 'E-FIELD-FORM': 199 200 echo "<div class='error p-12' id='message'><div class='p-12'>Error : No Form Selected</div></div>"; 201 202 break; 203 204 case 'S-INSERTED': 205 206 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data Saved Successfully !</div></div>"; 207 208 break; 209 210 case 'STATUS': 211 212 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Status Updated Successfully !</div></div>"; 213 214 break; 215 216 case 'DELETED': 217 218 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data Deleted Successfully !</div></div>"; 219 220 break; 221 222 case 'NO-CHANGE': 223 224 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : No Data Changed !</div></div>"; 225 226 break; 227 228 default: 229 230 break; 231 232 } 233 234 } 235 236 237 238 public static function GetFormDataById($id='0'){ 239 240 global $wpdb; 241 242 $table_name = $wpdb->prefix . "mj_contact_forms"; 243 244 $data = $wpdb->get_row("SELECT * FROM $table_name WHERE form_id = '$id'", ARRAY_A); 245 246 return $data; 247 248 } 249 250 251 252 253 254 public static function GetFormFieldDataById($id = '0'){ 255 256 global $wpdb; 257 258 $table_name = $wpdb->prefix . "mj_contact_fields"; 259 260 $data = $wpdb->get_row("SELECT * FROM $table_name WHERE `column_id` = '$id'", ARRAY_A); 261 262 return $data; 263 264 } 265 266 267 268 public static function getFormFieldbyFormId($form_ref_id = '0'){ 269 270 global $wpdb; 271 272 $table_name = $wpdb->prefix . "mj_contact_fields"; 273 274 $data = $wpdb->get_results("SELECT * FROM $table_name WHERE `form_ref_id` = '$form_ref_id' AND column_status='1' order by serial", ARRAY_A); 275 276 return $data; 277 278 } 279 280 281 282 public static function GetFormDataDropdown($selected = '',$class){ 283 284 $data = self::GetFormData(); 285 286 echo "<select name='formrefid' id='formrefid' class='{$class}'>"; 287 288 echo "<option value='0'>Select a form</option>"; 289 290 foreach($data as $value){ 291 292 if($value->form_id==$selected){ 293 294 echo "<option value='{$value->form_id}' selected='selected' >{$value->form_name}</option>"; 295 296 }else{ 297 298 echo "<option value='{$value->form_id}'>{$value->form_name}</option>"; 299 300 } 301 302 } 303 304 echo "</select>"; 305 306 } 307 308 309 310 public static function getFieldType($selected = '',$class=''){ 311 312 313 314 $data = self::$fieldType; 315 316 echo "<select name='column_type' id='column_type' class='{$class}'>"; 317 318 echo "<option value='0'>Select a field type</option>"; 319 320 foreach($data as $key=>$value){ 321 322 if($key==$selected){ 323 324 echo "<option selected='selected' value='{$key}'>{$value}</option>"; 325 326 }else{ 327 328 echo "<option value='{$key}'>{$value}</option>"; 329 330 } 331 332 } 333 334 echo "</select>"; 335 336 } 337 338 339 340 public static function getFieldValidationType($selected = '',$class=''){ 341 342 $data = self::$validationRules; 343 344 echo "<select name='fieldvalidation' id='fieldvalidation' class='{$class}'>"; 345 346 echo "<option value='0'>Select a validation type</option>"; 347 348 foreach($data as $key=>$value){ 349 350 if($key==$selected){ 351 352 echo "<option selected='selected' value='{$key}'>{$value}</option>"; 353 354 }else{ 355 356 echo "<option value='{$key}'>{$value}</option>"; 357 358 } 359 360 } 361 362 echo "</select>"; 363 364 } 365 366 367 368 /* 369 370 * function user to update field status 371 372 */ 373 374 375 376 public static function updateFieldStatus(){ 377 378 global $wpdb; 379 380 $table_name = $wpdb->prefix . "mj_contact_fields"; 381 382 $id = $_REQUEST['id']; 383 384 385 386 if(empty($id) && !is_numeric($id)){ 387 388 return 'InValidCode'; 389 390 } 391 392 393 394 $Update = $wpdb->query("UPDATE $table_name SET `column_status`= CASE WHEN `column_status` = 1 THEN 0 WHEN `column_status` = 0 THEN 1 END WHERE `column_id`=$id"); 395 396 return $Update; 397 398 } 399 400 401 402 403 404 /* 405 406 * function use to delete field 407 408 */ 409 410 411 412 public static function deleteField(){ 413 414 global $wpdb; 415 416 $table_name = $wpdb->prefix . "mj_contact_fields"; 417 418 $id = $_REQUEST['id']; 419 420 421 422 if(empty($id) && !is_numeric($id)){ 423 424 return 'InValidCode'; 425 426 } 427 428 429 430 $Delete = $wpdb->query( $wpdb->prepare( 431 432 "delete from $table_name where `column_id`='%d'" 433 434 ,array( 435 436 $id, 437 438 ) 439 440 )); 441 442 return $Delete; 443 444 445 446 } 447 448 449 450 public static function editField(){ 451 452 453 454 if(isset($_POST['MJfieldact'])) { 455 456 457 458 global $wpdb; 459 460 $table_name = $wpdb->prefix . "mj_contact_fields"; 461 462 463 464 $serial = (isset($_POST['serial']) && !empty($_POST['serial'])) ? $_POST['serial'] :''; 465 466 $column_name = (isset($_POST['column_name']) && !empty($_POST['column_name'])) ? $_POST['column_name'] :''; 467 468 $column_name_id = (isset($_POST['column_name_id']) && !empty($_POST['column_name_id'])) ? $_POST['column_name_id'] :''; 469 470 $column_lable = (isset($_POST['column_lable']) && !empty($_POST['column_lable'])) ? $_POST['column_lable'] :''; 471 472 $column_type = (isset($_POST['column_type']) && !empty($_POST['column_type'])) ? $_POST['column_type'] :'0'; 473 474 $column_description = (isset($_POST['column_description']) && !empty($_POST['column_description'])) ? $_POST['column_description']:''; 475 476 $column_classes = (isset($_POST['column_classes']) && !empty($_POST['column_classes'])) ? $_POST['column_classes'] :''; 477 478 $column_required = (isset($_POST['column_required']) && !empty($_POST['column_required'])) ? $_POST['column_required'] :'0'; 479 480 $fieldvalidation = (isset($_POST['fieldvalidation']) && !empty($_POST['fieldvalidation'])) ? $_POST['fieldvalidation'] :'0'; 481 482 $formrefid = (isset($_POST['formrefid']) && !empty($_POST['formrefid'])) ? $_POST['formrefid'] :'0'; 483 484 $column_status = (isset($_POST['column_status']) && !empty($_POST['column_status'])) ? $_POST['column_status'] :'0'; 485 486 $current_user = get_current_user_id(); 487 488 $column_id = $_POST['id']; 489 490 491 492 if(empty($column_name)){ 493 494 495 496 return 'EmptyColumnName'; 497 498 499 500 }elseif(empty($column_name_id)){ 501 502 503 504 return 'EmptyColumnId'; 505 506 507 508 }elseif($column_type==0){ 509 510 511 512 return 'EmptyColumnType'; 513 514 515 516 }elseif($formrefid==0){ 517 518 519 520 return 'EmptyFormType'; 521 522 523 524 } 525 526 527 528 $update = $wpdb->update( 529 530 $table_name, 531 532 array( 533 534 'column_name' => $column_name, 535 536 'column_name_id' => $column_name_id, 537 538 'column_lable' => $column_lable, 539 540 'column_type' => $column_type, 541 542 'column_description' => $column_description, 543 544 'column_classes' => $column_classes, 545 546 'column_required' => $column_required, 547 548 'column_Validation_type'=> $fieldvalidation, 549 550 'form_ref_id' => $formrefid, 551 552 'column_status' => $column_status, 553 554 'serial' => $serial, 555 556 'added_by' => $current_user 557 558 ), 559 560 array('column_id'=>$column_id), 561 562 array( 563 564 '%s', 565 566 '%s', 567 568 '%s', 569 570 '%d', 571 572 '%s', 573 574 '%s', 575 576 '%d', 577 578 '%d', 579 580 '%d', 581 582 '%d', 583 584 '%d', 585 586 '%d' 587 588 ), 589 590 array('%d') 591 592 ); 593 594 return $update; 595 596 } 597 598 } 599 600 601 602 603 604 public function dynamicForm($formId){ 605 606 $data = self::GetFormDataById($formId); 607 608 if($data){ 609 610 mjContactPRO::dynamicFormProcess(); 611 612 self::createDynamicForm($formId); 613 614 }else{ 615 616 echo "invalid Form Id"; 617 618 } 619 620 } 621 622 623 624 public function createDynamicForm($formid){ 625 626 global $post; 627 628 $form = self::GetFormDataById($formid); 629 630 $data = self::getFormFieldbyFormId($formid); 631 632 $action = get_permalink($post->ID); 633 634 $name = (is_page())? 'page_id' : (is_home()) ? 'page_id' : 'post_id'; 635 636 $form_name = self::removeSpace($form[form_name]); 637 638 $form_div_id = self::removeSpace($form[form_div_id]); 639 640 ?> 641 642 <script>jQuery(document).ready(function() { jQuery("#<?php echo $form_div_id; ?>").validate(); });</script> 643 644 <?php 645 646 echo "<form id='$form_div_id' action='$action' method='post'>"; 647 648 foreach($data as $key => $value){ 649 650 echo "<div class='fieldBlock'>"; 651 652 echo '<div for="label" class="label">'.self::Labels($value).'</div>'; 653 654 echo '<div for="field" class="field">'.self::Fields($value).'</div>'; 655 656 echo "</div>"; 657 658 } ?> 659 660 <?php 661 662 echo "<input type='hidden' name='page_id' value='$post->ID'>"; 663 664 echo "<input type='hidden' name='dnForm' value='$formid'>"; 665 666 echo '</form>'; 667 668 } 669 670 671 672 /* 673 674 * function to generate dynamic field 675 676 * 1=>'Text',2=>'Textarea',3=>'Submit',4=>'Radio',5=>'Checkbox',6=>'DropDown', 677 678 */ 679 680 public static function Fields($field){ 681 682 $id = $field['column_validation_type']; 683 684 $column_classes = $field['column_classes']; 685 686 $textFieldType = self::$validationRules[$id]; 687 688 $column_id = $field[column_id]; 689 690 $column_name = self::removeSpace($field[column_name]); 691 692 //$column_name = ($column_name=='name')? 'mj_'.$column_name : $column_name; 693 694 $column_name_id = self::removeSpace($field[column_name_id]); 695 696 $required = (isset($field['column_required']) && $field['column_required']==1)? "required='required'" : ""; 697 698 switch($field['column_type']){ 699 700 case '1': # text field 701 702 $data = "<input type='$textFieldType' $required name='field[$column_id]' id='$column_name_id' class='$column_classes'>"; 703 704 705 706 break; 707 708 709 710 case '2': # textarea 711 712 $data = "<textarea $required name='field[$column_id]' id='$column_name_id' class='$field[column_classes]' ></textarea>"; 713 714 break; 715 716 717 718 case '3': # radio 719 720 $data = "<input type='submit' name='$column_name' id='submit' class='$field[column_classes] btnsubmit' value='send'>"; 721 722 break; 723 724 725 726 case '4': # radio 727 728 $count = strlen(strstr($field[column_description],"\r\n")); 729 730 if((int)$count>0){ 731 732 $list = explode("\r\n",$field[column_description]); 733 734 foreach($list as $value){ 735 736 $data .= "$value : <input type='radio' $required name='field[$column_id]' id='$column_name_id' class='$field[column_classes]' value='$value' >"; 737 738 } 739 740 }else{ 741 742 $data = "<input type='radio' $required name='field[$column_id]' id='$column_name_id' class='$field[column_classes]' value='$field[column_description]' >"; 743 744 } 745 746 break; 747 748 749 750 case '5': # checkbox 751 752 $count = strlen(strstr($field[column_description],"\r\n")); 753 754 if((int)$count>0){ 755 756 $list = explode("\r\n",$field[column_description]); 757 758 foreach($list as $value){ 759 760 $data .= "$value : <input type='checkbox' $required name='field[$column_id]' id='$column_name_id' class='$field[column_classes]' value='$value' >"; 761 762 } 763 764 }else{ 765 766 $data = "<input type='checkbox' $required name='field[$column_id]' id='$column_name_id' class='$field[column_classes]' value='$field[column_description]' >"; 767 768 } 769 770 break; 771 772 773 774 case '6': # dropdown 775 776 $count = strlen(strstr($field[column_description],"\r\n")); 777 778 if((int)$count>0){ 779 780 $list = explode("\r\n",$field[column_description]); 781 782 $data = "<select name='field[$column_id]' $required>"; 783 784 $data .= "<option value=''>Please select $field[column_lable] </option>"; 785 786 foreach ($list as $values){ 787 788 $data .= "<option value='$values'>$values</option>"; 789 790 } 791 792 $data .= "</select>"; 793 794 795 796 }else{ 797 798 $data = "invalid data value"; 799 800 } 801 802 break; 803 804 805 806 case '8': 807 808 $data = '<img src="'.WP_CAPTCHA_DIR_URL.'captcha_code_file.php?s='.$field[form_ref_id].'&rand='.rand().'" />'; 809 810 $data .= '<input type="text" name="captcha" value="">'; 811 812 break; 813 814 } 815 816 return $data; 817 818 } 819 820 821 822 823 824 /* 825 826 * function to generate dynamic label 827 828 * 1=>'Text',2=>'Textarea',3=>'Submit',4=>'Radio',5=>'Checkbox',6=>'DropDown', 829 830 */ 831 832 public static function Labels($field){ 833 834 switch($field['column_type']){ 835 836 case '1': 837 838 case '2': 839 840 case '4': 841 842 case '5': 843 844 case '6': 845 846 $label = "<lable for='$field[column_lable]' name='$field[column_lable]'>".$field['column_lable']."</label>"; 847 848 break; 849 850 default: 851 852 $label = ""; 853 854 break; 855 856 } 857 858 return $label; 859 860 } 861 862 863 864 865 866 /* 867 868 * function to add form 869 870 */ 871 872 public static function addForm(){ 873 874 875 876 if(isset($_REQUEST['addform']) && $_REQUEST['addform']=="new"){ 877 878 879 880 global $wpdb; 881 882 $table_name = $wpdb->prefix . "mj_contact_forms"; 883 884 $formName = self::FormTrim($_POST['formname']); 885 886 $formId = self::FormTrim($_POST['formid']); 887 888 if(isset($formName) && empty($formName)){ 889 890 return "EmptyFormName"; 891 892 }elseif(isset($formId) && empty($formId)){ 893 894 return "EmptyFormId"; 895 896 } 897 898 899 900 $Subject = $_POST['subject']; 901 902 $Email = $_POST['email']; 903 904 $EmailCc = $_POST['email_cc']; 905 906 $EmailBcc = $_POST['email_bcc']; 907 908 $Status = $_POST['status']; 909 910 $Saved = $_POST['saved']; 911 912 $sendMail = $_POST['sendMail']; 913 914 $AddedBy = get_current_user_id(); 915 916 $Insert = $wpdb->query( $wpdb->prepare( 917 918 "INSERT INTO $table_name (form_name, form_div_id, subject, email, email_cc, email_bcc, status, saved, sendmail, added_by) VALUES ( %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", 919 920 array( 921 922 $formName, 923 924 $formId, 925 926 $Subject, 927 928 $Email, 929 930 $EmailCc, 931 932 $EmailBcc, 933 934 $Status, 935 936 $Saved, 937 938 $sendMail, 939 940 $AddedBy 941 942 ) 943 944 )); 945 946 947 948 return $Insert; 949 950 } 951 952 return false; 953 954 } 955 956 957 958 /* 959 960 * function use to edit form data 961 962 */ 963 964 public static function EditForm(){ 965 966 if(isset($_REQUEST['addform']) && $_REQUEST['addform']=="update"){ 967 968 global $wpdb; 969 970 $table_name = $wpdb->prefix . "mj_contact_forms"; 971 972 973 974 $formName = self::FormTrim($_POST['formname']); 975 976 $formId = self::FormTrim($_POST['formid']); 977 978 if(isset($formName) && empty($formName)){ 979 980 return "EmptyFormName"; 981 982 }elseif(isset($formId) && empty($formId)){ 983 984 return "EmptyFormId"; 985 986 } 987 988 $Subject = $_POST['subject']; 989 990 $Email = $_POST['email']; 991 992 $EmailCc = $_POST['email_cc']; 993 994 $EmailBcc = $_POST['email_bcc']; 995 996 $Status = $_POST['status']; 997 998 $Saved = $_POST['saved']; 999 1000 $sendMail = $_POST['sendMail']; 1001 1002 $Id = $_POST['id']; 1003 1004 $query = $wpdb->prepare("update $table_name set `form_name`=%s,`form_div_id`=%s,`subject`=%s,`email`=%s,`email_cc`=%s,`email_bcc`=%s,`status`='%d',`saved`='%d',`sendmail`='%d' where `form_id`='%d'" 1005 1006 ,array( 1007 1008 $formName, 1009 1010 $formId, 1011 1012 $Subject, 1013 1014 $Email, 1015 1016 $EmailCc, 1017 1018 $EmailBcc, 1019 1020 $Status, 1021 1022 $Saved, 1023 1024 $sendMail, 1025 1026 $Id, 1027 1028 ) 1029 1030 ); 1031 1032 $Insert = $wpdb->query($query); 1033 1034 return $Insert; 1035 1036 } 1037 1038 return false; 1039 1040 } 1041 1042 1043 1044 /* 1045 1046 * function use to redirect on url with message 1047 1048 */ 1049 1050 1051 1052 public static function mRedirect($MSG = '', $url = ''){ 1053 1054 $redirect = add_query_arg(array('MSG' => $MSG), $url); 1055 1056 wp_redirect($redirect,'301'); 1057 1058 } 1059 1060 1061 1062 /* 1063 1064 * function use to update status of form 1065 1066 */ 1067 1068 1069 1070 public static function updateFormStatus(){ 1071 1072 global $wpdb; 1073 1074 $table_name = $wpdb->prefix . "mj_contact_forms"; 1075 1076 $id = $_REQUEST['id']; 1077 1078 1079 1080 if(empty($id) && !is_numeric($id)){ 1081 1082 return 'InValidCode'; 1083 1084 } 1085 1086 1087 1088 $Update = $wpdb->query("UPDATE $table_name SET `status`= CASE WHEN `status` = 1 THEN 0 WHEN `status` = 0 THEN 1 END WHERE `form_id`=$id"); 1089 1090 return $Update; 1091 1092 } 1093 1094 1095 1096 /* 1097 1098 * function use to update status of form 1099 1100 */ 1101 1102 1103 1104 public static function deleteForm(){ 1105 1106 1107 1108 if(isset($_REQUEST['atn']) && $_REQUEST['atn']=="delete"){ 1109 1110 global $wpdb; 1111 1112 $table_name = $wpdb->prefix . "mj_contact_forms"; 1113 1114 $id = $_REQUEST['id']; 1115 1116 1117 1118 if(empty($id) && !is_numeric($id)){ 1119 1120 return 'InValidCode'; 1121 1122 } 1123 1124 1125 1126 $delete = $wpdb->query( $wpdb->prepare( 1127 1128 "delete from $table_name where `form_id`='%d'" 1129 1130 ,array( 1131 1132 $id, 1133 1134 ) 1135 1136 )); 1137 1138 return $delete; 1139 1140 } 1141 1142 return false; 1143 1144 } 1145 1146 1147 1148 1149 1150 public static function addField(){ 1151 1152 1153 1154 if(isset($_POST['MJfieldact'])) { 1155 1156 global $wpdb; 1157 1158 $table_name = $wpdb->prefix . "mj_contact_fields"; 1159 1160 1161 1162 $serial = (isset($_POST['serial']) && !empty($_POST['serial'])) ? $_POST['serial'] :''; 1163 1164 $column_name = (isset($_POST['column_name']) && !empty($_POST['column_name'])) ? $_POST['column_name'] :''; 1165 1166 $column_name_id = (isset($_POST['column_name_id']) && !empty($_POST['column_name_id'])) ? $_POST['column_name_id'] :''; 1167 1168 $column_lable = (isset($_POST['column_lable']) && !empty($_POST['column_lable'])) ? $_POST['column_lable'] :''; 1169 1170 $column_type = (isset($_POST['column_type']) && !empty($_POST['column_type'])) ? $_POST['column_type'] :'0'; 1171 1172 $column_description = (isset($_POST['column_description']) && !empty($_POST['column_description'])) ? $_POST['column_description']:''; 1173 1174 $column_classes = (isset($_POST['column_classes']) && !empty($_POST['column_classes'])) ? $_POST['column_classes'] :''; 1175 1176 $column_required = (isset($_POST['column_required']) && !empty($_POST['column_required'])) ? $_POST['column_required'] :'0'; 1177 1178 $fieldvalidation = (isset($_POST['fieldvalidation']) && !empty($_POST['fieldvalidation'])) ? $_POST['fieldvalidation'] :'0'; 1179 1180 $formrefid = (isset($_POST['formrefid']) && !empty($_POST['formrefid'])) ? $_POST['formrefid'] :'0'; 1181 1182 $column_status = (isset($_POST['column_status']) && !empty($_POST['column_status'])) ? $_POST['column_status'] :'0'; 1183 1184 $current_user = get_current_user_id(); 1185 1186 1187 1188 if(empty($column_name)){ 1189 1190 1191 1192 return 'EmptyColumnName'; 1193 1194 1195 1196 }elseif(empty($column_name_id)){ 1197 1198 1199 1200 return 'EmptyColumnId'; 1201 1202 1203 1204 }elseif($column_type==0){ 1205 1206 1207 1208 return 'EmptyColumnType'; 1209 1210 1211 1212 }elseif($formrefid==0){ 1213 1214 1215 1216 return 'EmptyFormType'; 1217 1218 1219 1220 } 1221 1222 1223 1224 $Inserted = $wpdb->insert( 1225 1226 $table_name, 1227 1228 array( 1229 1230 'column_name' => $column_name, 1231 1232 'column_name_id' => $column_name_id, 1233 1234 'column_lable' => $column_lable, 1235 1236 'column_type' => $column_type, 1237 1238 'column_description' => $column_description, 1239 1240 'column_classes' => $column_classes, 1241 1242 'column_required' => $column_required, 1243 1244 'column_Validation_type'=> $fieldvalidation, 1245 1246 'form_ref_id' => $formrefid, 1247 1248 'column_status' => $column_status, 1249 1250 'serial' => $serial, 1251 1252 'added_by' => $current_user 1253 1254 ), 1255 1256 array( 1257 1258 '%s', 1259 1260 '%s', 1261 1262 '%s', 1263 1264 '%d', 1265 1266 '%s', 1267 1268 '%s', 1269 1270 '%d', 1271 1272 '%d', 1273 1274 '%d', 1275 1276 '%d', 1277 1278 '%d', 1279 1280 '%d' 1281 1282 ) 1283 1284 ); 1285 1286 return $Inserted; 1287 1288 } 1289 1290 } 1291 1292 1293 1294 public static function removeSpace($data){ 1295 1296 $replaceTo = array(' ','_','-','~','!','@','#','$','%','^','&','*','(',')','+','=','-','{','}',']','[','|','.',';',':','`'); 1297 1298 $replaceWith = array('_'); 1299 1300 $filterData = str_replace($replaceTo,$replaceWith,$data); 1301 1302 return $filterData; 1303 1304 } 1305 1306 1307 1308 function mj_captcha_init_sessions(){ 1309 1310 if(!session_id()){ 1311 1312 session_start(); 1313 1314 } 1315 1316 $_SESSION['captcha_type'] = 'alphanumeric'; 1317 1318 $_SESSION['captcha_letters'] = 'capitalsmall'; 1319 1320 $_SESSION['total_no_of_characters'] = '5'; 1321 1322 if(empty($_SESSION['total_no_of_characters'])){ 1323 1324 $_SESSION['total_no_of_characters'] = 6; 1325 1326 } 1327 1328 } 1329 1330 1331 1332 public static function isFieldRequired($id){ 1333 1334 global $wpdb; 1335 1336 $table_name = $wpdb->prefix . "mj_contact_fields"; 1337 1338 $data = $wpdb->get_row("SELECT column_id FROM $table_name WHERE column_id = '$id' AND column_required=1", ARRAY_A); 1339 1340 if($data){ 1341 1342 return true; 1343 1344 }else{ 1345 1346 return false; 1347 1348 } 1349 1350 } 1351 1352 1353 1354 public static function getFieldDetail($id){ 1355 1356 global $wpdb; 1357 1358 $table_name = $wpdb->prefix . "mj_contact_fields"; 1359 1360 $data = $wpdb->get_row("SELECT * FROM $table_name WHERE column_id = '$id' ", ARRAY_A); 1361 1362 return $data; 1363 1364 } 1365 1366 1367 1368 public static function isValidEmail($email){ 1369 1370 return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i", $email); 1371 1372 } 1373 1374 1375 1376 public static function isValidNumber($Number){ 1377 1378 return is_numeric($Number); 1379 1380 } 1381 1382 1383 1384 function isValidURL($url) 1385 1386 { 1387 1388 return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); 1389 1390 } 1391 1392 1393 1394 function sendDynamicMail(){ 1395 1396 $formData = self::GetFormDataById($_POST['dnForm']); 1397 1398 $message = " 1399 1400 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 1401 1402 <html> 1403 1404 <head> 1405 1406 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> 1407 1408 <title>\".$formData[form_name].\"</title> 1409 1410 </head> 1411 1412 <body> 1413 1414 <p>Hello Admin<br/></p> 1415 1416 <p>Please find the details of contact us mail send by a new user</p> 1417 1418 <p>=============================================================</p> 1419 1420 <table>"; 1421 1422 1423 1424 foreach($_POST['field'] as $key => $fields){ 1425 1426 $details = self::getFieldDetail($key); 1427 1428 if($formData['saved']==1){ 1429 1430 self::storeFormData(array('forms_ref_id'=>$_POST['dnForm'],'field_ref_id'=>$key,'form_value'=>$fields)); 1431 1432 } 1433 1434 $message .= " 1435 1436 <tr> 1437 1438 <th>{$details[column_lable]}: </th> 1439 1440 <td>{$fields}</td> 1441 1442 </tr> 1443 1444 "; 1445 1446 1447 1448 } 1449 1450 $message .= " 1451 1452 </table> 1453 1454 <p>=============================================================</p> 1455 1456 <p>Thanks & Regards</p> 1457 <p>".get_bloginfo()."</p> 1458 </body> 1459 1460 </html>"; 1461 1462 1463 1464 $headers = 'MIME-Version: 1.0' . "\r\n"; 1465 1466 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 1467 1468 $headers .= 'From: '.$formData[form_name].'' . "\r\n" . 1469 'CC: '.$formData[email_cc].'' . "\r\n". 1470 'BCC: '.$formData[email_bcc].'' . "\r\n". 1471 'Reply-To: '.$formData[email].'' . "\r\n" . 1472 'X-Mailer: PHP/' . phpversion(); 1473 $sent = wp_mail($formData[email],$formData[form_name],$message,$headers); 1474 1475 if($sent){ 1476 1477 return true; 1478 1479 }else{ 1480 1481 return false; 1482 1483 } 1484 1485 } 1486 1487 1488 1489 public static function DmFormValidation(){ 1490 1491 1492 1493 1494 1495 if(isset($_POST['captcha'])){ 1496 1497 $validate = self::stringCaptchaValidate($_POST['dnForm']); 1498 1499 } 1500 1501 exit; 1502 1503 } 1504 1505 1506 1507 public static function storeFormData($data = array()){ 1508 1509 global $wpdb; 1510 1511 $table_name = $wpdb->prefix . "mj_contact_saved_forms"; 1512 1513 $id = get_current_user_id(); 1514 1515 $Inserted = $wpdb->insert( 1516 1517 $table_name, 1518 1519 array( 1520 1521 'form_ref_id' => $data['forms_ref_id'], 1522 1523 'field_ref_id' => $data['field_ref_id'], 1524 1525 'form_value' => $data['form_value'], 1526 1527 'added_by' => $id, 1528 1529 ), 1530 1531 array( 1532 1533 '%d', 1534 1535 '%d', 1536 1537 '%s', 1538 1539 '%d' 1540 1541 ) 1542 1543 ); 1544 1545 return $Inserted; 1546 1547 } 1548 1549 1550 1551 public static function GetStoreForms(){ 1552 1553 global $wpdb; 1554 1555 $tbl1 = $wpdb->prefix . "mj_contact_forms"; 1556 1557 $tbl2 = $wpdb->prefix . "mj_contact_saved_forms"; 1558 1559 $query = "SELECT count(*) as total,s.form_ref_id,s.added_on,f.form_name FROM $tbl2 s join $tbl1 f on s.form_ref_id=f.form_id group by s.added_on"; 1560 1561 $data = $wpdb->get_results($query, ARRAY_A); 1562 1563 return $data; 1564 1565 } 1566 1567 1568 1569 public static function StoreDataDetailByDate($date = '0'){ 1570 1571 global $wpdb; 1572 1573 $tbl1 = $wpdb->prefix . "mj_contact_forms"; 1574 1575 $tbl2 = $wpdb->prefix . "mj_contact_saved_forms"; 1576 1577 $query = "SELECT s.*,f.form_name FROM $tbl2 s join $tbl1 f on s.form_ref_id=f.form_id where s.added_on='$date'"; 1578 1579 $data = $wpdb->get_results($query, ARRAY_A); 1580 1581 return $data; 1582 1583 } 1584 1585 public static function FormTrim($str) 1586 1587 { 1588 1589 return trim(preg_replace('/\s+/', ' ', $str)); 1590 1591 } 1592 1593 public static function setval($value = ''){ 1594 1595 return (isset($_REQUEST[$value]) && !empty($_REQUEST[$value])) ? $_REQUEST[$value] : ''; 1596 1597 } 1598 1599 }5 -
mj-contact-us/trunk/files/mj-class-html.php
r659596 r690252 3 3 public function mjForm(){ 4 4 global $post; 5 ?> 6 <div> 7 8 <script type="text/javascript"> 9 10 jQuery(document).ready(function() { 11 jQuery("#mailform").validate(); 12 }); 13 </script> 14 15 16 <div id="container"> 17 <h3 id="reply-title"><?php _e('Contact US') ;?></h3> 18 19 20 <form action="<?php echo get_permalink($post->ID); ?>" method="post" id="mailform" enctype="multipart/form-data"> 21 <div class="h-71"> 22 <label for="name"><?php _e('Name') ;?><?php echo (get_option('MJname')==1)? "*" : "";?></label> 23 <input <?php echo (get_option('MJname')==1)? "required='required'" : "";?> name="uname" id="uname" type="name" aria-required="true" > 24 25 </div> 26 <div class="h-71"> 27 <label for="email"><?php _e('E-mail') ;?><?php echo (get_option('MJemail')==1)? "*" : "";?></label> 28 <input id="email" <?php echo (get_option('MJemail')==1)? "required" : "";?> name="email" type="email" aria-required="true"> 29 30 </div> 31 <div class="h-71"> 32 <label for="subject"><?php _e('Subject') ;?><?php echo (get_option('MJsubject')==1)? "*" : "";?></label> 33 <input id="subject" <?php echo (get_option('MJsubject')==1)? "required" : "";?> name="subject" type="subject" size="30" aria-required="true"> 34 35 </div> 36 <div class="h-71"> 37 <label for="url"><?php _e('Website') ;?><?php echo (get_option('MJwebsite')==1)? "*" : "";?></label> 38 <input id="url" <?php echo (get_option('MJwebsite')==1)? "required" : "";?> name="url" type="url" value="" aria-required="true"> 39 </div> 40 <div class="h-134"> 41 <label for="message"><?php _e('Comment') ;?><?php echo (get_option('MJcomment')==1)? "*" : "";?></label> 42 <textarea id="comment" name="comment" <?php echo (get_option('MJcomment')==1)? "required" : "";?> cols="" rows=""></textarea> 43 </div> 44 <?php if(get_option('MJcopytome')==1):?> 45 <div class="h-71"> 46 <label for="message"><?php _e('Send copy to me') ;?></label> 47 <input type="checkbox" name="copytome" class="w-16" id="copytome" value="1"> 48 </div> 49 <?php endif; ?> 50 <?php //if(get_option('MJCapcha')==0):?> 51 <div class="h-71"> 52 <label for="message"><?php _e('Captcha : '. MjFunctions::MathCaptcha()) ;?></label> 53 <input id="captcha" required name="captcha" type="text" value="" aria-required="true"> 54 </div> 55 <?php //endif; ?> 56 <?php if(get_option('MJattachment')):?> 57 <div class="h-71"> 58 <label for="message"><?php _e('Upload Files') ;?></label> 59 <input type="file" name="file" id="file" /> 60 </div> 61 <?php endif; ?> 62 <input type="hidden" name="CODEINCODE" value="<?php echo MjFunctions::BaseIncode(); ?>"> 5 $namelbl = (get_option('MJname')==1)? '*' : ''; 6 $namefld = (get_option('MJname')==1)? 'required' : ''; 7 $emaillbl = (get_option('MJemail')==1)? "*" : ""; 8 $emailfld = (get_option('MJemail')==1)? 'required' : ''; 9 $subjectlbl = (get_option('MJsubject')==1)? "*" : ""; 10 $subjectfld = (get_option('MJsubject')==1)? "required" : ""; 11 $websitelbl = (get_option('MJwebsite')==1)? "*" : ""; 12 $websitefld = (get_option('MJwebsite')==1)? "required" : ""; 13 $commentlbl = (get_option('MJcomment')==1)? "*" : ""; 14 $commentfld = (get_option('MJcomment')==1)? "required" : ""; 15 16 $form = "<div> 17 18 <script type='text/javascript'>jQuery(document).ready(function() { jQuery('#mailform').validate(); }); </script> 19 20 <div id='container' class='mjcontactus'> 21 <h3 id='reply-title'><?php _e('Contact US') ;?></h3> 22 <form action=".get_permalink($post->ID)." method='post' id='mailform' enctype='multipart/form-data'> 23 <div class='h-71'> 24 <label for='name'>".__('Name')." $namelbl</label> 25 <input $namefld name='uname' id='uname' type='name' aria-required='true'> 26 </div>"; 27 $form .= "<div class='h-71'> 28 <label for='email'>".__('E-mail')." $emaillbl</label> 29 <input id='email' $emailfld name='email' type='email' aria-required='true'> 30 </div>"; 31 $form .= "<div class='h-71'> 32 <label for='subject'>".__('Subject')." $subjectlbl</label> 33 <input id='subject' $subjectfld name='subject' type='subject' size='30' aria-required='true'> 34 </div>"; 35 $form .= "<div class='h-71'> 36 <label for='url'>".__('Website')." $websitelbl</label> 37 <input id='url' $websitefld name='url' type='url' value='' aria-required='true'> 38 </div>"; 39 $form .= "<div class='h-134'> 40 <label for='message'>".__('Comment')." $commentlbl</label> 41 <textarea id='comment' name='comment' $commentfld cols='' rows=''></textarea> 42 </div>"; 43 if(get_option('MJcopytome')==1): 44 $form .= "<div class='h-71'> 45 <label for='message'>".__('Send copy to me')."</label> 46 <input type='checkbox' name='copytome' class='w-16' id='copytome' value='1'> 47 </div>"; 48 endif; 49 50 if(get_option('mjEnableCaptcha')==1){ 51 $form .= "<div class='h-71'> 52 <label for='message'>".__('Captcha : '. MjFunctions::MathCaptcha())."</label> 53 <input id='captcha' required name='captcha' type='number' value='' aria-required='true'> 54 </div> 55 <input type='hidden' name='CODEINCODE' value=".MjFunctions::BaseIncode().">"; 56 } elseif(get_option('mjEnableCaptcha')==0){ 57 $form .= "<div class='h-71'> 58 <label for='message'><img src=".WP_CAPTCHA_DIR_URL.'captcha_code_file.php?s=single&rand='.rand()." /></label> 59 <input id='captcha' required name='captcha' type='text' value='' aria-required='true'> 60 </div>"; 61 } 62 63 64 if(get_option('MJattachment')): 65 $form .= "<div class='h-71'> 66 <label for='message'>".__('Upload Files')."</label> 67 <input type='file' name='file' id='file' /> 68 </div>"; 69 endif; 63 70 64 <div>71 $form .= "<div> 65 72 66 <input name= "mj_submit" type="submit" id="submit" value="<?php _e('Send') ;?>">67 <input type= "hidden" name="mj_submit" value="active">68 <input type= "hidden" name="page_id" value="<?php echo $post->ID; ?>">73 <input name='mj_submit' type='submit' id='submit' value=".__('Send')."> 74 <input type='hidden' name='mj_submit' value='active'> 75 <input type='hidden' name='page_id' value=".$post->ID."> 69 76 70 77 </div> 71 78 </form> 72 79 </div> 73 </div> 74 <?php 80 </div>"; 81 return $form; 82 75 83 } 76 84 function AdminOption(){ ?> … … 95 103 <input type="checkbox" class="w-16" name="MJwebsite" <?php echo (get_option('MJwebsite')==1)? "checked='checked'" : "";?> value="1"><?php _e(' - Required Website ?') ;?><br/> 96 104 <input type="checkbox" class="w-16" name="MJcomment" <?php echo (get_option('MJcomment')==1)? "checked='checked'" : "";?> value="1"><?php _e(' - Required Comment ?') ;?><br/> 97 <input type="checkbox" class="w-16" name="MJattachment" <?php echo (get_option('MJattachment')==1)? "checked='checked'" : "";?> value="1"><?php _e(' - Enable Attachment ?') ;?><br/> 105 <!--<input type="checkbox" class="w-16" name="MJattachment" <?php echo (get_option('MJattachment')==1)? "checked='checked'" : "";?> value="1"><?php _e(' - Enable Attachment ?') ;?><br/>--> 106 <input type="radio" class="w-16" name="mjEnableCaptcha" <?php echo (get_option('mjEnableCaptcha')==1)? "checked='checked'" : "";?> value="1"><?php _e(' - Enable number captcha') ;?><br/> 107 <input type="radio" class="w-16" name="mjEnableCaptcha" <?php echo (get_option('mjEnableCaptcha')==0)? "checked='checked'" : "";?> value="0"><?php _e(' - Enable string captcha') ;?><br/> 98 108 </div> 99 109 <div> … … 106 116 <?php 107 117 } 118 public static function getFormList(){ 119 120 ?> 121 <h2><?php _e('Manage Contact forms') ?> </h2> 122 <a class='button-secondary fl' href='<?php echo ADDFORM; ?>' title='All Attendees'><?php _e('Add Form') ?></a> 123 <div class="clear"></div> 124 <div class='wrap'> 125 <table class="widefat"> 126 <thead> 127 <tr> 128 <th>S. No.</th> 129 <th>Form Name</th> 130 <th>Subject</th> 131 <th>Email (To)</th> 132 <th>Email (Cc)</th> 133 <th>Email (Bcc)</th> 134 <th>Status</th> 135 <th>ShortCode</th> 136 <th>Action</th> 137 </tr> 138 </thead> 139 <tfoot> 140 <tr> 141 <th>S. No.</th> 142 <th>Form Name</th> 143 <th>Subject</th> 144 <th>Email (To)</th> 145 <th>Email (Cc)</th> 146 <th>Email (Bcc)</th> 147 <th>Status</th> 148 <th>ShortCode</th> 149 <th>Action</th> 150 </tr> 151 </tfoot> 152 <tbody> 153 <?php 154 $data = MjFunctions::GetFormData(); 155 $i=1; 156 foreach ( $data as $value){ 157 $edit = add_query_arg(array('id' => $value->form_id,'atn' => 'edit'), FORMURL); 158 $delete = add_query_arg(array('id' => $value->form_id,'atn' => 'delete'), FORMURL); 159 $status = add_query_arg(array('id' => $value->form_id,'atn' => 'status'), FORMURL); 160 ?> 161 <tr> 162 <td><?php echo $i; ?></td> 163 <td><?php echo $value->form_name; ?></td> 164 <td><?php echo $value->subject; ?></td> 165 <td><?php echo $value->email; ?></td> 166 <td><?php echo $value->email_cc; ?></td> 167 <td><?php echo $value->email_bcc; ?></td> 168 <td><?php echo ($value->status) ? 'Enable' : 'Disable'; ?></td> 169 <td>[mjform id='<?php echo $value->form_id; ?>']</td> 170 <td> 171 <a href="<?php echo $status; ?>"><?php echo ($value->status) ? 'Disable' : 'Enable'; ?></a> | 172 <a href="<?php echo $edit; ?>" >Edit</a> | 173 <a onclick="return (confirm('Are you sure you want to delete this data ?'));" href="<?php echo $delete; ?>" >Delete</a> 174 </td> 175 </tr> 176 <?php $i++; } ?> 177 </tbody> 178 </table> 179 </div> 180 <?php 181 } 182 183 public static function getFieldList(){ 184 MjFunctions::message(); 185 ?> 186 187 <h2><?php _e('Manage Contact forms Fields') ?></h2> 188 <a class='button-secondary fl' href='<?php echo ADDFIELD; ?>' title='All Attendees'><?php _e('Add Field') ?></a> 189 <div class="clear"></div> 190 <div class='wrap'> 191 192 <table class="widefat"> 193 <thead> 194 <tr> 195 <th>S. No.</th> 196 <th>Field Name</th> 197 <th>Field ID</th> 198 <th>Field Type</th> 199 <th>Field Required</th> 200 <th>Form Name</th> 201 <th>Status</th> 202 <th align='center'>Action</th> 203 </tr> 204 </thead> 205 <tfoot> 206 <tr> 207 <th>S. No.</th> 208 <th>Field Name</th> 209 <th>Field ID</th> 210 <th>Field Type</th> 211 <th>Field Required</th> 212 <th>Form Name</th> 213 <th>Status</th> 214 <th align='center'>Action</th> 215 </tr> 216 </tfoot> 217 <tbody> 218 <?php 219 220 $data = MjFunctions::GetFormFielsData(); 221 $i=1; 222 foreach ( $data as $value){ 223 $edit = add_query_arg(array('id' => $value->column_id,'atn' => 'edit'), FIELDSURL); 224 $delete = add_query_arg(array('id' => $value->column_id,'atn' => 'delete'), FIELDSURL); 225 $status = add_query_arg(array('id' => $value->column_id,'atn' => 'status'), FIELDSURL); 226 $formData = MjFunctions::GetFormDataById($value->form_ref_id); 227 ?> 228 <tr> 229 <td><?php echo $i; ?></td> 230 <td><?php echo $value->column_name; ?></td> 231 <td><?php echo $value->column_name_id; ?></td> 232 <td><?php echo MjFunctions::$fieldType[$value->column_type]; ?></td> 233 <td><?php echo ($value->column_required) ? 'Yes' : 'No'; ?></td> 234 <td><?php echo $formData['form_name']; ?></td> 235 <?php MjFunctions::GetFormDataById($value->form_ref_id); ?> 236 <td><?php echo ($value->column_status) ? 'Enable' : 'Disable'; ?></td> 237 <td> 238 <a href="<?php echo $status; ?>"><?php echo ($value->column_status) ? 'Disable' : 'Enable'; ?></a> | 239 <a href="<?php echo $edit; ?>" >Edit</a> | 240 <a onclick="return (confirm('Are you sure you want to delete this data ?'));" href="<?php echo $delete; ?>" >Delete</a> 241 </td> 242 </tr> 243 <?php $i++; } ?> 244 </tbody> 245 </table> 246 </div> 247 <?php 248 } 249 250 251 252 public static function AddFormHtml(){ 253 $id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : '0'; 254 ?> 255 <div class="wrap" id="mjContact"> 256 <h2><?php _e('Add Contact Form'); ?></h2> 257 <form method="POST" action="<?php echo ADDFORM; ?>"> 258 <table> 259 <tr> 260 <td style="width:143px"><label for="status">Save Form Data: </label></td> 261 <td> 262 Yes <input type="radio" id="saved" name="saved" checked="checked" value="1" /> 263 No <input type="radio" id="saved" name="saved" value="0" /> 264 </td> 265 </tr> 266 <tr> 267 <td><label for="status">Send Mail: </label></td> 268 <td> 269 Yes <input type="radio" id="sendMail" class="sendMail" name="sendMail" checked="checked" value="1" /> 270 No <input type="radio" id="sendMail" class="sendMail" name="sendMail" value="0" /> 271 </td> 272 </tr> 273 274 275 <tr> 276 <td><label for="formname">Form Name: </label></td> 277 <td><input id="formname" maxlength="45" required aria-required="true" title="Please enter Form Name" size="30" name="formname" value="<?php echo MjFunctions::setval('formname'); ?>" /></td> 278 </tr> 279 280 <tr> 281 <td><label for="formid">Form ID: </label></td> 282 <td><input id="formid" maxlength="45" size="30" required aria-required="true" title="Please enter Form ID" name="formid" value="<?php echo MjFunctions::setval('formid'); ?>" /></td> 283 </tr> 284 285 <tr class="emailtd"> 286 <td><label for="subject">Subject: </label></td> 287 <td><input id="subject" maxlength="45" size="30" name="subject" value="<?php echo MjFunctions::setval('subject'); ?>" /></td> 288 </tr> 289 290 <tr class="emailtd"> 291 <td><label for="emailto">Email Address (To): </label></td> 292 <td><input id="email" maxlength="45" size="30" name="email" value="<?php echo MjFunctions::setval('email'); ?>" /></td> 293 </tr> 294 <tr class="emailtd"> 295 <td><label for="emailcc">Email Address (Cc): </label></td> 296 <td><input id="email_cc" maxlength="45" size="30" name="email_cc" value="<?php echo MjFunctions::setval('email_cc'); ?>" /></td> 297 </tr> 298 <tr class="emailtd"> 299 <td><label for="emailbcc">Email Address (Bcc): </label></td> 300 <td><input id="email_bcc" maxlength="45" size="30" name="email_bcc" value="<?php echo MjFunctions::setval('email_bcc'); ?>" /></td> 301 </tr> 302 <tr> 303 <td><label for="status">Status: </label></td> 304 <td> 305 Yes <input type="radio" id="status" name="status" checked="checked" value="1" /> 306 No <input type="radio" id="status" name="status" value="0" /> 307 </td> 308 </tr> 309 310 <tr> 311 <td><input type='submit' name="submit" value='<?php _e('Submit'); ?>' class='button-secondary' /></td> 312 </tr> 313 </table> 314 <input type="hidden" name="addform" id="addform" value="new"/> 315 </form> 316 </div> 317 318 <?php 319 } 320 321 public static function EditFormHtml(){ 322 $id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : '0'; 323 $data = MjFunctions::GetFormDataById($id); 324 if($data['sendmail']==0){ 325 echo "<style>.emailtd{display:none;}</style>"; 326 } 327 328 ?> 329 330 <div class="wrap" id="mjContact"> 331 <h2><?php _e('Edit Contact Form - '.$data['form_name']); ?> </h2> 332 <form method="POST" action="<?php echo add_query_arg(array('id'=>$_REQUEST['id']), EDITFORM); ?>"> 333 <table> 334 335 <tr> 336 <td style="width:143px"><label for="status">Save Form Data: </label></td> 337 <td> 338 Yes <input type="radio" id="saved" name="saved" <?php echo (isset($data['saved']) && $data['saved']=='1')? "checked='checked'" : "";?> value="1" /> 339 No <input type="radio" id="saved" name="saved" <?php echo (isset($data['saved']) && ($data['saved']=='0' || $data['saved']=='')) ? "checked='checked'" : "";?> value="0" /> 340 </td> 341 </tr> 342 343 <tr> 344 <td><label for="status">Send Mail: </label></td> 345 <td> 346 Yes <input type="radio" id="sendMail" class="sendMail" name="sendMail" <?php echo (isset($data['sendmail']) && $data['sendmail']=='1')? "checked='checked'" : "";?> value="1" /> 347 No <input type="radio" id="sendMail" class="sendMail" name="sendMail" <?php echo (isset($data['sendmail']) && ($data['sendmail']=='0' || $data['sendmail']=='')) ? "checked='checked'" : "";?> value="0" /> 348 </td> 349 </tr> 350 351 <tr> 352 <td><label for="formname">Form Name: </label></td> 353 <td><input id="formname" maxlength="45" size="30" name="formname" required aria-required="true" value="<?php echo (isset($data['form_name'])) ? $data['form_name'] : ''; ?>" /></td> 354 </tr> 355 356 <tr> 357 <td><label for="formid">Form ID: </label></td> 358 <td><input id="formid" maxlength="45" size="30" name="formid" required aria-required="true" value="<?php echo (isset($data['form_div_id'])) ? $data['form_div_id'] : ''; ?>" /></td> 359 </tr> 360 <tr class="emailtd"> 361 <td><label for="subject">Subject: </label></td> 362 <td><input id="subject" maxlength="45" size="30" name="subject" value="<?php echo (isset($data['subject'])) ? $data['subject'] : ''; ?>" /></td> 363 </tr> 364 365 <tr class="emailtd"> 366 <td><label for="emailto">Email Address (To): </label></td> 367 <td><input id="email" maxlength="45" size="30" name="email" value="<?php echo (isset($data['email'])) ? $data['email'] : ''; ?>" /></td> 368 </tr> 369 370 <tr class="emailtd"> 371 <td><label for="emailcc">Email Address (Cc): </label></td> 372 <td><input id="email_cc" maxlength="45" size="30" name="email_cc" value="<?php echo (isset($data['email_cc'])) ? $data['email_cc'] : ''; ?>" /></td> 373 </tr> 374 375 <tr class="emailtd"> 376 <td><label for="emailbcc">Email Address (Bcc): </label></td> 377 <td><input id="email_bcc" maxlength="45" size="30" name="email_bcc" value="<?php echo (isset($data['email_bcc'])) ? $data['email_bcc'] : ''; ?>" /></td> 378 </tr> 379 380 <tr> 381 <td><label for="status">Status: </label></td> 382 <td> 383 Yes <input type="radio" <?php echo (isset($data['status']) && $data['status']=='1')? "checked='checked'" : "";?> id="status" name="status" checked="checked" value="1" /> 384 No <input type="radio" <?php echo (isset($data['status']) && $data['status']=='0')? "checked='checked'" : ""; ?> id="status" name="status" value="0" /> 385 </td> 386 </tr> 387 388 389 <tr> 390 <td><input type='submit' name="submit" value='<?php _e('Submit'); ?>' class='button-secondary' /></td> 391 </tr> 392 </table> 393 <input type="hidden" name="addform" id="addform" value="<?php echo (isset($data['form_id'])) ? 'update': 'new'; ?>"> 394 <input type="hidden" name="id" id="id" value="<?php echo (isset($data['form_id'])) ? $data['form_id']: ''; ?>"> 395 </form> 396 </div> 397 398 <?php 399 } 400 401 public static function addFieldHtml(){ 402 MjFunctions::message(); 403 ?> 404 <div id="wrap"> 405 <div id="container"> 406 <h3 id="reply-title"><?php _e('Contact US Page Settings') ;?></h3> 407 <form action="<?php echo ADDFIELD; ?>" method="post" id="mailform"> 408 409 <div class="h-43"> 410 <label for="name"><?php _e('Field type ') ;?></label> 411 <?php MjFunctions::getFieldType(); ?> 412 </div> 413 414 <div class="h-43"> 415 <label for="serial"><?php _e('Serial No.') ;?></label> 416 <input name="serial" class="f-13" id="serial" type="text" aria-required="true" value="" > 417 </div> 418 419 <div class="h-43"> 420 <label for="name"><?php _e('Field Name') ;?></label> 421 <input name="column_name" class="f-13" id="column_name" required type="text" aria-required="true" value="" > 422 <small><i><?php _e('Do not use space in words. Use underscore in place of space like `first_name`');?></i></small> 423 </div> 424 425 <div class="h-43"> 426 <label for="name"><?php _e('Field ID') ;?></label> 427 <input name="column_name_id" class="f-13" id="column_name_id" type="text" aria-required="true" value="" > 428 <small><i><?php _e('Do not use space in words. Use underscore in place of space like `first_name`');?></i></small> 429 </div> 430 431 <div class="h-43"> 432 <label for="name"><?php _e('Field Label') ;?></label> 433 <input name="column_lable" class="f-13" id="column_lable" type="text" aria-required="true" value="" > 434 </div> 435 436 437 <div class="h-43"> 438 <label for="name"><?php _e('Field Description') ;?></label> 439 <textarea name="column_description" class="f-13" id="column_description"></textarea> 440 </div> 441 442 <div class="h-43"> 443 <label for="name"><?php _e('Field Classes') ;?></label> 444 <input name="column_classes" class="f-13" id="column_classes" type="text" aria-required="true" value="" > 445 <small><i><?php _e('Insert multiple classes with command saprated like class1,class2,class3');?></i></small> 446 </div> 447 448 449 <div class="h-43"> 450 <label for="name"><?php _e('Form field required ') ;?></label> 451 <input name="column_required" class="f-13" id="column_required" type="checkbox" aria-required="true" value="1" > 452 </div> 453 <div class="h-43"> 454 <label for="name"><?php _e('Form field validation Type') ;?></label> 455 <?php MjFunctions::getFieldValidationType(); ?> 456 </div> 457 458 459 460 <div class="h-43"> 461 <label for="name"><?php _e('Form Name') ;?></label> 462 <?php MjFunctions::GetFormDataDropdown($selected,'f-13'); ?> 463 </div> 464 465 <div class="h-43"> 466 <label for="name"><?php _e('Status') ;?></label> 467 <input type="radio" checked="checked" name="column_status" id="column_status" value="1"/> : Yes | 468 <input type="radio" name="column_status" id="column_status" value="0"/> : No 469 </div> 470 <div> 471 <input name="MJfieldact" type="hidden" id="MJact" value="insertfield"> 472 <input name="Save" type="submit" id="Save" value="<?php _e('Save') ;?>"> 473 </div> 474 </form> 475 </div> 476 </div> 477 <?php 478 } 479 480 public static function editFieldHtml(){ 481 482 $id = $_REQUEST['id']; 483 $fieldData = MjFunctions::GetFormFieldDataById($id); 484 MjFunctions::message(); 485 ?> 486 <div id="wrap"> 487 <div id="container"> 488 <h3 id="reply-title"><?php _e('Edit Field') ;?></h3> 489 <form action="<?php echo EDITFIELD; ?>" method="post" id="mailform"> 490 491 <div class="h-43"> 492 <label for="name"><?php _e('Field type ') ;?></label> 493 <?php MjFunctions::getFieldType($fieldData['column_type'],''); ?> 494 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 495 </div> 496 497 <div class="h-43"> 498 <label for="serial"><?php _e('Serial No.') ;?></label> 499 <input name="serial" class="f-13" id="serial" required type="text" aria-required="true" value="<?php echo $fieldData['serial']; ?>" > 500 </div> 501 <div class="h-43"> 502 <label for="name"><?php _e('Field Name') ;?></label> 503 <input name="column_name" class="f-13" id="column_name" required type="text" aria-required="true" value="<?php echo $fieldData['column_name']; ?>" > 504 <small><i><?php _e('Do not use space in words. Use underscore in place of space like `first_name`');?></i></small> 505 </div> 506 507 <div class="h-43"> 508 <label for="name"><?php _e('Field ID') ;?></label> 509 <input name="column_name_id" class="f-13" id="column_name_id" type="text" aria-required="true" value="<?php echo $fieldData['column_name_id']; ?>"> 510 <small><i><?php _e('Do not use space in words. Use underscore in place of space like `first_name`');?></i></small> 511 </div> 512 513 <div class="h-43"> 514 <label for="name"><?php _e('Field Label') ;?></label> 515 <input name="column_lable" class="f-13" id="column_lable" type="text" aria-required="true" value="<?php echo $fieldData['column_lable']; ?>"> 516 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 517 </div> 518 519 520 <div class="h-43"> 521 <label for="name"><?php _e('Field Description') ;?></label> 522 <textarea name="column_description" class="f-13" id="column_description"><?php echo $fieldData['column_description']; ?></textarea> 523 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 524 </div> 525 526 <div class="h-43"> 527 <label for="name"><?php _e('Field Classes') ;?></label> 528 <input name="column_classes" class="f-13" id="column_classes" type="text" aria-required="true" value="<?php echo $fieldData['column_classes']; ?>"> 529 <small><i><?php _e('Insert multiple classes with command saprated like class1,class2,class3');?></i></small> 530 </div> 531 <div class="h-43"> 532 <label for="name"><?php _e('Form field required ') ;?></label> 533 <input name="column_required" class="f-13" id="column_required" type="checkbox" aria-required="true" value="1" <?php echo ($fieldData['column_required']) ? "checked='checked'": ''; ?>> 534 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 535 </div> 536 <div class="h-43"> 537 <label for="name"><?php _e('Form field validation Type') ;?></label> 538 <?php MjFunctions::getFieldValidationType($fieldData['column_validation_type'],''); ?> 539 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 540 </div> 541 542 543 544 <div class="h-43"> 545 <label for="name"><?php _e('Form Name') ;?></label> 546 <?php MjFunctions::GetFormDataDropdown($fieldData['form_ref_id'],'f-13'); ?> 547 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 548 </div> 549 550 <div class="h-43"> 551 <label for="name"><?php _e('Status') ;?></label> 552 <input type="radio" <?php echo ($fieldData['column_status']==1 || !isset($fieldData['column_status'])) ? "checked='checked'": ''; ?> name="column_status" id="column_status" value="1"/> : Yes | 553 <input type="radio" name="column_status" id="column_status" <?php echo ($fieldData['column_status']==0) ? "checked='checked'": ''; ?> value="0"/> : No 554 <small><i><?php //_e('if blank then default mail will goes on '.get_option('admin_email'));?></i></small> 555 </div> 556 <div> 557 <input name="MJfieldact" type="hidden" id="MJact" value="insertfield"> 558 <input name="id" type="hidden" id="id" value="<?php echo $id; ?>"> 559 <input name="Save" type="submit" id="Save" value="<?php _e('Save') ;?>"> 560 </div> 561 </form> 562 </div> 563 </div> 564 <?php 565 } 566 567 public static function getStoreFormList(){ 568 $formData = MjFunctions::GetStoreForms(); 569 570 ?> 571 <h2><?php _e('Stored Form Data') ?> </h2> 572 <div class="clear"></div> 573 <div class='wrap'> 574 <table class="widefat"> 575 <thead> 576 <tr> 577 <th>Form ID</th> 578 <th>Form Name</th> 579 <th>Total Fields</th> 580 </tr> 581 </thead> 582 <tfoot> 583 <tr> 584 <th>Form ID</th> 585 <th>Form Name</th> 586 <th>Total Fields</th> 587 </tr> 588 </tfoot> 589 <tbody> 590 <?php 591 foreach ( $formData as $value){ 592 ?> 593 <tr> 594 <td><?php echo $value['form_ref_id']; ?></td> 595 <td><a href="<?php echo STOREDDATAVIEW.'='.$value['added_on']; ?>"><?php echo $value['form_name']; ?></a></td> 596 <td><?php echo $value['total']; ?></td> 597 </tr> 598 <?php $i++; } ?> 599 </tbody> 600 </table> 601 </div> 602 <?php } 603 604 public static function StoreDataDetail(){ 605 $formData = MjFunctions::StoreDataDetailByDate($_REQUEST['id']); 606 ?> 607 <h2><?php _e('Stored Data') ?> </h2> 608 <div class="clear"></div> 609 <div class='wrap'> 610 <table class="widefat"> 611 <thead> 612 <tr> 613 <th>Serial No.</th> 614 <th>Field Name</th> 615 <th></th> 616 <th>Field Value</th> 617 </tr> 618 </thead> 619 <tfoot> 620 <tr> 621 <th>Serial No.</th> 622 <th>Field Name</th> 623 <th></th> 624 <th>Field Value</th> 625 </tr> 626 </tfoot> 627 <tbody> 628 <?php $i=1; 629 foreach ( $formData as $value){ 630 $fieldvalue = MjFunctions::getFieldDetail($value['field_ref_id']); 631 ?> 632 <tr> 633 <td><?php echo $i; ?></td> 634 <td><?php echo $fieldvalue['column_name']; ?></td> 635 <td> : </td> 636 <td><?php echo $value['form_value']; ?></td> 637 </tr> 638 <?php $i++; } ?> 639 </tbody> 640 </table> 641 </div> 642 <?php } 108 643 } 109 644 -
mj-contact-us/trunk/files/mj-class-process.php
r659596 r690252 68 68 } 69 69 } 70 70 71 public static function SimpleMail(){ 71 if($_REQUEST['captcha'] == MjFunctions::BaseDecode($_POST['CODEINCODE'])){ 72 $mjEnableCaptcha = get_option('mjEnableCaptcha'); 73 74 if(isset($mjEnableCaptcha) && $mjEnableCaptcha=='1') { 75 $validate = self::numberCaptchaValidate(); 76 }else{ 77 $validate = self::stringCaptchaValidate('single'); 78 } 79 80 if($validate){ 72 81 self::copytome(); 73 82 $name = strip_tags($_REQUEST['uname']); … … 111 120 <p>=============================================================</p> 112 121 <p>Thanks & Regards</p> 122 <p>".get_bloginfo()."</p> 113 123 </body> 114 124 </html> … … 116 126 $headers = 'MIME-Version: 1.0' . "\r\n"; 117 127 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 118 $headers .= 'From: '. $to.'' . "\r\n" .128 $headers .= 'From: '.get_bloginfo().'<'.$to.'>' . "\r\n" . 119 129 'Reply-To: '.$to.'' . "\r\n" . 120 130 'X-Mailer: PHP/' . phpversion(); … … 128 138 129 139 public static function SimpleMailWithAttachment(){ 130 if($_REQUEST['captcha'] == MjFunctions::BaseDecode($_POST['CODEINCODE'])){ 140 $mjEnableCaptcha = get_option('mjEnableCaptcha'); 141 if(isset($mjEnableCaptcha) && $mjEnableCaptcha=='1') { 142 $validate = self::numberCaptchaValidate(); 143 }else{ 144 $validate = self::stringCaptchaValidate('single'); 145 } 146 147 if($validate){ 131 148 if($_FILES['file']['name']!=""){ 132 149 self::copytome(); … … 140 157 141 158 142 $message = " 143 <html> 144 <head> 145 <title>Contact US Mail</title> 146 </head> 147 <body> 148 <p>Hello Admin<br/></p> 159 $msg = " 160 <p>Hello Admin</p> 149 161 <p>Please find the details of contact us mail send by a new user</p> 150 162 <p>=============================================================</p> … … 170 182 <td>{$comment}</td> 171 183 </tr> 172 173 184 </table> 174 185 <p>=============================================================</p> 175 <p>Thanks & Regards</p> 176 </body> 177 </html> 178 "; 179 self::sendEmail("admin", $email, $to, $subject, $message, $_FILES['file']); 180 echo "<div class='updatedcss' id='message'> Mail Sent Successfully</div>"; 186 <p>Thanks & Regards</p>"; 187 $msg="this is testing message"; 188 $response = self::sendEmail($name, $email, $to, $subject, $msg, $_FILES['file']); 189 if($response){ 190 echo "<div class='updatedcss' id='message'> Mail Sent Successfully</div>"; 191 }else{ 192 echo "<div class='Eerror p-12' id='message'> Error: Mail Not Sent. Please try again later</div>"; 193 } 181 194 }else{ 182 echo "<div class=' error p-12' id='message'>Please Upload Files</div>";195 echo "<div class='Eerror p-12' id='message'>Please Upload Files</div>"; 183 196 } 184 197 }else{ 185 echo "<div class=' error p-12' id='message'>Invalid Captcha</div>";186 } 187 } 188 189 function sendEmail($name, $email, $to_mail, $subject, $msg, $attachment = "") {198 echo "<div class='Eerror p-12' id='message'>Invalid Captcha</div>"; 199 } 200 } 201 202 function sendEmail($name, $email, $to_mail, $subject, $msg, $attachment = "") { 190 203 $sending = false; 191 204 … … 200 213 if ($sending) { 201 214 $eol = "\n"; 202 203 215 $tosend['email'] = $to_mail; 204 216 $tosend['subject'] = $subject; 205 206 $tosend['message'] = " 207 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 217 $tosend['message'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 208 218 <html> 209 219 <head> … … 242 252 $tosend['headers'] .= "--PHP-mixed-".$uid."--"; 243 253 $tosend['message'] = "";//-- The message is already in the headers. 244 } 245 246 if ( mail($tosend['email'], $tosend['subject'], $tosend['message'] , $tosend['headers']))254 } 255 $sent = mail($tosend['email'],$tosend['subject'],$tosend['message'],$tosend['headers']); 256 if ($sent) 247 257 return true; 248 258 else … … 250 260 } 251 261 return false; 252 } 253 262 } 263 264 265 266 267 254 268 function AdminOptionProcess(){ 255 269 if(isset($_POST['MJact']) && $_POST['MJact']=="insert"){ … … 262 276 $MJcomment = isset($_POST['MJcomment'])? 1 :0; 263 277 $MJattachment = isset($_POST['MJattachment'])? 1 :0; 278 $Captcha = $_POST['mjEnableCaptcha']; 279 264 280 if(is_email($MJmailto)){ 265 281 update_option('MJmailto',$MJmailto); … … 271 287 update_option('MJcomment',$MJcomment); 272 288 update_option('MJattachment',$MJattachment); 289 update_option('mjEnableCaptcha',$Captcha); 273 290 echo "<div class='updated p-12' id='message'><div class='p-12'>Success : Data saved Successfully</div></div>"; 274 291 … … 291 308 } 292 309 } 293 310 311 public static function AddFormProcess(){ 312 $Response = MjFunctions::addForm(); 313 if($Response){ 314 switch($Response){ 315 case "EmptyFormName": 316 $errorCode = 'E-FRM-NAME'; 317 break; 318 case "EmptyFormId": 319 $errorCode = 'E-FRM-ID'; 320 break; 321 case '1': 322 $errorCode = 'S-INSERTED'; 323 break; 324 default: 325 $errorCode = 'E-FRM-INVALID'; 326 } 327 MjFunctions::message($errorCode); //MjFunctions::mRedirect($errorCode,ADDFORM); 328 } 329 } 330 331 public static function EditFormProcess(){ 332 $Response = ''; 333 $Response = MjFunctions::EditForm(); 334 if($Response){ 335 switch($Response){ 336 case "EmptyFormName": 337 $errorCode = 'E-FRM-NAME'; 338 break; 339 case "EmptyFormId": 340 $errorCode = 'E-FRM-ID'; 341 break; 342 case '1': 343 $errorCode = 'S-INSERTED'; 344 break; 345 default: 346 $errorCode = 'E-FRM-INVALID'; 347 break; 348 } 349 #$url = add_query_arg(array('id'=>$_REQUEST['id']), EDITFORM); 350 MjFunctions::message($errorCode); #MjFunctions::mRedirect($errorCode,$url); 351 } 352 } 353 354 public static function updateFormStatusProcess(){ 355 $Response = MjFunctions::updateFormStatus(); 356 if($Response){ 357 switch($Response){ 358 case "InValidCode": 359 $errorCode = 'E-FRM-INVALID'; 360 break; 361 case '1': 362 $errorCode = 'STATUS'; 363 break; 364 default: 365 $errorCode = 'E-FRM-INVALID'; 366 break; 367 } 368 MjFunctions::mRedirect($errorCode,FORMURL); 369 } 370 } 371 public static function deleteFormProcess(){ 372 373 $Response = MjFunctions::deleteForm(); 374 if($Response){ 375 switch($Response){ 376 case "InValidCode": 377 $errorCode = 'E-FRM-INVALID'; 378 break; 379 case '1': 380 $errorCode = 'DELETED'; 381 break; 382 default: 383 $errorCode = 'E-FRM-INVALID'; 384 break; 385 } 386 MjFunctions::mRedirect($errorCode,FORMURL); 387 } 388 } 389 390 /* 391 * add field process function 392 */ 393 394 public static function addFieldProcess(){ 395 $Response = MjFunctions::addField(); 396 if($Response){ 397 switch($Response){ 398 case "EmptyColumnName": 399 $errorCode = 'E-FIELD-NAME'; 400 break; 401 case "EmptyColumnId": 402 $errorCode = 'E-FIELD-ID'; 403 break; 404 case "EmptyColumnType": 405 $errorCode = 'E-FIELD-TYPE'; 406 break; 407 case "EmptyFormType": 408 $errorCode = 'E-FIELD-FORM'; 409 break; 410 case '1': 411 $errorCode = 'S-INSERTED'; 412 break; 413 default: 414 $errorCode = 'E-FRM-INVALID'; 415 break; 416 } 417 MjFunctions::mRedirect($errorCode,ADDFIELD); 418 } 419 } /* 420 * add field process function 421 */ 422 423 public static function editFieldProcess(){ 424 $Response = MjFunctions::editField(); 425 if($Response){ 426 switch($Response){ 427 case "EmptyColumnName": 428 $errorCode = 'E-FIELD-NAME'; 429 break; 430 case "EmptyColumnId": 431 $errorCode = 'E-FIELD-ID'; 432 break; 433 case "EmptyColumnType": 434 $errorCode = 'E-FIELD-TYPE'; 435 break; 436 case "EmptyFormType": 437 $errorCode = 'E-FIELD-FORM'; 438 break; 439 case '1': 440 $errorCode = 'S-INSERTED'; 441 break; 442 default: 443 $errorCode = 'E-FRM-INVALID'; 444 break; 445 } 446 $url = add_query_arg(array('id'=>$_REQUEST['id']), EDITFIELD); 447 MjFunctions::mRedirect($errorCode,$url); 448 } 449 } 450 /* 451 * update field status process function 452 */ 453 public static function updateFieldStatusProcess(){ 454 $Response = MjFunctions::updateFieldStatus(); 455 if($Response){ 456 switch($Response){ 457 case "InValidCode": 458 $errorCode = 'E-FRM-INVALID'; 459 break; 460 case '1': 461 $errorCode = 'STATUS'; 462 break; 463 default: 464 $errorCode = 'E-FRM-INVALID'; 465 break; 466 } 467 MjFunctions::mRedirect($errorCode,FIELDSURL); 468 } 469 } 470 471 /* 472 * delete field process function 473 */ 474 475 public static function deleteFieldProcess(){ 476 477 $Response = MjFunctions::deleteField(); 478 if($Response){ 479 switch($Response){ 480 case "InValidCode": 481 $errorCode = 'E-FRM-INVALID'; 482 break; 483 case '1': 484 $errorCode = 'DELETED'; 485 break; 486 default: 487 $errorCode = 'E-FRM-INVALID'; 488 break; 489 } 490 MjFunctions::mRedirect($errorCode,FIELDSURL); 491 } 492 } 493 494 function ManageFields(){ 495 switch(ACTION){ 496 case 'add': 497 self::addFieldProcess(); 498 mjContactHTML::addFieldHtml(); 499 break; 500 case 'status': 501 self::updateFieldStatusProcess(); 502 break; 503 case 'delete': 504 self::deleteFieldProcess(); 505 break; 506 case 'edit': 507 self::editFieldProcess(); 508 mjContactHTML::editFieldHtml(); 509 break; 510 default : 511 mjContactHTML::getFieldList(); 512 break; 513 } 514 } 515 516 function ManageStoreForms(){ 517 switch(ACTION){ 518 case 'view': 519 mjContactHTML::StoreDataDetail(); 520 break; 521 default : 522 mjContactHTML::getStoreFormList(); 523 break; 524 } 525 } 526 527 528 function ManageForms(){ 529 switch(ACTION){ 530 case 'add': 531 mjContactHTML::AddFormProcess(); 532 mjContactHTML::AddFormHtml(); 533 break; 534 case 'edit': 535 self::EditFormProcess(); 536 mjContactHTML::EditFormHtml(); 537 break; 538 case 'status': 539 mjContactHTML::updateFormStatusProcess(); 540 break; 541 case 'delete': 542 mjContactHTML::deleteFormProcess(); 543 break; 544 default : 545 mjContactHTML::getFormList(); 546 break; 547 } 548 } 549 550 public function stringCaptchaValidate($code = ""){ 551 552 if($_REQUEST['captcha'] == $_SESSION['captcha_'.$code]){ 553 return true; 554 }else{ 555 return false; 556 } 557 } 558 559 public function numberCaptchaValidate(){ 560 if($_REQUEST['captcha'] == MjFunctions::BaseDecode($_POST['CODEINCODE'])){ 561 return true; 562 }else{ 563 return false; 564 } 565 } 566 567 public static function dynamicFormProcess(){ 568 if(isset($_POST['dnForm'])){ 569 //$validate = MjFunctions::DmFormValidation(); 570 $mail = MjFunctions::sendDynamicMail(); 571 if($mail){ 572 echo "send"; 573 }else{ 574 echo "exit"; 575 } 576 } 577 } 578 579 294 580 } 295 581 ?> -
mj-contact-us/trunk/index.php
r659596 r690252 5 5 Description: mj contact us a simple form with 4-5 fields to send email address to admin . its a simple contact us form with easy to customize coding standard and easy to customize html standard. <strong>add this code</strong> [mjcontactus] <strong>in page from admin section to activate plugin form also be sure that you have get_header() function in your header file so that validation can be work properly</strong> 6 6 Author: anil kumar 7 Version: 5.2 7 Version: 5.2.2 8 8 Author URI: http://about.me/anilDhiman 9 9 10 */ 11 12 13 14 global $MjCon_db_version; 15 16 $MjCon_db_version = "5.2.2"; 17 18 10 19 11 20 include( plugin_dir_path( __FILE__ ) . 'files/includes.php'); 12 21 13 22 add_action("wp_enqueue_scripts", "my_jquery_enqueue"); 23 14 24 add_shortcode('mjcontactus', 'mj_contact_us'); 25 15 26 add_action('admin_menu', 'AdminIndex'); 27 16 28 add_action( 'admin_init', 'my_jquery_enqueue' ); 29 30 add_action('init', '_init_sessions'); 31 32 33 34 35 17 36 function my_jquery_enqueue() { 18 wp_deregister_script('mjform'); 19 wp_register_script( 'mjform', plugins_url( '/js/mj.js', __FILE__ ),'','1.0' ); 20 wp_register_script( 'mjvalidation', plugins_url( '/js/jquery.validate.js', __FILE__ ) ); 37 38 //wp_deregister_script('mjform'); 39 40 wp_register_script( 'JsMj', plugins_url( '/js/mjCon.js', __FILE__ ),__FILE__,'1.0' ); 41 42 wp_register_script( 'jQuery.validation', plugins_url( '/js/jquery.validate.js', __FILE__ ) ); 43 21 44 wp_enqueue_script('jquery'); 22 wp_enqueue_script('mjvalidation'); 23 wp_register_style( 'mjform', plugins_url( '/css/mj.css', __FILE__ ) ); 24 wp_enqueue_style( 'mjform' ); 45 46 wp_enqueue_script('JsMj'); 47 48 wp_enqueue_script('jQuery.validation'); 49 50 wp_register_style( 'CssMj', plugins_url( '/css/mjCont.css', __FILE__ ) ); 51 52 wp_enqueue_style( 'CssMj' ); 53 25 54 } 26 27 55 28 function mj_contact_us(){ 29 $object = new mjContactHTML; 30 $object->SendMail(); 31 $object->mjForm(); 56 57 58 59 60 function mj_contact_us(){ 61 62 $MjObj = new mjContactHTML; 63 64 $MjObj->SendMail(); 65 66 echo $MjObj->mjForm(); 67 32 68 } 69 33 70 function AdminIndex(){ 34 add_menu_page('Mj Contact US', 'Mj Contact US', 'manage_options', 'mj-mainpage', 'AdminMainPage'); 71 72 add_menu_page('Contact US', 'Contact US', 'manage_options', 'mj-mainpage', 'AdminMainPage'); 73 74 add_submenu_page( 'mj-mainpage', 'Mj Contact form', 'Contact Forms', 'manage_options', 'mj-contact-forms', 'MjContactForms'); 75 76 add_submenu_page( 'mj-mainpage', 'Mj Contact fields', 'Contact Field', 'manage_options', 'mj-contact-fields', 'MjContactFields'); 77 78 add_submenu_page( 'mj-mainpage', 'Mj store fields', 'Stored Data', 'manage_options', 'mj-store-fields', 'MjContactStoreForms'); 79 35 80 } 81 36 82 function AdminMainPage(){ 37 $obj = new mjContactPRO; 38 $obj->AdminSwitch(); 83 84 $MjObj = new mjContactHTML; 85 86 $MjObj->AdminSwitch(); 87 39 88 } 89 90 91 92 function MjContactForms(){ 93 94 MjFunctions::message(); 95 96 $MjObj = new mjContactHTML; 97 98 $MjObj->ManageForms(); 99 100 } 101 102 103 104 function MjContactFields(){ 105 106 $MjObj = new mjContactHTML; 107 108 $MjObj->ManageFields(); 109 110 } 111 112 113 114 function MjContactStoreForms(){ 115 116 $MjObj = new mjContactHTML; 117 118 $MjObj->ManageStoreForms(); 119 120 } 121 122 function addShortCode($attr){ 123 124 125 126 if(!isset($attr['id'])){ 127 128 echo "Please place form id"; 129 130 }else{ 131 132 MjFunctions::dynamicForm($attr['id']); 133 134 } 135 136 } 137 138 add_shortcode('mjform', 'addShortCode'); 139 140 141 142 function _init_sessions(){ 143 144 MjFunctions::mj_captcha_init_sessions(); 145 146 } 147 148 149 150 function MjCon_deinstall(){ 151 152 global $wpdb; 153 154 $field = $wpdb->prefix . "mj_contact_fields"; 155 156 $form = $wpdb->prefix . "mj_contact_forms"; 157 158 $save = $wpdb->prefix . "mj_contact_saved_forms"; 159 160 mysql_query("DROP TABLE $save,$form,$field") or die(mysql_error()); 161 162 delete_option('MjCon_db_version'); 163 164 } 165 166 167 168 register_deactivation_hook(__FILE__,'MjCon_deinstall'); 169 170 171 40 172 ?> -
mj-contact-us/trunk/js/mj.js
r626822 r690252 54 54 /* above given code validate the empty fields*/ 55 55 } 56 var dynamicForm = function (){ 57 //var str = jQuery('#contactForm').serialize(); 58 jQuery.ajax({ 59 type: "POST", 60 url: "/wp-admin/admin-ajax.php", 61 data: 'action=contact_form&'+str, 62 success: function(msg) { 63 jQuery("#node").ajaxComplete(function(event, request, settings){ 64 if(msg == 'sent') { 65 jQuery(".contact #node").hide(); 66 jQuery(".contact #success").fadeIn("slow"); 67 } 68 else { 69 result = msg; 70 jQuery(".contact #node").html(result); 71 jQuery(".contact #node").fadeIn("slow"); 72 } 73 }); 74 } 75 }); 76 return false; 77 } 78 jQuery(document).ready(function($) { 79 $(".btnsubmit").bind("submit",dynamicForm); 80 }); 81 -
mj-contact-us/trunk/readme.txt
r659596 r690252 1 1 === MJ Contact us === 2 2 3 Contributors: anildhiman 4 3 5 Donate link: http://mecontact.wordpress.com/mj-contact-us-plugin/ 6 4 7 Tags: contact us, simple and easy contact us form, contact us form, contact form, wordpress contact form, wordpress simple contact us form, javascript contact us form, customizable contact us form, captcha contact us form, numeric captcha, file upload, send attachment with mail. 8 5 9 Requires at least: 3.0.1 10 6 11 Tested up to: 3.5 7 Stable tag: 5.2 12 13 Stable tag: 5.2.2 14 8 15 License: GPLv2 or later 16 9 17 License URI: http://www.gnu.org/licenses/gpl-2.0.html 18 19 10 20 11 21 MJ Contact us is a simple/small/easy to integrate/ and fully tested contact us form 12 22 23 24 13 25 == Description == 14 26 27 28 15 29 <p>MJ Contact us is a simple and easy to integreate with any design and easy to change in coding as per requirement and easy to 30 16 31 handle contact us form. client can easy integrate this . make sure that your header.php file consist wp_head() and footer.php file should consist wp_footer(); function to use proper use of any plugin 32 17 33 these are some of features that this plugin consist</p> 34 18 35 <ul> 36 19 37 <li> - easy to install.</li> 38 20 39 <li> - easy to integrate with any html design</li> 40 21 41 <li> - easy to change html formate as per design requirement.</li> 42 22 43 <li> - easy to manupulate jQuery validations according to requirement</li> 44 23 45 <li> - easy to call using two method one is using shortcode [mjcontactus] and other using paste this code 46 24 47 mj_contact_us(); php code</li> 48 25 49 <li> - fast form </li> 50 26 51 <li> - easy to add new fields by customising form</li> 52 27 53 <li> - easy to understand coding standard</li> 54 28 55 <li> - contact us with numeric captcha</li> 29 <li> - contact us with file upload and send attachment with mail</li> 56 57 <li> - cotact us with string captcha </li> 58 59 <li> - contact us form with dynamic form creation capability </li> 60 61 <li> - contact us form with dynamic fields creation capability </li> 62 63 <li> - contact us form with save dynamic form capability </li> 64 30 65 </ul> 31 66 67 68 32 69 == Installation == 70 71 33 72 34 73 install the plugin as we install the plugin. use short code [mjcontactus] to call in any page from admin section or call mj_contact_us() functin in any template file to call form directly 35 74 36 75 76 77 78 37 79 e.g. 38 80 81 82 39 83 1. Upload 'mj-contactus' file to the `/wp-content/plugins/` directory 84 40 85 2. Activate the plugin through the 'Plugins' menu in WordPress 86 41 87 3. Place `[mjcontactus]` in your page editor or in templates paste this code mj_contact_us(); 88 42 89 4. Do the admin setting as per your requirement 90 91 43 92 44 93 == Frequently Asked Questions == 45 94 95 96 46 97 = can we customize html of contact us form = 98 99 47 100 48 101 yes its very easy to customize html of contact us form 49 102 103 104 50 105 = is this form is compatible with IE versions/ mozilla and chrome = 106 107 51 108 52 109 yes this is totally competible with IE/mozilla and chrome 53 110 54 111 112 113 114 55 115 == Screenshots == 56 116 117 118 57 119 1. Simple contact us form screen shot. 120 58 121 2. Validation view of form. 122 59 123 3. Admin area for setting. 124 125 4. Add dynamic form area. 126 127 5. Add only save Data form. 128 129 6. Manage dynamic created forms. 130 131 7. Create dynamic fields for forms. 132 133 8. Manage Fields area. 134 135 9. Manage Saved form area. 136 60 137 61 138 == Changelog == 62 139 140 = 5.2.2 = 141 142 * resolve issue "When I/anyone submits a form i get the following error , 143 144 Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/72/10314672/html/setpforwardpak/wp-content/plugins/mj-contact-us/files/mj-class-process.php on line 246" 145 146 * resolved issue " 147 I'm working on adding a form to a site that needs to use a bit of data out of the WP DB. The only issue I had was the plugin does not draw itself where it is called with the shortcode, instead it is drawing itself at the top of the page. I'm just getting back to it today, so I'm not clear if it is a CSS issue or something else. 148 149 I'm getting notices on updates to this thread so I'll watch for you. 150 151 I really like your idea here, editing the code directly for customization is a simple and direct method for a simple task like this, it makes it smaller, tighter and faster, all good things :)" 152 153 * added multiple form capability 154 155 * added mulitple form field added capability. 156 157 * added save form capability 158 159 63 160 = 5.2 = 161 64 162 * added admin options 163 65 164 * validations are optional 165 66 166 * introduce numeric captcha. like 12 + 2 - 4 = ? 167 67 168 * file upload and send attachment. 169 68 170 171 69 172 = 5.1 = 173 70 174 * add the jquery validation 175 71 176 * changes in form design 177 72 178 * copy to me option added 179 73 180 * add object and classes 74 181 182 183 75 184 = 4.3 = 185 76 186 simple javascript form 77 187 188 189 78 190 == Upgrade Notice == 191 79 192 = 4.3 = 193 80 194 = 5.0 = 195 81 196 = 5.1 = 197 82 198 = 5.2 =
Note: See TracChangeset
for help on using the changeset viewer.