예제 #1
0
function tdomf_overview_menu()
{
    global $wpdb, $wp_roles;
    // Initilise the plugin for the first time here. This gets called when you click the TDOMF button in the menu.
    // Doing it here means you can delete all the options!
    tdomf_init();
    // get feed_messages
    require_once ABSPATH . WPINC . '/rss.php';
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->role_objects;
    ?>
  <div class="wrap">
    <h2><?php 
    _e('Welcome to TDO Mini Forms', 'tdomf');
    ?>
</h2>

    <div id="zeitgeist">

        <?php 
    $features = tdomf_new_features();
    if ($features) {
        ?>
                <h2><?php 
        printf(__("New Features in %s for you", "tdomf"), TDOMF_VERSION);
        ?>
</h2>
                <?php 
        echo $features;
        ?>
        <?php 
    }
    ?>
    
    	  <h2><?php 
    _e('Latest Activity', 'tdomf');
    ?>
</h2>
        
    	  <h3><?php 
    _e('Log', 'tdomf');
    if (current_user_can('manage_options')) {
        ?>
<a href="admin.php?page=tdomf_show_log_menu" title="Full Log...">&raquo;</a><?php 
    }
    ?>
</h3>

    	  <p><?php 
    echo tdomf_get_log(5);
    ?>
</p>

        <?php 
    if (tdomf_is_moderation_in_use()) {
        ?>

          <?php 
        $posts = tdomf_get_unmoderated_posts(0, 10);
        if (!empty($posts)) {
            ?>
            
        	  <h3><?php 
            _e('Latest Submissions', 'tdomf');
            if (current_user_can('edit_others_posts')) {
                ?>
<a href="admin.php?page=tdomf_show_mod_posts_menu&f=0" title="<?php 
                _e("Moderate Submissions...", "tdomf");
                ?>
">&raquo;</a><?php 
            }
            ?>
</h3>

          <ul>

              
                <?php 
            foreach ($posts as $p) {
                echo tdomf_get_post_list_line($p);
            }
        }
        ?>
    	  </ul>

    	  <?php 
    }
    ?>

          <?php 
    if (get_option(TDOMF_OPTION_SPAM)) {
        ?>
              <?php 
        $spam_count = tdomf_get_spam_posts_count();
        if ($spam_count > 0) {
            ?>
                  <h3><?php 
            printf(__('There are %d spam submissions', 'tdomf'), $spam_count);
            if (current_user_can('edit_others_posts')) {
                ?>
<a href="admin.php?page=tdomf_show_mod_posts_menu&f=3" title="<?php 
                _e("Moderate Spam...", "tdomf");
                ?>
">&raquo;</a><?php 
            }
            ?>
</h3>
              <?php 
        }
        ?>
          <?php 
    }
    ?>
          
          <?php 
    $posts = tdomf_get_published_posts(0, 10);
    if (!empty($posts)) {
        ?>

    	  <h3><?php 
        _e('Latest Approved Submissions', 'tdomf');
        if (current_user_can('edit_others_posts')) {
            ?>
<a href="admin.php?page=tdomf_show_mod_posts_menu&f=1" title="Moderate Posts...">&raquo;</a><?php 
        }
        ?>
</h3>

    	  <ul>
                  
                  
              <?php 
        foreach ($posts as $p) {
            echo tdomf_get_post_list_line($p);
        }
    }
    ?>
    	  </ul>

          

    	  <h3><?php 
    _e('Stats', 'tdomf');
    ?>
</h3>

          <?php 
    $stat_sub_ever = get_option(TDOMF_STAT_SUBMITTED);
    $stat_edit_ever = get_option(TDOMF_STAT_EDITED);
    $stat_unmod = tdomf_get_unmoderated_posts_count();
    $stat_edit_unmod = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
    $stat_sub_cur = tdomf_get_submitted_posts_count();
    $stat_edit_cur = tdomf_get_edits(array('count' => true, 'unique_post_ids' => true));
    $stat_mod = $stat_sub_cur - $stat_unmod;
    $stat_edit_mod = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'unique_post_ids' => true));
    $stat_spam = get_option(TDOMF_STAT_SPAM);
    ?>

          <?php 
    if (get_option(TDOMF_OPTION_SPAM)) {
        ?>
              <p><?php 
        printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved. %d spam submissions have been caught by Akismet", "tdomf"), TDOMF_VERSION, get_option(TDOMF_VERSION_CURRENT), $stat_sub_ever, $stat_edit_ever, $stat_mod, $stat_edit_mod, $stat_spam);
        ?>
          <?php 
    } else {
        ?>
              <p><?php 
        printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved.", "tdomf"), TDOMF_VERSION, get_option(TDOMF_VERSION_CURRENT), $stat_sub_ever, $stat_edit_ever, $stat_mod, $stat_edit_mod);
        ?>
          <?php 
    }
    ?>
        
        <?php 
    $rss = fetch_rss('http://thedeadone.net/forum/?cat=6&feed=rss');
    if (isset($rss->items) && 0 != count($rss->items)) {
        $rss->items = array_slice($rss->items, 0, 5);
        echo "<h3>" . __('Latest Support Forum Topics', 'tdomf') . "</h3><ul>";
        foreach ($rss->items as $item) {
            ?>
                 <li><a href='<?php 
            echo wp_filter_kses($item['link']);
            ?>
'><?php 
            echo wp_specialchars($item['title']);
            ?>
</a></li>
        <?php 
        }
        echo "</ul>";
    }
    ?>
        
    </div>

    <?php 
    echo "<p>" . ($message = tdomf_get_error_messages() . "</p>");
    ?>

    <table style="margin:0px;padding:0px">
      <tr>
        <td>
          <form action="https://www.paypal.com/cgi-bin/webscr" method="post" >
          <input type="hidden" name="cmd" value="_s-xclick">
          <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px;" >
          <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
          <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
">
          </form>
        </td><td>
          <?php 
    printf(__("[<a href='%s'>My Amazon Wishlist</a>]", "tdomf"), "http://www.amazon.co.uk/gp/registry/23S7OL9W6Q4JT");
    ?>
        </td>
        <td>
          <?php 
    printf(__("[<a href='%s'>Rate TDO-Mini-Forms on Wordpress.org!</a>]", "tdomf"), "http://wordpress.org/extend/plugins/tdo-mini-forms/#rate-response");
    ?>
        </td>
      </tr>
    </table>
    
    <p><?php 
    _e("Use these links to get started:", "tdomf");
    ?>
