Plugin Directory

Changeset 1125443


Ignore:
Timestamp:
04/01/2015 02:57:07 PM (10 years ago)
Author:
everybit
Message:

Version 1.1

Location:
encrypted-contact-form
Files:
4 edited
6 copied

Legend:

Unmodified
Added
Removed
  • encrypted-contact-form/tags/1.1/contact-form-configurator.php

    r1111277 r1125443  
    1 <?php 
     1<?php
    22/*
    33    Plugin Name: Encrypted Contact Form
    44    Plugin URI: https://i.cx/?icx.screen=formCreator
    5     Version: 1.0.4
     5    Version: 1.1
    66    Author: EveryBit Inc.
    77    Author URI:  https://everybit.com
     
    1313
    1414add_action( 'admin_menu', 'conformconf_menu');
    15    
    16    
     15
     16
    1717function conformconf_admin_styles() {
    18     wp_enqueue_style( 'conformconf', plugins_url('css/style.css', __FILE__) );
     18    wp_enqueue_style( 'conformconf', plugins_url('css/style.css', __FILE__) );
    1919}
    2020
    2121
    2222function conformconf_admin_scripts() {
    23     wp_enqueue_script( 'conformconf', plugins_url('js/main.js', __FILE__) );       
    24 }
    25  
    26    
     23    wp_enqueue_script( 'conformconf', plugins_url('js/main.js', __FILE__) );
     24}
     25
     26
    2727function conformconf_menu(){
    28     $menu_id = add_options_page(
    29         'Encrypted Contact Form',
    30         'Encrypted Contact Form',
    31         'manage_options',
    32         'conformconf',
    33         'conformconf_settings'
    34     );
    35     add_action( 'admin_print_styles-'  . $menu_id, 'conformconf_admin_styles' );
    36     add_action( 'admin_print_scripts-' . $menu_id, 'conformconf_admin_scripts'  );
     28    $menu_id = add_options_page(
     29        'Encrypted Contact Form',
     30        'Encrypted Contact Form',
     31        'manage_options',
     32        'conformconf',
     33        'conformconf_settings'
     34    );
     35    add_action( 'admin_print_styles-'  . $menu_id, 'conformconf_admin_styles' );
     36    add_action( 'admin_print_scripts-' . $menu_id, 'conformconf_admin_scripts'  );
    3737}
    3838
    3939
    4040function conformconf_settings(){
    41    
    42     global $wpdb;
    43     $options = get_option( 'conformconf_options' );
    44     $user_error = false;
    45     $found = false;     
    46     $cfc_pages_parsed = array();
    47     $replacements = array(
    48         'NOP' => '',
    49         'NOF' => '',
    50         'NRE' => '',
    51         'EOP' => '',
    52         'EOF'  => '',
    53         'ERE'  => '',
    54         'POP'  => '',
    55         'POF'  => '',
    56         'PRE'  => '',
    57         'MOP'  => '',
    58         'MOF'  => '',
    59         'MRE'  => '',
    60         'PGNM' => '',
    61         'OPTS' => '',
    62         'DISPLAY' => '',
    63         'ERRD1'   => 'display:none',
    64         'ERRD2'   => 'display:none',
    65     );
    66    
    67     $page_name = isset( $_POST['cfc_page_name'] ) ? stripslashes( $_POST['cfc_page_name'] ) : "";
    68     $existing_page = isset( $_POST['existing_page'] ) ? (int) $_POST['existing_page'] : false; 
    69    
    70     if ( $page_name or $existing_page ){
    71         $response = file_get_contents( "https://i.cx/api/users/api.php?type=getUser&username=" . stripslashes( $_POST['recipient_name'] ) );
    72         if ( $response ){
    73             $response_json = json_decode( $response );
    74             if ( isset($response_json->FAIL) ){
    75                 $user_error = true;
    76             } else if ( $response_json->username ){
    77                 $user_error = false;
    78             } else {
    79                 $user_error = true;
    80             }
    81         } else {
    82             $user_error = true;
    83         }
    84        
    85         if ( $user_error ){
    86             $replacements['PGNM'] = $page_name;
    87             $replacements['ERRD1'] = '';
    88             echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Username not found. Please enter a valid I.CX username. If you do not yet have an I.CX account, <a href="https://i.cx" target="_new">sign up for one now<a/>.</p></div>';       
    89         } else {
    90             $iframe_link = $_POST['iframe_url'];
    91             if ( $page_name ) {
    92                 $pid =  $wpdb->get_var( $wpdb->prepare( "SELECT count(*) from $wpdb->posts
    93                                            WHERE post_type = 'page'
    94                                            AND post_title = %s",
    95                                            $page_name
    96                                       ) );
    97                 if ( $pid ) {
    98                     echo '<br/><div class="error" style="margin-left:1px;color:red"><p>A page with that name already exists!</p></div>';       
    99                 } else {
    100                     $pid = wp_insert_post(
    101                         array(
    102                             'post_title'   => $page_name,
    103                             'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
    104                             'post_author'  => 1,
    105                             'post_type'    => 'page',
    106                             'post_status'  => 'publish',
    107                         )
    108                     );
    109                     if ( $pid ){
    110                         update_post_meta( $pid, 'cfc_page', 1);
    111                         $permalink = get_permalink( $pid );
    112                         echo '<br/><div class="updated" style="margin-left:1px"><p>Page Created: <a href="' . $permalink . '">' . $page_name . '</a></p></div>';
    113                     } else {
    114                         echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Unexpected error occured while creating page</p></div>';     
    115                     }       
    116                 }
    117             } else if ($existing_page) {
    118                 wp_update_post(
    119                     array(
    120                         'ID'   => $existing_page,
    121                         'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
    122                     )
    123                 );
    124                 $updated_post = get_post( $existing_page );
    125                 $permalink = get_permalink( $existing_page );
    126                 echo '<br/><div class="updated" style="margin-left:1px"><p>Page Updated: <a href="' . $permalink . '">' . $updated_post->post_title . '</a></p></div>';
    127             }
    128         }
    129        
    130         $options['name']    = $_POST['name'];
    131         $options['email']   = $_POST['email'];
    132         $options['phone']   = $_POST['phone'];
    133         $options['message'] = $_POST['message'];
    134         $options['recipient_name'] = stripslashes( $_POST['recipient_name'] );
    135         $options['display_name']   = stripslashes( $_POST['display_name'] );
    136         $options['iframe_url']     = $_POST['iframe_url'];
    137         update_option( 'conformconf_options', $options );
    138        
    139     }
    140        
    141     if ( $options['name'] == 'optional' ){
    142         $replacements['NOP'] = 'checked';
    143     } else if ( $options['name'] == 'required' ){
    144         $replacements['NRE'] = 'checked';
    145     } else if ( $options['name'] == 'off' ){
    146         $replacements['NOF'] = 'checked';   
    147     } else {
    148         $replacements['NRE'] = 'checked';
    149     }
    150    
    151     if ( $options['email'] == 'optional' ){
    152         $replacements['EOP'] = 'checked';
    153     } else if ( $options['email'] == 'required' ){
    154         $replacements['ERE'] = 'checked';
    155     } else if ( $options['email'] == 'off' ){
    156         $replacements['EOF'] = 'checked';   
    157     } else {
    158         $replacements['EOP'] = 'checked';
    159     }   
    160    
    161     if ( $options['phone'] == 'optional' ){
    162         $replacements['POP'] = 'checked';
    163     } else if ( $options['phone'] == 'required' ){
    164         $replacements['PRE'] = 'checked';
    165     } else if ( $options['phone'] == 'off' ){
    166         $replacements['POF'] = 'checked';   
    167     } else {
    168         $replacements['POF'] = 'checked';
    169     }   
    170    
    171     if ( $options['message'] == 'optional' ){
    172         $replacements['MOP'] = 'checked';
    173     } else if ( $options['message'] == 'required' ){
    174         $replacements['MRE'] = 'checked';
    175     } else if ( $options['message'] == 'off' ){
    176         $replacements['MOF'] = 'checked';   
    177     } else {
    178         $replacements['MRE'] = 'checked';
    179     }       
    180    
    181     $replacements['iframe_url'] = $options['iframe_url'];
    182    
    183     if ( $options['display_name'] ){
    184         $replacements['DISN'] = $options['display_name'];   
    185     } else {
    186         $replacements['DISN'] = 'Example'; 
    187     }
    188    
    189     if ( $options['recipient_name'] ){
    190         $replacements['RECN'] = $options['recipient_name'];
    191     } else {
    192         $replacements['RECN'] = 'example'; 
    193     }
    194    
    195     $cfc_pages = $wpdb->get_results(
    196                         $wpdb->prepare(
    197                             "SELECT p.ID as pid, p.post_title as title
     41
     42    global $wpdb, $user_ID;
     43    $options = get_option( 'conformconf_options' );
     44    $user_error = false;
     45    $found = false;
     46    $cfc_pages_parsed = array();
     47    $replacements = array(
     48        'NOP' => '',
     49        'NOF' => '',
     50        'NRE' => '',
     51        'EOP' => '',
     52        'EOF'  => '',
     53        'ERE'  => '',
     54        'POP'  => '',
     55        'POF'  => '',
     56        'PRE'  => '',
     57        'MOP'  => '',
     58        'MOF'  => '',
     59        'MRE'  => '',
     60        'PGNM' => '',
     61        'OPTS' => '',
     62        'DISPLAY' => '',
     63        'ERRD1'   => 'display:none',
     64        'ERRD2'   => 'display:none',
     65    );
     66
     67    $page_name = isset( $_POST['cfc_page_name'] ) ? stripslashes( $_POST['cfc_page_name'] ) : "";
     68    $existing_page = isset( $_POST['existing_page'] ) ? (int) $_POST['existing_page'] : false;
     69
     70    if ( $page_name or $existing_page ){
     71        $response = file_get_contents( "https://i.cx/api/users/api.php?type=getUser&username=" . stripslashes( $_POST['recipient_name'] ) );
     72        if ( $response ){
     73            $response_json = json_decode( $response );
     74            if ( isset($response_json->FAIL) ){
     75                $user_error = true;
     76            } else if ( $response_json->username ){
     77                $user_error = false;
     78            } else {
     79                $user_error = true;
     80            }
     81        } else {
     82            $user_error = true;
     83        }
     84
     85        if ( $user_error ){
     86            $replacements['PGNM'] = $page_name;
     87            $replacements['ERRD1'] = '';
     88            echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Username not found. Please enter a valid I.CX username. If you do not yet have an I.CX account, <a href="https://i.cx" target="_new">sign up for one now<a/>.</p></div>';
     89        } else {
     90
     91            if ( ! wp_verify_nonce( $_POST['cfcnonce'], 'cfcn-' . $user_ID ) ) {
     92                echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Invalid or expired security token!</p></div>';
     93            } else {
     94                $iframe_link = $_POST['iframe_url'];
     95
     96                // Replace spaces so URL validates
     97                $iframe_link = str_replace(' ', '%20', $iframe_link);
     98
     99                if (filter_var($iframe_link, FILTER_VALIDATE_URL) === FALSE or !preg_match("/^https:\/\/i.cx\/.+/", $iframe_link)) {
     100                    echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Invalid iFrame Content!</p></div>';
     101
     102
     103                } else if ( $page_name ) {
     104                    $pid =  $wpdb->get_var( $wpdb->prepare( "SELECT count(*) from $wpdb->posts
     105                                               WHERE post_type = 'page'
     106                                               AND post_title = %s",
     107                        $page_name
     108                    ) );
     109                    if ( $pid ) {
     110                        echo '<br/><div class="error" style="margin-left:1px;color:red"><p>A page with that name already exists!</p></div>';
     111                    } else {
     112                        $pid = wp_insert_post(
     113                            array(
     114                                'post_title'   => $page_name,
     115                                'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
     116                                'post_author'  => 1,
     117                                'post_type'    => 'page',
     118                                'post_status'  => 'publish',
     119                            )
     120                        );
     121                        if ( $pid ){
     122                            update_post_meta( $pid, 'cfc_page', 1);
     123                            $permalink = get_permalink( $pid );
     124                            echo '<br/><div class="updated" style="margin-left:1px"><p>Page Created: <a href="' . $permalink . '">' . $page_name . '</a></p></div>';
     125                        } else {
     126                            echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Unexpected error occured while creating page</p></div>';
     127                        }
     128                    }
     129                } else if ($existing_page) {
     130                    wp_update_post(
     131                        array(
     132                            'ID'   => $existing_page,
     133                            'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
     134                        )
     135                    );
     136                    $updated_post = get_post( $existing_page );
     137                    $permalink = get_permalink( $existing_page );
     138                    echo '<br/><div class="updated" style="margin-left:1px"><p>Page Updated: <a href="' . $permalink . '">' . $updated_post->post_title . '</a></p></div>';
     139                }
     140            }
     141        }
     142
     143        $options['name']    = $_POST['name'];
     144        $options['email']   = $_POST['email'];
     145        $options['phone']   = $_POST['phone'];
     146        $options['message'] = $_POST['message'];
     147        $options['recipient_name'] = stripslashes( $_POST['recipient_name'] );
     148        $options['display_name']   = stripslashes( $_POST['display_name'] );
     149        $options['iframe_url']     = $_POST['iframe_url'];
     150        update_option( 'conformconf_options', $options );
     151
     152    }
     153
     154    if ( $options['name'] == 'optional' ){
     155        $replacements['NOP'] = 'checked';
     156    } else if ( $options['name'] == 'required' ){
     157        $replacements['NRE'] = 'checked';
     158    } else if ( $options['name'] == 'off' ){
     159        $replacements['NOF'] = 'checked';
     160    } else {
     161        $replacements['NRE'] = 'checked';
     162    }
     163
     164    if ( $options['email'] == 'optional' ){
     165        $replacements['EOP'] = 'checked';
     166    } else if ( $options['email'] == 'required' ){
     167        $replacements['ERE'] = 'checked';
     168    } else if ( $options['email'] == 'off' ){
     169        $replacements['EOF'] = 'checked';
     170    } else {
     171        $replacements['EOP'] = 'checked';
     172    }
     173
     174    if ( $options['phone'] == 'optional' ){
     175        $replacements['POP'] = 'checked';
     176    } else if ( $options['phone'] == 'required' ){
     177        $replacements['PRE'] = 'checked';
     178    } else if ( $options['phone'] == 'off' ){
     179        $replacements['POF'] = 'checked';
     180    } else {
     181        $replacements['POF'] = 'checked';
     182    }
     183
     184    if ( $options['message'] == 'optional' ){
     185        $replacements['MOP'] = 'checked';
     186    } else if ( $options['message'] == 'required' ){
     187        $replacements['MRE'] = 'checked';
     188    } else if ( $options['message'] == 'off' ){
     189        $replacements['MOF'] = 'checked';
     190    } else {
     191        $replacements['MRE'] = 'checked';
     192    }
     193
     194    $replacements['iframe_url'] = $options['iframe_url'];
     195
     196    if ( $options['display_name'] ){
     197        $replacements['DISN'] = $options['display_name'];
     198    } else {
     199        $replacements['DISN'] = 'Example';
     200    }
     201
     202    if ( $options['recipient_name'] ){
     203        $replacements['RECN'] = $options['recipient_name'];
     204    } else {
     205        $replacements['RECN'] = 'example';
     206    }
     207
     208    $cfc_pages = $wpdb->get_results(
     209        $wpdb->prepare(
     210            "SELECT p.ID as pid, p.post_title as title
    198211                            FROM $wpdb->posts p
    199212                            LEFT JOIN $wpdb->postmeta pm ON pm.post_id = p.ID
    200213                            WHERE pm.meta_key = %s"
    201                             , 'cfc_page'
    202                         )
    203                     );
    204 
    205    
    206     foreach( $cfc_pages as $cfc_page){
    207         $cfc_pages_parsed[ $cfc_page->pid ] = $cfc_page->title;
    208         $found = true;
    209     }
    210    
    211     if ( ! $found ){
    212         $replacements['DISPLAY'] = 'display:none';
    213     } else {
    214         $opts = '';
    215         foreach( $cfc_pages_parsed as $pid => $title ){
    216             $opts .= '<option value="' . $pid . '">' . $title . '</option>' . "\r\n";
    217         }
    218         $replacements['OPTS'] = $opts;
    219     }
    220 
    221     conformconf_show_settings( $replacements );
    222    
     214            , 'cfc_page'
     215        )
     216    );
     217
     218
     219    foreach( $cfc_pages as $cfc_page){
     220        $cfc_pages_parsed[ $cfc_page->pid ] = $cfc_page->title;
     221        $found = true;
     222    }
     223
     224    if ( ! $found ){
     225        $replacements['DISPLAY'] = 'display:none';
     226    } else {
     227        $opts = '';
     228        foreach( $cfc_pages_parsed as $pid => $title ){
     229            $opts .= '<option value="' . $pid . '">' . $title . '</option>' . "\r\n";
     230        }
     231        $replacements['OPTS'] = $opts;
     232    }
     233
     234    $nonce = wp_create_nonce( 'cfcn-' . $user_ID );
     235    $replacements['NONCE'] = "<input type='hidden' name='cfcnonce' value='$nonce'/>";
     236
     237    conformconf_show_settings( $replacements );
     238
    223239}
    224240
    225241
    226242function conformconf_show_settings( $replacements ){
    227     $file_content = file_get_contents( dirname( __FILE__ ) . "/tpl/admin_settings.html" );
    228     foreach( $replacements as $tag => $repl ){
    229         $file_content = str_replace( "%$tag%", $repl, $file_content );
    230     }
    231     echo $file_content;
    232 }
     243    $file_content = file_get_contents( dirname( __FILE__ ) . "/tpl/admin_settings.html" );
     244    foreach( $replacements as $tag => $repl ){
     245        $file_content = str_replace( "%$tag%", $repl, $file_content );
     246    }
     247    echo $file_content;
     248}
  • encrypted-contact-form/tags/1.1/readme.txt

    r1111277 r1125443  
    44Requires at least: 3.0
    55Tested up to: 4.1
    6 Stable tag: 1.0.4
     6Stable tag: 1.1
    77License: MIT
    88
     
    2020
    2121== Changelog ==
     22
     23= 1.1 =
     24Detection of CSRF attacks added
    2225
    2326= 1.0.4 =
  • encrypted-contact-form/tags/1.1/tpl/admin_settings.html

    r1078358 r1125443  
    11<form method="post" action="options-general.php?page=conformconf">
    2 <div class="panel panel-primary panel-pricing">
    3     <div class="panel-heading">Contact Form Creator</div>
    4     <div class="panel-body">
    5         <span class="subheaderExtraSpace">Step 1: Choose fields to include</span>
    6         <br>
    7         <div>
    8             <table style="padding:10px;border:0;">
    9             <tbody>
    10             <tr>
    11                 <td><u><strong>Field</strong></u></td>
    12                 <td><u><strong>Optional</strong></u></td>
    13                 <td><u><strong>Required</strong></u></td>
    14                 <td><u><strong>Off</strong></u></td>
    15             </tr>
    16             <tr style="text-align:center;">
    17                 <td><strong>Name</strong></td>
    18                 <td><input class="contact-checkbox" %NOP% id="nameoptional" name="name" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    19                 <td><input class="contact-checkbox" %NRE% id="namerequired" name="name" value="required" type="radio" onChange="handleRegenOptions();"></td>
    20                 <td><input class="contact-checkbox" %NOF% id="nameoff"  name="name" value="off" type="radio" onChange="handleRegenOptions();"></td>
    21             </tr>
    22             <tr style="text-align:center;">
    23                 <td><strong>Email</strong></td>
    24                 <td><input class="contact-checkbox" %EOP% id="emailoptional" name="email" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    25                 <td><input class="contact-checkbox" %ERE% id="emailrequired" name="email" value="required" type="radio" onChange="handleRegenOptions();"></td>
    26                 <td><input class="contact-checkbox" %EOF% id="emailoff" name="email" value="off" type="radio" onChange="handleRegenOptions();"></td>
    27             </tr>
    28             <tr style="text-align:center;">
    29                 <td><strong>Phone</strong></td>
    30                 <td><input class="contact-checkbox" %POP% id="phoneoptional" name="phone" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    31                 <td><input class="contact-checkbox" %PRE% id="phonerequired" name="phone" value="required" type="radio" onChange="handleRegenOptions();"></td>
    32                 <td><input class="contact-checkbox" %POF% id="phoneoff"  name="phone" value="off" type="radio" onChange="handleRegenOptions();"></td>
    33             </tr>
    34             <tr style="text-align:center;">
    35                 <td><strong>Message</strong></td>
    36                 <td><input class="contact-checkbox" %MOP% id="messageoptional" name="message" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    37                 <td><input class="contact-checkbox" %MRE% id="messagerequired" name="message" value="required" type="radio" onChange="handleRegenOptions();"></td>
    38                 <td><input class="contact-checkbox" %MOF% id="messageoff" name="message" value="off" type="radio" onChange="handleRegenOptions();"></td>
    39             </tr>
    40             </tbody>
    41             </table>
    42         </div>
    43        
    44         <br>
    45         <span class="subheaderExtraSpace">Step 2: Set form recipient</span>
    46         <br>
     2    %NONCE%
     3    <div class="panel panel-primary panel-pricing">
     4        <div class="panel-heading">Contact Form Creator</div>
     5        <div class="panel-body">
     6            <span class="subheaderExtraSpace">Step 1: Choose fields to include</span>
     7            <br>
     8            <div>
     9                <table style="padding:10px;border:0;">
     10                    <tbody>
     11                    <tr>
     12                        <td><u><strong>Field</strong></u></td>
     13                        <td><u><strong>Optional</strong></u></td>
     14                        <td><u><strong>Required</strong></u></td>
     15                        <td><u><strong>Off</strong></u></td>
     16                    </tr>
     17                    <tr style="text-align:center;">
     18                        <td><strong>Name</strong></td>
     19                        <td><input class="contact-checkbox" %NOP% id="nameoptional" name="name" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     20                        <td><input class="contact-checkbox" %NRE% id="namerequired" name="name" value="required" type="radio" onChange="handleRegenOptions();"></td>
     21                        <td><input class="contact-checkbox" %NOF% id="nameoff"  name="name" value="off" type="radio" onChange="handleRegenOptions();"></td>
     22                    </tr>
     23                    <tr style="text-align:center;">
     24                        <td><strong>Email</strong></td>
     25                        <td><input class="contact-checkbox" %EOP% id="emailoptional" name="email" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     26                        <td><input class="contact-checkbox" %ERE% id="emailrequired" name="email" value="required" type="radio" onChange="handleRegenOptions();"></td>
     27                        <td><input class="contact-checkbox" %EOF% id="emailoff" name="email" value="off" type="radio" onChange="handleRegenOptions();"></td>
     28                    </tr>
     29                    <tr style="text-align:center;">
     30                        <td><strong>Phone</strong></td>
     31                        <td><input class="contact-checkbox" %POP% id="phoneoptional" name="phone" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     32                        <td><input class="contact-checkbox" %PRE% id="phonerequired" name="phone" value="required" type="radio" onChange="handleRegenOptions();"></td>
     33                        <td><input class="contact-checkbox" %POF% id="phoneoff"  name="phone" value="off" type="radio" onChange="handleRegenOptions();"></td>
     34                    </tr>
     35                    <tr style="text-align:center;">
     36                        <td><strong>Message</strong></td>
     37                        <td><input class="contact-checkbox" %MOP% id="messageoptional" name="message" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     38                        <td><input class="contact-checkbox" %MRE% id="messagerequired" name="message" value="required" type="radio" onChange="handleRegenOptions();"></td>
     39                        <td><input class="contact-checkbox" %MOF% id="messageoff" name="message" value="off" type="radio" onChange="handleRegenOptions();"></td>
     40                    </tr>
     41                    </tbody>
     42                </table>
     43            </div>
    4744
    48         <span id="cfc_username_error" style="color:red;font-size:16px;%ERRD1%">Username Not Exists</span>
    49         <table style="padding:5px;border:0;width:600px;">
    50         <tbody>
    51         <tr>
    52             <td><strong>Display name:</strong></td>
    53             <td><strong>Recipient username:</strong></td>
    54         </tr>
    55         <tr>
    56             <td><input name="display_name" style="width:80%;padding:7px;" value="%DISN%" id="cfcdisplayname" type="text" onkeyup="setUsername();"></td>
    57             <td><input name="recipient_name" readonly="" value="%RECN%" style="width:80%;padding:7px;" type="text" id="cfcdisplayparsed"></td>
    58         </tr>
    59         </tbody>
    60         </table>
    61        
    62         <div class="small">
    63         The contents of your contact form will be encrypted and sent to this I.CX username.
    64         Your display name will be shown on the "Send" button of the form.
    65         You can use capital letters and add spaces in your display name, but it must be otherwise identical to your username.
    66         This ensures that no two users will have the same display name.
    67         </div>
    68        
    69         <br/>
    70         <span class="subheaderExtraSpace">Step 3: Preview and test your form</span>
    71         <br/>
    72        
    73         <div class="cfc-iframe-holder">
    74         <iframe id="cfc-preview" src="https://i.cx/secureForm.html?id_name=name&amp;element_name=text&amp;require_name=true&amp;id_email=email&amp;element_email=text&amp;validate_email=email&amp;id_message=message&amp;element_message=textarea&amp;require_message=true&amp;toUser=Smugdarkseagreenkitty" frameborder="0" height="500" width="100%"></iframe>
    75         </div>
    76         <span class="subheaderExtraSpace">Step 4: Copy embed code</span>
    77         <br/>
    78        
    79         <div class="cfc-embed-url-holder">
    80             <div class="form-group">
    81             <input value="<iframe src=&quot;undefined&quot; width=&quot;600&quot; height=&quot;500&quot;></iframe>" readonly="" class="form-control" id="cfcpreview" type="text"  onfocus="this.select();" onmouseup="return false;" />
    82             </div>
    83         </div>
    84         <br/>
    85         <span class="subheaderExtraSpace">Step 5: Create a page with form iframe embedded</span><br/>
    86         <span class="small">Page Name:</span> <br/>
    87         <input id="pageinput_text" value="%PGNM%" type="text" size="40" name="cfc_page_name" pattern=".{2,}" required title="2 characters minimum" />
    88         <span id="cfc_page_error" style="color:red;font-size:16px;%ERRD2%">Page with this name already exists</span>       
    89         <select id="pageinput_select" name="existing_page" style="display:none;margin:7px;">
    90         %OPTS%
    91         </select><br/>
    92         <div id='cfc_selection' style="padding:10px;%DISPLAY%">
    93         <input type="radio" name="cfc_selection" value="new" onclick="switchPage('new');" id="cfc_new" checked /> <label for="cfc_new">New Page</label>
    94         &nbsp;&nbsp;&nbsp;
    95         <input type="radio" name="cfc_selection" value="upd" onclick="switchPage('upd');" id="cfc_upd" /> <label for="cfc_upd">Update Existing</label>
    96         </div>
    97         <input type="hidden" name="iframe_url" id="iframe_url" />
    98         <input type="submit" id="cfc_createpage" class="button-primary" value="Create Page" style="margin-top:10px" />
    99         <br/>
    100         <span class="subheaderExtraSpace">Step 6 (optional): Sign up for email notifications</span>
    101         <br>
    102         <span class="small">If you would like to be notified by email every time someone fills out your contact form, </span>
    103         <a href="https://i.cx/?icx.screen=dashboard" target="_blank">visit your I.CX dashboard</a>
    104         <span class="small"> to set Email notifications.</span>
    105     </div>
    106 </div>
     45            <br>
     46            <span class="subheaderExtraSpace">Step 2: Set form recipient</span>
     47            <br>
     48
     49            <span id="cfc_username_error" style="color:red;font-size:16px;%ERRD1%">Username Not Exists</span>
     50            <table style="padding:5px;border:0;width:600px;">
     51                <tbody>
     52                <tr>
     53                    <td><strong>Display name:</strong></td>
     54                    <td><strong>Recipient username:</strong></td>
     55                </tr>
     56                <tr>
     57                    <td><input name="display_name" style="width:80%;padding:7px;" value="%DISN%" id="cfcdisplayname" type="text" onkeyup="setUsername();"></td>
     58                    <td><input name="recipient_name" readonly="" value="%RECN%" style="width:80%;padding:7px;" type="text" id="cfcdisplayparsed"></td>
     59                </tr>
     60                </tbody>
     61            </table>
     62
     63            <div class="small">
     64                The contents of your contact form will be encrypted and sent to this I.CX username.
     65                Your display name will be shown on the "Send" button of the form.
     66                You can use capital letters and add spaces in your display name, but it must be otherwise identical to your username.
     67                This ensures that no two users will have the same display name.
     68            </div>
     69
     70            <br/>
     71            <span class="subheaderExtraSpace">Step 3: Preview and test your form</span>
     72            <br/>
     73
     74            <div class="cfc-iframe-holder">
     75                <iframe id="cfc-preview" src="https://i.cx/secureForm.html?id_name=name&amp;element_name=text&amp;require_name=true&amp;id_email=email&amp;element_email=text&amp;validate_email=email&amp;id_message=message&amp;element_message=textarea&amp;require_message=true&amp;toUser=Smugdarkseagreenkitty" frameborder="0" height="500" width="100%"></iframe>
     76            </div>
     77            <span class="subheaderExtraSpace">Step 4: Copy embed code</span>
     78            <br/>
     79
     80            <div class="cfc-embed-url-holder">
     81                <div class="form-group">
     82                    <input value="<iframe src=&quot;undefined&quot; width=&quot;600&quot; height=&quot;500&quot;></iframe>" readonly="" class="form-control" id="cfcpreview" type="text"  onfocus="this.select();" onmouseup="return false;" />
     83                </div>
     84            </div>
     85            <br/>
     86            <span class="subheaderExtraSpace">Step 5: Create a page with form iframe embedded</span><br/>
     87            <span class="small">Page Name:</span> <br/>
     88            <input id="pageinput_text" value="%PGNM%" type="text" size="40" name="cfc_page_name" pattern=".{2,}" required title="2 characters minimum" />
     89            <span id="cfc_page_error" style="color:red;font-size:16px;%ERRD2%">Page with this name already exists</span>
     90            <select id="pageinput_select" name="existing_page" style="display:none;margin:7px;">
     91                %OPTS%
     92            </select><br/>
     93            <div id='cfc_selection' style="padding:10px;%DISPLAY%">
     94                <input type="radio" name="cfc_selection" value="new" onclick="switchPage('new');" id="cfc_new" checked /> <label for="cfc_new">New Page</label>
     95                &nbsp;&nbsp;&nbsp;
     96                <input type="radio" name="cfc_selection" value="upd" onclick="switchPage('upd');" id="cfc_upd" /> <label for="cfc_upd">Update Existing</label>
     97            </div>
     98            <input type="hidden" name="iframe_url" id="iframe_url" />
     99            <input type="submit" id="cfc_createpage" class="button-primary" value="Create Page" style="margin-top:10px" />
     100            <br/>
     101            <span class="subheaderExtraSpace">Step 6 (optional): Sign up for email notifications</span>
     102            <br>
     103            <span class="small">If you would like to be notified by email every time someone fills out your contact form, </span>
     104            <a href="https://i.cx/?icx.screen=dashboard" target="_blank">visit your I.CX dashboard</a>
     105            <span class="small"> to set Email notifications.</span>
     106        </div>
     107    </div>
    107108</form>
    108109<script>
    109     handleRegenOptions();
     110    handleRegenOptions();
    110111</script>
  • encrypted-contact-form/trunk/contact-form-configurator.php

    r1111277 r1125443  
    1 <?php 
     1<?php
    22/*
    33    Plugin Name: Encrypted Contact Form
    44    Plugin URI: https://i.cx/?icx.screen=formCreator
    5     Version: 1.0.4
     5    Version: 1.1
    66    Author: EveryBit Inc.
    77    Author URI:  https://everybit.com
     
    1313
    1414add_action( 'admin_menu', 'conformconf_menu');
    15    
    16    
     15
     16
    1717function conformconf_admin_styles() {
    18     wp_enqueue_style( 'conformconf', plugins_url('css/style.css', __FILE__) );
     18    wp_enqueue_style( 'conformconf', plugins_url('css/style.css', __FILE__) );
    1919}
    2020
    2121
    2222function conformconf_admin_scripts() {
    23     wp_enqueue_script( 'conformconf', plugins_url('js/main.js', __FILE__) );       
    24 }
    25  
    26    
     23    wp_enqueue_script( 'conformconf', plugins_url('js/main.js', __FILE__) );
     24}
     25
     26
    2727function conformconf_menu(){
    28     $menu_id = add_options_page(
    29         'Encrypted Contact Form',
    30         'Encrypted Contact Form',
    31         'manage_options',
    32         'conformconf',
    33         'conformconf_settings'
    34     );
    35     add_action( 'admin_print_styles-'  . $menu_id, 'conformconf_admin_styles' );
    36     add_action( 'admin_print_scripts-' . $menu_id, 'conformconf_admin_scripts'  );
     28    $menu_id = add_options_page(
     29        'Encrypted Contact Form',
     30        'Encrypted Contact Form',
     31        'manage_options',
     32        'conformconf',
     33        'conformconf_settings'
     34    );
     35    add_action( 'admin_print_styles-'  . $menu_id, 'conformconf_admin_styles' );
     36    add_action( 'admin_print_scripts-' . $menu_id, 'conformconf_admin_scripts'  );
    3737}
    3838
    3939
    4040function conformconf_settings(){
    41    
    42     global $wpdb;
    43     $options = get_option( 'conformconf_options' );
    44     $user_error = false;
    45     $found = false;     
    46     $cfc_pages_parsed = array();
    47     $replacements = array(
    48         'NOP' => '',
    49         'NOF' => '',
    50         'NRE' => '',
    51         'EOP' => '',
    52         'EOF'  => '',
    53         'ERE'  => '',
    54         'POP'  => '',
    55         'POF'  => '',
    56         'PRE'  => '',
    57         'MOP'  => '',
    58         'MOF'  => '',
    59         'MRE'  => '',
    60         'PGNM' => '',
    61         'OPTS' => '',
    62         'DISPLAY' => '',
    63         'ERRD1'   => 'display:none',
    64         'ERRD2'   => 'display:none',
    65     );
    66    
    67     $page_name = isset( $_POST['cfc_page_name'] ) ? stripslashes( $_POST['cfc_page_name'] ) : "";
    68     $existing_page = isset( $_POST['existing_page'] ) ? (int) $_POST['existing_page'] : false; 
    69    
    70     if ( $page_name or $existing_page ){
    71         $response = file_get_contents( "https://i.cx/api/users/api.php?type=getUser&username=" . stripslashes( $_POST['recipient_name'] ) );
    72         if ( $response ){
    73             $response_json = json_decode( $response );
    74             if ( isset($response_json->FAIL) ){
    75                 $user_error = true;
    76             } else if ( $response_json->username ){
    77                 $user_error = false;
    78             } else {
    79                 $user_error = true;
    80             }
    81         } else {
    82             $user_error = true;
    83         }
    84        
    85         if ( $user_error ){
    86             $replacements['PGNM'] = $page_name;
    87             $replacements['ERRD1'] = '';
    88             echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Username not found. Please enter a valid I.CX username. If you do not yet have an I.CX account, <a href="https://i.cx" target="_new">sign up for one now<a/>.</p></div>';       
    89         } else {
    90             $iframe_link = $_POST['iframe_url'];
    91             if ( $page_name ) {
    92                 $pid =  $wpdb->get_var( $wpdb->prepare( "SELECT count(*) from $wpdb->posts
    93                                            WHERE post_type = 'page'
    94                                            AND post_title = %s",
    95                                            $page_name
    96                                       ) );
    97                 if ( $pid ) {
    98                     echo '<br/><div class="error" style="margin-left:1px;color:red"><p>A page with that name already exists!</p></div>';       
    99                 } else {
    100                     $pid = wp_insert_post(
    101                         array(
    102                             'post_title'   => $page_name,
    103                             'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
    104                             'post_author'  => 1,
    105                             'post_type'    => 'page',
    106                             'post_status'  => 'publish',
    107                         )
    108                     );
    109                     if ( $pid ){
    110                         update_post_meta( $pid, 'cfc_page', 1);
    111                         $permalink = get_permalink( $pid );
    112                         echo '<br/><div class="updated" style="margin-left:1px"><p>Page Created: <a href="' . $permalink . '">' . $page_name . '</a></p></div>';
    113                     } else {
    114                         echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Unexpected error occured while creating page</p></div>';     
    115                     }       
    116                 }
    117             } else if ($existing_page) {
    118                 wp_update_post(
    119                     array(
    120                         'ID'   => $existing_page,
    121                         'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
    122                     )
    123                 );
    124                 $updated_post = get_post( $existing_page );
    125                 $permalink = get_permalink( $existing_page );
    126                 echo '<br/><div class="updated" style="margin-left:1px"><p>Page Updated: <a href="' . $permalink . '">' . $updated_post->post_title . '</a></p></div>';
    127             }
    128         }
    129        
    130         $options['name']    = $_POST['name'];
    131         $options['email']   = $_POST['email'];
    132         $options['phone']   = $_POST['phone'];
    133         $options['message'] = $_POST['message'];
    134         $options['recipient_name'] = stripslashes( $_POST['recipient_name'] );
    135         $options['display_name']   = stripslashes( $_POST['display_name'] );
    136         $options['iframe_url']     = $_POST['iframe_url'];
    137         update_option( 'conformconf_options', $options );
    138        
    139     }
    140        
    141     if ( $options['name'] == 'optional' ){
    142         $replacements['NOP'] = 'checked';
    143     } else if ( $options['name'] == 'required' ){
    144         $replacements['NRE'] = 'checked';
    145     } else if ( $options['name'] == 'off' ){
    146         $replacements['NOF'] = 'checked';   
    147     } else {
    148         $replacements['NRE'] = 'checked';
    149     }
    150    
    151     if ( $options['email'] == 'optional' ){
    152         $replacements['EOP'] = 'checked';
    153     } else if ( $options['email'] == 'required' ){
    154         $replacements['ERE'] = 'checked';
    155     } else if ( $options['email'] == 'off' ){
    156         $replacements['EOF'] = 'checked';   
    157     } else {
    158         $replacements['EOP'] = 'checked';
    159     }   
    160    
    161     if ( $options['phone'] == 'optional' ){
    162         $replacements['POP'] = 'checked';
    163     } else if ( $options['phone'] == 'required' ){
    164         $replacements['PRE'] = 'checked';
    165     } else if ( $options['phone'] == 'off' ){
    166         $replacements['POF'] = 'checked';   
    167     } else {
    168         $replacements['POF'] = 'checked';
    169     }   
    170    
    171     if ( $options['message'] == 'optional' ){
    172         $replacements['MOP'] = 'checked';
    173     } else if ( $options['message'] == 'required' ){
    174         $replacements['MRE'] = 'checked';
    175     } else if ( $options['message'] == 'off' ){
    176         $replacements['MOF'] = 'checked';   
    177     } else {
    178         $replacements['MRE'] = 'checked';
    179     }       
    180    
    181     $replacements['iframe_url'] = $options['iframe_url'];
    182    
    183     if ( $options['display_name'] ){
    184         $replacements['DISN'] = $options['display_name'];   
    185     } else {
    186         $replacements['DISN'] = 'Example'; 
    187     }
    188    
    189     if ( $options['recipient_name'] ){
    190         $replacements['RECN'] = $options['recipient_name'];
    191     } else {
    192         $replacements['RECN'] = 'example'; 
    193     }
    194    
    195     $cfc_pages = $wpdb->get_results(
    196                         $wpdb->prepare(
    197                             "SELECT p.ID as pid, p.post_title as title
     41
     42    global $wpdb, $user_ID;
     43    $options = get_option( 'conformconf_options' );
     44    $user_error = false;
     45    $found = false;
     46    $cfc_pages_parsed = array();
     47    $replacements = array(
     48        'NOP' => '',
     49        'NOF' => '',
     50        'NRE' => '',
     51        'EOP' => '',
     52        'EOF'  => '',
     53        'ERE'  => '',
     54        'POP'  => '',
     55        'POF'  => '',
     56        'PRE'  => '',
     57        'MOP'  => '',
     58        'MOF'  => '',
     59        'MRE'  => '',
     60        'PGNM' => '',
     61        'OPTS' => '',
     62        'DISPLAY' => '',
     63        'ERRD1'   => 'display:none',
     64        'ERRD2'   => 'display:none',
     65    );
     66
     67    $page_name = isset( $_POST['cfc_page_name'] ) ? stripslashes( $_POST['cfc_page_name'] ) : "";
     68    $existing_page = isset( $_POST['existing_page'] ) ? (int) $_POST['existing_page'] : false;
     69
     70    if ( $page_name or $existing_page ){
     71        $response = file_get_contents( "https://i.cx/api/users/api.php?type=getUser&username=" . stripslashes( $_POST['recipient_name'] ) );
     72        if ( $response ){
     73            $response_json = json_decode( $response );
     74            if ( isset($response_json->FAIL) ){
     75                $user_error = true;
     76            } else if ( $response_json->username ){
     77                $user_error = false;
     78            } else {
     79                $user_error = true;
     80            }
     81        } else {
     82            $user_error = true;
     83        }
     84
     85        if ( $user_error ){
     86            $replacements['PGNM'] = $page_name;
     87            $replacements['ERRD1'] = '';
     88            echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Username not found. Please enter a valid I.CX username. If you do not yet have an I.CX account, <a href="https://i.cx" target="_new">sign up for one now<a/>.</p></div>';
     89        } else {
     90
     91            if ( ! wp_verify_nonce( $_POST['cfcnonce'], 'cfcn-' . $user_ID ) ) {
     92                echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Invalid or expired security token!</p></div>';
     93            } else {
     94                $iframe_link = $_POST['iframe_url'];
     95
     96                // Replace spaces so URL validates
     97                $iframe_link = str_replace(' ', '%20', $iframe_link);
     98
     99                if (filter_var($iframe_link, FILTER_VALIDATE_URL) === FALSE or !preg_match("/^https:\/\/i.cx\/.+/", $iframe_link)) {
     100                    echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Invalid iFrame Content!</p></div>';
     101
     102
     103                } else if ( $page_name ) {
     104                    $pid =  $wpdb->get_var( $wpdb->prepare( "SELECT count(*) from $wpdb->posts
     105                                               WHERE post_type = 'page'
     106                                               AND post_title = %s",
     107                        $page_name
     108                    ) );
     109                    if ( $pid ) {
     110                        echo '<br/><div class="error" style="margin-left:1px;color:red"><p>A page with that name already exists!</p></div>';
     111                    } else {
     112                        $pid = wp_insert_post(
     113                            array(
     114                                'post_title'   => $page_name,
     115                                'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
     116                                'post_author'  => 1,
     117                                'post_type'    => 'page',
     118                                'post_status'  => 'publish',
     119                            )
     120                        );
     121                        if ( $pid ){
     122                            update_post_meta( $pid, 'cfc_page', 1);
     123                            $permalink = get_permalink( $pid );
     124                            echo '<br/><div class="updated" style="margin-left:1px"><p>Page Created: <a href="' . $permalink . '">' . $page_name . '</a></p></div>';
     125                        } else {
     126                            echo '<br/><div class="error" style="margin-left:1px;color:red"><p>Unexpected error occured while creating page</p></div>';
     127                        }
     128                    }
     129                } else if ($existing_page) {
     130                    wp_update_post(
     131                        array(
     132                            'ID'   => $existing_page,
     133                            'post_content' => '<iframe src="' . $iframe_link . '" width="600" height="500"></iframe>',
     134                        )
     135                    );
     136                    $updated_post = get_post( $existing_page );
     137                    $permalink = get_permalink( $existing_page );
     138                    echo '<br/><div class="updated" style="margin-left:1px"><p>Page Updated: <a href="' . $permalink . '">' . $updated_post->post_title . '</a></p></div>';
     139                }
     140            }
     141        }
     142
     143        $options['name']    = $_POST['name'];
     144        $options['email']   = $_POST['email'];
     145        $options['phone']   = $_POST['phone'];
     146        $options['message'] = $_POST['message'];
     147        $options['recipient_name'] = stripslashes( $_POST['recipient_name'] );
     148        $options['display_name']   = stripslashes( $_POST['display_name'] );
     149        $options['iframe_url']     = $_POST['iframe_url'];
     150        update_option( 'conformconf_options', $options );
     151
     152    }
     153
     154    if ( $options['name'] == 'optional' ){
     155        $replacements['NOP'] = 'checked';
     156    } else if ( $options['name'] == 'required' ){
     157        $replacements['NRE'] = 'checked';
     158    } else if ( $options['name'] == 'off' ){
     159        $replacements['NOF'] = 'checked';
     160    } else {
     161        $replacements['NRE'] = 'checked';
     162    }
     163
     164    if ( $options['email'] == 'optional' ){
     165        $replacements['EOP'] = 'checked';
     166    } else if ( $options['email'] == 'required' ){
     167        $replacements['ERE'] = 'checked';
     168    } else if ( $options['email'] == 'off' ){
     169        $replacements['EOF'] = 'checked';
     170    } else {
     171        $replacements['EOP'] = 'checked';
     172    }
     173
     174    if ( $options['phone'] == 'optional' ){
     175        $replacements['POP'] = 'checked';
     176    } else if ( $options['phone'] == 'required' ){
     177        $replacements['PRE'] = 'checked';
     178    } else if ( $options['phone'] == 'off' ){
     179        $replacements['POF'] = 'checked';
     180    } else {
     181        $replacements['POF'] = 'checked';
     182    }
     183
     184    if ( $options['message'] == 'optional' ){
     185        $replacements['MOP'] = 'checked';
     186    } else if ( $options['message'] == 'required' ){
     187        $replacements['MRE'] = 'checked';
     188    } else if ( $options['message'] == 'off' ){
     189        $replacements['MOF'] = 'checked';
     190    } else {
     191        $replacements['MRE'] = 'checked';
     192    }
     193
     194    $replacements['iframe_url'] = $options['iframe_url'];
     195
     196    if ( $options['display_name'] ){
     197        $replacements['DISN'] = $options['display_name'];
     198    } else {
     199        $replacements['DISN'] = 'Example';
     200    }
     201
     202    if ( $options['recipient_name'] ){
     203        $replacements['RECN'] = $options['recipient_name'];
     204    } else {
     205        $replacements['RECN'] = 'example';
     206    }
     207
     208    $cfc_pages = $wpdb->get_results(
     209        $wpdb->prepare(
     210            "SELECT p.ID as pid, p.post_title as title
    198211                            FROM $wpdb->posts p
    199212                            LEFT JOIN $wpdb->postmeta pm ON pm.post_id = p.ID
    200213                            WHERE pm.meta_key = %s"
    201                             , 'cfc_page'
    202                         )
    203                     );
    204 
    205    
    206     foreach( $cfc_pages as $cfc_page){
    207         $cfc_pages_parsed[ $cfc_page->pid ] = $cfc_page->title;
    208         $found = true;
    209     }
    210    
    211     if ( ! $found ){
    212         $replacements['DISPLAY'] = 'display:none';
    213     } else {
    214         $opts = '';
    215         foreach( $cfc_pages_parsed as $pid => $title ){
    216             $opts .= '<option value="' . $pid . '">' . $title . '</option>' . "\r\n";
    217         }
    218         $replacements['OPTS'] = $opts;
    219     }
    220 
    221     conformconf_show_settings( $replacements );
    222    
     214            , 'cfc_page'
     215        )
     216    );
     217
     218
     219    foreach( $cfc_pages as $cfc_page){
     220        $cfc_pages_parsed[ $cfc_page->pid ] = $cfc_page->title;
     221        $found = true;
     222    }
     223
     224    if ( ! $found ){
     225        $replacements['DISPLAY'] = 'display:none';
     226    } else {
     227        $opts = '';
     228        foreach( $cfc_pages_parsed as $pid => $title ){
     229            $opts .= '<option value="' . $pid . '">' . $title . '</option>' . "\r\n";
     230        }
     231        $replacements['OPTS'] = $opts;
     232    }
     233
     234    $nonce = wp_create_nonce( 'cfcn-' . $user_ID );
     235    $replacements['NONCE'] = "<input type='hidden' name='cfcnonce' value='$nonce'/>";
     236
     237    conformconf_show_settings( $replacements );
     238
    223239}
    224240
    225241
    226242function conformconf_show_settings( $replacements ){
    227     $file_content = file_get_contents( dirname( __FILE__ ) . "/tpl/admin_settings.html" );
    228     foreach( $replacements as $tag => $repl ){
    229         $file_content = str_replace( "%$tag%", $repl, $file_content );
    230     }
    231     echo $file_content;
    232 }
     243    $file_content = file_get_contents( dirname( __FILE__ ) . "/tpl/admin_settings.html" );
     244    foreach( $replacements as $tag => $repl ){
     245        $file_content = str_replace( "%$tag%", $repl, $file_content );
     246    }
     247    echo $file_content;
     248}
  • encrypted-contact-form/trunk/readme.txt

    r1111277 r1125443  
    44Requires at least: 3.0
    55Tested up to: 4.1
    6 Stable tag: 1.0.4
     6Stable tag: 1.1
    77License: MIT
    88
     
    2020
    2121== Changelog ==
     22
     23= 1.1 =
     24Detection of CSRF attacks added
    2225
    2326= 1.0.4 =
  • encrypted-contact-form/trunk/tpl/admin_settings.html

    r1078358 r1125443  
    11<form method="post" action="options-general.php?page=conformconf">
    2 <div class="panel panel-primary panel-pricing">
    3     <div class="panel-heading">Contact Form Creator</div>
    4     <div class="panel-body">
    5         <span class="subheaderExtraSpace">Step 1: Choose fields to include</span>
    6         <br>
    7         <div>
    8             <table style="padding:10px;border:0;">
    9             <tbody>
    10             <tr>
    11                 <td><u><strong>Field</strong></u></td>
    12                 <td><u><strong>Optional</strong></u></td>
    13                 <td><u><strong>Required</strong></u></td>
    14                 <td><u><strong>Off</strong></u></td>
    15             </tr>
    16             <tr style="text-align:center;">
    17                 <td><strong>Name</strong></td>
    18                 <td><input class="contact-checkbox" %NOP% id="nameoptional" name="name" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    19                 <td><input class="contact-checkbox" %NRE% id="namerequired" name="name" value="required" type="radio" onChange="handleRegenOptions();"></td>
    20                 <td><input class="contact-checkbox" %NOF% id="nameoff"  name="name" value="off" type="radio" onChange="handleRegenOptions();"></td>
    21             </tr>
    22             <tr style="text-align:center;">
    23                 <td><strong>Email</strong></td>
    24                 <td><input class="contact-checkbox" %EOP% id="emailoptional" name="email" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    25                 <td><input class="contact-checkbox" %ERE% id="emailrequired" name="email" value="required" type="radio" onChange="handleRegenOptions();"></td>
    26                 <td><input class="contact-checkbox" %EOF% id="emailoff" name="email" value="off" type="radio" onChange="handleRegenOptions();"></td>
    27             </tr>
    28             <tr style="text-align:center;">
    29                 <td><strong>Phone</strong></td>
    30                 <td><input class="contact-checkbox" %POP% id="phoneoptional" name="phone" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    31                 <td><input class="contact-checkbox" %PRE% id="phonerequired" name="phone" value="required" type="radio" onChange="handleRegenOptions();"></td>
    32                 <td><input class="contact-checkbox" %POF% id="phoneoff"  name="phone" value="off" type="radio" onChange="handleRegenOptions();"></td>
    33             </tr>
    34             <tr style="text-align:center;">
    35                 <td><strong>Message</strong></td>
    36                 <td><input class="contact-checkbox" %MOP% id="messageoptional" name="message" value="optional" type="radio" onChange="handleRegenOptions();"></td>
    37                 <td><input class="contact-checkbox" %MRE% id="messagerequired" name="message" value="required" type="radio" onChange="handleRegenOptions();"></td>
    38                 <td><input class="contact-checkbox" %MOF% id="messageoff" name="message" value="off" type="radio" onChange="handleRegenOptions();"></td>
    39             </tr>
    40             </tbody>
    41             </table>
    42         </div>
    43        
    44         <br>
    45         <span class="subheaderExtraSpace">Step 2: Set form recipient</span>
    46         <br>
     2    %NONCE%
     3    <div class="panel panel-primary panel-pricing">
     4        <div class="panel-heading">Contact Form Creator</div>
     5        <div class="panel-body">
     6            <span class="subheaderExtraSpace">Step 1: Choose fields to include</span>
     7            <br>
     8            <div>
     9                <table style="padding:10px;border:0;">
     10                    <tbody>
     11                    <tr>
     12                        <td><u><strong>Field</strong></u></td>
     13                        <td><u><strong>Optional</strong></u></td>
     14                        <td><u><strong>Required</strong></u></td>
     15                        <td><u><strong>Off</strong></u></td>
     16                    </tr>
     17                    <tr style="text-align:center;">
     18                        <td><strong>Name</strong></td>
     19                        <td><input class="contact-checkbox" %NOP% id="nameoptional" name="name" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     20                        <td><input class="contact-checkbox" %NRE% id="namerequired" name="name" value="required" type="radio" onChange="handleRegenOptions();"></td>
     21                        <td><input class="contact-checkbox" %NOF% id="nameoff"  name="name" value="off" type="radio" onChange="handleRegenOptions();"></td>
     22                    </tr>
     23                    <tr style="text-align:center;">
     24                        <td><strong>Email</strong></td>
     25                        <td><input class="contact-checkbox" %EOP% id="emailoptional" name="email" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     26                        <td><input class="contact-checkbox" %ERE% id="emailrequired" name="email" value="required" type="radio" onChange="handleRegenOptions();"></td>
     27                        <td><input class="contact-checkbox" %EOF% id="emailoff" name="email" value="off" type="radio" onChange="handleRegenOptions();"></td>
     28                    </tr>
     29                    <tr style="text-align:center;">
     30                        <td><strong>Phone</strong></td>
     31                        <td><input class="contact-checkbox" %POP% id="phoneoptional" name="phone" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     32                        <td><input class="contact-checkbox" %PRE% id="phonerequired" name="phone" value="required" type="radio" onChange="handleRegenOptions();"></td>
     33                        <td><input class="contact-checkbox" %POF% id="phoneoff"  name="phone" value="off" type="radio" onChange="handleRegenOptions();"></td>
     34                    </tr>
     35                    <tr style="text-align:center;">
     36                        <td><strong>Message</strong></td>
     37                        <td><input class="contact-checkbox" %MOP% id="messageoptional" name="message" value="optional" type="radio" onChange="handleRegenOptions();"></td>
     38                        <td><input class="contact-checkbox" %MRE% id="messagerequired" name="message" value="required" type="radio" onChange="handleRegenOptions();"></td>
     39                        <td><input class="contact-checkbox" %MOF% id="messageoff" name="message" value="off" type="radio" onChange="handleRegenOptions();"></td>
     40                    </tr>
     41                    </tbody>
     42                </table>
     43            </div>
    4744
    48         <span id="cfc_username_error" style="color:red;font-size:16px;%ERRD1%">Username Not Exists</span>
    49         <table style="padding:5px;border:0;width:600px;">
    50         <tbody>
    51         <tr>
    52             <td><strong>Display name:</strong></td>
    53             <td><strong>Recipient username:</strong></td>
    54         </tr>
    55         <tr>
    56             <td><input name="display_name" style="width:80%;padding:7px;" value="%DISN%" id="cfcdisplayname" type="text" onkeyup="setUsername();"></td>
    57             <td><input name="recipient_name" readonly="" value="%RECN%" style="width:80%;padding:7px;" type="text" id="cfcdisplayparsed"></td>
    58         </tr>
    59         </tbody>
    60         </table>
    61        
    62         <div class="small">
    63         The contents of your contact form will be encrypted and sent to this I.CX username.
    64         Your display name will be shown on the "Send" button of the form.
    65         You can use capital letters and add spaces in your display name, but it must be otherwise identical to your username.
    66         This ensures that no two users will have the same display name.
    67         </div>
    68        
    69         <br/>
    70         <span class="subheaderExtraSpace">Step 3: Preview and test your form</span>
    71         <br/>
    72        
    73         <div class="cfc-iframe-holder">
    74         <iframe id="cfc-preview" src="https://i.cx/secureForm.html?id_name=name&amp;element_name=text&amp;require_name=true&amp;id_email=email&amp;element_email=text&amp;validate_email=email&amp;id_message=message&amp;element_message=textarea&amp;require_message=true&amp;toUser=Smugdarkseagreenkitty" frameborder="0" height="500" width="100%"></iframe>
    75         </div>
    76         <span class="subheaderExtraSpace">Step 4: Copy embed code</span>
    77         <br/>
    78        
    79         <div class="cfc-embed-url-holder">
    80             <div class="form-group">
    81             <input value="<iframe src=&quot;undefined&quot; width=&quot;600&quot; height=&quot;500&quot;></iframe>" readonly="" class="form-control" id="cfcpreview" type="text"  onfocus="this.select();" onmouseup="return false;" />
    82             </div>
    83         </div>
    84         <br/>
    85         <span class="subheaderExtraSpace">Step 5: Create a page with form iframe embedded</span><br/>
    86         <span class="small">Page Name:</span> <br/>
    87         <input id="pageinput_text" value="%PGNM%" type="text" size="40" name="cfc_page_name" pattern=".{2,}" required title="2 characters minimum" />
    88         <span id="cfc_page_error" style="color:red;font-size:16px;%ERRD2%">Page with this name already exists</span>       
    89         <select id="pageinput_select" name="existing_page" style="display:none;margin:7px;">
    90         %OPTS%
    91         </select><br/>
    92         <div id='cfc_selection' style="padding:10px;%DISPLAY%">
    93         <input type="radio" name="cfc_selection" value="new" onclick="switchPage('new');" id="cfc_new" checked /> <label for="cfc_new">New Page</label>
    94         &nbsp;&nbsp;&nbsp;
    95         <input type="radio" name="cfc_selection" value="upd" onclick="switchPage('upd');" id="cfc_upd" /> <label for="cfc_upd">Update Existing</label>
    96         </div>
    97         <input type="hidden" name="iframe_url" id="iframe_url" />
    98         <input type="submit" id="cfc_createpage" class="button-primary" value="Create Page" style="margin-top:10px" />
    99         <br/>
    100         <span class="subheaderExtraSpace">Step 6 (optional): Sign up for email notifications</span>
    101         <br>
    102         <span class="small">If you would like to be notified by email every time someone fills out your contact form, </span>
    103         <a href="https://i.cx/?icx.screen=dashboard" target="_blank">visit your I.CX dashboard</a>
    104         <span class="small"> to set Email notifications.</span>
    105     </div>
    106 </div>
     45            <br>
     46            <span class="subheaderExtraSpace">Step 2: Set form recipient</span>
     47            <br>
     48
     49            <span id="cfc_username_error" style="color:red;font-size:16px;%ERRD1%">Username Not Exists</span>
     50            <table style="padding:5px;border:0;width:600px;">
     51                <tbody>
     52                <tr>
     53                    <td><strong>Display name:</strong></td>
     54                    <td><strong>Recipient username:</strong></td>
     55                </tr>
     56                <tr>
     57                    <td><input name="display_name" style="width:80%;padding:7px;" value="%DISN%" id="cfcdisplayname" type="text" onkeyup="setUsername();"></td>
     58                    <td><input name="recipient_name" readonly="" value="%RECN%" style="width:80%;padding:7px;" type="text" id="cfcdisplayparsed"></td>
     59                </tr>
     60                </tbody>
     61            </table>
     62
     63            <div class="small">
     64                The contents of your contact form will be encrypted and sent to this I.CX username.
     65                Your display name will be shown on the "Send" button of the form.
     66                You can use capital letters and add spaces in your display name, but it must be otherwise identical to your username.
     67                This ensures that no two users will have the same display name.
     68            </div>
     69
     70            <br/>
     71            <span class="subheaderExtraSpace">Step 3: Preview and test your form</span>
     72            <br/>
     73
     74            <div class="cfc-iframe-holder">
     75                <iframe id="cfc-preview" src="https://i.cx/secureForm.html?id_name=name&amp;element_name=text&amp;require_name=true&amp;id_email=email&amp;element_email=text&amp;validate_email=email&amp;id_message=message&amp;element_message=textarea&amp;require_message=true&amp;toUser=Smugdarkseagreenkitty" frameborder="0" height="500" width="100%"></iframe>
     76            </div>
     77            <span class="subheaderExtraSpace">Step 4: Copy embed code</span>
     78            <br/>
     79
     80            <div class="cfc-embed-url-holder">
     81                <div class="form-group">
     82                    <input value="<iframe src=&quot;undefined&quot; width=&quot;600&quot; height=&quot;500&quot;></iframe>" readonly="" class="form-control" id="cfcpreview" type="text"  onfocus="this.select();" onmouseup="return false;" />
     83                </div>
     84            </div>
     85            <br/>
     86            <span class="subheaderExtraSpace">Step 5: Create a page with form iframe embedded</span><br/>
     87            <span class="small">Page Name:</span> <br/>
     88            <input id="pageinput_text" value="%PGNM%" type="text" size="40" name="cfc_page_name" pattern=".{2,}" required title="2 characters minimum" />
     89            <span id="cfc_page_error" style="color:red;font-size:16px;%ERRD2%">Page with this name already exists</span>
     90            <select id="pageinput_select" name="existing_page" style="display:none;margin:7px;">
     91                %OPTS%
     92            </select><br/>
     93            <div id='cfc_selection' style="padding:10px;%DISPLAY%">
     94                <input type="radio" name="cfc_selection" value="new" onclick="switchPage('new');" id="cfc_new" checked /> <label for="cfc_new">New Page</label>
     95                &nbsp;&nbsp;&nbsp;
     96                <input type="radio" name="cfc_selection" value="upd" onclick="switchPage('upd');" id="cfc_upd" /> <label for="cfc_upd">Update Existing</label>
     97            </div>
     98            <input type="hidden" name="iframe_url" id="iframe_url" />
     99            <input type="submit" id="cfc_createpage" class="button-primary" value="Create Page" style="margin-top:10px" />
     100            <br/>
     101            <span class="subheaderExtraSpace">Step 6 (optional): Sign up for email notifications</span>
     102            <br>
     103            <span class="small">If you would like to be notified by email every time someone fills out your contact form, </span>
     104            <a href="https://i.cx/?icx.screen=dashboard" target="_blank">visit your I.CX dashboard</a>
     105            <span class="small"> to set Email notifications.</span>
     106        </div>
     107    </div>
    107108</form>
    108109<script>
    109     handleRegenOptions();
     110    handleRegenOptions();
    110111</script>
Note: See TracChangeset for help on using the changeset viewer.