function tdomf_prepare_string($message, $form_id = false, $mode = "", $post_id = false, $errors = "", $post_args = array()) { global $current_user; if ($post_id !== false) { $post =& get_post($post_id); // "post_date" is now only updated when a post is published // so now submission date is captured in a custom field // Failing that, go back to the old method of post_modified // if ($post->post_status == 'publish' || $post->post_status == 'future') { $submission_date = mysql2date(get_option('date_format'), $post->post_date_gmt); $submission_time = mysql2date(get_option('time_format'), $post->post_date_gmt); } else { if (get_post_meta($post_id, TDOMF_KEY_SUBMISSION_DATE_GMT, true)) { $date = get_post_meta($post_id, TDOMF_KEY_SUBMISSION_DATE_GMT, true); $submission_date = mysql2date(get_option('date_format'), $date); $submission_time = mysql2date(get_option('time_format'), $date); } else { $submission_date = mysql2date(get_option('date_format'), $post->post_modified_gmt); $submission_time = mysql2date(get_option('time_format'), $post->post_modified_gmt); } } // url, date and time are safe but title is not: scrub $patterns = array('/' . TDOMF_MACRO_SUBMISSIONURL . '/', '/' . TDOMF_MACRO_SUBMISSIONDATE . '/', '/' . TDOMF_MACRO_SUBMISSIONTIME . '/', '/' . TDOMF_MACRO_SUBMISSIONTITLE . '/'); $replacements = array(get_permalink($post_id), $submission_date, $submission_time, tdomf_protect_input($post->post_title)); $message = preg_replace($patterns, $replacements, $message); } if (!empty($errors)) { $message = preg_replace('/' . TDOMF_MACRO_SUBMISSIONERRORS . '/', $errors, $message); } if (is_user_logged_in()) { get_currentuserinfo(); // might not be safe $message = preg_replace('/' . TDOMF_MACRO_USERNAME . '/', tdomf_protect_input($current_user->display_name), $message); } else { if ($post_id !== false) { // may not be safe at all $message = preg_replace('/' . TDOMF_MACRO_USERNAME . '/', tdomf_protect_input(get_post_meta($post_id, TDOMF_KEY_NAME, true)), $message); } else { $message = preg_replace('/' . TDOMF_MACRO_USERNAME . '/', __("Unregistered", "tdomf"), $message); } } $message = preg_replace('/' . TDOMF_MACRO_IP . '/', $_SERVER['REMOTE_ADDR'], $message); if ($form_id !== false) { // these macros are inputed by form admin so are considered safe $patterns = array('/' . TDOMF_MACRO_FORMURL . '/', '/' . TDOMF_MACRO_FORMID . '/', '/' . TDOMF_MACRO_FORMNAME . '/', '/' . TDOMF_MACRO_FORMDESCRIPTION . '/'); $replacements = array($_SERVER['REQUEST_URI'] . '#tdomf_form' . $form_id, $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id), tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION, $form_id)); $message = preg_replace($patterns, $replacements, $message); } // A lot of people use the ID uppercase format $post_ID = $post_id; // execute any PHP code in the message ob_start(); extract($post_args, EXTR_PREFIX_INVALID, "tdomf_"); $message = @eval("?>" . $message); $message = ob_get_contents(); ob_end_clean(); return $message; }
function tdomf_widget_getcat_hack($args) { global $tdomf_getcat_var_name; extract($args); $getcat = tdomf_get_option_form(TDOMF_DEFAULT_CATEGORY, $tdomf_form_id); $output = "\t\t<?php \$getcat = {$getcat};\n"; $output .= "\t\tif(isset(\$_GET['{$tdomf_getcat_var_name}'])) {\n"; $output .= "\t\t\t\$getcat = intval(\$_GET['{$tdomf_getcat_var_name}']);\n"; $output .= "\t\t} else if(isset(\$post_args['{$tdomf_getcat_var_name}'])) {\n"; $output .= "\t\t\$getcat = intval(\$post_args['{$tdomf_getcat_var_name}']); } ?>\n"; $output .= "\t\t<div><input type='hidden' name='{$tdomf_getcat_var_name}' id='{$tdomf_getcat_var_name}' value='"; $output .= "<?php echo \$getcat; ?>' /></div>\n"; return $output; }
function tdomf_theme_widget_form($args, $params) { extract($args); $form_id = $params; if (!tdomf_form_exists($form_id)) { $form_id = tdomf_get_first_form_id(); } echo $before_widget; echo $before_title; echo tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id); echo $after_title; tdomf_the_form($form_id); echo "<br/><br/>\n"; echo $after_widget; }
function tdomf_export_form() { $form_id = $_GET['tdomf_export']; $ok = true; if (!tdomf_form_exists($form_id)) { $ok = false; } if (!current_user_can('manage_options')) { $ok = false; } if ($ok) { check_admin_referer('tdomf-export-' . $form_id); } if ($ok) { $form_data = array(); $form_data['options'] = tdomf_get_options_form($form_id); $form_data['options'][TDOMF_OPTION_NAME] = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id); $form_data['widgets'] = tdomf_get_widgets_form($form_id); $form_data['caps'] = array(); if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } $roles = $wp_roles->role_objects; foreach ($roles as $role) { if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) { $form_data['caps'][] = $role->name; } } $form_export = serialize($form_data); } @ignore_user_abort(); @set_time_limit(600); if ($ok) { header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename=\"form_export_{$form_id}.txt\""); header("Content-Length: " . strlen($form_export)); sleep(1); echo $form_export; } else { header("HTTP/1.0 404 Not Found"); } exit; }
function tdomf_ajax_exit($form_id, $message, $full = false, $preview = false, $post_id = false) { global $form_id; $is_edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id); if ($is_edit) { $form_tag = $form_id . '_' . $post_id; } else { $form_tag = $form_id; } $message = tdomf_js_escape($message); #tdomf_log_message("sending '$message' via ajax (tdomfDisplayMessage$form_tag)..."); if ($full) { die("tdomfDisplayMessage{$form_tag}('{$message}','full');"); } else { if ($preview) { die("tdomfDisplayMessage{$form_tag}('{$message}','preview');"); } else { die("tdomfDisplayMessage{$form_tag}('{$message}','');"); } } }
function tdomf_get_form_widget_default_order($form_id) { if (tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id)) { return array("who-am-i", "content"); } else { return array("who-am-i", "content", "notifyme"); } }
// allows the final check to work when editing // unset($post_id); } else { if (isset($_POST['tdomf_form' . $form_tag . '_clear'])) { $message = NULL; $save_post_info = false; $hide_form = false; } } } } // update form data *after* widgets have done their work! // $form_data = tdomf_get_form_data($form_id); if (!isset($post_id) || !$publish || !tdomf_get_option_form(TDOMF_OPTION_REDIRECT, $form_id)) { // Go back to form with args // $redirect_url = $_POST['redirect']; // Hack: set your own URL here if you wish to redirect to a different URL // Future versions of TDOMF will provide this as an option. // #if($publish || isset($post_id)) { $redirect_url = 'http://thedeadone.net/download/tdo-mini-forms-wordpress-plugin/'; } if ($save_post_info) { $args = $_POST; } else { $args = array(); } if ($hide_form) { $args['tdomf_no_form_' . $form_id] = true; }
/** * Action to be processed when post created successfully. Will send email * if valid post. * * @access public * @return Boolean */ function sendMailAction($post_id, $form_id) { // do nothing if no email set // $autorespondemail_email = get_post_meta($post_id, '_tdomf_autorespond_widget_email', true); if ($autorespondemail_email == false) { return false; } delete_post_meta($post_id, '_tdomf_autorespond_widget_email'); // if spam, do nothing // if (get_post_meta($post_id, TDOMF_KEY_SPAM, true)) { return false; } $options = $this->getOptions($form_id); if ($options['link']) { $nonce = wp_create_nonce('tdomf-autorespondemail-' . $post_id); $url = trailingslashit(get_bloginfo('wpurl')) . '?tdomf_autorespondemail_post_id=' . $post_id . '&key=' . $nonce; $patterns[] = '/' . TDOMF_MACRO_AUTORESPONDEMAIL_LINK . '/'; $replacements[] = $url; } $subject = tdomf_prepare_string($options['subject'], $form_id, "", $post_id); $body = tdomf_prepare_string($options['body'], $form_id, "", $post_id); if ($options['link']) { $body = preg_replace($patterns, $replacements, $body); } $body = str_replace("\n", "\r\n", $body); // Use custom from field // if (tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id)) { // We can modify the "from" field by using the "header" option at the end! // $headers = "MIME-Version: 1.0\n" . "From: " . tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id) . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; $status = @wp_mail($autorespondemail_email, $subject, $body, $headers); } else { $status = @wp_mail($autorespondemail_email, $subject, $body); } // should we do some sort of error handling here? // tdomf_log_message("wp_mail returned {$status} for auto responde email on post {$post_id}"); return true; }
function tdomfinfo_text_display() { ?> <pre> ^**Option** ^ **Value** ^ <?php $alloptions = wp_load_alloptions(); foreach ($alloptions as $id => $val) { if (preg_match('#^tdomf_.+#', $id) && $id != TDOMF_LOG) { ?> | <?php echo $id; ?> | <?php echo htmlentities(strval($val)); ?> | <?php } } $form_ids = tdomf_get_form_ids(); foreach ($form_ids as $form_id) { $name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id->form_id); ?> == Form <?php echo $form_id->form_id; ?> == = Name = <?php echo $name; ?> <?php $options = tdomf_get_options_form($form_id->form_id); foreach ($options as $option => $value) { ?> = <?php echo $option; ?> = <?php echo htmlentities(var_export($value, true)); ?> <?php } $widgets = tdomf_get_widgets_form($form_id->form_id); if (!empty($widgets)) { ?> == Widgets for Form == <?php foreach ($widgets as $widget) { ?> = <?php echo $widget->widget_key; ?> = <?php echo htmlentities($widget->widget_value); ?> <?php } } } ?> </pre> <?php }
function tdomf_widget_notifyme_hack_messages($form_id, $mode) { $widget_order = tdomf_get_widget_order($form_id); if (in_array('notifyme', $widget_order) && tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id)) { if (isset($_REQUEST['tdomf_hack_messages_save'])) { #if (get_magic_quotes_gpc()) { $options = array('approved' => stripslashes($_REQUEST['tdomf_widget_notifyme_msg_approved']), 'rejected' => stripslashes($_REQUEST['tdomf_widget_notifyme_msg_rejected']), 'approved_subject' => stripslashes($_REQUEST['tdomf_widget_notifyme_msg_approved_subject']), 'rejected_subject' => stripslashes($_REQUEST['tdomf_widget_notifyme_msg_rejected_subject'])); #} else { # $options = array( 'approved' => $_REQUEST['tdomf_widget_notifyme_msg_approved'], # 'rejected' => $_REQUEST['tdomf_widget_notifyme_msg_rejected'], # 'approved_subject' => $_REQUEST['tdomf_widget_notifyme_msg_approved_subject'], # 'rejected_subject' => $_REQUEST['tdomf_widget_notifyme_msg_rejected_subject'] ); #} tdomf_set_option_widget('notifyme', $options, $form_id); } else { if (isset($_REQUEST['tdomf_hack_messages_reset'])) { tdomf_set_option_widget('notifyme', false, $form_id); } } ?> <h3><?php _e('Submission Approved Email', 'tdomf'); ?> </h3> <input type="textfield" name="tdomf_widget_notifyme_msg_approved_subject" id="tdomf_widget_notifyme_msg_approved_subject" size="70" value="<?php echo htmlentities(tdomf_widget_notify_get_message($form_id, 'approved_subject'), ENT_QUOTES, get_bloginfo('charset')); ?> " /> <textarea title="true" rows="5" cols="70" name="tdomf_widget_notifyme_msg_approved" id="tdomf_widget_notifyme_msg_approved" ><?php echo htmlentities(tdomf_widget_notify_get_message($form_id, 'approved'), ENT_NOQUOTES, get_bloginfo('charset')); ?> </textarea> <br/><br/> <h3><?php _e('Submission Rejected Email', 'tdomf'); ?> </h3> <input type="textfield" name="tdomf_widget_notifyme_msg_rejected_subject" id="tdomf_widget_notifyme_msg_rejected_subject" size="70" value="<?php echo htmlentities(tdomf_widget_notify_get_message($form_id, 'rejected_subject'), ENT_QUOTES, get_bloginfo('charset')); ?> " /> <textarea title="true" rows="5" cols="70" name="tdomf_widget_notifyme_msg_rejected" id="tdomf_widget_notifyme_msg_rejected" ><?php echo htmlentities(tdomf_widget_notify_get_message($form_id, 'rejected'), ENT_NOQUOTES, get_bloginfo('charset')); ?> </textarea> <br/><br/> <?php } }
function tdomf_get_error_messages($show_links = true, $form_id = 0) { global $wpdb, $wp_roles; if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } $roles = $wp_roles->role_objects; $message = ""; #if(ini_get('register_globals') && !TDOMF_HIDE_REGISTER_GLOBAL_ERROR){ # $message .= "<font color=\"red\"><strong>".__("ERROR: <em>register_globals</em> is enabled. This is a security risk and also prevents TDO Mini Forms from working.")."</strong></font>"; #} if (version_compare("5.0.0", phpversion(), ">")) { $message .= sprintf(__("Warning: You are currently using PHP version %s. It is strongly recommended to use PHP5 with TDO Mini Forms.", "tdomf"), phpversion()); $message .= "<br/>"; } if (get_option(TDOMF_OPTION_VERIFICATION_METHOD) == 'none') { $message .= __("Warning: Form input verification is disabled. This is a potential security risk.", "tdomf"); $message .= "<br/>"; } # Revisions disabled => editing won't work well if (!constant('WP_POST_REVISIONS')) { $form_ids = tdomf_get_form_ids(); foreach ($form_ids as $a_form_id) { if (tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $a_form_id->form_id)) { $message .= __("Error: Post Revisioning is disabled, post editing will not work correctly!", "tdomf"); $message .= "<br/>"; break; } } } if (isset($_REQUEST['form']) || $form_id != 0) { if ($form_id == 0) { $form_id = intval($_REQUEST['form']); } // permissions error if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) == false) { $caps = tdomf_get_option_form(TDOMF_OPTION_ALLOW_CAPS, $form_id); if (is_array($caps) && empty($caps)) { $caps = false; } $users = tdomf_get_option_form(TDOMF_OPTION_ALLOW_USERS, $form_id); if (is_array($users) && empty($users)) { $users = false; } $publish = tdomf_get_option_form(TDOMF_OPTION_ALLOW_PUBLISH, $form_id); $role_count = 0; $role_publish_count = 0; foreach ($roles as $role) { if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) { $role_count++; if (isset($role->capabilities['publish_posts'])) { $role_publish_count++; } } } // if nothing set if ($role_count == 0 && $caps == false && $users == false && $publish == false) { if ($show_links) { $message .= "<font color=\"red\">" . sprintf(__("<b>Warning</b>: No-one has been configured to be able to access the form! <a href=\"%s\">Configure on Options Page »</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_form_options_menu&form={$form_id}") . "</font><br/>"; } else { $message .= "<font color=\"red\">" . __("<b>Warning</b>: No-one has been configured to be able to access the form!", "tdomf") . "</font><br/>"; } tdomf_log_message("No-one has been configured to access this form ({$form_id})", TDOMF_LOG_BAD); } else { if ($caps == false && $users == false && $role_count == $role_publish_count && $publish == false) { if ($show_links) { $message .= "<font color=\"red\">" . sprintf(__("<b>Warning</b>: Only users who can <i>already publish posts</i>, can see the form! <a href=\"%s\">Configure on Options Page »</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_form_options_menu&form={$form_id}") . "</font><br/>"; } else { $message .= "<font color=\"red\">" . __("<b>Warning</b>: Only users who can <i>already publish posts</i>, can see this form!", "tdomf") . "</font><br/>"; } tdomf_log_message("Only users who can already publish can access the form ({$form_id})", TDOMF_LOG_BAD); } } } // form hacker modified $mode = tdomf_generate_default_form_mode($form_id) . '-hack'; $curr_unmod_prev = trim(tdomf_preview_form(array('tdomf_form_id' => $form_id), $mode)); $org_unmod_prev = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL, $form_id)); $hacked_prev = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK, $form_id)); if ($hacked_prev != false && $curr_unmod_prev != $org_unmod_prev) { $message .= "<font color=\"red\">"; $diffs = "admin.php?page=tdomf_show_form_hacker&form={$form_id}&mode={$mode}&diff&form2=cur&form1=org&type=preview"; $form_hacker = "admin.php?page=tdomf_show_form_hacker&form={$form_id}"; $dismiss = wp_nonce_url("admin.php?page=tdomf_show_form_hacker&form={$form_id}&dismiss&type=preview", 'tdomf-form-hacker'); $message .= sprintf(__("<b>Warning</b>: Form configuration has been changed that affect the preview output but Form Hacker has not been updated! <a href='%s'>Diff »</a> | <a href='%s'>Hack Form »</a> | <a href='%s'>Dismiss</a>", "tdomf"), $diffs, $form_hacker, $dismiss); $message .= "</font><br/>"; } $curr_unmod_form = trim(tdomf_generate_form($form_id, $mode)); $org_unmod_form = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL, $form_id)); $hacked_form = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK, $form_id)); if ($hacked_form != false && $curr_unmod_form != $org_unmod_form) { $message .= "<font color=\"red\">"; $diffs = "admin.php?page=tdomf_show_form_hacker&form={$form_id}&mode={$mode}&diff&form2=cur&form1=org"; $form_hacker = "admin.php?page=tdomf_show_form_hacker&form={$form_id}"; $dismiss = wp_nonce_url("admin.php?page=tdomf_show_form_hacker&form={$form_id}&dismiss", 'tdomf-form-hacker'); $message .= sprintf(__("<b>Warning</b>: Form configuration has been changed that affect the generated form but Form Hacker has not been updated! <a href='%s'>Diff »</a> | <a href='%s'>Hack Form »</a> | <a href='%s'>Dismiss</a>", "tdomf"), $diffs, $form_hacker, $dismiss); $message .= "</font><br/>"; } // widget errors global $tdomf_form_widgets_admin_errors; $mode = "new-post"; if (tdomf_get_option_form(TDOMF_OPTION_SUBMIT_PAGE, $form_id)) { $mode = "new-page"; } $uri = "admin.php?page=tdomf_show_form_menu&form=" . $form_id; do_action('tdomf_control_form_start', $form_id, $mode); $widget_order = tdomf_get_widget_order($form_id); $widgets = tdomf_filter_widgets($mode, $tdomf_form_widgets_admin_errors); foreach ($widget_order as $w) { if (isset($widgets[$w])) { $widget_message = call_user_func($widgets[$w]['cb'], $form_id, $widgets[$w]['params']); if (!empty($widget_message)) { $message .= "<font color=\"red\">" . $widget_message . sprintf(__(" <a href='%s'>Fix »</a>", "tdomf"), $uri) . "</font><br/>"; } } } // @todo check that key is unique in custom fields } if (get_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES) && !get_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES)) { $message .= "<font color=\"red\">"; if ($show_links) { $message .= sprintf(__("<b>Warning:</b> You have enabled 'Extra Debug Messages' and disabled 'Disable Error Messages'. This invokes a special mode where all PHP errors are turned on. This can lead to unexpected problems and could be considered a security leak! <a href=\"%s\">Change on the Options Page »</a>", "tdomf"), get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_options_menu"); } else { $message .= __("<b>Warning:</b> You have enabled 'Extra Debug Messages' and disabled 'Disable Error Messages'. This invokes a special mode where all PHP errors are turned on. This can lead to unexpected problems and could be considered a security leak! This should only be used for debugging purposes.", "tdomf"); } $message .= "</font><br/>"; } $create_user_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_options_menu&action=create_dummy_user"; if (function_exists('wp_nonce_url')) { $create_user_link = wp_nonce_url($create_user_link, 'tdomf-create-dummy-user'); } if (get_option(TDOMF_DEFAULT_AUTHOR) == false) { $message .= "<font color=\"red\">" . sprintf(__("<b>Error</b>: No default author set! <a href=\"%s\">Create dummy user for default author automatically »</a>", "tdomf"), $create_user_link) . "</font><br/>"; tdomf_log_message("Option Default Author not set!", TDOMF_LOG_BAD); } else { $def_aut = new WP_User(get_option(TDOMF_DEFAULT_AUTHOR)); if (empty($def_aut->data->ID)) { // User does not exist! Deleting option delete_option(TDOMF_DEFAULT_AUTHOR); $message .= "<font color=\"red\">" . sprintf(__("<b>Error</b>: Current Default Author does not exist! <a href=\"%s\">Create dummy user for default author automatically »</a>", "tdomf"), $create_user_link) . "</font><br/>"; tdomf_log_message("Current Default Author does not exist! Deleting option.", TDOMF_LOG_BAD); } if ($def_aut->has_cap("publish_posts")) { $message .= "<font color=\"red\">" . sprintf(__("<b>Error</b>: Default author can publish posts. Default author should not be able to publish posts! <a href=\"%s\">Create a dummy user for default author automatically »</a>", "tdomf"), $create_user_link) . "</font><br/>"; tdomf_log_message("Option Default Author is set to an author who can publish posts.", TDOMF_LOG_BAD); } } if (function_exists('wp_get_http')) { $post_uri = TDOMF_URLPATH . 'tdomf-form-post.php'; $headers = wp_get_http($post_uri, false, 1); if ($headers != false && $headers["response"] != '200') { $message .= "<font color=\"red\">"; $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will prevent posts from being submitted. The permissions may be wrong on the tdo-mini-forms folder.", "tdomf"), $headers["response"], $post_uri, $post_uri); $message .= "</font><br/>"; tdomf_log_message("Did not receive a 200 response when checking {$post_uri}:<pre>" . var_export($headers, true) . "</pre>", TDOMF_LOG_ERROR); } $ajax_uri = TDOMF_URLPATH . 'tdomf-form-ajax.php'; $headers = wp_get_http($ajax_uri, false, 1); if ($headers != false && $headers["response"] != '200') { $message .= "<font color=\"red\">"; $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will prevent forms that use AJAX from submitting posts. The permissions may be wrong on the tdo-mini-forms folder.", "tdomf"), $headers["response"], $ajax_uri, $ajax_uri); $message .= "</font><br/>"; tdomf_log_message("Did not receive a 200 response when checking {$ajax_uri}:<pre>" . var_export($headers, true) . "</pre>", TDOMF_LOG_ERROR); } $css_uri = TDOMF_URLPATH . 'tdomf-style-form.css'; $headers = wp_get_http($css_uri, false, 1); if ($headers != false && $headers["response"] != '200') { $message .= "<font color=\"red\">"; $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will make your forms, by default, look very ugly. The permissions may be wrong on the tdo-mini-forms folder.", "tdomf"), $headers["response"], $css_uri, $css_uri); $message .= "</font><br/>"; tdomf_log_message("Did not receive a 200 response when checking {$css_uri}:<pre>" . var_export($headers, true) . "</pre>", TDOMF_LOG_ERROR); } } return $message; }
function tdomf_widget_categories($args, $params) { $number = 1; if (is_array($params) && count($params) >= 1) { $number = $params[0]; } $options = tdomf_widget_categories_get_options($number, $args['tdomf_form_id']); $postfix = ""; if ($number != 1) { $postfix = "-{$number}"; } $defcat = tdomf_get_option_form(TDOMF_DEFAULT_CATEGORY, $args['tdomf_form_id']); if (isset($args["categories{$postfix}"])) { $defcat = $args["categories{$postfix}"]; } else { if (isset($options['include']) && !empty($options['include'])) { $includes = explode(',', $options['include']); if (!empty($includes)) { $defcat = $includes[0]; } } else { // check if defcat is in the exclude list: $excludes = explode(',', $options['exclude']); if (in_array($defcat, $excludes)) { // need to pick a "new" default $cats = get_categories(array('exclude' => $options['exclude'], 'hide_empty' => false)); if (!empty($cats)) { $defcat = $cats[0]->term_id; } # else ERROR: no categories to select from! } } } extract($args); $hack = false; if (strpos($mode, '-hack') !== false) { $hack = true; } $output = $before_widget; if ($hack) { $output .= "\t\t<?php \$defcat = {$defcat}; "; $output .= "if(isset(\$post_args['categories{$postfix}'])) { "; $output .= "\$defcat = \$post_args['categories{$postfix}']; } ?>\n"; } if (!empty($options['title'])) { $output .= $before_title . $options['title'] . $after_title; } $name = "categories{$postfix}"; if ($options['multi']) { $name = 'categories' . $postfix . '[]'; } # no point putting a label as we can't use "id" on ul or li or combobox $output .= "\t\t" . __('Select a category:', 'tdomf') . " \n"; $excludes = $options['exclude']; if (!empty($options['include'])) { $includes = explode(',', trim($options['include'])); $excludes = ""; $cats = get_categories(array('hide_empty' => false, 'order' => $options['order'], 'orderby' => $options['orderby'])); foreach ($cats as $cat) { if (!in_array($cat->term_id, $includes)) { $excludes .= $cat->term_id . ","; } } } $catargs = array('exclude' => $excludes, 'hide_empty' => false, 'hierarchical' => $options['hierarchical'], 'echo' => false, 'name' => $name, 'class' => "tdomf_categories{$postfix}", 'multiple' => $options['multi'], 'selected' => $defcat, 'mode' => $mode, 'hack' => $hack, 'order' => $options['order'], 'orderby' => $options['orderby']); if ($options['display'] == "dropdown") { $catargs['size'] = 1; $output .= tdomf_dropdown_categories($catargs); } else { if ($options['display'] == "checkbox") { $output .= "\t\t<br/>\n"; $output .= "\t\t<ul class='tdomf_category_checklist' >\n"; $catargs['class'] = 'tdomf_categorychecklist'; if ($options['multi'] && !is_array($defcat)) { $defcat = array($defcat); } $output .= tdomf_category_checklist(0, 0, $defcat, $catargs); $output .= "\t\t</ul>\n"; } else { # list $output .= "\t\t<br/>\n"; $catargs['size'] = 5; $output .= tdomf_dropdown_categories($catargs); } } $output .= $after_widget; return $output; }
function tdomf_show_your_submissions_menu() { global $current_user; // how many of the recently published/approved entries to see // $limit = 10; get_currentuserinfo(); $tdomf_flag = get_usermeta($current_user->ID, TDOMF_KEY_FLAG); $sub_total = tdomf_get_users_submitted_posts_count($current_user->ID); $app_total = tdomf_get_users_published_posts_count($current_user->ID); $user_status = get_usermeta($current_user->ID, TDOMF_KEY_STATUS); $app_posts = tdomf_get_user_published_posts($current_user->ID, 0, $limit); $mod_posts = tdomf_get_user_draft_posts($current_user->ID); $mod_total = count($mod_posts); $fut_posts = tdomf_get_user_scheduled_posts($current_user->ID); $fut_total = count($fut_posts); $unapp_edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'user_id' => $current_user->ID)); $app_edits = tdomf_get_edits(array('state' => 'approved', 'unique_post_ids' => true, 'user_id' => $current_user->ID, 'limit' => $limit)); ?> <div class="wrap"> <h2><?php _e('Your Submissions', 'tdomf'); ?> </h2> <?php if (in_array($_REQUEST['REMOTE_ADDR'], tdomf_get_ips_banned())) { ?> <?php printf(__("You are logged on from the banned IP %s. If this is in error please contact the <a href='mailto:%s'>admins</a>.", "tdomf"), $_SERVER['REMOTE_ADDR'], get_bloginfo('admin_email')); ?> <?php } else { if ($user_status == TDOMF_USER_STATUS_BANNED) { ?> <?php printf(__("You are banned from using this functionality on this site. If this is in error please contact the <a href='mailto:%s'>admins</a>.", "tdomf"), get_bloginfo('admin_email')); ?> <?php } else { ?> <p> <?php if ($user_status == TDOMF_USER_STATUS_TRUSTED) { ?> <?php printf(__("Good to see you again <b>%s</b>! ", "tdomf"), $current_user->display_name); ?> <?php } else { if ($tdomf_flag) { ?> <?php printf(__("Welcome back <b>%s</b>!", "tdomf"), $current_user->display_name); ?> <?php } else { ?> <?php printf(__("Welcome <b>%s</b>.", "tdomf"), $current_user->display_name); ?> <?php } } ?> </p> <p><?php printf(__("From here you can submit posts to the %s using the form below and check on the status of your submissions.", "tdomf"), get_bloginfo()); ?> </p> <?php if (current_user_can('edit_others_posts') || current_user_can('manage_options')) { ?> <ul> <?php if (current_user_can('manage_options')) { ?> <li><a href="admin.php?page=tdomf_show_options_menu"><?php _e("Configure Options", "tdomf"); ?> </a></li> <li><a href="admin.php?page=tdomf_show_form_menu"><?php _e("Modify Form", "tdomf"); ?> </a></li> <?php } ?> <li><a href="admin.php?page=tdomf_show_mod_posts_menu"><?php _e("Moderate Submissions", "tdomf"); ?> </a></li> </ul> <?php } ?> <?php if ($tdomf_flag && ($sub_total > 0 || $app_total > 0)) { ?> <?php if ($fut_total > 0) { ?> <h3><?php printf(__('Your Next %d Scheduled Submissions', 'tdomf'), $fut_total); ?> </h3> <ul> <?php foreach ($fut_posts as $p) { ?> <li> <?php $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $p->post_date; $time = tdomf_get_post_time('G', true, $p); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s from now'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } ?> <?php printf(__("<a href='%s'>%s</a> will be published %s", "tdomf"), get_permalink($p->ID), $p->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>"); ?> </li> <?php } ?> </ul> <?php } ?> <?php if ($app_total > 0) { ?> <h3><?php printf(__('Your Last %d Published Submissions', 'tdomf'), $app_total < 5 ? $app_total : 5); ?> </h3> <ul> <?php foreach ($app_posts as $p) { ?> <li> <?php $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $p->post_date; $time = tdomf_get_post_time('G', true, $p); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } ?> <?php printf(__("<a href='%s'>%s</a> approved %s", "tdomf"), get_permalink($p->ID), $p->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>"); ?> </li> <?php } ?> </ul> <?php } ?> <?php if ($mod_total > 0) { ?> <h3><?php _e('Your Sumissions awaiting Moderation', 'tdomf'); ?> </h3> <ul> <?php foreach ($mod_posts as $p) { ?> <li>"<?php echo $p->post_title; ?> "</li> <?php } ?> </ul> <?php } ?> <?php } ?> <?php if (!empty($app_edits)) { $num = number_format_i18n(count($app_edits)); $text = __ngettext('Your Last Approved Contribution', 'Your Last %d Approved Contributions', count($app_edits)); ?> <h3><?php printf($text, count($app_edits)); ?> </h3> <ul> <?php foreach ($app_edits as $app_edit) { ?> <li> <?php $edit = tdomf_get_edits(array('state' => 'approved', 'post_id' => $app_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1)); $edit = $edit[0]; $t_time = get_the_time(__('Y/m/d g:i:s A')); $h_time = mysql2date(__('Y/m/d'), $edit->date); $post = get_post($app_edit->post_id); printf(__("<a href='%s'>%s</a> edited %s", "tdomf"), get_permalink($app_edit->post_id), $post->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>"); ?> </li> <?php } ?> </ul> <?php } ?> <?php if (!empty($unapp_edits)) { $num = number_format_i18n(count($unapp_edits)); $text = __ngettext('Your Contribution awaiting Moderation', 'Your Contributions awaiting Moderation', count($unapp_edits)); ?> <h3><?php printf($text, count($unapp_edits)); ?> </h3> <ul> <?php foreach ($unapp_edits as $unapp_edit) { ?> <li> <?php $edit = tdomf_get_edits(array('state' => 'unapproved', 'post_id' => $unapp_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1)); $edit = $edit[0]; $t_time = get_the_time(__('Y/m/d g:i:s A')); $h_time = mysql2date(__('Y/m/d'), $edit->date); $post = get_post($unapp_edit->post_id); printf(__("<a href='%s'>%s</a> edited %s", "tdomf"), get_permalink($unapp_edit->post_id), $post->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>"); ?> </li> <?php } ?> </ul> <?php } ?> </div> <!-- Form formatting --> <style> .tdomf_form { } .tdomf_form fieldset legend { #border-bottom: 1px dotted black; font-weight: bold; padding: 0px; margin: 0px; padding-bottom: 10px; } .tdomf_form_preview { border: 1px dotted black; padding: 5px; margin: 5px; margin-bottom: 20px; } .tdomf_form_preview p { margin-left: 15px; } .tdomf_form .required { color: red; } .tdomf_form fieldset { margin-bottom: 10px; border: 0; } </style> <?php $form_ids = tdomf_get_form_ids(); if (!empty($form_ids)) { foreach ($form_ids as $form_id) { if (tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $form_id->form_id)) { $edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id->form_id); $post_id = false; if (isset($_REQUEST['tdomf_post_id'])) { $post_id = intval($_REQUEST['tdomf_post_id']); } $good = true; if ($edit && tdomf_check_permissions_form($form_id->form_id, $post_id) != NULL) { $good = false; } if ($good) { ?> <div class="wrap"> <h2><?php echo tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id->form_id); ?> </h2> <p><?php echo tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION, $form_id->form_id); ?> </p> <?php echo tdomf_generate_form($form_id->form_id); ?> <br/><br/> </div> <?php } } } } ?> <?php } } ?> </div> <p><center><?php _e('Powered by the <a href="http://thedeadone.net/software/tdo-mini-forms-wordpress-plugin/">TDO Mini Forms Plugin.', 'tdomf'); ?> </a></center></p> <?php }
function tdomf_show_edit_post_revision_panel() { global $post; // don't show on new post if ($post->ID > 0) { $edits = tdomf_get_edits(array('post_id' => $post->ID)); if (count($edits) > 0) { echo "<ul class='post-revisions'>\n"; foreach ($edits as $edit) { echo "<li>"; // actual revision if ($edit->revision_id != 0) { #echo '<a href="'.get_bloginfo('wpurl').'/wp-admin/revision.php?revision='.$edit->revision_id.'">'; echo '<a href="admin.php?page=' . TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $edit->edit_id . '">'; } echo mysql2date(__('d F, Y @ H:i'), $edit->date_gmt); if ($edit->revision_id != 0) { echo '</a>'; } // status if ($edit->state == 'unapproved') { _e(' [Pending]', "tdomf"); } else { if ($edit->state == 'spam') { _e(' [Spam]', "tdomf"); } } // user echo _e(' by ', 'tdomf'); $name = __("N/A", "tdomf"); if (isset($edit->data[TDOMF_KEY_NAME])) { $name = $ledit->data[TDOMF_KEY_NAME]; } $email = __("N/A", "tdomf"); if (isset($edit->data[TDOMF_KEY_EMAIL])) { $email = $edit->data[TDOMF_KEY_EMAIL]; } if ($edit->user_id != 0) { ?> <a href="user-edit.php?user_id=<?php echo $edit->user_id; ?> " class="edit"> <?php $u = get_userdata($edit->user_id); echo $u->user_login; ?> </a> <?php } else { if (!empty($name) && !empty($email)) { echo $name . " (" . $email . ")"; } else { if (!empty($name)) { echo $name; } else { if (!empty($email)) { echo $email; } else { _e("N/A", "tdomf"); } } } } // form if (tdomf_form_exists($edit->form_id) != false) { $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$edit->form_id}"; $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $edit->form_id); _e(' using ', 'tdomf'); echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $edit->form_id, $form_name) . '</a>'; } // ip echo ' (' . $edit->ip . ')'; echo "</li>"; } echo "</ul>\n"; } } }
function tdomf_is_submission_in_use() { $form_ids = tdomf_get_form_ids(); $retValue = false; foreach ($form_ids as $form_id) { if (!tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id)) { $retValue = true; break; } } return $retValue; }
function tdomf_show_form_export($form_id) { if (!tdomf_form_exists($form_id)) { ?> <div><font color="red"><?php printf(__("Form id %d does not exist!", "tdomf"), $form_id); ?> </font></div> <?php } else { ?> <div class="wrap"> <h2><?php printf(__("Export and Import Form %d Configuration:\"%s\"", "tdomf"), $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id)); ?> </h2> <?php tdomf_forms_under_title_toolbar($form_id, 'tdomf_show_form_export_menu'); ?> <?php $export_url = get_bloginfo('wpurl') . "?tdomf_export={$form_id}"; $export_url = wp_nonce_url($export_url, 'tdomf-export-' . $form_id); ?> <p> <?php printf(__('To export the configuration of this file, just <a href="%s">save this link</a>. To import, just use the form below to select a previousily exported file and click "Import"', "tdomf"), $export_url); ?> </p> </p> <form enctype="multipart/form-data" method="post" action="admin.php?page=tdomf_show_form_export_menu&form=<?php echo $form_id; ?> "> <label for="import_file"><b><?php _e("Form saved configuration to import: "); ?> </b></label> <!-- <input type="hidden" name="MAX_FILE_SIZE" value="3000000" /> --> <input type="hidden" name='form_id' id='form_id' value='<?php echo $form_id; ?> '> <input type='file' name='import_file' id='import_file' size='30' /> <input type="submit" name="tdomf_import" id="tdomf_import" value="<?php _e("Import", "tdomf"); ?> " /> <?php wp_nonce_field('tdomf-import-' . $form_id); ?> </form> </div> <!-- wrap --> <?php } }
function validate($args, $opts, $preview = false, $original_field_name = false) { $output = ""; $text = false; // grab the input because we're going to test it $text = false; if (empty($output)) { if (isset($args[$this->prefix . 'ta'])) { $text = $args[$this->prefix . 'ta']; } else { if ($original_field_name != false && isset($args[$original_field_name])) { $text = $args[$original_field_name]; } else { $output .= __("ERROR: Form is invalid. Please check TDO Mini Forms admin.", "tdomf"); } } } // is it empty? if (empty($output) && $opts[$this->prefix . 'required']) { if (empty($text) || trim($text) == "" || $text == $opts[$this->prefix . 'default-text']) { if (!empty($opts[$this->prefix . 'title'])) { $output .= sprintf(__("You must specify some %s.", "tdomf"), $opts[$this->prefix . 'title']); } else { $output .= __("You must specify some text.", "tdomf"); } } } // does it fit the counts? if (empty($output) && ($opts[$this->prefix . 'word-limit'] > 0 || $opts[$this->prefix . 'char-limit'] > 0)) { // prefitler the text so it's as close to the end result as possible #if($opts[$this->prefix.'use-filter'] && !empty($opts[$this->prefix.'filter'])) { $text = preg_replace('|\\<!--tdomf_form.*-->|', '', $text); $text = preg_replace('|\\[tdomf_form.*\\]|', '', $text); #} if ($opts[$this->prefix . 'kses'] && !tdomf_get_option_form(TDOMF_OPTION_MODERATION, $args['tdomf_form_id'])) { // if moderation is enabled, we don't do kses filtering, might as well // give full picture to user! $text = wp_filter_post_kses($text); } if ($opts[$this->prefix . 'allowable-tags'] != "" && $opts[$this->prefix . 'restrict-tags']) { $text = strip_tags($text, $opts[$this->prefix . 'allowable-tags']); } /*$output .= "Stripped output: <pre>".htmlentities($text)."</pre><br/>";*/ $len = strlen($text); if ($opts[$this->prefix . 'char-limit'] > 0 && $len > $opts[$this->prefix . 'char-limit']) { if (!empty($opts[$this->prefix . 'title'])) { $output .= sprintf(__("You have exceeded the max character length by %d characters for %s.", "tdomf"), $len - $opts[$this->prefix . 'char-limit'], $opts[$this->prefix . 'title']); } else { $output .= sprintf(__("You have exceeded the max character length by %d characters.", "tdomf"), $len - $opts[$this->prefix . 'char-limit']); } } else { if ($opts[$this->prefix . 'word-limit'] > 0) { // Remove all HTML tags as they do not count as "words"! $text = trim(strip_tags($text)); // Replace newlines with spaces $text = preg_replace("/\r?\n/", " ", $text); // Remove excess whitespace $text = preg_replace('/\\s\\s+/', ' ', $text); // count the words! $word_count = count(explode(" ", $text)); if ($word_count > $opts[$this->prefix . 'word-limit']) { if (!empty($opts[$this->prefix . 'title'])) { $output .= sprintf(__("You have exceeded the max word count by %d words for %s.", "tdomf"), $word_count - $opts[$this->prefix . 'word-limit'], $opts[$this->prefix . 'title']); } else { $output .= sprintf(__("You have exceeded the max word count by %d words.", "tdomf"), $word_count - $opts[$this->prefix . 'word-limit']); } } } } } return $output; }
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 »', 'tdomf'); ?> " id="tdomf_hack_messages_save" name="tdomf_hack_messages_save" /> <input type="submit" value="<?php _e('Reset »', '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 »', 'tdomf'); ?> " id="tdomf_hack_messages_save" name="tdomf_hack_messages_save" /> <input type="submit" value="<?php _e('Reset »', '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 »', 'tdomf'); ?> " id="tdomf_form_hack_save" name="tdomf_form_hack_save" /> <input type="submit" value="<?php _e('Reset »', '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 »', 'tdomf'); ?> " id="tdomf_form_hack_save" name="tdomf_form_hack_save" /> <input type="submit" value="<?php _e('Reset »', 'tdomf'); ?> " id="tdomf_form_hack_reset" name="tdomf_form_hack_reset" /> </span> </form> <!-- @TODO: warning about updated form (with dismiss link) --> <?php } ?> </div> <?php } } }
function tdomf_show_mod_posts_menu() { tdomf_moderation_handler(); $user_id = false; if (isset($_REQUEST['user_id'])) { $user_id = intval($_REQUEST['user_id']); } $ip = false; if (isset($_REQUEST['ip'])) { $ip = $_REQUEST['ip']; } $form_id = false; if (isset($_REQUEST['form_id'])) { $form_id = intval($_REQUEST['form_id']); if ($form_id <= 0) { $form_id = false; } } $pending_count = tdomf_get_posts(array('count' => true, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $scheduled_count = tdomf_get_posts(array('count' => true, 'post_status' => array('future'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $published_count = tdomf_get_posts(array('count' => true, 'post_status' => array('publish'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $spam_count = tdomf_get_posts(array('count' => true, 'spam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $all_count = tdomf_get_posts(array('count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $form_ids = tdomf_get_form_ids(); $pending_edits_count = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $spam_edits_count = tdomf_get_edits(array('state' => 'spam', 'count' => true, 'unique_post_ids' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $limit = 10; # fixed if (isset($_REQUEST['limit'])) { $limit = intval($_REQUEST['limit']); } $paged = 1; if (isset($_GET['paged'])) { $paged = intval($_GET['paged']); } $offset = $limit * ($paged - 1); $show = 'all'; if (isset($_REQUEST['show'])) { $show = $_REQUEST['show']; } $posts = false; $max_pages = 0; $max_items = 0; if ($show == 'all') { $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($all_count / $limit); $max_items = $all_count; } else { if ($show == 'pending_submissions') { $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($pending_count / $limit); $max_items = $pending_count; } else { if ($show == 'scheduled') { $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('future'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($scheduled_count / $limit); $max_items = $scheduled_count; } else { if ($show == 'published') { $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('publish'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($published_count / $limit); $max_items = $published_count; } else { if ($show == 'spam_submissions') { $posts = tdomf_get_posts(array('offset' => $offset, 'spam' => true, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($spam_count / $limit); $max_items = $spam_count; } else { if ($show == 'pending_edits') { $edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($pending_edits_count / $limit); $posts = array(); # a little hacky magic foreach ($edits as $e) { $posts[] = (object) array('ID' => $e->post_id); } $max_items = $pending_edits_count; } else { if ($show == 'spam_edits') { $edits = tdomf_get_edits(array('state' => 'spam', 'unique_post_ids' => true, 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($spam_edits_count / $limit); $posts = array(); # a little hacky magic foreach ($edits as $e) { $posts[] = (object) array('ID' => $e->post_id); } $max_items = $spam_edits_count; } else { if ($show == 'approved_edits') { $edits = tdomf_get_edits(array('state' => 'approved', 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($approved_edits_count / $limit); $posts = array(); # a little hacky magic foreach ($edits as $e) { $posts[] = (object) array('ID' => $e->post_id, 'edit_id' => $e->edit_id); } $max_items = $approved_edits_count; } } } } } } } } # max is incorrect... doesn't account for form filter... $mode = 'list'; if (isset($_GET['mode'])) { $mode = $_GET['mode']; } $count = 0; # what bulk actions to support $bulk_sub_publish_now = false; $bulk_sub_publish = false; $bulk_sub_unpublish = false; $bulk_sub_spamit = false; $bulk_sub_hamit = false; $bulk_sub_lock = false; $bulk_sub_unlock = false; $bulk_edit_approve = false; $bulk_edit_revert = false; $bulk_edit_delete = false; $bulk_edit_spamit = false; $bulk_edit_hamit = false; ?> <div class="wrap"> <?php /* screen_icon(); */ ?> <h2> <?php if ($user_id || $ip) { if ($user_id) { $u = get_userdata($user_id); printf(__('Posts submitted by user %s', 'tdomf'), $u->user_login); } else { if ($ip) { printf(__('Posts submitted from IP %s', 'tdomf'), $ip); } } } else { ?> <?php _e('Moderation', 'tdomf'); ?> <?php } ?> </h2> <?php /*if(count($posts) <= 0) { ?> <div class="clear"></div> <p><?php _e('No submissions found','tdomf') ?></p> </div> <!-- wrap --><?php return; }*/ ?> <form id="posts-filter" action="<?php tdomf_get_mod_posts_url(true, $show, 0); ?> " method="post"> <!-- hidden vars --> <ul class="subsubsub"> <?php if ($all_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'all')); ?> "<?php if ($show == 'all') { ?> class="current"<?php } ?> ><?php printf(__('All Submissions (%s)', 'tdomf'), $all_count); ?> </a> | </li> <?php } ?> <?php if ($pending_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'pending_submissions')); ?> "<?php if ($show == 'pending_submissions') { ?> class="current"<?php } ?> ><?php printf(__('Pending Submissions (%s)', 'tdomf'), $pending_count); ?> </a> | </li> <?php } ?> <?php if ($scheduled_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'scheduled')); ?> "<?php if ($show == 'scheduled') { ?> class="current"<?php } ?> ><?php printf(__('Scheduled Submissions (%s)', 'tdomf'), $scheduled_count); ?> </a> | </li> <?php } ?> <?php if ($published_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'published')); ?> "<?php if ($show == 'published') { ?> class="current"<?php } ?> ><?php printf(__('Published (%s)', 'tdomf'), $published_count); ?> </a> | </li> <?php } ?> <?php if ($spam_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'spam_submissions')); ?> "<?php if ($show == 'spam_submissions') { ?> class="current"<?php } ?> ><?php printf(__('Spam Submissions (%s)', 'tdomf'), $spam_count); ?> </a> | </li> <?php } ?> <?php if ($approved_edits_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'approved_edits')); ?> "<?php if ($show == 'approved_edits') { ?> class="current"<?php } ?> ><?php printf(__('Approved Edits (%s)', 'tdomf'), $approved_edits_count); ?> </a> | </li> <?php } ?> <?php if ($pending_edits_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'pending_edits')); ?> "<?php if ($show == 'pending_edits') { ?> class="current"<?php } ?> ><?php printf(__('Pending Edits (%s)', 'tdomf'), $pending_edits_count); ?> </a> | </li> <?php } ?> <?php if ($spam_edits_count > 0) { ?> <li><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'spam_edits')); ?> "<?php if ($show == 'spam_edits') { ?> class="current"<?php } ?> ><?php printf(__('Spam Edits (%s)', 'tdomf'), $spam_edits_count); ?> </a> | </li> <?php } ?> </ul> <div class="tablenav"> <?php $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%', tdomf_get_mod_posts_url(array())), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $max_pages, 'current' => $paged)); ?> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n($offset), number_format_i18n($offset + count($posts)), number_format_i18n($max_items), $page_links); echo $page_links_text; ?> </div> <?php } ?> <div class="view-switch"> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'mode' => 'list')); ?> "><img <?php if ('list' == $mode) { echo 'class="current"'; } ?> id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('List View'); ?> " alt="<?php _e('List View'); ?> " /></a> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'mode' => 'excerpt')); ?> "><img <?php if ('excerpt' == $mode) { echo 'class="current"'; } ?> id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('Excerpt View'); ?> " alt="<?php _e('Excerpt View'); ?> " /></a> </div> <?php $form_ids_check = array(); foreach ($form_ids as $form) { if (TDOMF_Widget::isSubmitForm(false, $form->form_id)) { $count = tdomf_get_posts(array('count' => true, 'form_id' => $form->form_id)); } else { $count = tdomf_get_edits(array('count' => true, 'form_id' => $form->form_id)); } if ($count > 0) { $form_ids_check[] = $form->form_id; } } if (!empty($form_ids_check)) { ?> <select name='form_id'> <option value="-1" selected="selected"><?php _e('Show All', 'tdomf'); ?> </option> <?php foreach ($form_ids_check as $form) { ?> <option value="<?php echo $form; ?> " <?php if ($form_id == $form) { ?> selected="selected" <?php } ?> ><?php printf(__('Form #%d', 'tdomf'), $form); ?> </option> <?php } ?> </select> <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?> " class="button-secondary" /> <?php } ?> <div class="clear"></div> </div> <!-- tablenav --> <div class="clear"></div> <table class="widefat post fixed" cellspacing="0"> <thead> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" id="title" class="manage-column column-title" style=""><?php _e('Post', 'tdomf'); ?> </th> <th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php _e('Submitted', 'tdomf'); ?> </th> <th scope="col" id="edited" class="manage-column column-edited" style=""> <?php if ($show == 'approved_edits') { _e('Edit', 'tdomf'); } else { if ($show == 'pending_edits') { _e('Pending Edit', 'tdomf'); } else { if ($show == 'spam_edits') { _e('Spam Edit', 'tdomf'); } else { _e('Most Recent Edit', 'tdomf'); } } } ?> </th> <th scope="col" id="status" class="manage-column column-status" style=""><?php _e('Status', 'tdomf'); ?> </th> </tr> </thead> <tfoot> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" id="title" class="manage-column column-title" style=""><?php _e('Post', 'tdomf'); ?> </th> <th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php _e('Submitted', 'tdomf'); ?> </th> <th scope="col" id="edited" class="manage-column column-edited" style=""> <?php if ($show == 'approved_edits') { _e('Edit', 'tdomf'); } else { if ($show == 'pending_edits') { _e('Pending Edit', 'tdomf'); } else { if ($show == 'spam_edits') { _e('Spam Edit', 'tdomf'); } else { _e('Most Recent Edit', 'tdomf'); } } } ?> </th> <th scope="col" id="status" class="manage-column column-status" style=""><?php _e('Status', 'tdomf'); ?> </th> </tr> </tfoot> <tbody> <?php if (!empty($posts)) { foreach ($posts as $p) { $count++; ?> <?php $post =& get_post($p->ID); /* seems I need this later */ ?> <?php if ($show == 'approved_edits') { // not really the "last" edit but lest pretend $last_edit = array(tdomf_get_edit($p->edit_id)); } else { $last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 2)); /* and need this earlier too */ } ?> <?php $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true); ?> <?php $queue = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id)); if ($queue > 0) { $queue = true; } else { $queue = false; } ?> <?php $is_spam = get_post_meta($p->ID, TDOMF_KEY_SPAM); ?> <?php $locked = get_post_meta($post->ID, TDOMF_KEY_LOCK, true); ?> <tr id='post-<?php echo $p->ID; ?> ' class='<?php if ($count % 2 != 0) { ?> alternate <?php } ?> status-<?php echo $post->post_status; ?> iedit' valign="top"> <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php echo $p->ID; ?> " /></th> <td class="post-title column-title"><strong><a class="row-title" href="post.php?action=edit&post=<?php echo $p->ID; ?> " title="Edit"><?php echo $post->post_title; ?> </a></strong> <?php /*$fuoptions = TDOMF_WidgetUploadFiles::getOptions($form_id);*/ $index = 0; $filelinks = ""; while (true) { $filename = get_post_meta($p->ID, TDOMF_KEY_DOWNLOAD_NAME . $index, true); if ($filename == false) { break; } /*if($fuoptions['nohandler'] && trim($fuoptions['url']) != "") { $uri = trailingslashit($fuoptions['url'])."$p->ID/".$filename; } else {*/ $uri = trailingslashit(get_bloginfo('wpurl')) . '?tdomf_download=' . $p->ID . '&id=' . $i; /*}*/ $filelinks .= "<a href='{$uri}' title='" . htmlentities($filename) . "'>{$index}</a>, "; $index++; } if (!empty($filelinks)) { ?> <?php _e('Uploaded Files: ', 'tdomf'); echo $filelinks; ?> <br/> <?php } ?> <?php if ('excerpt' == $mode) { # Have to create our own excerpt, the_excerpt() doesn't cut it # here :( if (empty($post->post_excerpt)) { $excerpt = apply_filters('the_content', $post->post_content); } else { $excerpt = apply_filters('the_excerpt', $post->post_excerpt); } $excerpt = str_replace(']]>', ']]>', $excerpt); $excerpt = wp_html_excerpt($excerpt, 252); if (strlen($excerpt) == 252) { $excerpt .= '...'; } echo '<blockquote>' . $excerpt . '</blockquote>'; } ?> <?php if (get_option(TDOMF_OPTION_MOD_SHOW_LINKS)) { ?> <div> <?php } else { ?> <div class="row-actions"> <?php } ?> <?php if ($post->post_status == 'future') { $bulk_sub_publish_now = true; ?> <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Publish this submission now', 'tdomf')); ?> "><?php _e('Publish Now', 'tdomf'); ?> </a> |</span> <?php } else { if ($post->post_status != 'publish') { ?> <?php if ($queue) { $bulk_sub_publish_now = true; $bulk_sub_publish = true; ?> <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Add submission to publish queue', 'tdomf')); ?> "><?php _e('Queue', 'tdomf'); ?> </a> |</span> <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Publish submission now', 'tdomf')); ?> "><?php _e('Publish Now', 'tdomf'); ?> </a> |</span> <?php } else { $bulk_sub_publish = true; ?> <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Publish submission', 'tdomf')); ?> "><?php _e('Publish', 'tdomf'); ?> </a> |</span> <?php } ?> <?php } else { if ($post->post_status == 'publish') { $bulk_sub_unpublish = true; ?> <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'unpublish', 'post_id' => $p->ID, 'nonce' => 'tdomf-unpublish_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Set submission to draft/unmoderated status.', 'tdomf')); ?> "><?php _e('Un-publish', 'tdomf'); ?> </a> |</span> <?php } } } ?> <span class='delete'><a class='submitdelete' title='Delete this submission' href='<?php echo wp_nonce_url("post.php?action=delete&post={$p->ID}", 'delete-post_' . $p->ID); ?> ' onclick="if ( confirm('<?php echo js_escape(sprintf(__("You are about to delete this post \\'%s\\'\n \\'Cancel\\' to stop, \\'OK\\' to delete.", 'tdomf'), $post->post_title)); ?> ') ) { return true;}return false;"><?php _e('Delete', 'tdomf'); ?> </a> | </span> <?php if ($locked) { $bulk_sub_unlock = true; ?> <span class="lock"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'unlock', 'post_id' => $p->ID, 'nonce' => 'tdomf-unlock_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Unlock submission so it can be edited.', 'tdomf')); ?> "><?php _e('Unlock', 'tdomf'); ?> </a> |</span> <?php } else { $bulk_sub_lock = true; ?> <span class="lock"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'lock', 'post_id' => $p->ID, 'nonce' => 'tdomf-lock_' . $p->ID)); ?> " title="<?php echo htmlentities(__('Lock submission from being edited.', 'tdomf')); ?> "><?php _e('Lock', 'tdomf'); ?> </a> |</span> <?php } ?> <?php if ($post->post_status == 'publish') { ?> <span class='view'><a href="<?php echo get_permalink($p->ID); ?> " title="<?php echo htmlentities(sprintf(__('View \'%s\'', 'tdomf'), $post->post_title)); ?> " rel="permalink"><?php _e('View', 'tdomf'); ?> </a> | </span> <?php } else { ?> <span class='view'><a href="<?php echo get_permalink($p->ID); ?> " title="<?php echo htmlentities(sprintf(__('Preview \'%s\'', 'tdomf'), $post->post_title)); ?> " rel="permalink"><?php _e('Preview', 'tdomf'); ?> </a> | </span> <?php } ?> <span class='edit'><a href="post.php?action=edit&post=<?php echo $p->ID; ?> " title="<?php echo htmlentities(__('Edit this submission', 'tdomf')); ?> "><?php _e('Edit', 'tdomf'); ?> </a> <?php if (get_option(TDOMF_OPTION_SPAM)) { ?> |</span><?php } ?> <?php if (get_option(TDOMF_OPTION_SPAM)) { if (!$is_spam) { $bulk_sub_spamit = true; ?> <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'spamit', 'post_id' => $p->ID, 'nonce' => 'tdomf-spamit_' . $p->ID)); ?> " onclick="if ( confirm('<?php echo js_escape(sprintf(__("You are about to flag this submission \\'%s\\' as spam\n \\'Cancel\\' to stop, \\'OK\\' to delete.", 'tdomf'), $post->post_title)); ?> ') ) { return true;}return false;"><?php _e('Spam', 'tdomf'); ?> </a></span> <?php } else { $bulk_sub_hamit = true; ?> <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'hamit', 'post_id' => $p->ID, 'nonce' => 'tdomf-hamit_' . $p->ID)); ?> " ><?php _e('Not Spam', 'tdomf'); ?> </span> <?php } } ?> </div> </td> <td class="column-submitted"> <ul style="font-size: 11px;"> <li> <?php $name = get_post_meta($p->ID, TDOMF_KEY_NAME, true); $email = get_post_meta($p->ID, TDOMF_KEY_EMAIL, true); $user_id = get_post_meta($p->ID, TDOMF_KEY_USER_ID, true); if ($user_id != false) { ?> <!-- <a href="user-edit.php?user_id=<?php echo $user_id; ?> " class="edit"> --> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'user_id' => $user_id, 'ip' => false, 'form_id' => false)); ?> "> <?php $u = get_userdata($user_id); echo $u->user_login; ?> </a> <?php } else { if (!empty($name) && !empty($email)) { echo $name . " (" . $email . ")"; } else { if (!empty($name)) { echo $name; } else { if (!empty($email)) { echo $email; } else { _e("N/A", "tdomf"); } } } } ?> / <?php $ip = get_post_meta($p->ID, TDOMF_KEY_IP, true); if (!empty($ip)) { ?> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'ip' => $ip, 'user_id' => false, 'form_id' => false)); ?> "> <?php } ?> <?php echo $ip; ?> <?php if (!empty($ip)) { ?> </a> <?php } ?> </li> <li> <?php if ($form_id == false || tdomf_form_exists($form_id) == false) { ?> <?php _e("Unknown or deleted form", "tdomf"); ?> <?php } else { $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$form_id}"; $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id); echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s</a>', 'tdomf'), $form_id, $form_name) . '</a>'; } ?> </li> <li> <?php if ($post->post_status != 'publish' && $post->post_status != 'future') { $post_date_gmt = get_post_meta($p->ID, TDOMF_KEY_SUBMISSION_DATE, true); if ($post_date_gmt) { echo mysql2date(__('Y/m/d'), $post_date_gmt); } else { #echo mysql2date(__('Y/m/d'), $post->post_modified_gmt); } } else { echo mysql2date(__('Y/m/d'), $post->post_date_gmt); } ?> </li> </ul> </td> <td class="column-edited"> <?php /*$last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 1));*/ if ($last_edit == false || empty($last_edit) || $last_edit == NULL) { ?> <!-- no edits --> <?php } else { $previous_edit = false; if (count($last_edit) == 2) { $previous_edit = $last_edit[1]; } $last_edit = $last_edit[0]; # only care about the first entry $last_edit_data = maybe_unserialize($last_edit->data); ?> <ul style="font-size: 11px;"> <li><?php $user_id = $last_edit->user_id; $name = __("N/A", "tdomf"); if (isset($last_edit_data[TDOMF_KEY_NAME])) { $name = $last_edit_data[TDOMF_KEY_NAME]; } $email = __("N/A", "tdomf"); if (isset($last_edit_data[TDOMF_KEY_EMAIL])) { $email = $last_edit_data[TDOMF_KEY_EMAIL]; } if ($user_id != 0) { ?> <a href="user-edit.php?user_id=<?php echo $user_id; ?> " class="edit"> <?php $u = get_userdata($user_id); echo $u->user_login; ?> </a> <?php } else { if (!empty($name) && !empty($email)) { echo $name . " (" . $email . ")"; } else { if (!empty($name)) { echo $name; } else { if (!empty($email)) { echo $email; } else { _e("N/A", "tdomf"); } } } } ?> / <?php echo $last_edit->ip; ?> </li> <li> <?php $form_id = $last_edit->form_id; if ($form_id == false || tdomf_form_exists($form_id) == false) { ?> <?php _e("Unknown or deleted form", "tdomf"); ?> <?php } else { $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$form_id}"; $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id); echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $form_id, $form_name) . '</a>'; } ?> </li> <li><?php echo mysql2date(__('Y/m/d'), $last_edit->date_gmt); ?> </li> <li><?php switch ($last_edit->state) { case 'unapproved': _e('Unapproved', "tdomf"); break; case 'approved': _e('Approved', "tdomf"); break; case 'spam': _e('Spam', "tdomf"); break; default: echo _e($last_edit->state, "tdomf"); break; } ?> </li> </ul> <div class="row-actions"> <?php /* nothing to do if revisioning is disabled for the edits... */ if ($last_edit->revision_id != 0) { ?> <?php if ($last_edit->state != 'approved') { ?> <span class='view'><a href="admin.php?page=<?php echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $last_edit->edit_id; ?> "><?php _e('View', 'tdomf'); ?> </a> |<span> <!-- <span class='view'><a href="revision.php?revision=<?php echo $last_edit->revision_id; ?> "><?php _e('View', 'tdomf'); ?> </a> |<span> --> <?php } ?> <?php if ($last_edit->state == 'approved') { $bulk_edit_revert = true; ?> <span class="edit"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'revert_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-revert_edit_' . $last_edit->edit_id)); ?> "><?php _e('Revert', 'tdomf'); ?> </a> | </span> <?php } else { if ($last_edit->state == 'unapproved' || $last_edit->state == 'spam') { $bulk_edit_delete = true; $bulk_edit_approve = true; ?> <span class="delete"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'delete_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-delete_edit_' . $last_edit->edit_id)); ?> "><?php _e('Delete', 'tdomf'); ?> </a> | </span> <span class="edit"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'approve_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-approve_edit_' . $last_edit->edit_id)); ?> "><?php _e('Approve', 'tdomf'); ?> </a> | </span> <?php } } ?> <?php if ($previous_edit) { ?> <span class="edit"><a href="admin.php?page=<?php echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $last_edit->edit_id; ?> &right=<?php echo $last_edit->edit_id; ?> &left=<?php echo $previous_edit->edit_id; ?> "><?php _e('Compare', 'tdomf'); ?> </a> <?php } else { ?> <!-- <span class="edit"><a href="revision.php?action=diff&right=<?php echo $last_edit->revision_id; ?> &left=<?php echo $last_edit->current_revision_id; ?> "><?php _e('Compare', 'tdomf'); ?> </a> --> <span class="edit"><a href="admin.php?page=<?php echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $last_edit->edit_id; ?> &right=<?php echo $last_edit->edit_id; ?> &left=previous"><?php _e('Compare', 'tdomf'); ?> </a> <?php } ?> <?php if (get_option(TDOMF_OPTION_SPAM)) { ?> |<?php } ?> </span> <?php if (get_option(TDOMF_OPTION_SPAM)) { if ($last_edit->state == 'spam') { $bulk_edit_hamit = true; ?> <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'hamit_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-hamit_edit_' . $last_edit->edit_id)); ?> " title="<?php echo htmlentities(__('Flag contributation as not being spam', 'tdomf')); ?> " ><?php _e('Not Spam', 'tdomf'); ?> </span> <?php } else { $bulk_edit_spamit = true; ?> <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'spamit_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-spamit_edit_' . $last_edit->edit_id)); ?> " title="<?php echo htmlentities(__('Flag contributation as being spam', 'tdomf')); ?> " onclick="if ( confirm('<?php echo js_escape(__("You are about to flag this contribution as spam\n \\'Cancel\\' to stop, \\'OK\\' to delete.", 'tdomf')); ?> ') ) { return true;}return false;"><?php _e('Spam', 'tdomf'); ?> </a></span> <?php } } ?> <?php } ?> </div> <?php } ?> </td> <td class="status column-status"> <!-- todo take into account edited status --> <?php if ($is_spam && $post->post_status == 'draft') { ?> <?php _e('Spam', "tdomf"); ?> <?php } else { switch ($post->post_status) { case 'draft': _e('Draft', "tdomf"); break; case 'publish': _e('Published', "tdomf"); break; case 'future': _e('Scheduled', "tdomf"); break; default: echo _e($post->post_status, "tdomf"); break; } if ($is_spam) { _e(' (Spam)', "tdomf"); } if ($locked) { _e(' [Locked]', 'tdomf'); } } ?> </td> <?php } } ?> </tbody> </table> <div class="tablenav"> <?php if ($page_links) { echo "<div class='tablenav-pages'>{$page_links_text}</div>"; } ?> <?php if (count($posts) > 0) { ?> <div class="alignleft actions"> <select name="action"> <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?> </option> <?php if ($bulk_sub_publish_now) { ?> <option value="publish_now"><?php _e('Publish Submissions (Now)', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_publish) { ?> <option value="publish"><?php _e('Publish/Queue Submissions', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_unpublish) { ?> <option value="unpublish"><?php _e('Un-publish Submissions', 'tdomf'); ?> </option> <?php } ?> <option value="delete"><?php _e('Delete Submissions', 'tdomf'); ?> </option> <?php if ($bulk_sub_unlock) { ?> <option value="unlock"><?php _e('Unlock Submissions', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_lock) { ?> <option value="lock"><?php _e('Lock Submissions', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_spamit) { ?> <option value="spamit"><?php _e('Mark Submissions as Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_hamit) { ?> <option value="hamit"><?php _e('Mark Submissions as Not Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_hamit || $bulk_sub_spamit) { ?> <option value="spam_recheck"><?php _e('Recheck Submssions for Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_approve) { ?> <option value="edit_approve"><?php _e('Approve Edits', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_revert) { ?> <option value="edit_revert"><?php _e('Revert Edits', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_delete) { ?> <option value="edit_delete"><?php _e('Delete Edits', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_spamit) { ?> <option value="edit_spamit"><?php _e('Mark Edits as Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_hamit) { ?> <option value="edit_hamit"><?php _e('Mark Edits as not Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_hamit || $bulk_edit_spamit) { ?> <option value="edit_spam_recheck"><?php _e('Recheck Edits for Spam', 'tdomf'); ?> </option> <?php } ?> </select> <input type="submit" value="<?php _e('Apply'); ?> " name="doaction" id="doaction" class="button-secondary action" /> <?php wp_nonce_field('tdomf-moderate-bulk'); } ?> <!-- hide filters <select name='form'> <option value="-1" selected="selected"><?php _e('Show All Forms', 'tdomf'); ?> </option> <?php foreach ($form_ids as $form) { ?> <option value="<?php echo $form->form_id; ?> "><?php printf(__('Form #%d', 'tdomf'), $form->form_id); ?> </option> <?php } ?> </select> --> <br class="clear" /> </div> <!-- tablenav --> <br class="clear" /> </div> <!-- wrap --> </form> <?php }
function tdomf_editpostlink_filter($url, $post_id) { $form_ids = tdomf_get_form_ids(); foreach ($form_ids as $form_id) { if (tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id->form_id) && tdomf_check_permissions_form($form_id->form_id, $post_ID) == NULL) { $edit_link_style = tdomf_get_option_form(TDOMF_OPTION_AUTO_EDIT_LINK, $form_id->form_id); if ($edit_link_style != 'none' && $edit_link_style != false) { if ($edit_link_style == 'page') { $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES, $form_id->form_id); $url = get_permalink($pages[0]); if (strpos($url, '?') !== false) { $url .= '&tdomf_post_id=' . $post_ID; } else { $url .= '?tdomf_post_id=' . $post_ID; } } else { if ($edit_link_style == 'your_submissions') { $url = trailingslashit(get_bloginfo('wpurl')) . 'wp-admin/users.php?page=tdomf_your_submissions&tdomf_post_id=' . $post_ID . '#tdomf_form' . $form_id->form_id . '_' . $post_ID; } else { if ($edit_link_style != 'none') { $url = $edit_link_style; if (strpos($url, '?') !== false) { $url .= '&tdomf_post_id=' . $post_ID; } else { $url = trailingslashit($url) . '?tdomf_post_id=' . $post_ID; } } } } // once we find one, use it! break; } } } return $url; }
if (!empty($email)) { echo $email; } else { _e("N/A", "tdomf"); } } } } ?> </td> <td> <?php if (tdomf_form_exists($e->form_id) != false) { #$form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form=$e->form_id"; $form_edit_url = tdomf_get_mod_posts_url(array('form_id' => $e->form_id)); $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $e->form_id); echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $e->form_id, $form_name) . '</a>'; } ?> </td> <td> <a href="<?php tdomf_get_mod_posts_url(array('ip' => $e->ip, 'echo' => true)); ?> "> <?php echo $e->ip; ?> </a> </td>
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 »</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 »</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; }