</p>

    <ul>
      <li><a href="admin.php?page=tdomf_show_options_menu"><?php 
    _e("Configure TDO Mini Forms", "tdomf");
    ?>
</a></li>
      <li><a href="admin.php?page=tdomf_show_form_menu"><?php 
    _e("Form Widgets", "tdomf");
    ?>
</a></li>
      <?php 
    if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
        ?>
          <?php 
        if (current_user_can('edit_users')) {
            ?>
                <li><a href="users.php?page=tdomf_your_submissions"><?php 
            _e("Your Submissions Page", "tdomf");
            ?>
</a></li>
          <?php 
        } else {
            ?>
                <li><a href="profile.php?page=tdomf_your_submissions"><?php 
            _e("Your Submissions Page", "tdomf");
            ?>
</a></li>
          <?php 
        }
        ?>
      <?php 
    }
    ?>
      <?php 
    if (current_user_can('manage_options')) {
        ?>
      <li><a href="<?php 
        echo TDOMF_URLPATH;
        ?>
tdomf-phpinfo.php"><?php 
        _e("phpinfo()", "tdomf");
        ?>
</a></li>
      <li><a href="admin.php?page=<?php 
        echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR;
        ?>
tdomf-info.php"><?php 
        _e("tdomfinfo()", "tdomf");
        ?>
</a></li>
      <?php 
    }
    ?>
    </ul>

<p><?php 
    _e('Need help with TDO Mini Forms? Please see the <a href="http://thedeadone.net/forum">support forums on thedeadone.net</a> or the <a href="http://wordpress.org/tags/tdo-mini-forms">support forums on wordpress.org</a>.', "tdomf");
    ?>
</p>

    <h3><?php 
    _e('Welcome', 'tdomf');
    ?>
</h3>

    <p>
    <?php 
    _e("TDO Mini Forms plugin allows you to provide a form to your readers and users so that they can submit posts to your blog, even if they don't have rights to do so. You can control what type of users, such as unregistered users and subscribers, can access and use the form. Posts are submitted as draft so that you can approve them before they are published. (You can optionally turn this off so that submissions are automatically published). As of version 0.7, you can now also customise the form using widgets.", "tdomf");
    ?>
    </p>
        
    <div id="devnews">
    <h3><?php 
    _e('Latest TDO Mini Forms News!', 'tdomf');
    ?>
