function __construct()
 {
     $this->Errors = array();
     if (cscf_PluginSettings::UseRecaptcha()) {
         $this->RecaptchaPublicKey = cscf_PluginSettings::PublicKey();
         $this->RecaptchaPrivateKey = cscf_PluginSettings::PrivateKey();
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['cscf'])) {
         $cscf = $_POST['cscf'];
         $this->Name = filter_var($cscf['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
         $this->Email = filter_var($cscf['email'], FILTER_SANITIZE_EMAIL);
         if (isset($cscf['confirm-email'])) {
             $this->ConfirmEmail = filter_var($cscf['confirm-email'], FILTER_SANITIZE_EMAIL);
         }
         $this->Message = filter_var($cscf['message'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
         if (isset($_POST['post-id'])) {
             $this->PostID = $_POST['post-id'];
         }
         unset($_POST['cscf']);
     }
     $this->IsSpam = false;
 }
Пример #2
0
    public function create_fields($args)
    {
        $fieldname = $args[0];
        switch ($fieldname) {
            case 'use_recaptcha':
                $checked = cscf_PluginSettings::UseRecaptcha() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="use_recaptcha"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[use_recaptcha]"><?php 
                break;
            case 'load_stylesheet':
                $checked = cscf_PluginSettings::LoadStyleSheet() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="load_stylesheet"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[load_stylesheet]"><?php 
                break;
            case 'recaptcha_public_key':
                $disabled = cscf_PluginSettings::UseRecaptcha() == false ? "readonly" : "";
                ?>
<input <?php 
                echo $disabled;
                ?>
 type="text" size="60" id="recaptcha_public_key"
                                                  name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[recaptcha_public_key]"
                                                  value="<?php 
                echo cscf_PluginSettings::PublicKey();
                ?>
" /><?php 
                break;
            case 'recaptcha_private_key':
                $disabled = cscf_PluginSettings::UseRecaptcha() == false ? "readonly" : "";
                ?>
<input <?php 
                echo $disabled;
                ?>
 type="text" size="60" id="recaptcha_private_key"
                                                  name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[recaptcha_private_key]"
                                                  value="<?php 
                echo cscf_PluginSettings::PrivateKey();
                ?>
" /><?php 
                break;
            case 'recipient_emails':
                ?>
                <ul id="recipients"><?php 
                foreach (cscf_PluginSettings::RecipientEmails() as $key => $recipientEmail) {
                    ?>
                    <li class="recipient_email" data-element="<?php 
                    echo $key;
                    ?>
">
                        <input class="enter_recipient" type="email" size="50"
                               name="<?php 
                    echo CSCF_OPTIONS_KEY;
                    ?>
[recipient_emails][<?php 
                    echo $key;
                    ?>
]"
                               value="<?php 
                    echo $recipientEmail;
                    ?>
"/>
                        <input class="add_recipient" title="Add New Recipient" type="submit" name="add_recipient"
                               value="+">
                        <input class="remove_recipient" title="Remove This Recipient" type="submit"
                               name="remove_recipient[<?php 
                    echo $key;
                    ?>
]" value="-">
                    </li>

                <?php 
                }
                ?>
</ul><?php 
                break;
            case 'confirm-email':
                $checked = cscf_PluginSettings::ConfirmEmail() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="confirm-email"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[confirm-email]"><?php 
                break;
            case 'override-from':
                $checked = cscf_PluginSettings::OverrideFrom() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="override-from"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[override-from]"><?php 
                break;
            case 'email-sender':
                $checked = cscf_PluginSettings::EmailToSender() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="email-sender"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[email-sender]"><?php 
                break;
            case 'from-email':
                $disabled = cscf_PluginSettings::OverrideFrom() == false ? "readonly" : "";
                ?>
<input <?php 
                echo $disabled;
                ?>
 type="text" size="60" id="from-email"
                                                  name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[from-email]"
                                                  value="<?php 
                echo cscf_PluginSettings::FromEmail();
                ?>
" /><?php 
                break;
            case 'subject':
                ?>
<input type="text" size="60" id="subject" name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[subject]"
                         value="<?php 
                echo cscf_PluginSettings::Subject();
                ?>
" /><?php 
                break;
            case 'sent_message_heading':
                ?>
<input type="text" size="60" id="sent_message_heading"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[sent_message_heading]"
                         value="<?php 
                echo cscf_PluginSettings::SentMessageHeading();
                ?>
" /><?php 
                break;
            case 'sent_message_body':
                ?>
<textarea cols="63" rows="8"
                            name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[sent_message_body]"><?php 
                echo cscf_PluginSettings::SentMessageBody();
                ?>
</textarea><?php 
                break;
            case 'message':
                ?>
<textarea cols="63" rows="8"
                            name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[message]"><?php 
                echo cscf_PluginSettings::Message();
                ?>
</textarea><?php 
                break;
            case 'theme':
                $theme = cscf_PluginSettings::Theme();
                $disabled = cscf_PluginSettings::UseRecaptcha() == false ? "disabled" : "";
                ?>
                <select <?php 
                echo $disabled;
                ?>
 id="theme" name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[theme]">
                    <option <?php 
                echo $theme == "light" ? "selected" : "";
                ?>
                        value="light"><?php 
                _e('Light', 'cleanandsimple');
                ?>
</option>
                    <option <?php 
                echo $theme == "dark" ? "selected" : "";
                ?>
                        value="dark"><?php 
                _e('Dark', 'cleanandsimple');
                ?>
</option>
                </select>
                <?php 
                break;
            case 'use_client_validation':
                $checked = cscf_PluginSettings::UseClientValidation() == true ? "checked" : "";
                ?>
<input type="checkbox" <?php 
                echo $checked;
                ?>
  id="use_client_validation"
                         name="<?php 
                echo CSCF_OPTIONS_KEY;
                ?>
[use_client_validation]"><?php 
                break;
            default:
                break;
        }
    }