</h3>

    <?php 
    $rss = fetch_rss('http://thedeadone.net/tag/tdomf/feed');
    if (isset($rss->items) && 0 != count($rss->items)) {
        $rss->items = array_slice($rss->items, 0, 4);
        foreach ($rss->items as $item) {
            ?>
          <h4><a href='<?php 
            echo wp_filter_kses($item['link']);
            ?>
'><?php 
            echo wp_specialchars($item['title']);
            ?>
</a> &#8212; <?php 
            echo human_time_diff(strtotime($item['pubdate'], time()));
            ?>
</h4>
          <p><?php 
            echo '<strong>' . date("F, jS", strtotime($item['pubdate'])) . '</strong> - ' . $item['description'];
            ?>
</p>
        <?php 
        }
    } else {
        ?>
        <p><?php 
        printf(__('Newsfeed could not be loaded.  Check the <a href="%s">thedeadone.net</a> to check for updates.', 'tdomf'), 'http://thedeadone.net/index.php?tag=tdomf');
        ?>
</p>
        <?php 
    }
    ?>
    </div>
    <br style="clear: both" />
   </div>
    <?php 
}
예제 #2
0
function tdomf_handle_options_actions()
{
    global $wpdb, $wp_roles;
    $message = "";
    $retValue = false;
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_dummy_user') {
        check_admin_referer('tdomf-create-dummy-user');
        tdomf_create_dummy_user();
        $message = "Dummy user created for Default Author!<br/>";
    } else {
        if (isset($_REQUEST['save_settings']) && !isset($_REQUEST['tdomf_form_id'])) {
            check_admin_referer('tdomf-options-save');
            // Default Author
            $def_aut = $_POST['tdomf_def_user'];
            if (!empty($def_aut) && !is_numeric($def_aut)) {
                if (($userdata = get_userdatabylogin($def_aut)) != false) {
                    $def_aut = $userdata->ID;
                } else {
                    $message .= "<font color='red'>" . sprintf(__("The user %s is not a valid user and cannot be used for Default Author", "tdomf"), $def_aut) . "</font><br/>";
                    $def_aut = false;
                }
            }
            update_option(TDOMF_DEFAULT_AUTHOR, $def_aut);
            // Author and Submitter fix
            $fix_aut = false;
            if (isset($_POST['tdomf_autocorrect_author'])) {
                $fix_aut = true;
            }
            update_option(TDOMF_AUTO_FIX_AUTHOR, $fix_aut);
            //Auto Trust Submitter Count
            $cnt = -1;
            if (isset($_POST['tdomf_trust_count']) && !empty($_POST['tdomf_trust_count']) && is_numeric($_POST['tdomf_trust_count'])) {
                $cnt = intval($_POST['tdomf_trust_count']);
            }
            update_option(TDOMF_OPTION_TRUST_COUNT, $cnt);
            //Author theme hack
            $author_theme_hack = false;
            if (isset($_POST['tdomf_author_theme_hack'])) {
                $author_theme_hack = true;
            }
            update_option(TDOMF_OPTION_AUTHOR_THEME_HACK, $author_theme_hack);
            //Add submitter info
            $add_submitter = false;
            if (isset($_POST['tdomf_add_submitter'])) {
                $add_submitter = true;
            }
            update_option(TDOMF_OPTION_ADD_SUBMITTER, $add_submitter);
            //disable errors
            $disable_errors = false;
            if (isset($_POST['tdomf_disable_errors'])) {
                $disable_errors = true;
            }
            update_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES, $disable_errors);
            // extra log messages
            $extra_log = false;
            if (isset($_POST['tdomf_extra_log'])) {
                $extra_log = true;
            }
            update_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES, $extra_log);
            // your submissions
            $your_submissions = false;
            if (isset($_POST['tdomf_your_submissions'])) {
                $your_submissions = true;
            }
            update_option(TDOMF_OPTION_YOUR_SUBMISSIONS, $your_submissions);
            // default widget max sizes
            if (tdomf_wp25()) {
                $widget_max_width = intval($_POST['widget_max_width']);
                update_option(TDOMF_OPTION_WIDGET_MAX_WIDTH, $widget_max_width);
                $widget_max_height = intval($_POST['widget_max_height']);
                update_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT, $widget_max_height);
            }
            // verification method
            $tdomf_verify = $_POST['tdomf_verify'];
            update_option(TDOMF_OPTION_VERIFICATION_METHOD, $tdomf_verify);
            $tdomf_form_data = $_POST['tdomf_form_data'];
            update_option(TDOMF_OPTION_FORM_DATA_METHOD, $tdomf_form_data);
            // Show links on moderation screen
            $tdomf_mod_show_links = isset($_POST['tdomf_mod_show_links']);
            update_option(TDOMF_OPTION_MOD_SHOW_LINKS, $tdomf_mod_show_links);
            // spam options
            $message .= tdomf_handle_spam_options_actions();
            // log options
            $tdomf_log_max_size = intval($_POST['tdomf_log_max_size']);
            update_option(TDOMF_OPTION_LOG_MAX_SIZE, $tdomf_log_max_size);
            $message .= "Options Saved!<br/>";
            tdomf_log_message("Options Saved");
        }
    }
    // Warnings
    $message .= tdomf_get_error_messages(false);
    if (!empty($message)) {
        ?>
   <div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
   <?php 
    }
    return $retValue;
}
예제 #3
0
function tdomf_handle_form_export_actions()
{
    global $wpdb, $wp_roles;
    $message = "";
    $retValue = false;
    if (isset($_REQUEST['tdomf_import'])) {
        $import_message = tdomf_import_form_from_file();
        if ($import_message != false) {
            $message .= $import_message . '<br/>';
        }
    }
    // Warnings
    $message .= tdomf_get_error_messages(false);
    if (!empty($message)) {
        ?>
   <div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
   <?php 
    }
    return $retValue;
}
예제 #4
0
function tdomf_show_form_hacker()
{
    global $wp_version;
    $form_id = false;
    if (isset($_REQUEST['form'])) {
        $form_id = $_REQUEST['form'];
    } else {
        $form_id = tdomf_get_first_form_id();
    }
    if ($form_id == false || !tdomf_form_exists($form_id)) {
        ?>
    <div class="wrap">
       <h2><?php 
        _e('Form Hacker', 'tdomf');
        ?>
</h2>
       <p><?php 
        if (is_numeric($form_id)) {
            printf(__('Invalid Form ID %s specified!'), $form_id);
        } else {
            _e('No Form ID specified!');
        }
        ?>
</p>
    </div>
  <?php 
    } else {
        if (isset($_REQUEST['diff'])) {
            ?>
    <div class="wrap">
          <?php 
            tdomf_form_hacker_diff($form_id);
            ?>
    </div> <!-- wrap -->
  <?php 
        } else {
            $mode = tdomf_generate_default_form_mode($form_id);
            $mode .= '-hack';
            tdomf_form_hacker_actions($form_id);
            $message = tdomf_get_error_messages(true, $form_id);
            if (!empty($message)) {
                ?>
        <div id="message" class="updated fade"><p><?php 
                echo $message;
                ?>
</p></div>
    <?php 
            }
            tdomf_forms_top_toolbar($form_id, 'tdomf_show_form_hacker');
            $form_ids = tdomf_get_form_ids();
            ?>
        
        <div class="wrap">
        <?php 
            if (!isset($_REQUEST['text'])) {
                ?>
          <h2><?php 
                printf(__("Form Hacker for Form %d: \"%s\"", "tdomf"), $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id));
                ?>
</h2>            
        <?php 
            } else {
                ?>
          <h2><?php 
                printf(__("Message Hacker for Form %d: \"%s\"", "tdomf"), $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id));
                ?>
</h2>            
        <?php 
            }
            ?>

          <script type="text/javascript">
            function tdomfHideHelp() {
                jQuery('#tdomf_help').attr('class','hidden');
                jQuery('#tdomf_show_help').attr('class','');
                jQuery('#tdomf_hide_help').attr('class','hidden');
            }
            function tdomfShowHelp() {
                jQuery('#tdomf_help').attr('class','');
                jQuery('#tdomf_show_help').attr('class','hidden');
                jQuery('#tdomf_hide_help').attr('class','');
            }
          </script>
          
          <?php 
            tdomf_forms_under_title_toolbar($form_id, 'tdomf_show_form_hacker');
            ?>
    
          <?php 
            if (isset($_REQUEST['text'])) {
                ?>
           
          <!-- <div id="tdomf_help" class='hidden'> -->
          
          <?php 
                $code_on = false;
                if (isset($_REQUEST['code'])) {
                    $code_on = true;
                }
                ?>
          
          <p><?php 
                _e("You can use this page to modify any messages outputed from TDOMF for your form. From here you can change the post published messages, post held in moderation, etc. etc.", "tdomf");
                ?>
</p>
            
          <?php 
                if (version_compare($wp_version, "2.8-beta2", ">=")) {
                    if (!$code_on) {
                        ?>
              <p><a href="admin.php?page=tdomf_show_form_hacker&text&code&form=<?php 
                        echo $form_id;
                        ?>
"><?php 
                        _e("Enable Code Syntax Highlighting...", 'tdomf');
                        ?>
</a></p>
          <?php 
                    } else {
                        ?>
              <p><a href="admin.php?page=tdomf_show_form_hacker&text&form=<?php 
                        echo $form_id;
                        ?>
"><?php 
                        _e("Disable Code Syntax Highlighting...", 'tdomf');
                        ?>
</a></p>
          <?php 
                    }
                }
                ?>
          
          <?php 
                $form_edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id);
                ?>
 
          
          <p><?php 
                _e("PHP code can be included in the hacked messages. Also TDOMF will automatically expand these macro strings:", "tdomf");
                ?>
             <ul>
             <li><?php 
                printf(__("<code>%s</code> - User name of the currently logged in user", "tdomf"), TDOMF_MACRO_USERNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - IP of the current visitor", "tdomf"), TDOMF_MACRO_IP);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The ID of the current form (which is currently %d)", "tdomf"), TDOMF_MACRO_FORMID, $form_id);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Name of the Form (set in options)", "tdomf"), TDOMF_MACRO_FORMNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Form Description (set in options)", "tdomf"), TDOMF_MACRO_FORMDESCRIPTION);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Submission Errors", "tdomf"), TDOMF_MACRO_SUBMISSIONERRORS);
                ?>
             <?php 
                if ($form_edit) {
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - URL of Post/Page being edited", "tdomf"), TDOMF_MACRO_SUBMISSIONURL);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Original Submission Date", "tdomf"), TDOMF_MACRO_SUBMISSIONDATE);
                    ?>
             
             <li><?php 
                    printf(__("<code>%s</code> - Original Submission Time", "tdomf"), TDOMF_MACRO_SUBMISSIONTIME);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Title of Post/Page being edited", "tdomf"), TDOMF_MACRO_SUBMISSIONTITLE);
                    ?>
             <?php 
                } else {
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - URL of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONURL);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Date of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONDATE);
                    ?>
             
             <li><?php 
                    printf(__("<code>%s</code> - Time of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONTIME);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Title of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONTITLE);
                    ?>
             <?php 
                }
                ?>
             </ul>
          </p>
          
          <!-- </div> -->
          
          <form method="post" name="formhackermsgs" id="formhackermsgs">
          <?php 
                if (function_exists('wp_nonce_field')) {
                    wp_nonce_field('tdomf-form-hacker');
                }
                ?>
          
          <p class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_save" name="tdomf_hack_messages_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_reset" name="tdomf_hack_messages_reset" />
          </p>
          
          <?php 
                if (!tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id) && !tdomf_get_option_form(TDOMF_OPTION_REDIRECT, $form_id)) {
                    ?>
              <h3><?php 
                    if ($form_edit) {
                        _e('Contribution Approved', 'tdomf');
                    } else {
                        _e('Submission Published', 'tdomf');
                    }
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_publish" id="tdomf_msg_sub_publish" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_PUBLISH, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
                    
          <?php 
                if (intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id)) > 0 && !tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id)) {
                    ?>
              <h3><?php 
                    _e('Submission Queued', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_future" id="tdomf_msg_sub_future" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_FUTURE, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (get_option(TDOMF_OPTION_SPAM)) {
                    ?>
              <h3><?php 
                    if ($form_edit) {
                        _e('Contribution is Spam', 'tdomf');
                    } else {
                        _e('Submission is Spam', 'tdomf');
                    }
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_spam" id="tdomf_msg_sub_spam" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_SPAM, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id)) {
                    ?>
              <h3><?php 
                    if ($form_edit) {
                        _e('Contribution awaiting Moderation', 'tdomf');
                    } else {
                        _e('Submission awaiting Moderation', 'tdomf');
                    }
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_mod" id="tdomf_msg_sub_mod" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_MOD, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <h3><?php 
                if ($form_edit) {
                    _e('Contribution contains Errors', 'tdomf');
                } else {
                    _e('Submission contains Errors', 'tdomf');
                }
                ?>
</h3>
          <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_error" id="tdomf_msg_sub_error" <?php 
                if ($code_on) {
                    ?>
class="codepress .php"<?php 
                }
                ?>
 ><?php 
                echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_ERROR, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
          <br/><br/>
          
          <h3><?php 
                _e('Banned User', 'tdomf');
                ?>
</h3>
          <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_banned_user" id="tdomf_msg_perm_banned_user" <?php 
                if ($code_on) {
                    ?>
class="codepress .php"<?php 
                }
                ?>
 ><?php 
                echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_BANNED_USER, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
          <br/><br/>

          <h3><?php 
                _e('Banned IP', 'tdomf');
                ?>
</h3>          
          <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_banned_ip" id="tdomf_msg_perm_banned_ip" <?php 
                if ($code_on) {
                    ?>
class="codepress .php"<?php 
                }
                ?>
 ><?php 
                echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_BANNED_IP, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
          <br/><br/>
          
          <?php 
                $throttle_rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
                if (is_array($throttle_rules) && !empty($throttle_rules)) {
                    ?>
              <h3><?php 
                    _e('Throttled Submission', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_throttle" id="tdomf_msg_perm_throttle" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_THROTTLE, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (!tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id)) {
                    ?>
              <h3><?php 
                    _e('Denied User', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_invalid_user" id="tdomf_msg_perm_invalid_user" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_INVALID_USER, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (!tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id)) {
                    ?>
              <h3><?php 
                    _e('Banned Unregistered User', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_invalid_nouser" id="tdomf_msg_perm_invalid_nouser" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_INVALID_NOUSER, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>

          <?php 
                if ($form_edit) {
                    ?>

              <?php 
                    /*if(tdomf_get_option_form(TDOMF_OPTION_AJAX_EDIT,$form_id)) {*/
                    ?>
              
                 <h3><?php 
                    _e('\'Edit Post\' Link Text', 'tdomf');
                    ?>
</h3>
                 <textarea title="true" rows="5" cols="70" name="tdomf_msg_edit_post_link" id="tdomf_msg_edit_post_link" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_ADD_EDIT_LINK_TEXT, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
                 <br/><br/>
             
              <?php 
                    /*}*/
                    ?>
              
              <h3><?php 
                    _e('Invalid Post for Form', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_invalid_post" id="tdomf_msg_invalid_post" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_INVALID_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
              
              <h3><?php 
                    _e('Invalid Form for Post', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_invalid_form" id="tdomf_msg_invalid_form" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_INVALID_FORM, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
              
              <h3><?php 
                    _e('Locked Post', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_locked_post" id="tdomf_msg_locked_post" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_LOCKED_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
              
              <?php 
                    if (get_option(TDOMF_OPTION_SPAM)) {
                        ?>

                 <h3><?php 
                        _e('Spam Edit on Post', 'tdomf');
                        ?>
</h3>
                 <textarea title="true" rows="5" cols="70" name="tdomf_msg_spam_edit_on_post" id="tdomf_msg_spam_edit_on_post" <?php 
                        if ($code_on) {
                            ?>
class="codepress .php"<?php 
                        }
                        ?>
 ><?php 
                        echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SPAM_EDIT_ON_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                        ?>
</textarea>
                 <br/><br/>
                  
              <?php 
                    }
                    ?>
              
             <h3><?php 
                    _e('Unapproved Edit on Post', 'tdomf');
                    ?>
</h3>
             <textarea title="true" rows="5" cols="70" name="tdomf_msg_unapproved_edit_on_post" id="tdomf_msg_unapproved_edit_on_post" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_UNAPPROVED_EDIT_ON_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
             <br/><br/>

          <?php 
                }
                ?>
          
          <?php 
                do_action('tdomf_form_hacker_messages_bottom', $form_id, $mode);
                ?>
                    
          <span class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_save" name="tdomf_hack_messages_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_reset" name="tdomf_hack_messages_reset" />
          </span>
          
          </form>
          
          <?php 
            } else {
                ?>
          
          <!-- <div id="tdomf_help" class='hidden'> -->
          
          <p><?php 
                _e("You can use this page to hack the generated HTML code for your form without modifing the code of TDOMF. Please only do this if you know what you are doing. From here you can modify titles, default values, re-arrange fields, etc. etc.", "tdomf");
                ?>
</p>
             
          <p><?php 
                _e('Do not modify or remove the "name" and "id" attributes of fields as this is what the widgets and TDOMF use to get input values for processing', 'tdomf');
                ?>
</p>
             
          <p><?php 
                printf(__("Every time a form is generated, it creates a unique key. If you hack the form, make sure you keep <code>%s</code> (and also <code>%s</code>) within the form. TDOMF will replace this string with the unique key.", "tdomf"), TDOMF_MACRO_FORMKEY, TDOMF_MACRO_FORMURL);
                ?>
</p>
          
          <p><?php 
                _e("PHP code can be included in the hacked form. Also TDOMF will automatically expand these macro strings:", "tdomf");
                ?>
             <ul>
             <li><?php 
                printf(__("<code>%s</code> - User name of the currently logged in user", "tdomf"), TDOMF_MACRO_USERNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - IP of the current visitor", "tdomf"), TDOMF_MACRO_IP);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The form's unique key", "tdomf"), TDOMF_MACRO_FORMKEY);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The current URL of the form", "tdomf"), TDOMF_MACRO_FORMURL);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The ID of the current form (which is currently %d)", "tdomf"), TDOMF_MACRO_FORMID, $form_id);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Name of the Form (set in options)", "tdomf"), TDOMF_MACRO_FORMNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Form Description (set in options)", "tdomf"), TDOMF_MACRO_FORMDESCRIPTION);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Form Output (such as preview, errors, etc.). This is automatically encapsulated in a div called tdomf_form_message (and tdomf_form_preview for preview)", "tdomf"), TDOMF_MACRO_FORMMESSAGE);
                ?>
             <li><?php 
                printf(__("<code>%swidget-name%s</code> - Original, unmodified output from 'widget-name'", "tdomf"), TDOMF_MACRO_WIDGET_START, TDOMF_MACRO_END);
                ?>
             </ul>
          </p>
          
          <!-- </div> -->
 
          <form method="post" name="formhacker" id="formhacker">
          <?php 
                if (function_exists('wp_nonce_field')) {
                    wp_nonce_field('tdomf-form-hacker');
                }
                ?>
      
          <p class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_save" name="tdomf_form_hack_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_reset" name="tdomf_form_hack_reset" />
          </p>
          
          <?php 
                if (tdomf_widget_is_preview_avaliable($form_id)) {
                    ?>
          
              <h3><?php 
                    _e('Core Form', 'tdomf');
                    ?>
</h3>
              
          <?php 
                }
                ?>
          
            <?php 
                $cur_form = tdomf_generate_form($form_id, $mode);
                $form = $cur_form;
                $hacked_form = tdomf_get_option_form(TDOMF_OPTION_FORM_HACK, $form_id);
                if ($hacked_form != false) {
                    $form = $hacked_form;
                }
                ?>
                  
            <?php 
                if ($hacked_form != false) {
                    ?>
              <?php 
                    _e("You can diff the hacked form to see what you have changed", "tdomf");
                    ?>
              <ul>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                    echo $form_id;
                    ?>
&mode=<?php 
                    echo $mode;
                    ?>
&diff&form1=hack&form2=cur"><?php 
                    _e("Diff Hacked Form with Current Form", "tdomf");
                    ?>
</a></li>
              <?php 
                    $org_form = tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL, $form_id);
                    if (trim($cur_form) != trim($org_form)) {
                        ?>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                        echo $form_id;
                        ?>
&mode=<?php 
                        echo $mode;
                        ?>
&diff&form2=hack&form1=org"><?php 
                        _e("Diff Hacked Form with Previous Form", "tdomf");
                        ?>
</a></li>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                        echo $form_id;
                        ?>
&mode=<?php 
                        echo $mode;
                        ?>
&diff&form2=cur&form1=org"><?php 
                        _e("Diff Current Form with Previous Form", "tdomf");
                        ?>
</a></li>
                    <?php 
                    }
                    ?>
              </ul>
            <?php 
                }
                ?>
                  
            <textarea title="true" rows="30" cols="100" name="tdomf_form_hack" id="tdomf_form_hack" class="codepress .php" ><?php 
                echo htmlentities($form, ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
            
          <br/><br/>
          
          <?php 
                if (tdomf_widget_is_preview_avaliable($form_id)) {
                    ?>
          
              <h3><?php 
                    _e('Form Preview', 'tdomf');
                    ?>
</h3>
              
              <?php 
                    $cur_preview = tdomf_preview_form(array('tdomf_form_id' => $form_id), $mode);
                    $preview = $cur_preview;
                    $hacked_preview = tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK, $form_id);
                    if ($hacked_preview != false) {
                        $preview = $hacked_preview;
                    }
                    ?>
              
              <?php 
                    if ($hacked_preview != false) {
                        ?>
              <?php 
                        _e("You can diff the hacked preview to see what you have changed", "tdomf");
                        ?>
              <ul>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                        echo $form_id;
                        ?>
&mode=<?php 
                        echo $mode;
                        ?>
&diff&form1=hack&form2=cur&type=preview"><?php 
                        _e("Diff Hacked Preview with Current Preview", "tdomf");
                        ?>
</a></li>
              <?php 
                        $org_preview = tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL, $form_id);
                        if (trim($cur_preview) != trim($org_preview)) {
                            ?>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                            echo $form_id;
                            ?>
&mode=<?php 
                            echo $mode;
                            ?>
&diff&form2=hack&form1=org&type=preview"><?php 
                            _e("Diff Hacked Preview with Previous Preview", "tdomf");
                            ?>
</a></li>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                            echo $form_id;
                            ?>
&mode=<?php 
                            echo $mode;
                            ?>
&diff&form2=cur&form1=org&type=preview"><?php 
                            _e("Diff Current Preview with Previous Preview", "tdomf");
                            ?>
</a></li>
                    <?php 
                        }
                        ?>
              </ul>
            <?php 
                    }
                    ?>
                    
                    
              <textarea title="true" rows="15" cols="100" name="tdomf_form_preview_hack" id="tdomf_form_preview_hack" class="codepress .php"><?php 
                    echo htmlentities($preview, ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
                
              <br/><br/>
                
          <?php 
                }
                ?>

          <!-- @TODO Validation Message Hacker -->
          <!-- @TODO Upload Form Hacker -->     
          <?php 
                do_action('tdomf_form_hacker_bottom', $form_id, $mode);
                ?>
          
          <span class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_save" name="tdomf_form_hack_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_reset" name="tdomf_form_hack_reset" />
          </span>
          
          </form>
          
          <!-- @TODO: warning about updated form (with dismiss link) -->
          
          <?php 
            }
            ?>
          
        </div>
    <?php 
        }
    }
}
예제 #5
0
 function tdomf_theme_widget_admin($args)
 {
     if (current_user_can('manage_options') || current_user_can('edit_others_posts')) {
         extract($args);
         $errors = tdomf_get_error_messages();
         if (trim($errors) != "") {
             echo $before_widget;
             echo $before_title . __("TDOMF Errors", "tdomf") . $after_title;
             echo "<p>{$errors}</p>";
             echo $after_widget;
         }
         $options = get_option('tdomf_theme_widget_admin');
         if ($options == false) {
             $log = 5;
             $mod = 5;
         } else {
             $log = $options['log'];
             $mod = $options['mod'];
         }
         if ($log > 0) {
             echo $before_widget;
             echo $before_title;
             _e('TDOMF Log', 'tdomf');
             if (current_user_can('manage_options')) {
                 echo "<a href=\"" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_log_menu\" title=\"Full Log...\">&raquo;</a>";
             }
             echo $after_title;
             echo '<p>' . tdomf_get_log($log) . '</p>';
             echo $after_widget;
         }
         if ($mod > 0) {
             $posts = tdomf_get_unmoderated_posts(0, $mod);
             if (!empty($posts)) {
                 echo $before_widget;
                 echo $before_title;
                 printf(__('Awaiting Approval (%d)', 'tdomf'), tdomf_get_unmoderated_posts_count());
                 if (current_user_can('edit_others_posts')) {
                     echo "<a href=\"" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&f=0\" title=\"Moderate Submissions...\">&raquo;</a>";
                 }
                 echo $after_title;
                 echo '<ul>';
                 foreach ($posts as $p) {
                     echo tdomf_get_post_list_line($p);
                 }
                 echo '</ul>';
                 echo $after_widget;
             }
         }
         if (get_option(TDOMF_OPTION_SPAM)) {
             $spam_count = tdomf_get_spam_posts_count();
             if ($spam_count > 0) {
                 echo $before_widget;
                 echo $before_title;
                 printf(__('Spam Queue (%d)', 'tdomf'), $spam_count);
                 if (current_user_can('edit_others_posts')) {
                     echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&f=3" title="' . __("Moderate Spam...", "tdomf") . '">&raquo;</a>';
                 }
                 echo $after_title;
                 echo $after_widget;
             }
         }
         echo $before_widget;
         echo $before_title;
         _e('TDOMF Admin Links', 'tdomf');
         echo $after_title;
         echo "<ul>";
         if ($mod <= 0 && tdomf_is_moderation_in_use()) {
             echo "<li>";
             printf(__("<a href=\"%s\">Moderate (%d)</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&f=0", tdomf_get_unmoderated_posts_count());
             echo "</li>";
         }
         echo "<li>";
         printf(__("<a href=\"%s\">Configure</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_options_menu");
         echo "</li>";
         echo "<li>";
         printf(__("<a href=\"%s\">Manage</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_manage_menu");
         echo "</li>";
         echo "<li>";
         printf(__("<a href=\"%s\">Create Form</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_form_menu");
         echo "</li>";
         if ($log <= 0) {
             echo "<li>";
             printf(__("<a href=\"%s\">Log</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_log_menu");
             echo "</li>";
         }
         echo "</ul>";
         echo $after_widget;
     }
 }
예제 #6
0
function tdomf_handle_form_options_actions()
{
    global $wpdb, $wp_roles;
    $message = "";
    $retValue = false;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->role_objects;
    $caps = tdomf_get_all_caps();
    $remove_throttle_rule = false;
    $rule_id = 0;
    if (isset($_REQUEST['tdomf_form_id'])) {
        $form_id = intval($_REQUEST['tdomf_form_id']);
        $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
        if (is_array($rules)) {
            foreach ($rules as $id => $r) {
                if (isset($_REQUEST["tdomf_remove_throttle_rule_{$id}"])) {
                    $remove_throttle_rule = true;
                    $rule_id = $id;
                    break;
                }
            }
        }
    }
    if ($remove_throttle_rule) {
        check_admin_referer('tdomf-options-save');
        unset($rules[$rule_id]);
        tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES, $rules, $form_id);
        $message .= "Throttle rule removed!<br/>";
        tdomf_log_message("Removed throttle rule");
    } else {
        if (isset($_REQUEST['tdomf_add_throttle_rule'])) {
            check_admin_referer('tdomf-options-save');
            $form_id = intval($_REQUEST['tdomf_form_id']);
            $rule = array();
            $rule['sub_type'] = $_REQUEST['tdomf_throttle_rule_sub_type'];
            $rule['count'] = $_REQUEST['tdomf_throttle_rule_count'];
            $rule['type'] = $_REQUEST['tdomf_throttle_rule_user_type'];
            $rule['opt1'] = isset($_REQUEST['tdomf_throttle_rule_opt1']);
            $rule['time'] = intval($_REQUEST['tdomf_throttle_rule_time']);
            $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
            if (!is_array($rules)) {
                $rules = array();
            }
            $rules[] = $rule;
            tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES, $rules, $form_id);
            $message .= "Throttle rule added!<br/>";
            tdomf_log_message("Added a new throttle rule: " . var_export($rule, true));
        } else {
            if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_form_page') {
                check_admin_referer('tdomf-create-form-page');
                $form_id = intval($_REQUEST['form']);
                $page_id = tdomf_create_form_page($form_id);
                $message = sprintf(__("A page with the form has been created. <a href='%s'>View page &raquo;</a><br/>", "tdomf"), get_permalink($page_id));
            } else {
                if (isset($_REQUEST['save_settings']) && isset($_REQUEST['tdomf_form_id'])) {
                    check_admin_referer('tdomf-options-save');
                    $form_id = intval($_REQUEST['tdomf_form_id']);
                    // Edit or Submit
                    $edit_form = false;
                    if (isset($_REQUEST['tdomf_mode']) && $_REQUEST['tdomf_mode'] == "edit") {
                        $edit_form = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_FORM_EDIT, $edit_form, $form_id);
                    // Allow pages with forms to be editted
                    $edit_page_form = isset($_REQUEST['tdomf_edit_page_form']);
                    tdomf_set_option_form(TDOMF_OPTION_EDIT_PAGE_FORM, $edit_page_form, $form_id);
                    // Allow authors to edit
                    $author_edit = false;
                    if (isset($_REQUEST['tdomf_author_edit'])) {
                        $author_edit = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ALLOW_AUTHOR, $author_edit, $form_id);
                    // Edit post within X seconds of being published
                    $time_edit = false;
                    if (isset($_REQUEST['tdomf_time_edit'])) {
                        $time_edit = intval($_REQUEST['tdomf_time_edit']);
                        if ($time_edit <= 0) {
                            $time_edit = false;
                        }
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ALLOW_TIME, $time_edit, $form_id);
                    // Who can access the form?
                    if (isset($_REQUEST['tdomf_special_access_anyone']) && tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) == false) {
                        tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE, true, $form_id);
                        foreach ($roles as $role) {
                            // remove cap as it's not needed
                            if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                                $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
                            }
                        }
                        tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS, array(), $form_id);
                    } else {
                        if (!isset($_REQUEST['tdomf_special_access_anyone'])) {
                            tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE, false, $form_id);
                            // add cap to right roles
                            foreach ($roles as $role) {
                                if (isset($_REQUEST["tdomf_access_" . $role->name])) {
                                    $role->add_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
                                } else {
                                    if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                                        $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
                                    }
                                }
                            }
                            // list caps that can access form
                            $allow_caps = array();
                            foreach ($caps as $cap) {
                                if (isset($_REQUEST['tdomf_access_caps_' . $cap])) {
                                    $allow_caps[] = $cap;
                                }
                            }
                            tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS, $allow_caps, $form_id);
                            // convert user names to ids
                            $allow_users = array();
                            if (isset($_REQUEST['tdomf_access_users_list'])) {
                                $user_names = trim($_REQUEST['tdomf_access_users_list']);
                                if (!empty($user_names)) {
                                    $user_names = explode(' ', $user_names);
                                    foreach ($user_names as $user_name) {
                                        if (!empty($user_name)) {
                                            if (($userdata = get_userdatabylogin($user_name)) != false) {
                                                $allow_users[] = $userdata->ID;
                                            } else {
                                                $message .= "<font color='red'>" . sprintf(__("{$user_name} is not a valid user name. Ignoring.<br/>", "tdomf"), $form_id) . "</font>";
                                                tdomf_log_message("User login {$user_name} is not recognised by wordpress. Ignoring.", TDOMF_LOG_BAD);
                                            }
                                        }
                                    }
                                }
                            }
                            tdomf_set_option_form(TDOMF_OPTION_ALLOW_USERS, $allow_users, $form_id);
                        }
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ALLOW_PUBLISH, isset($_REQUEST['tdomf_user_publish_override']), $form_id);
                    // Who gets notified?
                    $notify_roles = "";
                    foreach ($roles as $role) {
                        if (isset($_REQUEST["tdomf_notify_" . $role->name])) {
                            $notify_roles .= $role->name . ";";
                        }
                    }
                    if (!empty($notify_roles)) {
                        tdomf_set_option_form(TDOMF_NOTIFY_ROLES, $notify_roles, $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_NOTIFY_ROLES, false, $form_id);
                    }
                    $save = true;
                    $tdomf_admin_emails = $_POST['tdomf_admin_emails'];
                    $emails = explode(',', $tdomf_admin_emails);
                    foreach ($emails as $email) {
                        if (!empty($email)) {
                            if (!tdomf_check_email_address($email)) {
                                $message .= "<font color='red'>" . sprintf(__("The email %s is not valid! Please update 'Who Gets Notified' with valid email addresses.", "tdomf"), $email) . "</font><br/>";
                                $save = false;
                                break;
                            }
                        }
                    }
                    if ($save) {
                        tdomf_set_option_form(TDOMF_OPTION_ADMIN_EMAILS, $tdomf_admin_emails, $form_id);
                    }
                    // Default Category
                    $def_cat = $_POST['tdomf_def_cat'];
                    tdomf_set_option_form(TDOMF_DEFAULT_CATEGORY, $def_cat, $form_id);
                    // Restrict editing to posts submitted by tdomf
                    $edit_restrict_tdomf = isset($_REQUEST['tdomf_edit_tdomf_only']);
                    tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_TDOMF, $edit_restrict_tdomf, $form_id);
                    $edit_restrict_cats = explode(',', trim($_REQUEST['tdomf_edit_cats']));
                    if (!empty($edit_restrict_cats)) {
                        $cats = array();
                        foreach ($edit_restrict_cats as $cat) {
                            $cat = intval(trim($cat));
                            if ($cat > 0) {
                                $cats[] = $cat;
                            }
                        }
                        $edit_restrict_cats = $cats;
                    } else {
                        $edit_restrict_cats = array();
                    }
                    tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_CATS, $edit_restrict_cats, $form_id);
                    // add edit link
                    $add_edit_link = $_REQUEST['tdomf_add_edit_link'];
                    if ($add_edit_link == 'custom') {
                        $add_edit_link = $_REQUEST['tdomf_add_edit_link_custom_url'];
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ADD_EDIT_LINK, $add_edit_link, $form_id);
                    $ajax_edit = isset($_REQUEST['tdomf_ajax_edit']);
                    tdomf_set_option_form(TDOMF_OPTION_AJAX_EDIT, $ajax_edit, $form_id);
                    // auto modify edit link
                    $auto_edit_link = $_REQUEST['tdomf_auto_edit_link'];
                    if ($auto_edit_link == 'custom') {
                        $auto_edit_link = $_REQUEST['tdomf_auto_edit_link_custom_url'];
                    }
                    tdomf_set_option_form(TDOMF_OPTION_AUTO_EDIT_LINK, $auto_edit_link, $form_id);
                    //Turn On/Off Moderation
                    $mod = false;
                    if (isset($_POST['tdomf_moderation'])) {
                        $mod = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_MODERATION, $mod, $form_id);
                    $tdomf_redirect = isset($_POST['tdomf_redirect']);
                    tdomf_set_option_form(TDOMF_OPTION_REDIRECT, $tdomf_redirect, $form_id);
                    //Preview
                    $preview = false;
                    if (isset($_POST['tdomf_preview'])) {
                        $preview = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_PREVIEW, $preview, $form_id);
                    //From email
                    if (trim($_POST['tdomf_from_email']) == "") {
                        tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL, false, $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL, $_POST['tdomf_from_email'], $form_id);
                    }
                    // Form name
                    if (trim($_POST['tdomf_form_name']) == "") {
                        tdomf_set_option_form(TDOMF_OPTION_NAME, "", $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_OPTION_NAME, strip_tags($_POST['tdomf_form_name']), $form_id);
                    }
                    // Form description
                    if (trim($_POST['tdomf_form_descp']) == "") {
                        tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION, false, $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION, $_POST['tdomf_form_descp'], $form_id);
                    }
                    // Include on "your submissions" page
                    //
                    $include = false;
                    if (isset($_POST['tdomf_include_sub'])) {
                        $include = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $include, $form_id);
                    if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) && $include) {
                        $message .= sprintf(__("Saved Options for Form %d. <a href='%s'>See your form &raquo</a>", "tdomf"), $form_id, "users.php?page=tdomf_your_submissions#tdomf_form%d") . "<br/>";
                    } else {
                        $message .= sprintf(__("Saved Options for Form %d.", "tdomf"), $form_id) . "<br/>";
                    }
                    // widget count
                    //
                    $widget_count = 10;
                    if (isset($_POST['tdomf_widget_count'])) {
                        $widget_count = intval($_POST['tdomf_widget_count']);
                    }
                    if ($widget_count < 1) {
                        $widget_count = 1;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $widget_count, $form_id);
                    //Submit page instead of post
                    //
                    $use_page = false;
                    if (isset($_POST['tdomf_use_type']) && $_POST['tdomf_use_type'] == 'page') {
                        $use_page = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_SUBMIT_PAGE, $use_page, $form_id);
                    // Queue period
                    //
                    $tdomf_queue_period = intval($_POST['tdomf_queue_period']);
                    tdomf_set_option_form(TDOMF_OPTION_QUEUE_PERIOD, $tdomf_queue_period, $form_id);
                    // Queue on all
                    //
                    $tdomf_queue_on_all = isset($_POST['tdomf_queue_on_all']);
                    tdomf_set_option_form(TDOMF_OPTION_QUEUE_ON_ALL, $tdomf_queue_on_all, $form_id);
                    // ajax
                    //
                    $tdomf_ajax = isset($_POST['tdomf_ajax']);
                    tdomf_set_option_form(TDOMF_OPTION_AJAX, $tdomf_ajax, $form_id);
                    // Send moderation email even for published posts
                    //
                    $tdomf_mod_email_on_pub = isset($_POST['tdomf_mod_email_on_pub']);
                    tdomf_set_option_form(TDOMF_OPTION_MOD_EMAIL_ON_PUB, $tdomf_mod_email_on_pub, $form_id);
                    // Admin users auto-publish?
                    //
                    $tdomf_publish_no_mod = isset($_POST['tdomf_user_publish_auto']);
                    tdomf_set_option_form(TDOMF_OPTION_PUBLISH_NO_MOD, $tdomf_publish_no_mod, $form_id);
                    // Spam
                    //
                    $message .= tdomf_handle_spam_options_actions($form_id);
                    tdomf_log_message("Options Saved for Form ID {$form_id}");
                } else {
                    if (isset($_REQUEST['delete'])) {
                        $form_id = intval($_REQUEST['delete']);
                        check_admin_referer('tdomf-delete-form-' . $form_id);
                        if (tdomf_form_exists($form_id)) {
                            $count_forms = count(tdomf_get_form_ids());
                            if ($count_forms > 1) {
                                if (tdomf_delete_form($form_id)) {
                                    $message .= sprintf(__("Form %d deleted.<br/>", "tdomf"), $form_id);
                                } else {
                                    $message .= sprintf(__("Could not delete Form %d!<br/>", "tdomf"), $form_id);
                                }
                            } else {
                                $message .= sprintf(__("You cannot delete the last form! There must be at least one form in the system.<br/>", "tdomf"), $form_id);
                            }
                        } else {
                            $message .= sprintf(__("Form %d is not valid!<br/>", "tdomf"), $form_id);
                        }
                    } else {
                        if (isset($_REQUEST['copy'])) {
                            $form_id = intval($_REQUEST['copy']);
                            check_admin_referer('tdomf-copy-form-' . $form_id);
                            $copy_form_id = tdomf_copy_form($form_id);
                            if ($copy_form_id != 0) {
                                $message .= sprintf(__("Form %d copied with id %d.<br/>", "tdomf"), $form_id, $copy_form_id);
                                $retValue = $copy_form_id;
                            } else {
                                $message .= sprintf(__("Failed to copy Form %d!<br/>", "tdomf"), $form_id);
                            }
                        } else {
                            if (isset($_REQUEST['new'])) {
                                check_admin_referer('tdomf-new-form');
                                $form_id = tdomf_create_form(__('New Form', 'tdomf'), array());
                                if ($form_id != 0) {
                                    $message .= sprintf(__("New form created with %d.<br/>", "tdomf"), $form_id);
                                    $retValue = $form_id;
                                } else {
                                    $message .= __("Failed to create new Form!<br/>", "tdomf");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Warnings
    $message .= tdomf_get_error_messages(false);
    if (!empty($message)) {
        ?>
   <div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
   <?php 
    }
    return $retValue;
}