예제 #1
0
function gwolle_gb_get_author_name_html($entry)
{
    $author_name = gwolle_gb_sanitize_output(trim($entry->get_author_name()));
    // Registered User gets italic font-style
    $author_id = $entry->get_author_id();
    $is_moderator = gwolle_gb_is_moderator($author_id);
    if ($is_moderator) {
        $author_name_html = '<i>' . $author_name . '</i>';
    } else {
        $author_name_html = $author_name;
    }
    // Link the author website if set in options
    if (get_option('gwolle_gb-linkAuthorWebsite', 'true') === 'true') {
        $author_website = trim($entry->get_author_website());
        if ($author_website) {
            $pattern = '/^http/';
            if (!preg_match($pattern, $author_website, $matches)) {
                $author_website = "http://" . $author_website;
            }
            $author_name_html = '<a href="' . $author_website . '" target="_blank"
				title="' . __('Visit the website of', GWOLLE_GB_TEXTDOMAIN) . ' ' . $author_name . ': ' . $author_website . '">' . $author_name_html . '</a>';
        }
    }
    return $author_name_html;
}
예제 #2
0
function gwolle_gb_page_editor()
{
    if (function_exists('current_user_can') && !current_user_can('moderate_comments')) {
        die(__('Cheatin&#8217; uh?', 'gwolle-gb'));
    }
    ?>

	<!-- Do not replace Emoji with <img> elements in textarea, it screws saving the entry -->
	<script type="text/javascript">
		window._wpemojiSettings = '';
	</script>

	<?php 
    if (!get_option('gwolle_gb_version')) {
        // FIXME: do this on activation
        gwolle_gb_installSplash();
    } else {
        $gwolle_gb_errors = '';
        $gwolle_gb_messages = '';
        $sectionHeading = __('Edit guestbook entry', 'gwolle-gb');
        // Always fetch the requested entry, so we can compare the $entry and the $_POST.
        $entry = new gwolle_gb_entry();
        if (isset($_POST['entry_id'])) {
            // _POST has preference over _GET
            $entry_id = intval($_POST['entry_id']);
        } else {
            if (isset($_GET['entry_id'])) {
                $entry_id = intval($_GET['entry_id']);
            }
        }
        if (isset($entry_id) && $entry_id > 0) {
            $result = $entry->load($entry_id);
            if (!$result) {
                $gwolle_gb_messages .= '<p class="error">' . __('Entry could not be found.', 'gwolle-gb') . '</p>';
                $gwolle_gb_errors = 'error';
                $sectionHeading = __('Guestbook entry (error)', 'gwolle-gb');
            }
        } else {
            $sectionHeading = __('New guestbook entry', 'gwolle-gb');
        }
        /*
         * Handle the $_POST
         */
        if (isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'editor' && $gwolle_gb_errors == '') {
            if (!isset($_POST['entry_id']) || $_POST['entry_id'] != $entry->get_id()) {
                $gwolle_gb_messages .= '<p class="error">' . __('Something strange happened.', 'gwolle-gb') . '</p>';
                $gwolle_gb_errors = 'error';
            } else {
                if ($_POST['entry_id'] > 0 && $entry->get_id() > 0) {
                    /*
                     * Check for changes, and update accordingly. This is on an Existing Entry!
                     */
                    $changed = false;
                    /* Set as checked or unchecked, and by whom */
                    if (isset($_POST['ischecked']) && $_POST['ischecked'] == 'on') {
                        if ($_POST['ischecked'] == 'on' && $entry->get_ischecked() == 0) {
                            $entry->set_ischecked(true);
                            $user_id = get_current_user_id();
                            // returns 0 if no current user
                            $entry->set_checkedby($user_id);
                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-checked');
                            gwolle_gb_clear_cache();
                            $changed = true;
                        }
                    } else {
                        if ($entry->get_ischecked() == 1) {
                            $entry->set_ischecked(false);
                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-unchecked');
                            $changed = true;
                        }
                    }
                    /* Set as spam or not, and submit as ham or spam to Akismet service */
                    if (isset($_POST['isspam']) && $_POST['isspam'] == 'on') {
                        if ($_POST['isspam'] == 'on' && $entry->get_isspam() == 0) {
                            $entry->set_isspam(true);
                            $result = gwolle_gb_akismet($entry, 'submit-spam');
                            if ($result) {
                                $gwolle_gb_messages .= '<p>' . __('Submitted as Spam to the Akismet service.', 'gwolle-gb') . '</p>';
                            }
                            gwolle_gb_add_log_entry($entry->get_id(), 'marked-as-spam');
                            $changed = true;
                        }
                    } else {
                        if ($entry->get_isspam() == 1) {
                            $entry->set_isspam(false);
                            $result = gwolle_gb_akismet($entry, 'submit-ham');
                            if ($result) {
                                $gwolle_gb_messages .= '<p>' . __('Submitted as Ham to the Akismet service.', 'gwolle-gb') . '</p>';
                            }
                            gwolle_gb_add_log_entry($entry->get_id(), 'marked-as-not-spam');
                            $changed = true;
                        }
                    }
                    /* Set as trash or not */
                    if (isset($_POST['istrash']) && $_POST['istrash'] == 'on') {
                        if ($_POST['istrash'] == 'on' && $entry->get_istrash() == 0) {
                            $entry->set_istrash(true);
                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-trashed');
                            $changed = true;
                        }
                    } else {
                        if ($entry->get_istrash() == 1) {
                            $entry->set_istrash(false);
                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-untrashed');
                            $changed = true;
                        }
                    }
                    /* Check if the content changed, and update accordingly */
                    if (isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '') {
                        if (trim($_POST['gwolle_gb_content']) != $entry->get_content()) {
                            $entry_content = gwolle_gb_maybe_encode_emoji($_POST['gwolle_gb_content'], 'content');
                            $entry->set_content($entry_content);
                            $changed = true;
                        }
                    }
                    /* Check if the website changed, and update accordingly */
                    if (isset($_POST['gwolle_gb_author_website'])) {
                        if ($_POST['gwolle_gb_author_website'] != $entry->get_author_website()) {
                            $entry->set_author_website($_POST['gwolle_gb_author_website']);
                            $changed = true;
                        }
                    }
                    /* Check if the author_origin changed, and update accordingly */
                    if (isset($_POST['gwolle_gb_author_origin'])) {
                        if ($_POST['gwolle_gb_author_origin'] != $entry->get_author_origin()) {
                            $entry_origin = gwolle_gb_maybe_encode_emoji($_POST['gwolle_gb_author_origin'], 'author_origin');
                            $entry->set_author_origin($entry_origin);
                            $changed = true;
                        }
                    }
                    /* Check if the admin_reply changed, and update and log accordingly */
                    if (isset($_POST['gwolle_gb_admin_reply'])) {
                        if (trim($_POST['gwolle_gb_admin_reply']) != $entry->get_admin_reply()) {
                            $gwolle_gb_admin_reply = gwolle_gb_maybe_encode_emoji($_POST['gwolle_gb_admin_reply'], 'admin_reply');
                            if ($gwolle_gb_admin_reply != '' && $entry->get_admin_reply() == '') {
                                $entry->set_admin_reply_uid(get_current_user_id());
                                gwolle_gb_add_log_entry($entry->get_id(), 'admin-reply-added');
                            } else {
                                if ($gwolle_gb_admin_reply == '' && $entry->get_admin_reply() != '') {
                                    $entry->set_admin_reply_uid(0);
                                    gwolle_gb_add_log_entry($entry->get_id(), 'admin-reply-removed');
                                } else {
                                    if ($gwolle_gb_admin_reply != '' && $entry->get_admin_reply() != '') {
                                        gwolle_gb_add_log_entry($entry->get_id(), 'admin-reply-updated');
                                    }
                                }
                            }
                            $entry->set_admin_reply($gwolle_gb_admin_reply);
                            $changed = true;
                        }
                    }
                    /* Mail the author about the Admin Reply, if so requested */
                    if (isset($_POST['gwolle_gb_admin_reply_mail_author'])) {
                        if ($_POST['gwolle_gb_admin_reply_mail_author'] == 'on') {
                            gwolle_gb_mail_author_on_admin_reply($entry);
                        }
                    }
                    /* Check if the author_name changed, and update accordingly */
                    if (isset($_POST['gwolle_gb_author_name'])) {
                        if ($_POST['gwolle_gb_author_name'] != $entry->get_author_name()) {
                            $entry_name = gwolle_gb_maybe_encode_emoji($_POST['gwolle_gb_author_name'], 'author_name');
                            $entry->set_author_name($entry_name);
                            $changed = true;
                        }
                    }
                    /* Check if the datetime changed, and update accordingly */
                    if (isset($_POST['gwolle_gb_timestamp']) && is_numeric($_POST['gwolle_gb_timestamp'])) {
                        if ($_POST['gwolle_gb_timestamp'] != $entry->get_datetime()) {
                            $entry->set_datetime((int) $_POST['gwolle_gb_timestamp']);
                            $changed = true;
                        }
                    }
                    /* Check if the book_id changed, and update accordingly */
                    if (isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id'])) {
                        if ($_POST['gwolle_gb_book_id'] != $entry->get_book_id()) {
                            $entry->set_book_id((int) $_POST['gwolle_gb_book_id']);
                            $changed = true;
                        }
                    }
                    /* Save the entry */
                    if ($changed) {
                        $result = $entry->save();
                        if ($result) {
                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-edited');
                            $gwolle_gb_messages .= '<p>' . __('Changes saved.', 'gwolle-gb') . '</p>';
                        } else {
                            $gwolle_gb_messages .= '<p>' . __('Error happened during saving.', 'gwolle-gb') . '</p>';
                            $gwolle_gb_errors = 'error';
                        }
                    } else {
                        $gwolle_gb_messages .= '<p>' . __('Entry was not changed.', 'gwolle-gb') . '</p>';
                    }
                    /* Remove permanently */
                    if (isset($_POST['istrash']) && $_POST['istrash'] == 'on' && isset($_POST['remove']) && $_POST['remove'] == 'on') {
                        if ($entry->get_istrash() == 1) {
                            $entry->delete();
                            $entry->set_id(0);
                            $changed = true;
                            // Overwrite any other message, only removal is relevant.
                            $gwolle_gb_messages = '<p>' . __('Entry removed.', 'gwolle-gb') . '</p>';
                            $entry = new gwolle_gb_entry();
                        }
                    }
                } else {
                    if ($_POST['entry_id'] == 0 && $entry->get_id() == 0) {
                        /*
                         * Check for input, and save accordingly. This is on a New Entry! (So no logging)
                         */
                        $saved = false;
                        $data = array();
                        /* Set as checked anyway, new entry is always by an admin */
                        $data['ischecked'] = true;
                        $user_id = get_current_user_id();
                        // returns 0 if no current user
                        $data['checkedby'] = $user_id;
                        $data['author_id'] = $user_id;
                        /* Set metadata of the admin */
                        $userdata = get_userdata($user_id);
                        if (is_object($userdata)) {
                            if (isset($userdata->display_name)) {
                                $author_name = $userdata->display_name;
                            } else {
                                $author_name = $userdata->user_login;
                            }
                            $author_email = $userdata->user_email;
                        }
                        $data['author_name'] = $author_name;
                        $data['author_name'] = gwolle_gb_maybe_encode_emoji($data['author_name'], 'author_name');
                        $data['author_email'] = $author_email;
                        /* Set as Not Spam */
                        $data['isspam'] = false;
                        /* Do not set as trash */
                        $data['istrash'] = false;
                        /* Check if the content is filled in, and save accordingly */
                        if (isset($_POST['gwolle_gb_content']) && $_POST['gwolle_gb_content'] != '') {
                            $data['content'] = $_POST['gwolle_gb_content'];
                            $data['content'] = gwolle_gb_maybe_encode_emoji($data['content'], 'content');
                            $saved = true;
                        } else {
                            $form_setting = gwolle_gb_get_setting('form');
                            if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true' && isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
                                $gwolle_gb_messages .= '<p>' . __('Entry has no content, even though that is mandatory.', 'gwolle-gb') . '</p>';
                                $gwolle_gb_errors = 'error';
                            } else {
                                $data['content'] = '';
                                $saved = true;
                            }
                        }
                        /* Check if the website is set, and save accordingly */
                        if (isset($_POST['gwolle_gb_author_website'])) {
                            if ($_POST['gwolle_gb_author_website'] != '') {
                                $data['author_website'] = $_POST['gwolle_gb_author_website'];
                            } else {
                                $data['author_website'] = home_url();
                            }
                        }
                        /* Check if the author_origin is set, and save accordingly */
                        if (isset($_POST['gwolle_gb_author_origin'])) {
                            if ($_POST['gwolle_gb_author_origin'] != '') {
                                $data['author_origin'] = $_POST['gwolle_gb_author_origin'];
                                $data['author_origin'] = gwolle_gb_maybe_encode_emoji($data['author_origin'], 'author_origin');
                            }
                        }
                        /* Check if the admin_reply is set, and save accordingly */
                        if (isset($_POST['gwolle_gb_admin_reply'])) {
                            if ($_POST['gwolle_gb_admin_reply'] != '') {
                                $data['admin_reply'] = gwolle_gb_maybe_encode_emoji($_POST['gwolle_gb_admin_reply'], 'admin_reply');
                                $data['admin_reply_uid'] = get_current_user_id();
                                gwolle_gb_add_log_entry($entry->get_id(), 'admin-reply-added');
                            }
                        }
                        /* Check if the book_id is set, and save accordingly */
                        if (isset($_POST['gwolle_gb_book_id']) && is_numeric($_POST['gwolle_gb_book_id'])) {
                            $entry->set_book_id((int) $_POST['gwolle_gb_book_id']);
                        }
                        /* Network Information */
                        $entry->set_author_ip($_SERVER['REMOTE_ADDR']);
                        $entry->set_author_host(gethostbyaddr($_SERVER['REMOTE_ADDR']));
                        $result1 = $entry->set_data($data);
                        if ($saved) {
                            $result2 = $entry->save();
                            if ($result1 && $result2) {
                                $gwolle_gb_messages .= '<p>' . __('Entry saved.', 'gwolle-gb') . '</p>';
                                gwolle_gb_clear_cache();
                            } else {
                                $gwolle_gb_messages .= '<p>' . __('Error happened during saving.', 'gwolle-gb') . '</p>';
                                $gwolle_gb_errors = 'error';
                            }
                        } else {
                            $gwolle_gb_messages .= '<p>' . __('Entry was not saved.', 'gwolle-gb') . '</p>';
                        }
                    }
                }
            }
        }
        // FIXME: reload the entry, just for consistency?
        /*
         * Build the Page and the Form
         */
        ?>
		<div class="wrap gwolle_gb">
			<div id="icon-gwolle-gb"><br /></div>
			<h1><?php 
        echo $sectionHeading;
        ?>
</h1>

			<?php 
        if ($gwolle_gb_messages) {
            echo '
					<div id="message" class="updated fade notice is-dismissible ' . $gwolle_gb_errors . ' ">' . $gwolle_gb_messages . '</div>';
        }
        ?>

			<form name="gwolle_gb_editor" id="gwolle_gb_editor" method="POST" action="" accept-charset="UTF-8">
				<input type="hidden" name="gwolle_gb_page" value="editor" />
				<input type="hidden" name="entry_id" value="<?php 
        echo $entry->get_id();
        ?>
" />

				<div id="poststuff" class="metabox-holder">
					<div id="post-body" class="metabox-holder columns-2">

						<div id="post-body-content">
							<div id='normal-sortables' class='meta-box-sortables'>

								<div id="contentdiv" class="postbox" >
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
"><span><?php 
        _e('Guestbook entry', 'gwolle-gb');
        ?>
</span></h3>
									<div class="inside">
										<textarea rows="10" name="gwolle_gb_content" id="gwolle_gb_content" tabindex="1" placeholder="<?php 
        _e('Message', 'gwolle-gb');
        ?>
"><?php 
        echo gwolle_gb_sanitize_output($entry->get_content());
        ?>
</textarea>
										<?php 
        if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
            echo '<p>' . sprintf(__('Line breaks will not be visible to the visitors due to your <a href="%s">settings</a>.', 'gwolle-gb'), 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php') . '</p>';
        }
        $form_setting = gwolle_gb_get_setting('form');
        if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
            wp_enqueue_script('markitup', plugins_url('../frontend/markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_script('markitup_set', plugins_url('../frontend/markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('../frontend/markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
            $dataToBePassed = array('bold' => __('Bold', 'gwolle-gb'), 'italic' => __('Italic', 'gwolle-gb'), 'bullet' => __('Bulleted List', 'gwolle-gb'), 'numeric' => __('Numeric List', 'gwolle-gb'), 'picture' => __('Picture', 'gwolle-gb'), 'source' => __('Source', 'gwolle-gb'), 'link' => __('Link', 'gwolle-gb'), 'linktext' => __('Your text to link...', 'gwolle-gb'), 'clean' => __('Clean', 'gwolle-gb'), 'emoji' => __('Emoji', 'gwolle-gb'));
            wp_localize_script('markitup_set', 'gwolle_gb_localize', $dataToBePassed);
            // Emoji symbols
            echo '<div class="gwolle_gb_emoji" style="display:none;">';
            $emoji = gwolle_gb_get_emoji();
            // make it into images for nice colors.
            if (function_exists('wp_staticize_emoji')) {
                $emoji = wp_staticize_emoji($emoji);
            }
            echo $emoji;
            echo '</div>';
        }
        ?>
									</div>
								</div>

								<div id="authordiv" class="postbox " >
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
"><span><?php 
        _e('Website', 'gwolle-gb');
        ?>
</span></h3>
									<div class="inside">
										<input type="url" name="gwolle_gb_author_website" tabindex="2" value="<?php 
        echo gwolle_gb_sanitize_output($entry->get_author_website());
        ?>
" id="author_website" placeholder="<?php 
        _e('Website', 'gwolle-gb');
        ?>
" />
										<p><?php 
        _e("Example: <code>http://www.example.com/</code>", 'gwolle-gb');
        ?>
</p>
									</div>
								</div>

								<div id="authordiv" class="postbox ">
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
"><span><?php 
        _e('Origin', 'gwolle-gb');
        ?>
</span></h3>
									<div class="inside">
										<input type="text" name="gwolle_gb_author_origin" tabindex="3" placeholder="<?php 
        _e('City', 'gwolle-gb');
        ?>
" value="<?php 
        echo gwolle_gb_sanitize_output($entry->get_author_origin());
        ?>
" id="author_origin" />
									</div>
								</div>

								<div id="admin_reply" class="postbox" >
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
">
										<span><?php 
        _e('Admin Reply by:', 'gwolle-gb');
        echo ' ' . gwolle_gb_is_moderator($entry->get_admin_reply_uid());
        ?>
										</span>
									</h3>
									<div class="inside">
										<textarea rows="10" name="gwolle_gb_admin_reply" id="gwolle_gb_admin_reply" tabindex="4" placeholder="<?php 
        _e('Admin Reply', 'gwolle-gb');
        ?>
"><?php 
        echo gwolle_gb_sanitize_output($entry->get_admin_reply());
        ?>
</textarea>

										<input type="checkbox" name="gwolle_gb_admin_reply_mail_author" id="gwolle_gb_admin_reply_mail_author">
										<label for="gwolle_gb_admin_reply_mail_author">
											<?php 
        _e('Mail the author a notification about this reply.', 'gwolle-gb');
        ?>
										</label><br />

										<?php 
        if (get_option('gwolle_gb-showLineBreaks', 'false') == 'false') {
            echo '<p>' . sprintf(__('Line breaks will not be visible to the visitors due to your <a href="%s">settings</a>.', 'gwolle-gb'), 'admin.php?page=' . GWOLLE_GB_FOLDER . '/settings.php') . '</p>';
        }
        ?>
									</div>
								</div>

							</div><!-- .normal-sortables -->
						</div><!-- .post-body-content -->


						<div id="postbox-container-1" class="postbox-container">
							<div id='side-sortables' class='meta-box-sortables'>

								<?php 
        $class = '';
        // Attach 'spam' to class if the entry is spam
        if ($entry->get_isspam() === 1) {
            $class .= ' spam';
        } else {
            $class .= ' nospam';
        }
        // Attach 'trash' to class if the entry is in trash
        if ($entry->get_istrash() === 1) {
            $class .= ' trash';
        } else {
            $class .= ' notrash';
        }
        // Attach 'checked/unchecked' to class
        if ($entry->get_ischecked() === 1) {
            $class .= ' checked';
        } else {
            $class .= ' unchecked';
        }
        // Attach 'visible/invisible' to class
        if ($entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0) {
            $class .= ' invisible';
        } else {
            $class .= ' visible';
        }
        // Add admin-entry class to an entry from an admin
        $author_id = $entry->get_author_id();
        $is_moderator = gwolle_gb_is_moderator($author_id);
        if ($is_moderator) {
            $class .= ' admin-entry';
        }
        ?>

								<?php 
        $postid = gwolle_gb_get_postid();
        if ($postid) {
            $permalink = get_bloginfo('url') . '?p=' . $postid;
            ?>
									<div id="tagsdiv-post_tag" class="postbox">
										<div class="handlediv"></div>
										<h3 class='hndle' title="<?php 
            esc_attr_e('Click to open or close', 'gwolle-gb');
            ?>
"><span><?php 
            _e('View Frontend', 'gwolle-gb');
            ?>
</span></h3>
										<div class="inside">
											<div class="tagsdiv" id="post_tag">
												<div id="categories-pop" class="tabs-panel gwolle_gb_frontend">
													<a class="button rbutton button" href="<?php 
            echo $permalink;
            ?>
"><?php 
            esc_attr_e('View Guestbook', 'gwolle-gb');
            ?>
</a>
												</div>
											</div>
										</div>
									</div>
									<?php 
        }
        ?>

								<div id="submitdiv" class="postbox">
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
"><span><?php 
        _e('Options', 'gwolle-gb');
        ?>
</span></h3>
									<div class="inside">
										<div class="submitbox" id="submitpost">
											<div id="minor-publishing">
												<div id="misc-publishing-actions">
													<div class="misc-pub-section misc-pub-section-last">

														<?php 
        // Optional Icon column where CSS is being used to show them or not
        if (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') {
            ?>
															<span class="entry-icons <?php 
            echo $class;
            ?>
">
																<span class="visible-icon" title="<?php 
            _e('Visible', 'gwolle-gb');
            ?>
"></span>
																<span class="invisible-icon" title="<?php 
            _e('Invisible', 'gwolle-gb');
            ?>
"></span>
																<span class="spam-icon" title="<?php 
            _e('Spam', 'gwolle-gb');
            ?>
"></span>
																<!--<span class="trash-icon" title="<?php 
            _e('Trash', 'gwolle-gb');
            ?>
"></span>-->
																<?php 
            $admin_reply = gwolle_gb_sanitize_output($entry->get_admin_reply());
            if (strlen(trim($admin_reply)) > 0) {
                ?>
																	<span class="admin_reply-icon" title="<?php 
                _e('Admin Replied', 'gwolle-gb');
                ?>
"></span><?php 
            }
            ?>
																<span class="gwolle_gb_ajax" title="<?php 
            _e('Wait...', 'gwolle-gb');
            ?>
"></span>
															</span>
															<?php 
        }
        if ($entry->get_id() == 0) {
            echo '<h3 class="h3_invisible">' . __('This entry is not yet visible.', 'gwolle-gb') . '</h3>';
        } else {
            if ($entry->get_ischecked() == 1 && $entry->get_isspam() == 0 && $entry->get_istrash() == 0) {
                echo '
																	<h3 class="h3_visible">' . __('This entry is Visible.', 'gwolle-gb') . '</h3>
																	<h3 class="h3_invisible" style="display:none;">' . __('This entry is Not Visible.', 'gwolle-gb') . '</h3>
																	';
            } else {
                echo '
																	<h3 class="h3_visible" style="display:none;">' . __('This entry is Visible.', 'gwolle-gb') . '</h3>
																	<h3 class="h3_invisible">' . __('This entry is Not Visible.', 'gwolle-gb') . '</h3>
																	';
            }
            ?>

															<label for="ischecked" class="selectit">
																<input id="ischecked" name="ischecked" type="checkbox" <?php 
            if ($entry->get_ischecked() == '1' || $entry->get_id() == 0) {
                echo 'checked="checked"';
            }
            ?>
 />
																<?php 
            _e('Checked', 'gwolle-gb');
            ?>
															</label>

															<br />
															<label for="isspam" class="selectit">
																<input id="isspam" name="isspam" type="checkbox" <?php 
            if ($entry->get_isspam() == '1') {
                echo 'checked="checked"';
            }
            ?>
 />
																<?php 
            _e('Spam', 'gwolle-gb');
            ?>
															</label>

															<br />
															<label for="istrash" class="selectit">
																<input id="istrash" name="istrash" type="checkbox" <?php 
            if ($entry->get_istrash() == '1') {
                echo 'checked="checked"';
            }
            ?>
 />
																<?php 
            _e('Trash', 'gwolle-gb');
            ?>
															</label>

															<?php 
            if ($entry->get_istrash() == '1') {
                ?>
																<br />
																<label for="remove" class="selectit">
																	<input id="remove" name="remove" type="checkbox" />
																	<?php 
                _e('Remove this entry Permanently.', 'gwolle-gb');
                ?>
																</label>
															<?php 
            }
        }
        ?>

													</div>
												</div><!-- .misc-publishing-actions -->
												<div class="clear"></div>
											</div> <!-- .minor-publishing -->

											<div id="major-publishing-actions">
												<div id="publishing-action">
													<input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php 
        esc_attr_e('Save', 'gwolle-gb');
        ?>
" />
												</div> <!-- .publishing-action -->
												<div class="clear"></div>
											</div><!-- major-publishing-actions -->
										</div><!-- .submitbox -->
									</div><!-- .inside -->
								</div><!-- .submitdiv -->

								<?php 
        if ($entry->get_id() > 0) {
            ?>
								<div id="submitdiv" class="postbox">
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
            esc_attr_e('Click to open or close', 'gwolle-gb');
            ?>
"><span><?php 
            _e('Actions', 'gwolle-gb');
            ?>
</span></h3>
									<div class="inside">
										<div class="submitbox" id="submitpost">
											<div id="minor-publishing">
												<div id="misc-publishing-actions">
													<div class="misc-pub-section misc-pub-section-last">

														<?php 
            echo '
														<div class="gwolle_gb_actions ' . $class . '">
															<span class="gwolle_gb_check">
																<a id="check_' . $entry->get_id() . '" href="#" class="vim-a" title="' . __('Check entry', 'gwolle-gb') . '">' . __('Check', 'gwolle-gb') . '</a>
															</span>
															<span class="gwolle_gb_uncheck">
																<a id="uncheck_' . $entry->get_id() . '" href="#" class="vim-u" title="' . __('Uncheck entry', 'gwolle-gb') . '">' . __('Uncheck', 'gwolle-gb') . '</a>
															</span>
															<span class="gwolle_gb_spam">&nbsp;|&nbsp;
																<a id="spam_' . $entry->get_id() . '" href="#" class="vim-s vim-destructive" title="' . __('Mark entry as spam.', 'gwolle-gb') . '">' . __('Spam', 'gwolle-gb') . '</a>
															</span>
															<span class="gwolle_gb_unspam">&nbsp;|&nbsp;
																<a id="unspam_' . $entry->get_id() . '" href="#" class="vim-a" title="' . __('Mark entry as not-spam.', 'gwolle-gb') . '">' . __('Not spam', 'gwolle-gb') . '</a>
															</span>
															<span class="gwolle_gb_trash">&nbsp;|&nbsp;
																<a id="trash_' . $entry->get_id() . '" href="#" class="vim-d vim-destructive" title="' . __('Move entry to trash.', 'gwolle-gb') . '">' . __('Trash', 'gwolle-gb') . '</a>
															</span>
															<span class="gwolle_gb_untrash">&nbsp;|&nbsp;
																<a id="untrash_' . $entry->get_id() . '" href="#" class="vim-d" title="' . __('Recover entry from trash.', 'gwolle-gb') . '">' . __('Untrash', 'gwolle-gb') . '</a>
															</span><br />
															<span class="gwolle_gb_ajax">
																<a id="ajax_' . $entry->get_id() . '" href="#" class="ajax vim-d vim-destructive" title="' . __('Please wait...', 'gwolle-gb') . '">' . __('Wait...', 'gwolle-gb') . '</a>
															</span><br />
														</div>
														';
            ?>

													</div>
												</div><!-- .misc-publishing-actions -->
												<div class="clear"></div>
											</div> <!-- .minor-publishing -->
										</div><!-- .submitbox -->
									</div><!-- .inside -->
								</div><!-- .submitdiv -->
								<?php 
        }
        ?>

								<div id="gwolle_gb-entry-details" class="postbox " >
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
"><span><?php 
        _e('Details', 'gwolle-gb');
        ?>
</span></h3>
									<div class="inside">
										<div class="tagsdiv" id="post_tag">
											<p>
											<?php 
        _e('Author', 'gwolle-gb');
        ?>
: <span><?php 
        if ($entry->get_author_name()) {
            echo gwolle_gb_sanitize_output($entry->get_author_name());
        } else {
            echo '<i>(' . __('Unknown', 'gwolle-gb') . ')</i>';
        }
        ?>
											</span><br />
											<?php 
        _e('E-Mail', 'gwolle-gb');
        ?>
: <span><?php 
        if (strlen(str_replace(' ', '', $entry->get_author_email())) > 0) {
            echo gwolle_gb_sanitize_output($entry->get_author_email());
        } else {
            echo '<i>(' . __('Unknown', 'gwolle-gb') . ')</i>';
        }
        ?>
											</span><br />
											<?php 
        _e('Written', 'gwolle-gb');
        ?>
: <span><?php 
        if ($entry->get_datetime() > 0) {
            echo date_i18n(get_option('date_format'), $entry->get_datetime()) . ', ';
            echo date_i18n(get_option('time_format'), $entry->get_datetime());
        } else {
            echo '(' . __('Not yet', 'gwolle-gb') . ')';
        }
        ?>
											</span><br />
											<?php 
        _e("Author's IP-address", 'gwolle-gb');
        ?>
: <span><?php 
        if (strlen($entry->get_author_ip()) > 0) {
            echo '<a href="http://www.db.ripe.net/whois?form_type=simple&searchtext=' . $entry->get_author_ip() . '"
															title="' . __('Whois search for this IP', 'gwolle-gb') . '" target="_blank">
																' . $entry->get_author_ip() . '
															</a>';
        } else {
            echo '<i>(' . __('Unknown', 'gwolle-gb') . ')</i>';
        }
        ?>
											</span><br />
											<?php 
        _e('Host', 'gwolle-gb');
        ?>
: <span><?php 
        if (strlen($entry->get_author_host()) > 0) {
            echo $entry->get_author_host();
        } else {
            echo '<i>(' . __('Unknown', 'gwolle-gb') . ')</i>';
        }
        ?>
											</span><br />
											<?php 
        _e('Book', 'gwolle-gb');
        ?>
: <span><?php 
        echo $entry->get_book_id();
        ?>
											</span><br />
											<span class="gwolle_gb_edit_meta">
												<a href="#" title="<?php 
        _e('Edit metadata', 'gwolle-gb');
        ?>
"><?php 
        _e('Edit', 'gwolle-gb');
        ?>
</a>
											</span>
											</p>

											<div class="gwolle_gb_edit_meta_inputs">
												<label for="gwolle_gb_author_name"><?php 
        _e('Author', 'gwolle-gb');
        ?>
: </label><br />
												<input type="text" name="gwolle_gb_author_name" size="24" value="<?php 
        echo gwolle_gb_sanitize_output($entry->get_author_name());
        ?>
" id="gwolle_gb_author_name" /><br />

												<span><?php 
        _e('Date and time', 'gwolle-gb');
        ?>
: </span><br />
												<div class="gwolle_gb_date"><?php 
        gwolle_gb_touch_time($entry);
        ?>
												</div>

												<label for="gwolle_gb_book_id"><?php 
        _e('Book ID', 'gwolle-gb');
        ?>
: </label><br />
												<input type="text" name="gwolle_gb_book_id" size="4" value="<?php 
        echo (int) $entry->get_book_id();
        ?>
" id="gwolle_gb_book_id" />
											</div>

										</div><!-- .tagsdiv -->
									</div>
								</div><!-- .postbox -->

								<div id="tagsdiv-post_tag" class="postbox">
									<div class="handlediv"></div>
									<h3 class='hndle' title="<?php 
        esc_attr_e('Click to open or close', 'gwolle-gb');
        ?>
"><span><?php 
        _e('Entry log', 'gwolle-gb');
        ?>
</span></h3>
									<div class="inside">
										<div class="tagsdiv" id="post_tag">
											<div id="categories-pop" class="tabs-panel gwolle_gb_log">
												<ul>
												<?php 
        if ($entry->get_datetime() > 0) {
            echo '<li>';
            echo date_i18n(get_option('date_format'), $entry->get_datetime()) . ', ';
            echo date_i18n(get_option('time_format'), $entry->get_datetime());
            echo ': ' . __('Written', 'gwolle-gb') . '</li>';
            $log_entries = gwolle_gb_get_log_entries($entry->get_id());
            if (is_array($log_entries) && !empty($log_entries)) {
                foreach ($log_entries as $log_entry) {
                    echo '<li class="log_id_' . $log_entry['id'] . '">' . $log_entry['msg_html'] . '</li>';
                }
            }
        } else {
            echo '<li>(' . __('No log yet.', 'gwolle-gb') . ')</li>';
        }
        ?>
												</ul>
											</div>
										</div>
									</div>
								</div><!-- .postbox -->
							</div><!-- .side-sortables -->
						</div><!-- #postbox-container-1 -->

						<br class="clear" />

					</div><!-- .post-body -->
				</div><!-- .poststuff -->
			</form>
		</div>

		<?php 
    }
}
예제 #3
0
function gwolle_gb_frontend_write($shortcode_atts)
{
    global $gwolle_gb_errors, $gwolle_gb_error_fields, $gwolle_gb_messages, $gwolle_gb_data;
    $html5 = current_theme_supports('html5');
    $output = '';
    // Set data up for refilling an already submitted form that had errors
    $name = '';
    $origin = '';
    $email = '';
    $website = '';
    $antispam = '';
    $content = '';
    // Auto-fill the form if the user is already logged in
    $user_id = get_current_user_id();
    // returns 0 if no current user
    if ($user_id > 0) {
        $userdata = get_userdata($user_id);
        if (is_object($userdata)) {
            if (isset($userdata->display_name)) {
                $name = $userdata->display_name;
            } else {
                $name = $userdata->user_login;
            }
            $email = $userdata->user_email;
            $website = $userdata->user_url;
        }
    }
    // Only show old data when there are errors
    if ($gwolle_gb_errors) {
        if (is_array($gwolle_gb_data) && !empty($gwolle_gb_data)) {
            if (isset($gwolle_gb_data['author_name'])) {
                $name = stripslashes($gwolle_gb_data['author_name']);
            }
            if (isset($gwolle_gb_data['author_origin'])) {
                $origin = stripslashes($gwolle_gb_data['author_origin']);
            }
            if (isset($gwolle_gb_data['author_email'])) {
                $email = stripslashes($gwolle_gb_data['author_email']);
            }
            if (isset($gwolle_gb_data['author_website'])) {
                $website = stripslashes($gwolle_gb_data['author_website']);
            }
            if (isset($gwolle_gb_data['antispam'])) {
                $antispam = stripslashes($gwolle_gb_data['antispam']);
            }
            if (isset($gwolle_gb_data['content'])) {
                $content = stripslashes($gwolle_gb_data['content']);
            }
        }
    }
    // Initialize errors, if not set
    if (empty($gwolle_gb_error_fields)) {
        $gwolle_gb_error_fields = array();
    }
    /*
     * Handle Messaging to the user
     */
    $class = "";
    if ($gwolle_gb_errors) {
        $class = "error";
    }
    if (isset($gwolle_gb_messages) && $gwolle_gb_messages != '') {
        $output .= "<div id='gwolle_gb_messages' class='{$class}'>";
        $output .= $gwolle_gb_messages;
        $output .= "</div>";
    }
    $popuptitle = 'Merci ...';
    if (strpos($gwolle_gb_messages, 'signature') !== false && strpos($gwolle_gb_messages, 'doux') !== false) {
        $popuptitle = 'Oups ...';
        $gwolle_gb_messages = '<p class="error_fields"><strong>Ni les mots doux, ni le nom .. Quelle tristesse.</strong></p>';
    }
    if (strpos($gwolle_gb_messages, 'signature') !== false) {
        $popuptitle = 'Oups ...';
    }
    if (strpos($gwolle_gb_messages, 'doux') !== false) {
        $popuptitle = 'Oups ...';
    }
    $output .= '<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">';
    $output .= $popuptitle;
    $output .= '</h4>
      </div>
      <div class="modal-body">
        <p>';
    $output .= $gwolle_gb_messages;
    $output .= '</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
      </div>
    </div>
  </div>
</div>';
    /*
     * Button 'write a new entry.'
     */
    // $output .= '
    // 	<div id="gwolle_gb_write_button">
    // 		<input type="button" value="&raquo; ' . esc_attr__('Write a new entry.', 'gwolle-gb') . '" />
    // 	</div>';
    // Option to allow only logged-in users to post. Don't show the form if not logged-in. We still see the messages above.
    if (!is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true') {
        $output .= '
			<div id="gwolle_gb_new_entry">
				<h3>' . __('Log in to post an entry', 'gwolle-gb') . '</h3>';
        $args = array('echo' => false, 'redirect' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
        $output .= wp_login_form($args);
        $output .= wp_register('', '', false);
        $output .= '</div>';
        return $output;
    }
    /*
     * Build up Form including possible error_fields
     */
    $form_setting = gwolle_gb_get_setting('form');
    $autofocus = 'autofocus="autofocus"';
    // Form for submitting new entries
    $header = gwolle_gb_sanitize_output(get_option('gwolle_gb-header', false));
    if ($header == false) {
        $header = __('Write a new entry for the Guestbook', 'gwolle-gb');
    }
    $output .= '
		<form id="gwolle_gb_new_entry" action="#" method="POST" >
			<input type="hidden" name="gwolle_gb_function" id="gwolle_gb_function" value="add_entry" />';
    // The book_id from the shortcode, to be used by the posthandling function again.
    $output .= '<input type="hidden" name="gwolle_gb_book_id" id="gwolle_gb_book_id" value="' . $shortcode_atts['book_id'] . '" />';
    // Use this filter to just add something
    $output .= apply_filters('gwolle_gb_write_add_before', '');
    /* Name */
    if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_name">';
        if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
        }
        $output .= '
				<div class="input"><input class="';
        if (in_array('name', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $name . '" type="text" name="gwolle_gb_author_name" id="gwolle_gb_author_name" placeholder="' . __('Name', 'gwolle-gb') . '" ';
        if (in_array('name', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>';
    }
    // /* City / Origin */
    // if ( isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled']  === 'true' ) {
    // 	$output .= '<div class="gwolle_gb_author_origin">
    // 				<div class="label"><label for="gwolle_gb_author_origin">' . __('City', 'gwolle-gb') . ':';
    // 	if ( isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory']  === 'true' ) { $output .= ' *';}
    // 	$output .= '</label></div>
    // 				<div class="input"><input class="';
    // 	if (in_array('author_origin', $gwolle_gb_error_fields)) {
    // 		$output .= ' error';
    // 	}
    // 	$output .= '" value="' . $origin . '" type="text" name="gwolle_gb_author_origin" id="gwolle_gb_author_origin" placeholder="' . __('City', 'gwolle-gb') . '" ';
    // 	if ( in_array('author_origin', $gwolle_gb_error_fields) && isset($autofocus) ) {
    // 		$output .= $autofocus;
    // 		$autofocus = false; // disable it for the next error.
    // 	}
    // 	$output .= ' /></div>
    // 			</div>
    // 			<div class="clearBoth">&nbsp;</div>';
    // }
    /* Email */
    // if ( isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled']  === 'true' ) {
    // 	$output .= '<div class="gwolle_gb_author_email">
    // 			<div class="label"><label for="gwolle_gb_author_email">' . __('Email', 'gwolle-gb') . ':';
    // 	if ( isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory']  === 'true' ) { $output .= ' *';}
    // 	$output .= '</label></div>
    // 			<div class="input"><input class="';
    // 	if (in_array('author_email', $gwolle_gb_error_fields)) {
    // 		$output .= ' error';
    // 	}
    // 	$output .= '" value="' . $email . '" ' . ($html5 ? 'type="email"' : 'type="text"') . ' name="gwolle_gb_author_email" id="gwolle_gb_author_email" placeholder="' . __('Email', 'gwolle-gb') . '" ';
    // 	if ( in_array('author_email', $gwolle_gb_error_fields) && isset($autofocus) ) {
    // 		$output .= $autofocus;
    // 		$autofocus = false; // disable it for the next error.
    // 	}
    // 	$output .= ' /></div>
    // 		</div>
    // 		<div class="clearBoth">&nbsp;</div>';
    // } else {
    // 	if ( isset($email) && strlen($email) > 0 ) {
    // 		// For logged in users, just save the email anyway.
    // 		$output .= '<input class="" value="' . $email . '" type="hidden" name="gwolle_gb_author_email" id="gwolle_gb_author_email" />';
    // 	}
    // }
    /* Website / Homepage */
    // if ( isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled']  === 'true' ) {
    // 	$output .= '<div class="gwolle_gb_author_website">
    // 			<div class="label"><label for="gwolle_gb_author_website">' . __('Website', 'gwolle-gb') . ':';
    // 	if ( isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory']  === 'true' ) { $output .= ' *';}
    // 	$output .= '</label></div>
    // 			<div class="input"><input class="';
    // 	if (in_array('author_website', $gwolle_gb_error_fields)) {
    // 		$output .= ' error';
    // 	}
    // 	$output .= '" value="' . $website . '" ' . ($html5 ? 'type="url"' : 'type="text"') . ' name="gwolle_gb_author_website" id="gwolle_gb_author_website" placeholder="' . __('Website', 'gwolle-gb') . '" ';
    // 	if ( in_array('author_website', $gwolle_gb_error_fields) && isset($autofocus) ) {
    // 		$output .= $autofocus;
    // 		$autofocus = false; // disable it for the next error.
    // 	}
    // 	$output .= ' /></div>
    // 		</div>
    // 		<div class="clearBoth">&nbsp;</div>';
    // }
    /* Content */
    if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_content">';
        if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
        }
        $output .= '<div class="input"><textarea name="gwolle_gb_content" id="gwolle_gb_content" class="';
        if (in_array('content', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" placeholder="' . __('Message', 'gwolle-gb') . '" ';
        if (in_array('content', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' >' . $content . '</textarea>';
        if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
            // BBcode and MarkItUp
            wp_enqueue_script('markitup', plugins_url('markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_script('markitup_set', plugins_url('markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
            $dataToBePassed = array('bold' => __('Bold', 'gwolle-gb'), 'italic' => __('Italic', 'gwolle-gb'), 'bullet' => __('Bulleted List', 'gwolle-gb'), 'numeric' => __('Numeric List', 'gwolle-gb'), 'picture' => __('Picture', 'gwolle-gb'), 'source' => __('Source', 'gwolle-gb'), 'link' => __('Link', 'gwolle-gb'), 'linktext' => __('Your text to link...', 'gwolle-gb'), 'clean' => __('Clean', 'gwolle-gb'), 'emoji' => __('Emoji', 'gwolle-gb'));
            wp_localize_script('markitup_set', 'gwolle_gb_localize', $dataToBePassed);
            // Emoji symbols
            $output .= '<div class="gwolle_gb_emoji" style="display:none;">';
            $output .= gwolle_gb_get_emoji();
            $output .= '</div>';
        }
        $output .= '</div>';
        // .input
    }
    /* Custom Anti-Spam */
    // if ( isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled']  === 'true' ) {
    // 	$antispam_question = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-question') );
    // 	$antispam_answer   = gwolle_gb_sanitize_output( get_option('gwolle_gb-antispam-answer') );
    //
    // 	if ( isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0 ) {
    // 		$output .= '
    // 			<div class="gwolle_gb_antispam">
    // 				<div class="label">
    // 					<label for="gwolle_gb_antispam_answer">' . __('Anti-spam', 'gwolle-gb') . ': *<br />
    // 					' . __('Question:', 'gwolle-gb') . " " .  $antispam_question . '</label>
    // 				</div>
    // 				<div class="input"><input class="';
    // 		if (in_array('antispam', $gwolle_gb_error_fields)) {
    // 			$output .= ' error';
    // 		}
    // 		$output .= '" value="' . $antispam . '" type="text" name="gwolle_gb_antispam_answer" id="gwolle_gb_antispam_answer" placeholder="' . __('Answer', 'gwolle-gb') . '" ';
    // 		if ( in_array('antispam', $gwolle_gb_error_fields) && isset($autofocus) ) {
    // 			$output .= $autofocus;
    // 			$autofocus = false; // disable it for the next error.
    // 		}
    // 		$output .= ' />
    // 					</div>
    // 				</div>
    // 				<div class="clearBoth">&nbsp;</div>';
    // 	}
    // }
    //
    // /* CAPTCHA */
    // if ( isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled']  === 'true' ) {
    // 	if ( class_exists('ReallySimpleCaptcha') ) {
    // 		// Disable page caching, we want a new CAPTCHA image each time.
    // 		if ( ! defined( 'DONOTCACHEPAGE' ) )
    // 			define( "DONOTCACHEPAGE", "true" );
    //
    // 		// Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
    // 		$gwolle_gb_captcha = new ReallySimpleCaptcha();
    //
    // 		// Set Really Simple CAPTCHA Options
    // 		$gwolle_gb_captcha->chars           = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
    // 		$gwolle_gb_captcha->char_length     = '4';
    // 		$gwolle_gb_captcha->img_size        = array( '72', '24' );
    // 		$gwolle_gb_captcha->fg              = array( '0', '0', '0' );
    // 		$gwolle_gb_captcha->bg              = array( '255', '255', '255' );
    // 		$gwolle_gb_captcha->font_size       = '16';
    // 		$gwolle_gb_captcha->font_char_width = '15';
    // 		$gwolle_gb_captcha->img_type        = 'png';
    // 		$gwolle_gb_captcha->base            = array( '6', '18' );
    //
    // 		// Generate random word and image prefix
    // 		$gwolle_gb_captcha_word = $gwolle_gb_captcha->generate_random_word();
    // 		$gwolle_gb_captcha_prefix = mt_rand();
    // 		// Generate CAPTCHA image
    // 		$gwolle_gb_captcha_image_name = $gwolle_gb_captcha->generate_image($gwolle_gb_captcha_prefix, $gwolle_gb_captcha_word);
    // 		// Define values for CAPTCHA fields
    // 		$gwolle_gb_captcha_image_url = content_url('plugins/really-simple-captcha/tmp/');
    // 		$gwolle_gb_captcha_image_src = $gwolle_gb_captcha_image_url . $gwolle_gb_captcha_image_name;
    // 		$gwolle_gb_captcha_image_width = $gwolle_gb_captcha->img_size[0];
    // 		$gwolle_gb_captcha_image_height = $gwolle_gb_captcha->img_size[1];
    // 		$gwolle_gb_captcha_field_size = $gwolle_gb_captcha->char_length;
    //
    // 		// Enqueue and localize the frontend script for CAPTCHA.
    // 		wp_enqueue_script('gwolle_gb_captcha_js', plugins_url('js/captcha.js', __FILE__), 'jquery', GWOLLE_GB_VER, true );
    // 		$dataToBePassed = array(
    // 			// URL to wp-admin/admin-ajax.php to process the request
    // 			'ajaxurl'   => admin_url( 'admin-ajax.php' ),
    // 			// generate a nonce with a unique ID "gwolle_gb_captcha_ajax"
    // 			// so that you can check it later when an AJAX request is sent
    // 			'security'  => wp_create_nonce( 'gwolle_gb_captcha_ajax' ),
    // 			'correct'   => __ ('Correct CAPTCHA value.', 'gwolle-gb' ),
    // 			'incorrect' => __( 'Incorrect CAPTCHA value.', 'gwolle-gb' ),
    // 			'gwolle_gb_captcha_prefix' => $gwolle_gb_captcha_prefix
    // 		);
    // 		wp_localize_script( 'gwolle_gb_captcha_js', 'gwolle_gb_captcha', $dataToBePassed );
    //
    // 		// Output the CAPTCHA fields
    // 		$output .= '
    // 			<div class="gwolle_gb_captcha">
    // 				<div class="label">
    // 					<label for="gwolle_gb_captcha_code">' . __('Anti-spam', 'gwolle-gb') . ': *<br />
    // 					<img src="' . $gwolle_gb_captcha_image_src . '" alt="captcha" width="' . $gwolle_gb_captcha_image_width . '" height="' . $gwolle_gb_captcha_image_height . '" />
    // 					</label>
    // 				</div>
    // 				<div class="input">
    // 				<input class="';
    // 		if (in_array('captcha', $gwolle_gb_error_fields)) {
    // 			$output .= 'error';
    // 		}
    // 		$output .= '" value="" type="text" name="gwolle_gb_captcha_code" id="gwolle_gb_captcha_code" placeholder="' . __('CAPTCHA', 'gwolle-gb') . '" ';
    // 		if ( in_array('captcha', $gwolle_gb_error_fields) && isset($autofocus) ) {
    // 			$output .= $autofocus;
    // 			$autofocus = false; // disable it for the next error.
    // 		}
    // 		$output .= ' />
    // 						<input type="hidden" name="gwolle_gb_captcha_prefix" id="gwolle_gb_captcha_prefix" value="' . $gwolle_gb_captcha_prefix . '" />
    // 						<span id="gwolle_gb_captcha_verify"></span>
    // 					</div>
    // 				</div>
    // 				';
    // 	}
    // }
    // Use this filter to just add something
    $output .= apply_filters('gwolle_gb_write_add_form', '');
    $output .= '
			<div class="gwolle_gb_submit">
				<div class="input_button"><input type="submit" name="gwolle_gb_submit" value="' . esc_attr__('Valider', 'gwolle-gb') . '" /></div>
			</div></div>
			<div class="gwolle_gb_notice">
				';
    $notice = gwolle_gb_sanitize_output(get_option('gwolle_gb-notice', false));
    if ($notice == false) {
        // No text set by the user. Use the default text.
    }
    $notice = nl2br($notice);
    $output .= str_replace('%ip%', $_SERVER['REMOTE_ADDR'], $notice);
    $output .= '
			</div>';
    // Use this filter to just add something
    $output .= apply_filters('gwolle_gb_write_add_after', '');
    $output .= '</form>';
    if (get_option('gwolle_gb-labels_float', 'true') === 'true') {
        $output .= '
		<style type="text/css" scoped>
		</style>
		';
    }
    // Add filter for the form, so devs can manipulate it.
    $output = apply_filters('gwolle_gb_write', $output);
    return $output;
}
예제 #4
0
function gwolle_gb_frontend_posthandling()
{
    global $wpdb, $gwolle_gb_errors, $gwolle_gb_error_fields, $gwolle_gb_messages, $gwolle_gb_data;
    /*
     * Handle $_POST and check and save entry.
     */
    if (isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] == 'add_entry') {
        // Initialize errors
        $gwolle_gb_errors = false;
        $gwolle_gb_error_fields = array();
        // Initialize messages
        $gwolle_gb_messages = '';
        // Option to allow only logged-in users to post. Don't show the form if not logged-in.
        if (!is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true') {
            $gwolle_gb_errors = true;
            $gwolle_gb_messages .= '<p class="require_login"><strong>' . __('Submitting a new guestbook entry is only allowed for logged-in users.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
            return;
        }
        /*
         * Collect data from the Form
         */
        $gwolle_gb_data = array();
        $form_setting = gwolle_gb_get_setting('form');
        /* Name */
        if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_name'])) {
                $gwolle_gb_data['author_name'] = trim($_POST['gwolle_gb_author_name']);
                $gwolle_gb_data['author_name'] = gwolle_gb_maybe_encode_emoji($gwolle_gb_data['author_name'], 'author_name');
                if ($gwolle_gb_data['author_name'] == "") {
                    if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'name';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'name';
                    // mandatory
                }
            }
        }
        /* City / Origin */
        if (isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_origin'])) {
                $gwolle_gb_data['author_origin'] = trim($_POST['gwolle_gb_author_origin']);
                $gwolle_gb_data['author_origin'] = gwolle_gb_maybe_encode_emoji($gwolle_gb_data['author_origin'], 'author_origin');
                if ($gwolle_gb_data['author_origin'] == "") {
                    if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'author_origin';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'author_origin';
                    // mandatory
                }
            }
        }
        /* Email */
        if (isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_email'])) {
                $gwolle_gb_data['author_email'] = trim($_POST['gwolle_gb_author_email']);
                if (filter_var($gwolle_gb_data['author_email'], FILTER_VALIDATE_EMAIL)) {
                    // Valid Email address.
                } else {
                    if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'author_email';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'author_email';
                    // mandatory
                }
            }
        }
        /* Website / Homepage */
        if (isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_website'])) {
                $gwolle_gb_data['author_website'] = trim($_POST['gwolle_gb_author_website']);
                $pattern = '/^http/';
                if (!preg_match($pattern, $gwolle_gb_data['author_website'], $matches)) {
                    $gwolle_gb_data['author_website'] = "http://" . $gwolle_gb_data['author_website'];
                }
                if (filter_var($gwolle_gb_data['author_website'], FILTER_VALIDATE_URL)) {
                    // Valid Website URL.
                } else {
                    if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'author_website';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'author_website';
                    // mandatory
                }
            }
        }
        /* Message */
        if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_content'])) {
                $gwolle_gb_data['content'] = trim($_POST['gwolle_gb_content']);
                if ($gwolle_gb_data['content'] == "") {
                    if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'content';
                        // mandatory
                    }
                } else {
                    $gwolle_gb_data['content'] = gwolle_gb_maybe_encode_emoji($gwolle_gb_data['content'], 'content');
                }
            } else {
                if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'content';
                    // mandatory
                }
            }
        }
        /* Custom Anti-Spam */
        if (isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true') {
            $antispam_question = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-question'));
            $antispam_answer = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-answer'));
            if (isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0) {
                if (isset($_POST["gwolle_gb_antispam_answer"]) && trim($_POST["gwolle_gb_antispam_answer"]) == trim($antispam_answer)) {
                    //echo "You got it!";
                } else {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'antispam';
                    // mandatory
                }
            }
            if (isset($_POST["gwolle_gb_antispam_answer"])) {
                $gwolle_gb_data['antispam'] = trim($_POST['gwolle_gb_antispam_answer']);
            }
        }
        /* CAPTCHA */
        if (isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled'] === 'true') {
            if (class_exists('ReallySimpleCaptcha')) {
                $gwolle_gb_captcha = new ReallySimpleCaptcha();
                // This variable holds the CAPTCHA image prefix, which corresponds to the correct answer
                $gwolle_gb_captcha_prefix = $_POST['gwolle_gb_captcha_prefix'];
                // This variable holds the CAPTCHA response, entered by the user
                $gwolle_gb_captcha_code = $_POST['gwolle_gb_captcha_code'];
                // Validate the CAPTCHA response
                $gwolle_gb_captcha_correct = $gwolle_gb_captcha->check($gwolle_gb_captcha_prefix, $gwolle_gb_captcha_code);
                // If CAPTCHA validation fails (incorrect value entered in CAPTCHA field) mark comment as spam.
                if (true != $gwolle_gb_captcha_correct) {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'captcha';
                    // mandatory
                    //$gwolle_gb_messages .= '<p style="display_:none"><strong>' . $gwolle_gb_captcha_correct . '</strong></p>';
                } else {
                    // verified!
                    //$gwolle_gb_messages .= '<p class="error_fields"><strong>Verified.</strong></p>';
                }
                // clean up the tmp directory
                $gwolle_gb_captcha->remove($gwolle_gb_captcha_prefix);
                $gwolle_gb_captcha->cleanup();
            }
        }
        /* If there are errors, stop here and return false */
        if (is_array($gwolle_gb_error_fields) && !empty($gwolle_gb_error_fields)) {
            // There was no data filled in, even though that was mandatory.
            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('There were errors submitting your guestbook entry.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
            if (isset($gwolle_gb_error_fields)) {
                foreach ($gwolle_gb_error_fields as $field) {
                    switch ($field) {
                        case 'name':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your name is not filled in, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                        case 'author_origin':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your origin is not filled in, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                        case 'author_email':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your e-mail address is not filled in correctly, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                        case 'author_website':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your website is not filled in, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                        case 'content':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('There is no message, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                        case 'antispam':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('The anti-spam question was not answered correctly, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                        case 'captcha':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('The CAPTCHA was not filled in correctly, even though it is mandatory.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                            break;
                    }
                }
            }
            $gwolle_gb_messages .= '<p class="error_fields" style="display: none;">' . print_r($gwolle_gb_error_fields, true) . '</p>';
            return false;
            // no need to check and save
        }
        /* New Instance of gwolle_gb_entry. */
        $entry = new gwolle_gb_entry();
        /* Set the data in the instance */
        $set_data = $entry->set_data($gwolle_gb_data);
        if (!$set_data) {
            // Data is not set in the Instance, something happened
            $gwolle_gb_errors = true;
            $gwolle_gb_messages .= '<p class="set_data"><strong>' . __('There were errors submitting your guestbook entry.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
            return false;
        }
        /* Check for spam and set accordingly */
        $isspam = gwolle_gb_akismet($entry, 'comment-check');
        if ($isspam) {
            // Returned true, so considered spam
            $entry->set_isspam(true);
            // Is it wise to make them any wiser? Probably not...
            // $gwolle_gb_messages .= '<p><strong>' . __('Your guestbook entry is probably spam. A moderator will decide upon it.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
        }
        /* if Moderation is off, set it to "ischecked" */
        $user_id = get_current_user_id();
        // returns 0 if no current user
        if (get_option('gwolle_gb-moderate-entries', 'true') == 'true') {
            if (gwolle_gb_is_moderator($user_id)) {
                $entry->set_ischecked(true);
            } else {
                $entry->set_ischecked(false);
            }
        } else {
            // First set to checked
            $entry->set_ischecked(true);
            // Check for abusive content (too long words). Set it to unchecked, so manual moderation is needed.
            $maxlength = 100;
            $words = explode(" ", $entry->get_content());
            foreach ($words as $word) {
                if (strlen($word) > $maxlength) {
                    $entry->set_ischecked(false);
                    break;
                }
            }
            $maxlength = 60;
            $words = explode(" ", $entry->get_author_name());
            foreach ($words as $word) {
                if (strlen($word) > $maxlength) {
                    $entry->set_ischecked(false);
                    break;
                }
            }
        }
        /* Check for logged in user, and set the userid as author_id, just in case someone is also admin, or gets promoted some day */
        $entry->set_author_id($user_id);
        /*
         * Network Information
         */
        $entry->set_author_ip($_SERVER['REMOTE_ADDR']);
        $entry->set_author_host(gethostbyaddr($_SERVER['REMOTE_ADDR']));
        /*
         * Check for double post using email field and content.
         * Only if content is mandatory.
         */
        if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
            $entries = gwolle_gb_get_entries(array('email' => $entry->get_author_email()));
            if (is_array($entries) && !empty($entries)) {
                foreach ($entries as $entry_email) {
                    if ($entry_email->get_content() == $entry->get_content()) {
                        // Match is double entry
                        $gwolle_gb_errors = true;
                        $gwolle_gb_messages .= '<p class="double_post"><strong>' . __('Double post: An entry with the data you entered has already been saved.', GWOLLE_GB_TEXTDOMAIN) . '</strong></p>';
                        return false;
                    }
                }
            }
        }
        /*
         * Save the Entry
         */
        // $save = ""; // Testing mode
        $save = $entry->save();
        //if ( WP_DEBUG ) { echo "save: "; var_dump($save); }
        if ($save) {
            // We have been saved to the Database
            $gwolle_gb_messages .= '<p class="entry_saved">' . __('Thank you for your entry.', GWOLLE_GB_TEXTDOMAIN) . '</p>';
            if ($entry->get_ischecked() == 0) {
                $gwolle_gb_messages .= '<p>' . __('We will review it and unlock it in a short while.', GWOLLE_GB_TEXTDOMAIN) . '</p>';
            }
        }
        /*
         * Update Cache plugins
         */
        if ($entry->get_ischecked() == 1) {
            gwolle_gb_clear_cache();
        }
        /*
         * Send the Notification Mail to moderators that have subscribed (only when it is not Spam)
         */
        if (!$isspam) {
            $subscribers = array();
            $recipients = get_option('gwolle_gb-notifyByMail', array());
            if (count($recipients) > 0) {
                $recipients = explode(",", $recipients);
                foreach ($recipients as $recipient) {
                    if (is_numeric($recipient)) {
                        $userdata = get_userdata($recipient);
                        $subscribers[] = $userdata->user_email;
                    }
                }
            }
            @ini_set('sendmail_from', get_bloginfo('admin_mail'));
            // Set the Mail Content
            $mailTags = array('user_email', 'user_name', 'status', 'entry_management_url', 'blog_name', 'blog_url', 'wp_admin_url', 'entry_content', 'author_ip');
            $mail_body = gwolle_gb_sanitize_output(get_option('gwolle_gb-adminMailContent', false));
            if (!$mail_body) {
                $mail_body = __("\nHello,\n\nThere is a new guestbook entry at '%blog_name%'.\nYou can check it at %entry_management_url%.\n\nHave a nice day.\nYour Gwolle-GB-Mailer\n\n\nWebsite address: %blog_url%\nUser name: %user_name%\nUser email: %user_email%\nEntry status: %status%\nEntry content:\n%entry_content%\n", GWOLLE_GB_TEXTDOMAIN);
            }
            // Set the Mail Headers
            $subject = '[' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . '] ' . __('New Guestbook Entry', GWOLLE_GB_TEXTDOMAIN);
            $header = "";
            if (get_option('gwolle_gb-mail-from', false)) {
                $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . get_option('gwolle_gb-mail-from') . ">\r\n";
            } else {
                $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . get_bloginfo('admin_email') . ">\r\n";
            }
            $header .= "Content-Type: text/plain; charset=UTF-8\r\n";
            // Encoding of the mail
            // Replace the tags from the mailtemplate with real data from the website and entry
            $info['user_name'] = gwolle_gb_sanitize_output($entry->get_author_name());
            $info['user_email'] = $entry->get_author_email();
            $info['blog_name'] = get_bloginfo('name');
            $info['blog_url'] = get_bloginfo('wpurl');
            $info['wp_admin_url'] = $info['blog_url'] . '/wp-admin';
            $info['entry_management_url'] = $info['wp_admin_url'] . '/admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id();
            $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output($entry->get_content()));
            $info['author_ip'] = $_SERVER['REMOTE_ADDR'];
            if ($entry->get_ischecked()) {
                $info['status'] = __('Checked', GWOLLE_GB_TEXTDOMAIN);
            } else {
                $info['status'] = __('Unchecked', GWOLLE_GB_TEXTDOMAIN);
            }
            // The last tags are bloginfo-based
            for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
                $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
                $mail_body = gwolle_gb_format_values_for_mail($mail_body);
            }
            if (is_array($subscribers) && !empty($subscribers)) {
                foreach ($subscribers as $subscriber) {
                    wp_mail($subscriber, $subject, $mail_body, $header);
                }
            }
        }
        /*
         * Send Notification Mail to the author if set to true in an option
         */
        if (!$isspam) {
            if (get_option('gwolle_gb-mail_author', 'false') == 'true') {
                // Set the Mail Content
                $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content');
                $mail_body = gwolle_gb_sanitize_output(get_option('gwolle_gb-authorMailContent', false));
                if (!$mail_body) {
                    $mail_body = __("\nHello,\n\nYou have just posted a new guestbook entry at '%blog_name%'.\n\nHave a nice day.\nThe editors at %blog_name%.\n\n\nWebsite address: %blog_url%\nUser name: %user_name%\nUser email: %user_email%\nEntry content:\n%entry_content%\n", GWOLLE_GB_TEXTDOMAIN);
                }
                // Set the Mail Headers
                $subject = '[' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . '] ' . __('New Guestbook Entry', GWOLLE_GB_TEXTDOMAIN);
                $header = "";
                if (get_option('gwolle_gb-mail-from', false)) {
                    $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . gwolle_gb_sanitize_output(get_option('gwolle_gb-mail-from')) . ">\r\n";
                } else {
                    $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . get_bloginfo('admin_email') . ">\r\n";
                }
                $header .= "Content-Type: text/plain; charset=UTF-8\r\n";
                // Encoding of the mail
                // Replace the tags from the mailtemplate with real data from the website and entry
                $info['user_name'] = gwolle_gb_sanitize_output($entry->get_author_name());
                $info['user_email'] = $entry->get_author_email();
                $info['blog_name'] = get_bloginfo('name');
                $info['blog_url'] = get_bloginfo('wpurl');
                $info['entry_content'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output($entry->get_content()));
                for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
                    $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
                    $mail_body = gwolle_gb_format_values_for_mail($mail_body);
                }
                wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
            }
        }
        /*
         * No Log for the Entry needed, it has a default post date in the Entry itself.
         */
    }
}
예제 #5
0
function gwolle_gb_frontend_write()
{
    global $gwolle_gb_errors, $gwolle_gb_error_fields, $gwolle_gb_messages, $gwolle_gb_data;
    $output = '';
    // Set data up for refilling an already submitted form that had errors
    $name = '';
    $origin = '';
    $email = '';
    $website = '';
    $antispam = '';
    $content = '';
    // Auto-fill the form if the user is already logged in
    $user_id = get_current_user_id();
    // returns 0 if no current user
    if ($user_id > 0) {
        $userdata = get_userdata($user_id);
        if (is_object($userdata)) {
            if (isset($userdata->display_name)) {
                $name = $userdata->display_name;
            } else {
                $name = $userdata->user_login;
            }
            $email = $userdata->user_email;
            $website = $userdata->user_url;
        }
    }
    // Only show old data when there are errors
    if ($gwolle_gb_errors) {
        if (is_array($gwolle_gb_data) && !empty($gwolle_gb_data)) {
            if (isset($gwolle_gb_data['author_name'])) {
                $name = stripslashes($gwolle_gb_data['author_name']);
            }
            if (isset($gwolle_gb_data['author_origin'])) {
                $origin = stripslashes($gwolle_gb_data['author_origin']);
            }
            if (isset($gwolle_gb_data['author_email'])) {
                $email = stripslashes($gwolle_gb_data['author_email']);
            }
            if (isset($gwolle_gb_data['author_website'])) {
                $website = stripslashes($gwolle_gb_data['author_website']);
            }
            if (isset($gwolle_gb_data['antispam'])) {
                $antispam = stripslashes($gwolle_gb_data['antispam']);
            }
            if (isset($gwolle_gb_data['content'])) {
                $content = stripslashes($gwolle_gb_data['content']);
            }
        }
    }
    // Initialize errors, if not set
    if (empty($gwolle_gb_error_fields)) {
        $gwolle_gb_error_fields = array();
    }
    /*
     * Handle Messaging to the user
     */
    $class = "";
    if ($gwolle_gb_errors) {
        $class = "error";
    }
    if (isset($gwolle_gb_messages) && $gwolle_gb_messages != '') {
        $output .= "<div id='gwolle_gb_messages' class='{$class}'>";
        $output .= $gwolle_gb_messages;
        $output .= "</div>";
    }
    /*
     * Button 'write a new entry.'
     */
    $output .= '
		<div id="gwolle_gb_write_button">
			<input type="button" value="&raquo; ' . esc_attr__('Write a new entry.', GWOLLE_GB_TEXTDOMAIN) . '" />
		</div>';
    // Option to allow only logged-in users to post. Don't show the form if not logged-in. We still see the messages above.
    if (!is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true') {
        $output .= '
			<div id="gwolle_gb_new_entry">
				<h3>' . __('Log in to post an entry', GWOLLE_GB_TEXTDOMAIN) . '</h3>';
        $args = array('echo' => false, 'redirect' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
        $output .= wp_login_form($args);
        $output .= wp_register('', '', false);
        $output .= '</div>';
        return $output;
    }
    /*
     * Build up Form including possible error_fields
     */
    $form_setting = gwolle_gb_get_setting('form');
    $autofocus = 'autofocus="autofocus"';
    // Form for submitting new entries
    $header = gwolle_gb_sanitize_output(get_option('gwolle_gb-header', false));
    if ($header == false) {
        $header = __('Write a new entry for the Guestbook', GWOLLE_GB_TEXTDOMAIN);
    }
    $output .= '
		<form id="gwolle_gb_new_entry" action="#" method="POST">
			<h3>' . $header . '</h3>
			<input type="hidden" name="gwolle_gb_function" value="add_entry" />';
    /* Name */
    if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_name">
				<div class="label"><label for="gwolle_gb_author_name">' . __('Name', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('name', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $name . '" type="text" name="gwolle_gb_author_name" id="gwolle_gb_author_name" placeholder="' . __('Name', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('name', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* City / Origin */
    if (isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_origin">
					<div class="label"><label for="gwolle_gb_author_origin">' . __('City', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
					<div class="input"><input class="';
        if (in_array('author_origin', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $origin . '" type="text" name="gwolle_gb_author_origin" id="gwolle_gb_author_origin" placeholder="' . __('City', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('author_origin', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
				</div>
				<div class="clearBoth">&nbsp;</div>';
    }
    /* Email */
    if (isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_email">
				<div class="label"><label for="gwolle_gb_author_email">' . __('Email', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('author_email', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $email . '" type="text" name="gwolle_gb_author_email" id="gwolle_gb_author_email" placeholder="' . __('Email', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('author_email', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Website / Homepage */
    if (isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_website">
				<div class="label"><label for="gwolle_gb_author_website">' . __('Website', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('author_website', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $website . '" type="text" name="gwolle_gb_author_website" id="gwolle_gb_author_website" placeholder="' . __('Website', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('author_website', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Content */
    if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_content">
				<div class="label"><label for="gwolle_gb_content">' . __('Guestbook entry', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><textarea name="gwolle_gb_content" id="gwolle_gb_content" class="';
        if (in_array('content', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" placeholder="' . __('Message', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('content', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' >' . $content . '</textarea>';
        if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
            // BBcode and MarkItUp
            wp_enqueue_script('markitup', plugins_url('markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_script('markitup_set', plugins_url('markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
            // Emoji symbols
            $output .= '<div class="gwolle_gb_emoji" style="display:none;">';
            $output .= gwolle_gb_get_emoji();
            $output .= '</div>';
        }
        $output .= '</div>';
        // .input
        $output .= '
				</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Custom Anti-Spam */
    if (isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true') {
        $antispam_question = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-question'));
        $antispam_answer = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-answer'));
        if (isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0) {
            $output .= '
				<div class="gwolle_gb_antispam">
					<div class="label">
						<label for="gwolle_gb_antispam_answer">' . __('Anti-spam', GWOLLE_GB_TEXTDOMAIN) . ': *<br />
						' . __('Question:', GWOLLE_GB_TEXTDOMAIN) . " " . $antispam_question . '</label>
					</div>
					<div class="input"><input class="';
            if (in_array('antispam', $gwolle_gb_error_fields)) {
                $output .= ' error';
            }
            $output .= '" value="' . $antispam . '" type="text" name="gwolle_gb_antispam_answer" id="gwolle_gb_antispam_answer" placeholder="' . __('Answer', GWOLLE_GB_TEXTDOMAIN) . '" ';
            if (in_array('antispam', $gwolle_gb_error_fields) && isset($autofocus)) {
                $output .= $autofocus;
                $autofocus = false;
                // disable it for the next error.
            }
            $output .= ' />
						</div>
					</div>
					<div class="clearBoth">&nbsp;</div>';
        }
    }
    /* CAPTCHA */
    if (isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled'] === 'true') {
        if (class_exists('ReallySimpleCaptcha')) {
            // Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
            $gwolle_gb_captcha = new ReallySimpleCaptcha();
            // Set Really Simple CAPTCHA Options
            $gwolle_gb_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
            $gwolle_gb_captcha->char_length = '4';
            $gwolle_gb_captcha->img_size = array('72', '24');
            $gwolle_gb_captcha->fg = array('0', '0', '0');
            $gwolle_gb_captcha->bg = array('255', '255', '255');
            $gwolle_gb_captcha->font_size = '16';
            $gwolle_gb_captcha->font_char_width = '15';
            $gwolle_gb_captcha->img_type = 'png';
            $gwolle_gb_captcha->base = array('6', '18');
            // Generate random word and image prefix
            $gwolle_gb_captcha_word = $gwolle_gb_captcha->generate_random_word();
            $gwolle_gb_captcha_prefix = mt_rand();
            // Generate CAPTCHA image
            $gwolle_gb_captcha_image_name = $gwolle_gb_captcha->generate_image($gwolle_gb_captcha_prefix, $gwolle_gb_captcha_word);
            // Define values for CAPTCHA fields
            $gwolle_gb_captcha_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
            $gwolle_gb_captcha_image_src = $gwolle_gb_captcha_image_url . $gwolle_gb_captcha_image_name;
            $gwolle_gb_captcha_image_width = $gwolle_gb_captcha->img_size[0];
            $gwolle_gb_captcha_image_height = $gwolle_gb_captcha->img_size[1];
            $gwolle_gb_captcha_field_size = $gwolle_gb_captcha->char_length;
            // AJAX url
            $gwolle_gb_captcha_ajax_url = GWOLLE_GB_URL . '/frontend/captcha/ajaxresponse.php';
            // ABSPATH
            $gwolle_gb_abspath = urlencode(ABSPATH);
            // Output the CAPTCHA fields
            ?>
			<script>
			function gwolle_gb_captcha_check( code, prefix, url, abspath ) {
				// Setup variables
				var code_string = '?code=' + code;
				var prefix_string = '&prefix=' + prefix;
				var abspath_string = '&abspath=' + abspath;
				var request_url_base = url;
				var request_url = request_url_base + code_string + prefix_string + abspath_string;

				// Instantiate request
				var xmlhttp = new XMLHttpRequest();

				// Parse resonse
				xmlhttp.onreadystatechange = function() {
					if ( 4 == xmlhttp.readyState && 200 == xmlhttp.status ) {
						var ajax_response = xmlhttp.responseText;

						// Update form verification feedback
						if ( 'true' == ajax_response ) {
							document.getElementById( 'gwolle_gb_captcha_verify' ).innerHTML = '<span style="color:green"><?php 
            _e('Correct CAPTCHA value.', GWOLLE_GB_TEXTDOMAIN);
            ?>
</span>';
							jQuery( '#gwolle_gb_captcha_code' ).removeClass('error');
						} else if ( 'false' == ajax_response ) {
							document.getElementById( 'gwolle_gb_captcha_verify' ).innerHTML = '<span style="color:red"><?php 
            _e('Incorrect CAPTCHA value.', GWOLLE_GB_TEXTDOMAIN);
            ?>
</span>';
							jQuery( '#gwolle_gb_captcha_code' ).addClass('error');
						}
					}
				}
				// Send request
				xmlhttp.open( 'GET', request_url, true );
				xmlhttp.send();
			}
			</script>

			<?php 
            $output .= '
				<div class="gwolle_gb_captcha">
					<div class="label">
						<label for="gwolle_gb_captcha_code">' . __('Anti-spam', GWOLLE_GB_TEXTDOMAIN) . ': *<br />
						<img src="' . $gwolle_gb_captcha_image_src . '" alt="captcha" width="' . $gwolle_gb_captcha_image_width . '" height="' . $gwolle_gb_captcha_image_height . '" />
						</label>
					</div>
					<div class="input">
					<input class="';
            if (in_array('captcha', $gwolle_gb_error_fields)) {
                $output .= 'error';
            }
            $output .= '" value="" type="text" name="gwolle_gb_captcha_code" id="gwolle_gb_captcha_code" placeholder="' . __('CAPTCHA', GWOLLE_GB_TEXTDOMAIN) . '" onblur="gwolle_gb_captcha_check( this.value, \'' . $gwolle_gb_captcha_prefix . '\', \'' . $gwolle_gb_captcha_ajax_url . '\', \'' . $gwolle_gb_abspath . '\' )" ';
            if (in_array('captcha', $gwolle_gb_error_fields) && isset($autofocus)) {
                $output .= $autofocus;
                $autofocus = false;
                // disable it for the next error.
            }
            $output .= ' />
							<input type="hidden" name="gwolle_gb_captcha_prefix" id="gwolle_gb_captcha_prefix" value="' . $gwolle_gb_captcha_prefix . '" />
							<span id="gwolle_gb_captcha_verify"></span>
						</div>
					</div>
					<div class="clearBoth">&nbsp;</div>';
        }
    }
    $output .= '
			<div class="gwolle_gb_submit">
				<div class="label">&nbsp;</div>
				<div class="input"><input type="submit" name="gwolle_gb_submit" value="' . esc_attr__('Submit', GWOLLE_GB_TEXTDOMAIN) . '" /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>

			<div class="gwolle_gb_notice">
				';
    $notice = gwolle_gb_sanitize_output(get_option('gwolle_gb-notice', false));
    if ($notice == false) {
        // No text set by the user. Use the default text.
        $notice = __('
Fields marked with * are obligatory.
Your E-mail address wil not be published.
For security reasons we save the ip address %ip%.
It might be that your entry will only be visible in the guestbook after we reviewed it.
We reserve our right to edit, delete, or not publish entries.
', GWOLLE_GB_TEXTDOMAIN);
    }
    $notice = nl2br($notice);
    $output .= str_replace('%ip%', $_SERVER['REMOTE_ADDR'], $notice);
    $output .= '
			</div>
		</form>';
    if (get_option('gwolle_gb-labels_float', 'true') === 'true') {
        $output .= '
		<style type="text/css" scoped>
			#gwolle_gb .label,
			#gwolle_gb .input {
				float: left;
			}
		</style>
		';
    }
    // Add filter for the form, so devs can manipulate it.
    $output = apply_filters('gwolle_gb_write', $output);
    return $output;
}
예제 #6
0
function gwolle_gb_page_settings()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('Cheatin&#8217; uh?', 'gwolle-gb'));
    }
    if (!get_option('gwolle_gb_version')) {
        // FIXME: do this on activation
        gwolle_gb_installSplash();
    } else {
        $active_tab = "gwolle_gb_forms";
        $saved = false;
        $uninstalled = false;
        //if ( WP_DEBUG ) { echo "_POST: "; var_dump($_POST); }
        if (isset($_POST['option_page']) && $_POST['option_page'] == 'gwolle_gb_options') {
            if (isset($_POST['gwolle_gb_tab'])) {
                $active_tab = $_POST['gwolle_gb_tab'];
                switch ($active_tab) {
                    case 'gwolle_gb_forms':
                        /* Form Settings */
                        if (isset($_POST['require_login']) && $_POST['require_login'] == 'on') {
                            update_option('gwolle_gb-require_login', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-require_login', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['labels_float']) && $_POST['labels_float'] == 'on') {
                            update_option('gwolle_gb-labels_float', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-labels_float', 'false');
                            $saved = true;
                        }
                        // Always save it, even when empty, for MultiLingual plugins.
                        $header = gwolle_gb_sanitize_input($_POST['header']);
                        update_option('gwolle_gb-header', $header);
                        $saved = true;
                        $notice = gwolle_gb_sanitize_input($_POST['notice']);
                        update_option('gwolle_gb-notice', $notice);
                        $saved = true;
                        $list = array('form_name_enabled', 'form_name_mandatory', 'form_city_enabled', 'form_city_mandatory', 'form_email_enabled', 'form_email_mandatory', 'form_homepage_enabled', 'form_homepage_mandatory', 'form_message_enabled', 'form_message_mandatory', 'form_bbcode_enabled', 'form_antispam_enabled', 'form_recaptcha_enabled');
                        $form_setting = array();
                        foreach ($list as $item) {
                            if (isset($_POST[$item]) && $_POST[$item] == 'on') {
                                $form_setting[$item] = 'true';
                            } else {
                                $form_setting[$item] = 'false';
                            }
                        }
                        $form_setting = serialize($form_setting);
                        update_option('gwolle_gb-form', $form_setting);
                        $saved = true;
                        break;
                    case 'gwolle_gb_reading':
                        /* Reading Settings */
                        if (isset($_POST['entriesPerPage']) && is_numeric($_POST['entriesPerPage']) && $_POST['entriesPerPage'] > 0) {
                            update_option('gwolle_gb-entriesPerPage', (int) $_POST['entriesPerPage']);
                            $saved = true;
                        }
                        if (isset($_POST['showLineBreaks']) && $_POST['showLineBreaks'] == 'on') {
                            update_option('gwolle_gb-showLineBreaks', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-showLineBreaks', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['excerpt_length']) && is_numeric($_POST['excerpt_length'])) {
                            update_option('gwolle_gb-excerpt_length', (int) $_POST['excerpt_length']);
                            if ($_POST['excerpt_length'] > 0) {
                                // Will not be shown anyway with wp_trim_words()
                                update_option('gwolle_gb-showLineBreaks', 'false');
                            }
                            $saved = true;
                        }
                        if (isset($_POST['showSmilies']) && $_POST['showSmilies'] == 'on') {
                            update_option('gwolle_gb-showSmilies', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-showSmilies', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['linkAuthorWebsite']) && $_POST['linkAuthorWebsite'] == 'on') {
                            update_option('gwolle_gb-linkAuthorWebsite', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-linkAuthorWebsite', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['admin_style']) && $_POST['admin_style'] == 'on') {
                            update_option('gwolle_gb-admin_style', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-admin_style', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['paginate_all']) && $_POST['paginate_all'] == 'on') {
                            update_option('gwolle_gb-paginate_all', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-paginate_all', 'false');
                            $saved = true;
                        }
                        $list = array('read_avatar', 'read_name', 'read_city', 'read_datetime', 'read_date', 'read_content', 'read_editlink');
                        $read_setting = array();
                        foreach ($list as $item) {
                            if (isset($_POST[$item]) && $_POST[$item] == 'on') {
                                $read_setting[$item] = 'true';
                            } else {
                                $read_setting[$item] = 'false';
                            }
                        }
                        $read_setting = serialize($read_setting);
                        update_option('gwolle_gb-read', $read_setting);
                        $saved = true;
                        break;
                    case 'gwolle_gb_admin':
                        /* Admin Settings */
                        if (isset($_POST['entries_per_page']) && is_numeric($_POST['entries_per_page']) && $_POST['entries_per_page'] > 0) {
                            update_option('gwolle_gb-entries_per_page', (int) $_POST['entries_per_page']);
                            $saved = true;
                        }
                        if (isset($_POST['showEntryIcons']) && $_POST['showEntryIcons'] == 'on') {
                            update_option('gwolle_gb-showEntryIcons', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-showEntryIcons', 'false');
                            $saved = true;
                        }
                        break;
                    case 'gwolle_gb_antispam':
                        /* Anti-Spam Settings */
                        if (isset($_POST['moderate-entries']) && $_POST['moderate-entries'] == 'on') {
                            update_option('gwolle_gb-moderate-entries', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-moderate-entries', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['akismet-active']) && $_POST['akismet-active'] == 'on') {
                            update_option('gwolle_gb-akismet-active', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-akismet-active', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['antispam-question'])) {
                            update_option('gwolle_gb-antispam-question', gwolle_gb_sanitize_input($_POST['antispam-question']));
                            $saved = true;
                        }
                        if (isset($_POST['antispam-answer'])) {
                            update_option('gwolle_gb-antispam-answer', gwolle_gb_sanitize_input($_POST['antispam-answer']));
                            $saved = true;
                        }
                        break;
                    case 'gwolle_gb_mail':
                        /* Mail Settings */
                        if (isset($_POST['admin_mail_from']) && $_POST['admin_mail_from'] != gwolle_gb_sanitize_output(get_option('gwolle_gb-mail-from'))) {
                            $admin_mail_from = gwolle_gb_sanitize_input($_POST['admin_mail_from']);
                            if (filter_var($admin_mail_from, FILTER_VALIDATE_EMAIL)) {
                                // Valid Email address.
                                update_option('gwolle_gb-mail-from', $admin_mail_from);
                                $saved = true;
                            }
                        }
                        if (isset($_POST['unsubscribe']) && $_POST['unsubscribe'] > 0) {
                            $user_id = (int) $_POST['unsubscribe'];
                            $user_ids = array();
                            $user_ids_old = get_option('gwolle_gb-notifyByMail');
                            if (strlen($user_ids_old) > 0) {
                                $user_ids_old = explode(",", $user_ids_old);
                                foreach ($user_ids_old as $user_id_old) {
                                    if ($user_id_old == $user_id) {
                                        continue;
                                    }
                                    if (is_numeric($user_id_old)) {
                                        $user_ids[] = $user_id_old;
                                    }
                                }
                            }
                            $user_ids = implode(",", $user_ids);
                            update_option('gwolle_gb-notifyByMail', $user_ids);
                            $saved = true;
                        }
                        if (isset($_POST['subscribe']) && $_POST['subscribe'] > 0) {
                            $user_id = (int) $_POST['subscribe'];
                            $user_ids = array();
                            $user_ids_old = get_option('gwolle_gb-notifyByMail');
                            if (strlen($user_ids_old) > 0) {
                                $user_ids_old = explode(",", $user_ids_old);
                                foreach ($user_ids_old as $user_id_old) {
                                    if ($user_id_old == $user_id) {
                                        continue;
                                        // will be added again below the loop
                                    }
                                    if (is_numeric($user_id_old)) {
                                        $user_ids[] = $user_id_old;
                                    }
                                }
                            }
                            $user_ids[] = $user_id;
                            // Really add it.
                            $user_ids = implode(",", $user_ids);
                            update_option('gwolle_gb-notifyByMail', $user_ids);
                            $saved = true;
                        }
                        if (isset($_POST['adminMailContent'])) {
                            $mail_content = gwolle_gb_sanitize_input($_POST['adminMailContent']);
                            update_option('gwolle_gb-adminMailContent', $mail_content);
                            $saved = true;
                        }
                        if (isset($_POST['mail_author']) && $_POST['mail_author'] == 'on') {
                            update_option('gwolle_gb-mail_author', 'true');
                            $saved = true;
                        } else {
                            update_option('gwolle_gb-mail_author', 'false');
                            $saved = true;
                        }
                        if (isset($_POST['authorMailContent'])) {
                            $mail_content = gwolle_gb_sanitize_input($_POST['authorMailContent']);
                            update_option('gwolle_gb-authorMailContent', $mail_content);
                            $saved = true;
                        }
                        if (isset($_POST['gwolle_gb-mail_admin_replyContent'])) {
                            $mail_content = gwolle_gb_sanitize_input($_POST['gwolle_gb-mail_admin_replyContent']);
                            update_option('gwolle_gb-mail_admin_replyContent', $mail_content);
                            $saved = true;
                        }
                        break;
                    case 'gwolle_gb_uninstall':
                        /* Uninstall */
                        if (isset($_POST['gwolle_gb_uninstall_confirmed']) && $_POST['gwolle_gb_uninstall_confirmed'] == 'on') {
                            // uninstall the plugin -> delete all tables and preferences of the plugin
                            gwolle_gb_uninstall();
                            $uninstalled = true;
                        } else {
                            // Uninstallation not confirmed.
                        }
                        break;
                    default:
                        /* Just load the first tab */
                        $active_tab = "gwolle_gb_forms";
                }
            }
        }
        ?>

		<div class="wrap gwolle_gb">

			<div id="icon-gwolle-gb"><br /></div>
			<h1><?php 
        _e('Settings', 'gwolle-gb');
        ?>
</h1>

			<?php 
        if ($saved) {
            echo '
					<div id="message" class="updated fade notice is-dismissible">
						<p>' . __('Changes saved.', 'gwolle-gb') . '</p>
					</div>';
        }
        ?>

			<?php 
        /* The rel attribute will be the form that becomes active */
        ?>
			<h2 class="nav-tab-wrapper gwolle-nav-tab-wrapper">
				<a href="#" class="nav-tab <?php 
        if ($active_tab == 'gwolle_gb_forms') {
            echo "nav-tab-active";
        }
        ?>
" rel="gwolle_gb_forms"><?php 
        _e('Form', 'gwolle-gb');
        ?>
</a>
				<a href="#" class="nav-tab <?php 
        if ($active_tab == 'gwolle_gb_reading') {
            echo "nav-tab-active";
        }
        ?>
" rel="gwolle_gb_reading"><?php 
        _e('Reading', 'gwolle-gb');
        ?>
</a>
				<a href="#" class="nav-tab <?php 
        if ($active_tab == 'gwolle_gb_admin') {
            echo "nav-tab-active";
        }
        ?>
" rel="gwolle_gb_admin"><?php 
        _e('Admin', 'gwolle-gb');
        ?>
</a>
				<a href="#" class="nav-tab <?php 
        if ($active_tab == 'gwolle_gb_antispam') {
            echo "nav-tab-active";
        }
        ?>
" rel="gwolle_gb_antispam"><?php 
        _e('Anti-spam', 'gwolle-gb');
        ?>
</a>
				<a href="#" class="nav-tab <?php 
        if ($active_tab == 'gwolle_gb_mail') {
            echo "nav-tab-active";
        }
        ?>
" rel="gwolle_gb_mail"><?php 
        _e('E-mail', 'gwolle-gb');
        ?>
</a>
				<a href="#" class="nav-tab <?php 
        if ($active_tab == 'gwolle_gb_uninstall') {
            echo "nav-tab-active";
        }
        ?>
" rel="gwolle_gb_uninstall"><?php 
        _e('Uninstall', 'gwolle-gb');
        ?>
</a>
			</h2>


			<form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_forms <?php 
        if ($active_tab == 'gwolle_gb_forms') {
            echo "active";
        }
        ?>
" method="post" action="">
				<?php 
        gwolle_gb_page_settingstab_form();
        ?>
			</form>


			<form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_reading <?php 
        if ($active_tab == 'gwolle_gb_reading') {
            echo "active";
        }
        ?>
" method="post" action="">
				<?php 
        gwolle_gb_page_settingstab_reading();
        ?>
			</form>


			<form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_admin <?php 
        if ($active_tab == 'gwolle_gb_admin') {
            echo "active";
        }
        ?>
" method="post" action="">
				<?php 
        gwolle_gb_page_settingstab_admin();
        ?>
			</form>


			<form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_antispam <?php 
        if ($active_tab == 'gwolle_gb_antispam') {
            echo "active";
        }
        ?>
" method="post" action="">
				<?php 
        gwolle_gb_page_settingstab_antispam();
        ?>
			</form>


			<form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_mail <?php 
        if ($active_tab == 'gwolle_gb_mail') {
            echo "active";
        }
        ?>
" method="post" action="">
				<?php 
        gwolle_gb_page_settingstab_email();
        ?>
			</form>


			<form name="gwolle_gb_options" class="gwolle_gb_options gwolle_gb_uninstall <?php 
        if ($active_tab == 'gwolle_gb_uninstall') {
            echo "active";
        }
        ?>
" method="post" action="">
				<?php 
        gwolle_gb_page_settingstab_uninstall($uninstalled);
        ?>
			</form>

		</div> <!-- wrap -->
		<?php 
    }
}
예제 #7
0
function gwolle_gb_frontend_posthandling()
{
    global $wpdb, $gwolle_gb_errors, $gwolle_gb_error_fields, $gwolle_gb_messages, $gwolle_gb_data;
    /*
     * Handle $_POST and check and save entry.
     */
    if (isset($_POST['gwolle_gb_function']) && $_POST['gwolle_gb_function'] == 'add_entry') {
        // Initialize errors
        $gwolle_gb_errors = false;
        $gwolle_gb_error_fields = array();
        // Initialize messages
        $gwolle_gb_messages = '';
        // Option to allow only logged-in users to post. Don't show the form if not logged-in.
        if (!is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true') {
            $gwolle_gb_errors = true;
            $gwolle_gb_messages .= '<p class="require_login"><strong>' . __('Submitting a new guestbook entry is only allowed for logged-in users.', 'gwolle-gb') . '</strong></p>';
            return;
        }
        /*
         * Collect data from the Form
         */
        $gwolle_gb_data = array();
        $form_setting = gwolle_gb_get_setting('form');
        /* Name */
        if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_name'])) {
                $gwolle_gb_data['author_name'] = trim($_POST['gwolle_gb_author_name']);
                $gwolle_gb_data['author_name'] = gwolle_gb_maybe_encode_emoji($gwolle_gb_data['author_name'], 'author_name');
                if ($gwolle_gb_data['author_name'] == "") {
                    if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'name';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'name';
                    // mandatory
                }
            }
        }
        /* City / Origin */
        if (isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_origin'])) {
                $gwolle_gb_data['author_origin'] = trim($_POST['gwolle_gb_author_origin']);
                $gwolle_gb_data['author_origin'] = gwolle_gb_maybe_encode_emoji($gwolle_gb_data['author_origin'], 'author_origin');
                if ($gwolle_gb_data['author_origin'] == "") {
                    if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'author_origin';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'author_origin';
                    // mandatory
                }
            }
        }
        /* Email */
        if (isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_email'])) {
                $gwolle_gb_data['author_email'] = trim($_POST['gwolle_gb_author_email']);
                if (filter_var($gwolle_gb_data['author_email'], FILTER_VALIDATE_EMAIL)) {
                    // Valid Email address.
                } else {
                    if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'author_email';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'author_email';
                    // mandatory
                }
            }
        } else {
            if (isset($_POST['gwolle_gb_author_email'])) {
                $gwolle_gb_data['author_email'] = trim($_POST['gwolle_gb_author_email']);
            }
        }
        /* Website / Homepage */
        if (isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_author_website'])) {
                $gwolle_gb_data['author_website'] = trim($_POST['gwolle_gb_author_website']);
                $pattern = '/^http/';
                if (!preg_match($pattern, $gwolle_gb_data['author_website'], $matches)) {
                    $gwolle_gb_data['author_website'] = "http://" . $gwolle_gb_data['author_website'];
                }
                if (filter_var($gwolle_gb_data['author_website'], FILTER_VALIDATE_URL)) {
                    // Valid Website URL.
                } else {
                    if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'author_website';
                        // mandatory
                    }
                }
            } else {
                if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'author_website';
                    // mandatory
                }
            }
        }
        /* Message */
        if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
            if (isset($_POST['gwolle_gb_content'])) {
                $gwolle_gb_data['content'] = trim($_POST['gwolle_gb_content']);
                if ($gwolle_gb_data['content'] == "") {
                    if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
                        $gwolle_gb_errors = true;
                        $gwolle_gb_error_fields[] = 'content';
                        // mandatory
                    }
                } else {
                    $gwolle_gb_data['content'] = gwolle_gb_maybe_encode_emoji($gwolle_gb_data['content'], 'content');
                }
            } else {
                if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'content';
                    // mandatory
                }
            }
        }
        /* Custom Anti-Spam */
        if (isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true') {
            $antispam_question = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-question'));
            $antispam_answer = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-answer'));
            if (isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0) {
                if (isset($_POST["gwolle_gb_antispam_answer"]) && trim($_POST["gwolle_gb_antispam_answer"]) == trim($antispam_answer)) {
                    //echo "You got it!";
                } else {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'antispam';
                    // mandatory
                }
            }
            if (isset($_POST["gwolle_gb_antispam_answer"])) {
                $gwolle_gb_data['antispam'] = trim($_POST['gwolle_gb_antispam_answer']);
            }
        }
        /* CAPTCHA */
        if (isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled'] === 'true') {
            if (class_exists('ReallySimpleCaptcha')) {
                $gwolle_gb_captcha = new ReallySimpleCaptcha();
                // This variable holds the CAPTCHA image prefix, which corresponds to the correct answer
                $gwolle_gb_captcha_prefix = $_POST['gwolle_gb_captcha_prefix'];
                // This variable holds the CAPTCHA response, entered by the user
                $gwolle_gb_captcha_code = $_POST['gwolle_gb_captcha_code'];
                // Validate the CAPTCHA response
                $gwolle_gb_captcha_correct = $gwolle_gb_captcha->check($gwolle_gb_captcha_prefix, $gwolle_gb_captcha_code);
                // If CAPTCHA validation fails (incorrect value entered in CAPTCHA field) mark comment as spam.
                if (true != $gwolle_gb_captcha_correct) {
                    $gwolle_gb_errors = true;
                    $gwolle_gb_error_fields[] = 'captcha';
                    // mandatory
                    //$gwolle_gb_messages .= '<p style="display_:none"><strong>' . $gwolle_gb_captcha_correct . '</strong></p>';
                } else {
                    // verified!
                    //$gwolle_gb_messages .= '<p class="error_fields"><strong>Verified.</strong></p>';
                }
                // clean up the tmp directory
                $gwolle_gb_captcha->remove($gwolle_gb_captcha_prefix);
                $gwolle_gb_captcha->cleanup();
            }
        }
        /* If there are errors, stop here and return false */
        if (is_array($gwolle_gb_error_fields) && !empty($gwolle_gb_error_fields)) {
            // There was no data filled in, even though that was mandatory.
            // $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('There were errors submitting your guestbook entry.', 'gwolle-gb') . '</strong></p>';
            if (isset($gwolle_gb_error_fields)) {
                foreach ($gwolle_gb_error_fields as $field) {
                    switch ($field) {
                        case 'name':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>Des mots aussi beaux, ça mérite une signature non ?</strong></p>';
                            break;
                        case 'author_origin':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your origin is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>';
                            break;
                        case 'author_email':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your e-mail address is not filled in correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>';
                            break;
                        case 'author_website':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('Your website is not filled in, even though it is mandatory.', 'gwolle-gb') . '</strong></p>';
                            break;
                        case 'content':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>Tu as oublié les mots doux ' . $gwolle_gb_data['author_name'] . ' :) !</strong></p>';
                            break;
                        case 'antispam':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('The anti-spam question was not answered correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>';
                            break;
                        case 'captcha':
                            $gwolle_gb_messages .= '<p class="error_fields"><strong>' . __('The CAPTCHA was not filled in correctly, even though it is mandatory.', 'gwolle-gb') . '</strong></p>';
                            break;
                    }
                }
            }
            $gwolle_gb_messages .= '<p class="error_fields" style="display: none;">' . print_r($gwolle_gb_error_fields, true) . '</p>';
            return false;
            // no need to check and save
        }
        /* New Instance of gwolle_gb_entry. */
        $entry = new gwolle_gb_entry();
        /* Set the data in the instance */
        $set_data = $entry->set_data($gwolle_gb_data);
        if (!$set_data) {
            // Data is not set in the Instance, something happened
            $gwolle_gb_errors = true;
            $gwolle_gb_messages .= '<p class="set_data"><strong>' . __('There were errors submitting your guestbook entry.', 'gwolle-gb') . '</strong></p>';
            return false;
        }
        /* Check for spam and set accordingly */
        $isspam = gwolle_gb_akismet($entry, 'comment-check');
        if ($isspam) {
            // Returned true, so considered spam
            $entry->set_isspam(true);
            // Is it wise to make them any wiser? Probably not...
            // $gwolle_gb_messages .= '<p><strong>' . __('Your guestbook entry is probably spam. A moderator will decide upon it.', 'gwolle-gb') . '</strong></p>';
        }
        /* if Moderation is off, set it to "ischecked" */
        $user_id = get_current_user_id();
        // returns 0 if no current user
        if (get_option('gwolle_gb-moderate-entries', 'true') == 'true') {
            if (gwolle_gb_is_moderator($user_id)) {
                $entry->set_ischecked(true);
            } else {
                $entry->set_ischecked(false);
            }
        } else {
            // First set to checked
            $entry->set_ischecked(true);
            // Check for abusive content (too long words). Set it to unchecked, so manual moderation is needed.
            $maxlength = 100;
            $words = explode(" ", $entry->get_content());
            foreach ($words as $word) {
                if (strlen($word) > $maxlength) {
                    $entry->set_ischecked(false);
                    break;
                }
            }
            $maxlength = 60;
            $words = explode(" ", $entry->get_author_name());
            foreach ($words as $word) {
                if (strlen($word) > $maxlength) {
                    $entry->set_ischecked(false);
                    break;
                }
            }
        }
        $entry->set_ischecked(false);
        /* Check for logged in user, and set the userid as author_id, just in case someone is also admin, or gets promoted some day */
        $entry->set_author_id($user_id);
        /*
         * Network Information
         */
        $entry->set_author_ip($_SERVER['REMOTE_ADDR']);
        $entry->set_author_host(gethostbyaddr($_SERVER['REMOTE_ADDR']));
        /*
         * Book ID
         */
        if (isset($_POST['gwolle_gb_book_id'])) {
            $gwolle_gb_data['book_id'] = (int) $_POST['gwolle_gb_book_id'];
        }
        if ($gwolle_gb_data['book_id'] < 1) {
            $gwolle_gb_data['book_id'] = 1;
        }
        $entry->set_book_id($gwolle_gb_data['book_id']);
        /*
         * Check for double post using email field and content.
         * Only if content is mandatory.
         */
        if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
            $entries = gwolle_gb_get_entries(array('email' => $entry->get_author_email()));
            if (is_array($entries) && !empty($entries)) {
                foreach ($entries as $entry_email) {
                    if ($entry_email->get_content() == $entry->get_content()) {
                        // Match is double entry
                        $gwolle_gb_errors = true;
                        $gwolle_gb_messages .= '<p class="double_post"><strong>' . __('Double post: An entry with the data you entered has already been saved.', 'gwolle-gb') . '</strong></p>';
                        return false;
                    }
                }
            }
        }
        /*
         * Save the Entry
         */
        // $save = ""; // Testing mode
        $save = $entry->save();
        //if ( WP_DEBUG ) { echo "save: "; var_dump($save); }
        if ($save) {
            // We have been saved to the Database
            $gwolle_gb_messages .= '<p class="entry_saved">Merci pour ton message ' . $gwolle_gb_data['author_name'] . ' !</p>';
            if ($entry->get_ischecked() == 0) {
                $gwolle_gb_messages .= '<p>Il apparaîtra bientôt sur le site !</p>';
            }
        }
        /*
         * Update Cache plugins
         */
        if ($entry->get_ischecked() == 1) {
            gwolle_gb_clear_cache();
        }
        /*
         * Send the Notification Mail to moderators that have subscribed (only when it is not Spam)
         */
        gwolle_gb_mail_moderators($entry);
        /*
         * Send Notification Mail to the author if set to true in an option
         */
        gwolle_gb_mail_author($entry);
        /*
         * No Log for the Entry needed, it has a default post date in the Entry itself.
         */
    }
}
예제 #8
0
function gwolle_gb_page_settingstab_form()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('Cheatin&#8217; uh?', GWOLLE_GB_TEXTDOMAIN));
    }
    ?>

	<input type="hidden" id="gwolle_gb_tab" name="gwolle_gb_tab" value="gwolle_gb_forms" />
	<?php 
    settings_fields('gwolle_gb_options');
    do_settings_sections('gwolle_gb_options');
    ?>
	<table class="form-table">
		<tbody>

		<tr valign="top">
			<th scope="row"><label for="require_login"><?php 
    _e('Require Login', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<input type="checkbox" id="require_login" name="require_login" <?php 
    if (get_option('gwolle_gb-require_login', 'false') === 'true') {
        echo 'checked="checked"';
    }
    ?>
 />
				<label for="require_login"><?php 
    _e('Require user to be logged in.', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
				<br />
				<span class="setting-description"><?php 
    _e('Only allow logged-in users to add a guestbook entry.', GWOLLE_GB_TEXTDOMAIN);
    ?>
</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="labels_float"><?php 
    _e('Labels float', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<input type="checkbox" id="labels_float" name="labels_float" <?php 
    if (get_option('gwolle_gb-labels_float', 'true') === 'true') {
        echo 'checked="checked"';
    }
    ?>
 />
				<label for="labels_float"><?php 
    _e('Labels in the form float to the left.', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
				<br />
				<span class="setting-description"><?php 
    _e('Labels in the form float to the left. Otherwise the labels will be above the input-fields.', GWOLLE_GB_TEXTDOMAIN);
    ?>
</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="header"><?php 
    _e('Header Text', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td><?php 
    $header = gwolle_gb_sanitize_output(get_option('gwolle_gb-header', false));
    if (!$header) {
        $header = __('Write a new entry for the Guestbook', GWOLLE_GB_TEXTDOMAIN);
    }
    ?>
				<input name="header" id="header" class="regular-text" type="text" value="<?php 
    echo $header;
    ?>
" />
				<br />
				<span class="setting-description">
					<?php 
    _e('You can set the header that is shown on top of the form.', GWOLLE_GB_TEXTDOMAIN);
    ?>
				</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="notice"><?php 
    _e('Notice Text', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<?php 
    $notice = gwolle_gb_sanitize_output(get_option('gwolle_gb-notice', false));
    if (!$notice) {
        // No text set by the user. Use the default text.
        $notice = __('
Fields marked with * are obligatory.
Your E-mail address wil not be published.
For security reasons we save the ip address %ip%.
It might be that your entry will only be visible in the guestbook after we reviewed it.
We reserve our right to edit, delete, or not publish entries.
', GWOLLE_GB_TEXTDOMAIN);
    }
    ?>
				<textarea name="notice" id="notice" style="width:400px;height:180px;" class="regular-text"><?php 
    echo $notice;
    ?>
</textarea>
				<br />
				<span class="setting-description">
					<?php 
    _e('You can set the content of the notice that gets shown below the form.', GWOLLE_GB_TEXTDOMAIN);
    echo '<br />';
    _e('You can use the tag %ip% to show the ip address.', GWOLLE_GB_TEXTDOMAIN);
    ?>
				</span>
			</td>
		</tr>

		</tbody>
	</table>
	<table class="form-table">
		<tbody>

		<?php 
    $form_setting = gwolle_gb_get_setting('form');
    ?>

		<tr valign="top">
			<td colspan="3"><h3><?php 
    _e('Configure the form that is shown to visitors.', GWOLLE_GB_TEXTDOMAIN);
    ?>
</h3></td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_name_enabled"><?php 
    _e('Name', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_name_enabled" name="form_name_enabled"<?php 
    if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_name_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<input type="checkbox" id="form_name_mandatory" name="form_name_mandatory"<?php 
    if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_name_mandatory"><?php 
    _e('Mandatory', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_city_enabled"><?php 
    _e('City', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_city_enabled" name="form_city_enabled"<?php 
    if (isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_city_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<input type="checkbox" id="form_city_mandatory" name="form_city_mandatory"<?php 
    if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_city_mandatory"><?php 
    _e('Mandatory', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_email_enabled"><?php 
    _e('Email', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_email_enabled" name="form_email_enabled"<?php 
    if (isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_email_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<input type="checkbox" id="form_email_mandatory" name="form_email_mandatory"<?php 
    if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_email_mandatory"><?php 
    _e('Mandatory', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_homepage_enabled"><?php 
    _e('Website', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_homepage_enabled" name="form_homepage_enabled"<?php 
    if (isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_homepage_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<input type="checkbox" id="form_homepage_mandatory" name="form_homepage_mandatory"<?php 
    if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_homepage_mandatory"><?php 
    _e('Mandatory', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_message_enabled"><?php 
    _e('Message', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_message_enabled" name="form_message_enabled"<?php 
    if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_message_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<input type="checkbox" id="form_message_mandatory" name="form_message_mandatory"<?php 
    if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_message_mandatory"><?php 
    _e('Mandatory', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_bbcode_enabled"><?php 
    _e('BBcode and Emoji', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_bbcode_enabled" name="form_bbcode_enabled"<?php 
    if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_bbcode_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<?php 
    _e('Will only be shown if the Message is enabled.', GWOLLE_GB_TEXTDOMAIN);
    ?>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_antispam_enabled"><?php 
    _e('Custom Anti-spam', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_antispam_enabled" name="form_antispam_enabled"<?php 
    if (isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_antispam_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<?php 
    _e('When enabled it is mandatory.', GWOLLE_GB_TEXTDOMAIN);
    ?>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="form_recaptcha_enabled"><?php 
    _e('CAPTCHA', GWOLLE_GB_TEXTDOMAIN);
    ?>
:</label></th>
			<td>
				<input type="checkbox" id="form_recaptcha_enabled" name="form_recaptcha_enabled"<?php 
    if (isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled'] === 'true') {
        echo ' checked="checked"';
    }
    ?>
 />
				<label for="form_recaptcha_enabled"><?php 
    _e('Enabled', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
			<td>
				<?php 
    _e('When enabled it is mandatory.', GWOLLE_GB_TEXTDOMAIN);
    ?>
			</td>
		</tr>

		<tr>
			<td colspan="3">
				<p class="submit">
					<input type="submit" name="gwolle_gb_settings_form" id="gwolle_gb_settings_form" class="button-primary" value="<?php 
    esc_attr_e('Save settings', GWOLLE_GB_TEXTDOMAIN);
    ?>
" />
				</p>
			</td>
		</tr>

		</tbody>
	</table>

	<?php 
}
예제 #9
0
function gwolle_gb_page_settingstab_email()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('Cheatin&#8217; uh?', GWOLLE_GB_TEXTDOMAIN));
    }
    ?>

	<input type="hidden" id="gwolle_gb_tab" name="gwolle_gb_tab" value="gwolle_gb_mail" />
	<?php 
    settings_fields('gwolle_gb_options');
    do_settings_sections('gwolle_gb_options');
    ?>
	<table class="form-table">
		<tbody>

		<tr valign="top">
			<th scope="row"><label for="admin_mail_from"><?php 
    _e('Admin mail from address', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<input type="text" name="admin_mail_from" id="admin_mail_from" class="regular-text" value="<?php 
    echo gwolle_gb_sanitize_output(get_option('gwolle_gb-mail-from', false));
    ?>
" placeholder="*****@*****.**" />
				<br />
				<span class="setting-description">
					<?php 
    _e('You can set the email address that is used for the From header of the mail that a notification subscriber gets on new entries.', GWOLLE_GB_TEXTDOMAIN);
    echo '<br />';
    _e('By default the main admin address is used from General >> Settings.', GWOLLE_GB_TEXTDOMAIN);
    ?>
				</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="unsubscribe"><?php 
    _e('Unsubscribe moderators', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<?php 
    // Check if function mail() exists. If not, display a hint to the user.
    if (!function_exists('mail')) {
        echo '<p class="setting-description">' . __('Sorry, but the function <code>mail()</code> required to notify you by mail is not enabled in your PHP configuration. You might want to install a WordPress plugin that uses SMTP instead of <code>mail()</code>. Or you can contact your hosting provider to change this.', GWOLLE_GB_TEXTDOMAIN) . '</p>';
    }
    ?>
				<select name="unsubscribe" id="unsubscribe">
					<option value="0"><?php 
    _e('Unsubscribe User', GWOLLE_GB_TEXTDOMAIN);
    ?>
</option>
					<?php 
    $user_ids = get_option('gwolle_gb-notifyByMail');
    if (strlen($user_ids) > 0) {
        $user_ids = explode(",", $user_ids);
        if (is_array($user_ids) && !empty($user_ids)) {
            foreach ($user_ids as $user_id) {
                $user_info = get_userdata($user_id);
                if ($user_info === FALSE) {
                    // Invalid $user_id
                    continue;
                }
                $username = $user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_email . ')';
                if ($user_info->ID == get_current_user_id()) {
                    $username .= ' ' . __('You', GWOLLE_GB_TEXTDOMAIN);
                }
                echo '<option value="' . $user_id . '">' . $username . '</option>';
            }
        }
    }
    ?>
				</select><br />
				<label for="unsubscribe"><?php 
    _e('These users have subscribed to the notification emails.', GWOLLE_GB_TEXTDOMAIN);
    ?>
<br />
				<?php 
    _e('Select a user if you want that user to unsubscribe from the notification emails.', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="subscribe"><?php 
    _e('Subscribe moderators', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<select name="subscribe" id="subscribe">
					<option value="0"><?php 
    _e('Subscribe User', GWOLLE_GB_TEXTDOMAIN);
    ?>
</option>
					<?php 
    $users = array();
    $roles = array('administrator', 'editor', 'author');
    foreach ($roles as $role) {
        $users_query = new WP_User_Query(array('fields' => 'all', 'role' => $role, 'orderby' => 'display_name'));
        $results = $users_query->get_results();
        if ($results) {
            $users = array_merge($users, $results);
        }
    }
    if (is_array($users) && !empty($users)) {
        foreach ($users as $user_info) {
            if ($user_info === FALSE) {
                // Invalid $user_id
                continue;
            }
            // Test if already subscribed
            if (is_array($user_ids) && !empty($user_ids)) {
                if (in_array($user_info->ID, $user_ids)) {
                    continue;
                }
            }
            // No capability
            if (!user_can($user_info, 'moderate_comments')) {
                continue;
            }
            $username = $user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_email . ')';
            if ($user_info->ID == get_current_user_id()) {
                $username .= ' ' . __('You', GWOLLE_GB_TEXTDOMAIN);
            }
            echo '<option value="' . $user_info->ID . '">' . $username . '</option>';
        }
    }
    ?>
				</select><br />
				<label for="subscribe"><?php 
    _e('You can subscribe a moderator to the notification emails.', GWOLLE_GB_TEXTDOMAIN);
    ?>
<br />
				<?php 
    _e('Select a user that you want subscribed to the notification emails.', GWOLLE_GB_TEXTDOMAIN);
    ?>
				<?php 
    _e("You will only see users with the roles of Administrator, Editor and Author, who have the capability 'moderate_comments' .", GWOLLE_GB_TEXTDOMAIN);
    ?>
				</label>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="adminMailContent"><?php 
    _e('Admin mail content', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<?php 
    $mailText = gwolle_gb_sanitize_output(get_option('gwolle_gb-adminMailContent', false));
    if (!$mailText) {
        // No text set by the user. Use the default text.
        $mailText = __("\nHello,\n\nThere is a new guestbook entry at '%blog_name%'.\nYou can check it at %entry_management_url%.\n\nHave a nice day.\nYour Gwolle-GB-Mailer\n\n\nWebsite address: %blog_url%\nUser name: %user_name%\nUser email: %user_email%\nEntry status: %status%\nEntry content:\n%entry_content%\n", GWOLLE_GB_TEXTDOMAIN);
    }
    ?>
				<textarea name="adminMailContent" id="adminMailContent" style="width:400px;height:300px;" class="regular-text"><?php 
    echo $mailText;
    ?>
</textarea>
				<br />
				<span class="setting-description">
					<?php 
    _e('You can set the content of the mail that a notification subscriber gets on new entries. The following tags are supported:', GWOLLE_GB_TEXTDOMAIN);
    echo '<br />';
    $mailTags = array('user_email', 'user_name', 'entry_management_url', 'blog_name', 'blog_url', 'wp_admin_url', 'entry_content', 'status', 'author_ip');
    for ($i = 0; $i < count($mailTags); $i++) {
        if ($i != 0) {
            echo ', ';
        }
        echo '%' . $mailTags[$i] . '%';
    }
    echo ".";
    ?>
				</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="mail_author"><?php 
    _e('Mail Author', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<input <?php 
    if (get_option('gwolle_gb-mail_author', 'false') == 'true') {
        echo 'checked="checked"';
    }
    ?>
					type="checkbox" name="mail_author" id="mail_author">
				<label for="mail_author">
					<?php 
    _e('Mail the author with a confirmation email.', GWOLLE_GB_TEXTDOMAIN);
    ?>
				</label>
				<br />
				<span class="setting-description">
					<?php 
    _e("The author of the guestbook entry will receive an email after posting. It will have a copy of the entry.", GWOLLE_GB_TEXTDOMAIN);
    ?>
				</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><label for="authorMailContent"><?php 
    _e('Author mail content', GWOLLE_GB_TEXTDOMAIN);
    ?>
</label></th>
			<td>
				<?php 
    $mailText = gwolle_gb_sanitize_output(get_option('gwolle_gb-authorMailContent', false));
    if (!$mailText) {
        // No text set by the user. Use the default text.
        $mailText = __("\nHello,\n\nYou have just posted a new guestbook entry at '%blog_name%'.\n\nHave a nice day.\nThe editors at %blog_name%.\n\n\nWebsite address: %blog_url%\nUser name: %user_name%\nUser email: %user_email%\nEntry content:\n%entry_content%\n", GWOLLE_GB_TEXTDOMAIN);
    }
    ?>
				<textarea name="authorMailContent" id="authorMailContent" style="width:400px;height:300px;" class="regular-text"><?php 
    echo $mailText;
    ?>
</textarea>
				<br />
				<span class="setting-description">
					<?php 
    _e('You can set the content of the mail that the author of the entry will receive. The following tags are supported:', GWOLLE_GB_TEXTDOMAIN);
    echo '<br />';
    $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'entry_content');
    for ($i = 0; $i < count($mailTags); $i++) {
        if ($i != 0) {
            echo ', ';
        }
        echo '%' . $mailTags[$i] . '%';
    }
    ?>
				</span>
			</td>
		</tr>

		<tr>
			<td colspan="2">
				<p class="submit">
					<input type="submit" name="gwolle_gb_settings_email" id="gwolle_gb_settings_email" class="button-primary" value="<?php 
    esc_attr_e('Save settings', GWOLLE_GB_TEXTDOMAIN);
    ?>
" />
				</p>
			</td>
		</tr>

		</tbody>
	</table>

	<?php 
}
예제 #10
0
    function gwolle_gb_entry_template($entry, $first, $counter)
    {
        $html5 = current_theme_supports('html5');
        // Get the needed settings.
        $form_setting = gwolle_gb_get_setting('form');
        $read_setting = gwolle_gb_get_setting('read');
        // Main Author div
        $entry_output = '<div class="';
        $entry_output .= ' gb-entry';
        $entry_output .= ' gb-entry_' . $entry->get_id();
        $entry_output .= ' gb-entry-count_' . $counter;
        if (is_int($counter / 2)) {
            $entry_output .= ' gwolle_gb_even';
        } else {
            $entry_output .= ' gwolle_gb_uneven';
        }
        if ($first == true) {
            $entry_output .= ' gwolle_gb_first';
        }
        if (get_option('gwolle_gb-admin_style', 'true') === 'true') {
            $author_id = $entry->get_author_id();
            $is_moderator = gwolle_gb_is_moderator($author_id);
            if ($is_moderator) {
                $entry_output .= ' admin-entry';
            }
        }
        $entry_output .= '">';
        if ($html5) {
            $entry_output .= '<article>';
        }
        // Use this filter to just add something
        $entry_output .= apply_filters('gwolle_gb_entry_read_add_before', '', $entry);
        // Author Avatar
        // if ( isset($read_setting['read_avatar']) && $read_setting['read_avatar']  === 'true' ) {
        // 	$avatar = get_avatar( $entry->get_author_email(), 32, '', $entry->get_author_name() );
        // 	if ($avatar) {
        // 		$entry_output .= '<span class="gb-author-avatar">' . $avatar . '</span>';
        // 	}
        // }
        // Author Origin
        // if ( isset($read_setting['read_city']) && $read_setting['read_city']  === 'true' ) {
        // 	$origin = $entry->get_author_origin();
        // 	if ( strlen(str_replace(' ', '', $origin)) > 0 ) {
        // 		$entry_output .= '<span class="gb-author-origin"> ' . __('from', 'gwolle-gb') . ' ' . gwolle_gb_sanitize_output($origin) . '</span>';
        // 	}
        // }
        // Entry Date and Time
        // if ( ( isset($read_setting['read_datetime']) && $read_setting['read_datetime']  === 'true' ) || ( isset($read_setting['read_date']) && $read_setting['read_date']  === 'true' ) ) {
        // 	$entry_output .= '<span class="gb-datetime">
        // 				<span class="gb-date"> ';
        // 	if ( isset($read_setting['read_name']) && $read_setting['read_name']  === 'true' ) {
        // 		$entry_output .= __('wrote on', 'gwolle-gb') . ' ';
        // 	}
        // 	$entry_output .= date_i18n( get_option('date_format'), $entry->get_datetime() ) . '</span>';
        // 	if ( isset($read_setting['read_datetime']) && $read_setting['read_datetime']  === 'true' ) {
        // 		$entry_output .= '<span class="gb-time"> ' . __('on', 'gwolle-gb') . ' ' . trim(date_i18n( get_option('time_format'), $entry->get_datetime() )) . '</span>';
        // 	}
        // 	$entry_output .= ':</span> ';
        // }
        // Main Content
        if (isset($read_setting['read_content']) && $read_setting['read_content'] === 'true') {
            $entry_output .= '<div class="gb-entry-content">';
            $entry_content = gwolle_gb_sanitize_output($entry->get_content());
            if (get_option('gwolle_gb-showSmilies', 'true') === 'true') {
                $entry_content = convert_smilies($entry_content);
            }
            if (get_option('gwolle_gb-showLineBreaks', 'false') === 'true') {
                $entry_content = nl2br($entry_content);
            }
            $excerpt_length = (int) get_option('gwolle_gb-excerpt_length', 0);
            if ($excerpt_length > 0) {
                $entry_content = wp_trim_words($entry_content, $excerpt_length, '...');
                // FIXME: add readmore link
            }
            if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
                $entry_content = gwolle_gb_bbcode_parse($entry_content);
            } else {
                $entry_content = gwolle_gb_bbcode_strip($entry_content);
            }
            $entry_output .= $entry_content;
            // // Edit Link for Moderators
            // if ( function_exists('current_user_can') && current_user_can('moderate_comments') ) {
            // 	$entry_output .= '
            // 		<a class="gwolle_gb_edit_link" href="' . admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&amp;entry_id=' . $entry->get_id() ) . '" title="' . __('Edit entry', 'gwolle-gb') . '">' . __('Edit', 'gwolle-gb') . '</a>';
            // }
            // Use this filter to just add something
            $entry_output .= apply_filters('gwolle_gb_entry_read_add_content', '', $entry);
            $entry_output .= '</div>
			';
            /* Admin Reply */
            $admin_reply_content = gwolle_gb_sanitize_output($entry->get_admin_reply());
            if ($admin_reply_content != '') {
                $class = '';
                if (get_option('gwolle_gb-admin_style', 'true') === 'true') {
                    $class = ' admin-entry';
                }
                $admin_reply = '<div class="gb-entry-admin_reply' . $class . '">';
                /* Admin Reply Author */
                $admin_reply .= '<div class="gb-admin_reply_uid">';
                $admin_reply_name = gwolle_gb_is_moderator($entry->get_admin_reply_uid());
                if (isset($read_setting['read_name']) && $read_setting['read_name'] === 'true' && $admin_reply_name) {
                    $admin_reply .= '<strong>' . __('Admin Reply by:', 'gwolle-gb') . '</strong>
						' . $admin_reply_name;
                } else {
                    $admin_reply .= '<strong>' . __('Admin Reply:', 'gwolle-gb') . '</strong>';
                }
                $admin_reply .= '</div> ';
                /* Admin Reply Content */
                if (get_option('gwolle_gb-showSmilies', 'true') === 'true') {
                    $admin_reply_content = convert_smilies($admin_reply_content);
                }
                if (get_option('gwolle_gb-showLineBreaks', 'false') === 'true') {
                    $admin_reply_content = nl2br($admin_reply_content);
                }
                if ($excerpt_length > 0) {
                    $admin_reply_content = wp_trim_words($admin_reply_content, $excerpt_length, '...');
                }
                if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
                    $admin_reply_content = gwolle_gb_bbcode_parse($admin_reply_content);
                } else {
                    $admin_reply_content = gwolle_gb_bbcode_strip($admin_reply_content);
                }
                $admin_reply .= '<div class="gb-admin_reply_content">
					' . $admin_reply_content . '
					</div>';
                $admin_reply .= '</div>';
                $entry_output .= $admin_reply;
            }
        }
        // Author Info
        $entry_output .= '<div class="gb-author-info">';
        // Author Name
        if (isset($read_setting['read_name']) && $read_setting['read_name'] === 'true') {
            $author_name_html = gwolle_gb_get_author_name_html($entry);
            $entry_output .= '<span class="gb-author-name">' . $author_name_html . '</span>';
        }
        $entry_output .= '</div>';
        // <div class="gb-author-info">
        // Use this filter to just add something
        $entry_output .= apply_filters('gwolle_gb_entry_read_add_after', '', $entry);
        if ($html5) {
            $entry_output .= '</article>';
        }
        $entry_output .= '</div>
			';
        return $entry_output;
    }
예제 #11
0
 public function get_admin_reply()
 {
     return gwolle_gb_sanitize_output($this->admin_reply);
 }
예제 #12
0
function gwolle_gb_page_settingstab_antispam()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('Cheatin&#8217; uh?', 'gwolle-gb'));
    }
    ?>

	<input type="hidden" id="gwolle_gb_tab" name="gwolle_gb_tab" value="gwolle_gb_antispam" />
	<?php 
    settings_fields('gwolle_gb_options');
    do_settings_sections('gwolle_gb_options');
    ?>
	<table class="form-table">
		<tbody>

		<tr valign="top">
			<th scope="row"><label for="moderate-entries"><?php 
    _e('Moderate Guestbook', 'gwolle-gb');
    ?>
</label></th>
			<td>
				<input <?php 
    if (get_option('gwolle_gb-moderate-entries', 'true') == 'true') {
        echo 'checked="checked"';
    }
    ?>
					type="checkbox" name="moderate-entries" id="moderate-entries">
				<label for="moderate-entries">
					<?php 
    _e('Moderate entries before publishing them.', 'gwolle-gb');
    ?>
				</label>
				<br />
				<span class="setting-description">
					<?php 
    _e("New entries have to be unlocked by a moderator before they are visible to the public.", 'gwolle-gb');
    ?>
					<br />
					<?php 
    _e("It is recommended that you turn this on, because you are responsible for the content on your website.", 'gwolle-gb');
    ?>
				</span>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row">
				<label for="akismet-active">Akismet</label>
				<br />
				<span class="setting-description">
					<a href="http://akismet.com/" title="<?php 
    _e('Learn more about Akismet...', 'gwolle-gb');
    ?>
" target="_blank"><?php 
    _e("What's that?", 'gwolle-gb');
    ?>
</a>
				</span>
			</th>
			<td>
				<?php 
    $current_plugins = get_option('active_plugins');
    $wordpress_api_key = get_option('wordpress_api_key');
    // Check wether Akismet is installed and activated or not.
    if (!in_array('akismet/akismet.php', $current_plugins)) {
        // Akismet is not installed and activated. Show notice with suggestion to install it.
        _e("Akismet helps you to fight spam. It's free and easy to install. Download and install it today to stop spam in your guestbook.", 'gwolle-gb');
    } elseif (!$wordpress_api_key) {
        // No WordPress API key is defined and set in the database.
        echo sprintf(__("Sorry, wasn't able to locate your <strong>WordPress API key</strong>. You can enter it at the <a href=\"%s\">Akismet configuration page</a>.", 'gwolle-gb'), 'options-general.php?page=akismet-key-config');
    } else {
        // Akismet is installed and activated and a WordPress API key exists (we just assume it is valid).
        echo '<input ';
        if (get_option('gwolle_gb-akismet-active', 'false') === 'true') {
            echo 'checked="checked" ';
        }
        echo 'name="akismet-active" id="akismet-active" type="checkbox" />
						<label for="akismet-active">
						' . __('Use Akismet', 'gwolle-gb') . '
						</label><br />';
        _e("The WordPress API key has been found, so you can start using Akismet right now.", 'gwolle-gb');
    }
    ?>
			</td>
		</tr>

		<?php 
    $antispam_question = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-question'));
    $antispam_answer = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-answer'));
    ?>
		<tr valign="top">
			<th scope="row"><label for="antispam-question"><?php 
    _e('Custom Anti-Spam Security Question', 'gwolle-gb');
    ?>
</label></th>
			<td>
				<div>
					<input name="antispam-question" type="text" id="antispam-question" value="<?php 
    echo $antispam_question;
    ?>
" class="regular-text" placeholder="<?php 
    _e('12 + six =', 'gwolle-gb');
    ?>
" />
					<label for="antispam-question" class="setting-description"><?php 
    _e('Custom security question to battle spam.', 'gwolle-gb');
    ?>
</label>
					<br />
					<input name="antispam-answer" type="text" id="antispam-answer" value="<?php 
    echo $antispam_answer;
    ?>
" class="regular-text" placeholder="<?php 
    _e('18', 'gwolle-gb');
    ?>
" />
					<label for="antispam-answer" class="setting-description"><?php 
    _e('The answer to your security question.', 'gwolle-gb');
    ?>
</label>
					<br />
					<span class="setting-description"><?php 
    _e('You can ask your visitors to answer a custom security question, so only real people can post an entry.', 'gwolle-gb');
    ?>
</span>
				</div>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><?php 
    _e('CAPTCHA', 'gwolle-gb');
    ?>
</th>
			<td>
				<div>
					<span class="setting-description">
						<?php 
    _e('A CAPTCHA is a way to have visitors fill in a field with a few letters or numbers. It is a way to make sure that you have a human visitor and not a spambot. Not every visitor will appreciate it though, some will consider it unfriendly.', 'gwolle-gb');
    ?>
						<br /><br />
						<?php 
    _e('For the CAPTCHA you need the plugin', 'gwolle-gb');
    ?>
						<a href="https://wordpress.org/plugins/really-simple-captcha/" title="<?php 
    _e('Really Simple CAPTCHA plugin at wordpress.org', 'gwolle-gb');
    ?>
" target="_blank"><?php 
    _e('Really Simple CAPTCHA', 'gwolle-gb');
    ?>
</a>
						<?php 
    _e('installed and activated', 'gwolle-gb');
    ?>
.
						<?php 
    if (class_exists('ReallySimpleCaptcha')) {
        echo '<br />';
        _e('This plugin is installed and activated, so the CAPTCHA is ready to be used.', 'gwolle-gb');
    }
    ?>
						<br /><br />
						<?php 
    _e('If you use any caching plugin together with this CAPTCHA, page caching will be disabled for the page that the CAPTCHA is shown on. This is to prevent errors and to have a fresh CAPCHA image each time.', 'gwolle-gb');
    ?>
					</span>
				</div>
			</td>
		</tr>

		<tr>
			<td colspan="2">
				<p class="submit">
					<input type="submit" name="gwolle_gb_settings_antispam" id="gwolle_gb_settings_antispam" class="button-primary" value="<?php 
    esc_attr_e('Save settings', 'gwolle-gb');
    ?>
" />
				</p>
			</td>
		</tr>

		</tbody>
	</table>

	<?php 
}
예제 #13
0
    function gwolle_gb_entry_template($entry, $first, $counter)
    {
        // Get the needed settings.
        $form_setting = gwolle_gb_get_setting('form');
        $read_setting = gwolle_gb_get_setting('read');
        // Main Author div
        $entry_output = '<div class="';
        $entry_output .= ' gb-entry';
        $entry_output .= ' gb-entry_' . $entry->get_id();
        if (is_int($counter / 2)) {
            $entry_output .= ' gwolle_gb_even';
        } else {
            $entry_output .= ' gwolle_gb_uneven';
        }
        if ($first == true) {
            $entry_output .= ' gwolle_gb_first';
        }
        if (get_option('gwolle_gb-admin_style', 'true') === 'true') {
            $author_id = $entry->get_author_id();
            $is_moderator = gwolle_gb_is_moderator($author_id);
            if ($is_moderator) {
                $entry_output .= ' admin-entry';
            }
        }
        $entry_output .= '">';
        // Author Info
        $entry_output .= '<div class="gb-author-info">';
        // Author Avatar
        if (isset($read_setting['read_avatar']) && $read_setting['read_avatar'] === 'true') {
            $avatar = get_avatar($entry->get_author_email(), 32, '', $entry->get_author_name());
            if ($avatar) {
                $entry_output .= '<span class="gb-author-avatar">' . $avatar . '</span>';
            }
        }
        // Author Name
        if (isset($read_setting['read_name']) && $read_setting['read_name'] === 'true') {
            $author_name_html = gwolle_gb_get_author_name_html($entry);
            $entry_output .= '<span class="gb-author-name">' . $author_name_html . '</span>';
        }
        // Author Origin
        if (isset($read_setting['read_city']) && $read_setting['read_city'] === 'true') {
            $origin = $entry->get_author_origin();
            if (strlen(str_replace(' ', '', $origin)) > 0) {
                $entry_output .= '<span class="gb-author-origin"> ' . __('from', GWOLLE_GB_TEXTDOMAIN) . ' ' . gwolle_gb_sanitize_output($origin) . '</span>';
            }
        }
        // Entry Date and Time
        if (isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true' || isset($read_setting['read_date']) && $read_setting['read_date'] === 'true') {
            $entry_output .= '<span class="gb-datetime">
						<span class="gb-date"> ';
            if (isset($read_setting['read_name']) && $read_setting['read_name'] === 'true') {
                $entry_output .= __('wrote on', GWOLLE_GB_TEXTDOMAIN) . ' ';
            }
            $entry_output .= date_i18n(get_option('date_format'), $entry->get_datetime()) . '</span>';
            if (isset($read_setting['read_datetime']) && $read_setting['read_datetime'] === 'true') {
                $entry_output .= '<span class="gb-time"> ' . __('on', GWOLLE_GB_TEXTDOMAIN) . ' ' . trim(date_i18n(get_option('time_format'), $entry->get_datetime())) . '</span>';
            }
            $entry_output .= ':</span> ';
        }
        $entry_output .= '</div>';
        // <div class="gb-author-info">
        // Main Content
        if (isset($read_setting['read_content']) && $read_setting['read_content'] === 'true') {
            $entry_output .= '<div class="gb-entry-content">';
            $entry_content = gwolle_gb_sanitize_output($entry->get_content());
            if (get_option('gwolle_gb-showSmilies', 'true') === 'true') {
                $entry_content = convert_smilies($entry_content);
            }
            if (get_option('gwolle_gb-showLineBreaks', 'false') === 'true') {
                $entry_content = nl2br($entry_content);
            }
            $excerpt_length = (int) get_option('gwolle_gb-excerpt_length', 0);
            if ($excerpt_length > 0) {
                $entry_content = wp_trim_words($entry_content, $excerpt_length, '...');
            }
            if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
                $entry_content = gwolle_gb_bbcode_parse($entry_content);
            } else {
                $entry_content = gwolle_gb_bbcode_strip($entry_content);
            }
            $entry_output .= $entry_content;
            // Edit Link for Moderators
            if (function_exists('current_user_can') && current_user_can('moderate_comments')) {
                $entry_output .= '
					<a class="gwolle_gb_edit_link" href="' . admin_url('admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id()) . '" title="' . __('Edit entry', GWOLLE_GB_TEXTDOMAIN) . '">' . __('Edit', GWOLLE_GB_TEXTDOMAIN) . '</a>';
            }
            $entry_output .= '</div>
			';
        }
        $entry_output .= '</div>
			';
        return $entry_output;
    }
예제 #14
0
function gwolle_gb_page_entries()
{
    if (function_exists('current_user_can') && !current_user_can('moderate_comments')) {
        die(__('Cheatin&#8217; uh?', 'gwolle-gb'));
    }
    if (!get_option('gwolle_gb_version')) {
        // FIXME: do this on activation
        gwolle_gb_installSplash();
    } else {
        $gwolle_gb_errors = '';
        $gwolle_gb_messages = '';
        if (isset($_POST['gwolle_gb_page']) && $_POST['gwolle_gb_page'] == 'entries') {
            $action = '';
            if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'check' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'check') {
                $action = 'check';
            } else {
                if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'uncheck' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'uncheck') {
                    $action = 'uncheck';
                } else {
                    if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'spam' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'spam') {
                        $action = 'spam';
                    } else {
                        if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'no-spam' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'no-spam') {
                            $action = 'no-spam';
                        } else {
                            if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'akismet' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'akismet') {
                                $action = 'akismet';
                            } else {
                                if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'trash' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'trash') {
                                    $action = 'trash';
                                } else {
                                    if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'untrash' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'untrash') {
                                        $action = 'untrash';
                                    } else {
                                        if (isset($_POST['massEditAction1']) && $_POST['massEditAction1'] == 'remove' || isset($_POST['massEditAction2']) && $_POST['massEditAction2'] == 'remove') {
                                            $action = 'remove';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if ($action != '') {
                // Initialize variables to generate messages with
                $entries_handled = 0;
                $entries_not_handled = 0;
                $akismet_spam = 0;
                $akismet_not_spam = 0;
                $akismet_already_spam = 0;
                $akismet_already_not_spam = 0;
                /* Handle the $_POST entries */
                foreach (array_keys($_POST) as $postElementName) {
                    if (strpos($postElementName, 'check') > -1 && !strpos($postElementName, '-all-') && $_POST[$postElementName] == 'on') {
                        $entry_id = str_replace('check-', '', $postElementName);
                        $entry_id = intval($entry_id);
                        if (isset($entry_id) && $entry_id > 0) {
                            $entry = new gwolle_gb_entry();
                            $result = $entry->load($entry_id);
                            if ($result) {
                                if ($action == 'check') {
                                    if ($entry->get_ischecked() == 0) {
                                        $entry->set_ischecked(true);
                                        $user_id = get_current_user_id();
                                        // returns 0 if no current user
                                        $entry->set_checkedby($user_id);
                                        gwolle_gb_add_log_entry($entry->get_id(), 'entry-checked');
                                        $result = $entry->save();
                                        if ($result) {
                                            $entries_handled++;
                                        } else {
                                            $entries_not_handled++;
                                        }
                                    } else {
                                        $entries_not_handled++;
                                    }
                                } else {
                                    if ($action == 'uncheck') {
                                        if ($entry->get_ischecked() == 1) {
                                            $entry->set_ischecked(false);
                                            $user_id = get_current_user_id();
                                            // returns 0 if no current user
                                            $entry->set_checkedby($user_id);
                                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-unchecked');
                                            $result = $entry->save();
                                            if ($result) {
                                                $entries_handled++;
                                            } else {
                                                $entries_not_handled++;
                                            }
                                        } else {
                                            $entries_not_handled++;
                                        }
                                    } else {
                                        if ($action == 'spam') {
                                            if ($entry->get_isspam() == 0) {
                                                $entry->set_isspam(true);
                                                if (get_option('gwolle_gb-akismet-active', 'false') == 'true') {
                                                    gwolle_gb_akismet($entry, 'submit-spam');
                                                }
                                                gwolle_gb_add_log_entry($entry->get_id(), 'marked-as-spam');
                                                $result = $entry->save();
                                                if ($result) {
                                                    $entries_handled++;
                                                } else {
                                                    $entries_not_handled++;
                                                }
                                            } else {
                                                $entries_not_handled++;
                                            }
                                        } else {
                                            if ($action == 'no-spam') {
                                                if ($entry->get_isspam() == 1) {
                                                    $entry->set_isspam(false);
                                                    if (get_option('gwolle_gb-akismet-active', 'false') == 'true') {
                                                        gwolle_gb_akismet($entry, 'submit-ham');
                                                    }
                                                    gwolle_gb_add_log_entry($entry->get_id(), 'marked-as-not-spam');
                                                    $result = $entry->save();
                                                    if ($result) {
                                                        $entries_handled++;
                                                    } else {
                                                        $entries_not_handled++;
                                                    }
                                                } else {
                                                    $entries_not_handled++;
                                                }
                                            } else {
                                                if ($action == 'akismet') {
                                                    /* Check for spam and set accordingly */
                                                    if (get_option('gwolle_gb-akismet-active', 'false') == 'true') {
                                                        $isspam = gwolle_gb_akismet($entry, 'comment-check');
                                                        if ($isspam) {
                                                            // Returned true, so considered spam
                                                            if ($entry->get_isspam() == 0) {
                                                                $entry->set_isspam(true);
                                                                gwolle_gb_add_log_entry($entry->get_id(), 'marked-as-spam');
                                                                $result = $entry->save();
                                                                if ($result) {
                                                                    $akismet_spam++;
                                                                } else {
                                                                    $akismet_not_spam++;
                                                                }
                                                            } else {
                                                                $akismet_already_spam++;
                                                            }
                                                        } else {
                                                            if ($entry->get_isspam() == 1) {
                                                                $entry->set_isspam(false);
                                                                gwolle_gb_add_log_entry($entry->get_id(), 'marked-as-not-spam');
                                                                $result = $entry->save();
                                                                if ($result) {
                                                                    $akismet_not_spam++;
                                                                } else {
                                                                    $akismet_spam++;
                                                                }
                                                            } else {
                                                                $akismet_already_not_spam++;
                                                            }
                                                        }
                                                    }
                                                } else {
                                                    if ($action == 'trash') {
                                                        if ($entry->get_istrash() == 0) {
                                                            $entry->set_istrash(true);
                                                            gwolle_gb_add_log_entry($entry->get_id(), 'entry-trashed');
                                                            $result = $entry->save();
                                                            if ($result) {
                                                                $entries_handled++;
                                                            } else {
                                                                $entries_not_handled++;
                                                            }
                                                        } else {
                                                            $entries_not_handled++;
                                                        }
                                                    } else {
                                                        if ($action == 'untrash') {
                                                            if ($entry->get_istrash() == 1) {
                                                                $entry->set_istrash(false);
                                                                gwolle_gb_add_log_entry($entry->get_id(), 'entry-untrashed');
                                                                $result = $entry->save();
                                                                if ($result) {
                                                                    $entries_handled++;
                                                                } else {
                                                                    $entries_not_handled++;
                                                                }
                                                            } else {
                                                                $entries_not_handled++;
                                                            }
                                                        } else {
                                                            if ($action == 'remove') {
                                                                $result = $entry->delete();
                                                                if ($result) {
                                                                    $entries_handled++;
                                                                } else {
                                                                    $entries_not_handled++;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            } else {
                                // no result on load()
                                $entries_not_handled++;
                            }
                        } else {
                            // entry_id is not set or not > 0
                            $entries_not_handled++;
                        }
                    }
                    // no entry with the check-'entry_id' input, continue
                }
                // foreach
                /* Construct Message */
                if ($action == 'check') {
                    if ($entries_handled == 1) {
                        $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry checked.', 'gwolle-gb') . '</p>';
                    } else {
                        if ($entries_handled > 1) {
                            $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries checked.', 'gwolle-gb') . '</p>';
                        } else {
                            $gwolle_gb_messages .= '<p>' . __('No entries checked.', 'gwolle-gb') . '</p>';
                        }
                    }
                } else {
                    if ($action == 'uncheck') {
                        if ($entries_handled == 1) {
                            $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry unchecked.', 'gwolle-gb') . '</p>';
                        } else {
                            if ($entries_handled > 1) {
                                $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries unchecked.', 'gwolle-gb') . '</p>';
                            } else {
                                $gwolle_gb_messages .= '<p>' . __('No entries unchecked.', 'gwolle-gb') . '</p>';
                            }
                        }
                    } else {
                        if ($action == 'spam') {
                            if ($entries_handled == 1) {
                                $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry marked as spam and submitted to Akismet as spam (if Akismet was enabled).', 'gwolle-gb') . '</p>';
                            } else {
                                if ($entries_handled > 1) {
                                    $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries marked as spam and submitted to Akismet as spam (if Akismet was enabled).', 'gwolle-gb') . '</p>';
                                } else {
                                    $gwolle_gb_messages .= '<p>' . __('No entries marked as spam.', 'gwolle-gb') . '</p>';
                                }
                            }
                        } else {
                            if ($action == 'no-spam') {
                                if ($entries_handled == 1) {
                                    $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', 'gwolle-gb') . '</p>';
                                } else {
                                    if ($entries_handled > 1) {
                                        $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries marked as not spam and submitted to Akismet as ham (if Akismet was enabled).', 'gwolle-gb') . '</p>';
                                    } else {
                                        $gwolle_gb_messages .= '<p>' . __('No entries marked as not spam.', 'gwolle-gb') . '</p>';
                                    }
                                }
                            } else {
                                if ($action == 'akismet') {
                                    if ($akismet_spam == 1) {
                                        $gwolle_gb_messages .= '<p>' . $akismet_spam . " " . __('entry considered spam and marked as such.', 'gwolle-gb') . '</p>';
                                    } else {
                                        if ($akismet_spam > 1) {
                                            $gwolle_gb_messages .= '<p>' . $akismet_spam . " " . __('entries considered spam and marked as such.', 'gwolle-gb') . '</p>';
                                        }
                                    }
                                    if ($akismet_not_spam == 1) {
                                        $gwolle_gb_messages .= '<p>' . $akismet_not_spam . " " . __('entry not considered spam and marked as such.', 'gwolle-gb') . '</p>';
                                    } else {
                                        if ($akismet_not_spam > 1) {
                                            $gwolle_gb_messages .= '<p>' . $akismet_not_spam . " " . __('entries not considered spam and marked as such.', 'gwolle-gb') . '</p>';
                                        }
                                    }
                                    if ($akismet_already_spam == 1) {
                                        $gwolle_gb_messages .= '<p>' . $akismet_already_spam . " " . __('entry already considered spam and not changed.', 'gwolle-gb') . '</p>';
                                    } else {
                                        if ($akismet_already_spam > 1) {
                                            $gwolle_gb_messages .= '<p>' . $akismet_already_spam . " " . __('entries already considered spam and not changed.', 'gwolle-gb') . '</p>';
                                        }
                                    }
                                    if ($akismet_already_not_spam == 1) {
                                        $gwolle_gb_messages .= '<p>' . $akismet_already_not_spam . " " . __('entry already considered not spam and not changed.', 'gwolle-gb') . '</p>';
                                    } else {
                                        if ($akismet_already_not_spam > 1) {
                                            $gwolle_gb_messages .= '<p>' . $akismet_already_not_spam . " " . __('entries already considered not spam and not changed.', 'gwolle-gb') . '</p>';
                                        }
                                    }
                                } else {
                                    if ($action == 'trash') {
                                        if ($entries_handled == 1) {
                                            $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry moved to trash.', 'gwolle-gb') . '</p>';
                                        } else {
                                            if ($entries_handled > 1) {
                                                $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries moved to trash.', 'gwolle-gb') . '</p>';
                                            } else {
                                                $gwolle_gb_messages .= '<p>' . __('No entries moved to trash.', 'gwolle-gb') . '</p>';
                                            }
                                        }
                                    } else {
                                        if ($action == 'untrash') {
                                            if ($entries_handled == 1) {
                                                $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry recovered from trash.', 'gwolle-gb') . '</p>';
                                            } else {
                                                if ($entries_handled > 1) {
                                                    $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries recovered from trash.', 'gwolle-gb') . '</p>';
                                                } else {
                                                    $gwolle_gb_messages .= '<p>' . __('No entries recovered from trash.', 'gwolle-gb') . '</p>';
                                                }
                                            }
                                        } else {
                                            if ($action == 'remove') {
                                                if ($entries_handled == 1) {
                                                    $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entry removed permanently.', 'gwolle-gb') . '</p>';
                                                } else {
                                                    if ($entries_handled > 1) {
                                                        $gwolle_gb_messages .= '<p>' . $entries_handled . " " . __('entries removed permanently.', 'gwolle-gb') . '</p>';
                                                    } else {
                                                        $gwolle_gb_messages .= '<p>' . __('No entries permanently removed.', 'gwolle-gb') . '</p>';
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (isset($_POST['delete_all']) || isset($_POST['delete_all2'])) {
                // Delete all entries in spam or trash
                if (isset($_POST['show']) && in_array($_POST['show'], array('spam', 'trash'))) {
                    $delstatus = $_POST['show'];
                    $deleted = gwolle_gb_del_entries($delstatus);
                    if ($deleted == 1) {
                        $gwolle_gb_messages .= '<p>' . $deleted . " " . __('entry removed permanently.', 'gwolle-gb') . '</p>';
                    } else {
                        if ($deleted > 1) {
                            $gwolle_gb_messages .= '<p>' . $deleted . " " . __('entries removed permanently.', 'gwolle-gb') . '</p>';
                        } else {
                            $gwolle_gb_messages .= '<p>' . __('No entries permanently removed.', 'gwolle-gb') . '</p>';
                        }
                    }
                }
            }
        }
        // Get entry counts
        $count = array();
        $count['checked'] = gwolle_gb_get_entry_count(array('checked' => 'checked', 'trash' => 'notrash', 'spam' => 'nospam'));
        $count['unchecked'] = gwolle_gb_get_entry_count(array('checked' => 'unchecked', 'trash' => 'notrash', 'spam' => 'nospam'));
        $count['spam'] = gwolle_gb_get_entry_count(array('spam' => 'spam'));
        $count['trash'] = gwolle_gb_get_entry_count(array('trash' => 'trash'));
        $count['all'] = gwolle_gb_get_entry_count(array('all' => 'all'));
        $show = isset($_REQUEST['show']) && in_array($_REQUEST['show'], array('checked', 'unchecked', 'spam', 'trash')) ? $_REQUEST['show'] : 'all';
        $entries_per_page = get_option('gwolle_gb-entries_per_page', 20);
        // If Akimet has not been activated yet and the user is looking at the spam tell him to activate Akismet.
        if ($show == 'spam' && get_option('gwolle_gb-akismet-active', 'false') != 'true') {
            $gwolle_gb_messages .= '<p>' . __('Please activate Akismet if you want to battle spam.', 'gwolle-gb') . '</p>';
        }
        // Check if the requested page number is an integer > 0
        $pageNum = isset($_REQUEST['pageNum']) && $_REQUEST['pageNum'] && (int) $_REQUEST['pageNum'] > 0 ? (int) $_REQUEST['pageNum'] : 1;
        // Pagination: Calculate the number of pages.
        $countPages = ceil($count[$show] / $entries_per_page);
        if ($pageNum > $countPages) {
            $pageNum = 1;
            // page doesnot exist, return to first page
        }
        // Calculate Query
        if ($pageNum == 1 && $count[$show] > 0) {
            $mysqlFirstRow = 0;
        } elseif ($count[$show] == 0) {
            $mysqlFirstRow = 0;
        } else {
            $firstEntryNum = ($pageNum - 1) * $entries_per_page + 1;
            $mysqlFirstRow = $firstEntryNum - 1;
        }
        // Get the entries
        if ($show == 'checked') {
            $entries = gwolle_gb_get_entries(array('num_entries' => $entries_per_page, 'offset' => $mysqlFirstRow, 'checked' => 'checked', 'trash' => 'notrash', 'spam' => 'nospam'));
        } else {
            if ($show == 'unchecked') {
                $entries = gwolle_gb_get_entries(array('num_entries' => $entries_per_page, 'offset' => $mysqlFirstRow, 'checked' => 'unchecked', 'trash' => 'notrash', 'spam' => 'nospam'));
            } else {
                if ($show == 'spam') {
                    $entries = gwolle_gb_get_entries(array('num_entries' => $entries_per_page, 'offset' => $mysqlFirstRow, 'spam' => 'spam'));
                } else {
                    if ($show == 'trash') {
                        $entries = gwolle_gb_get_entries(array('num_entries' => $entries_per_page, 'offset' => $mysqlFirstRow, 'trash' => 'trash'));
                    } else {
                        $entries = gwolle_gb_get_entries(array('num_entries' => $entries_per_page, 'offset' => $mysqlFirstRow, 'all' => 'all'));
                    }
                }
            }
        }
        ?>

		<div class="wrap gwolle_gb">
			<div id="icon-gwolle-gb"><br /></div>
			<h1><?php 
        _e('Guestbook entries', 'gwolle-gb');
        ?>
</h1>

			<?php 
        if ($gwolle_gb_messages) {
            echo '
					<div id="message" class="updated fade notice is-dismissible ' . $gwolle_gb_errors . ' ">' . $gwolle_gb_messages . '</div>';
        }
        // FIXME: add a searchform someday?
        ?>

			<form name="gwolle_gb_entries" id="gwolle_gb_entries" action="" method="POST" accept-charset="UTF-8">

				<input type="hidden" name="gwolle_gb_page" value="entries" />
				<!-- the following fields give us some information we're going to use processing the mass edit -->
				<input type="hidden" name="pageNum" value="<?php 
        echo $pageNum;
        ?>
">
				<input type="hidden" name="entriesOnThisPage" value="<?php 
        echo count($entries);
        ?>
">
				<input type="hidden" name="show" value="<?php 
        echo $show;
        ?>
">

				<ul class="subsubsub">
					<li><a href='admin.php?page=<?php 
        echo GWOLLE_GB_FOLDER;
        ?>
/entries.php' <?php 
        if ($show == 'all') {
            echo 'class="current"';
        }
        ?>
>
						<?php 
        _e('All', 'gwolle-gb');
        ?>
 <span class="count">(<?php 
        echo $count['all'];
        ?>
)</span></a> |
					</li>
					<li><a href='admin.php?page=<?php 
        echo GWOLLE_GB_FOLDER;
        ?>
/entries.php&amp;show=checked' <?php 
        if ($show == 'checked') {
            echo 'class="current"';
        }
        ?>
>
						<?php 
        _e('Unlocked', 'gwolle-gb');
        ?>
 <span class="count">(<?php 
        echo $count['checked'];
        ?>
)</span></a> |
					</li>
					<li><a href='admin.php?page=<?php 
        echo GWOLLE_GB_FOLDER;
        ?>
/entries.php&amp;show=unchecked' <?php 
        if ($show == 'unchecked') {
            echo 'class="current"';
        }
        ?>
><?php 
        _e('New', 'gwolle-gb');
        ?>
 <span class="count">(<?php 
        echo $count['unchecked'];
        ?>
)</span></a> |
					</li>
					<li><a href='admin.php?page=<?php 
        echo GWOLLE_GB_FOLDER;
        ?>
/entries.php&amp;show=spam' <?php 
        if ($show == 'spam') {
            echo 'class="current"';
        }
        ?>
><?php 
        _e('Spam', 'gwolle-gb');
        ?>
 <span class="count">(<?php 
        echo $count['spam'];
        ?>
)</span></a> |
					</li>
					<li><a href='admin.php?page=<?php 
        echo GWOLLE_GB_FOLDER;
        ?>
/entries.php&amp;show=trash' <?php 
        if ($show == 'trash') {
            echo 'class="current"';
        }
        ?>
><?php 
        _e('Trash', 'gwolle-gb');
        ?>
 <span class="count">(<?php 
        echo $count['trash'];
        ?>
)</span></a>
					</li>
				</ul>

				<div class="tablenav">
					<div class="alignleft actions">
						<?php 
        $massEditControls_select = '<select name="massEditAction1">';
        $massEditControls = '<option value="-1" selected="selected">' . __('Mass edit actions', 'gwolle-gb') . '</option>';
        if ($show == 'trash') {
            $massEditControls .= '
								<option value="untrash">' . __('Recover from trash', 'gwolle-gb') . '</option>
								<option value="remove">' . __('Remove permanently', 'gwolle-gb') . '</option>';
        } else {
            if ($show != 'checked') {
                $massEditControls .= '<option value="check">' . __('Mark as checked', 'gwolle-gb') . '</option>';
            }
            if ($show != 'unchecked') {
                $massEditControls .= '<option value="uncheck">' . __('Mark as not checked', 'gwolle-gb') . '</option>';
            }
            if ($show != 'spam') {
                $massEditControls .= '<option value="spam">' . __('Mark as spam', 'gwolle-gb') . '</option>';
            }
            $massEditControls .= '<option value="no-spam">' . __('Mark as not spam', 'gwolle-gb') . '</option>';
            if (get_option('gwolle_gb-akismet-active', 'false') == 'true') {
                $massEditControls .= '<option value="akismet">' . __('Check with Akismet', 'gwolle-gb') . '</option>';
            }
            $massEditControls .= '<option value="trash">' . __('Move to trash', 'gwolle-gb') . '</option>';
            if ($show == 'spam') {
                $massEditControls .= '<option value="remove">' . __('Remove permanently', 'gwolle-gb') . '</option>';
            }
        }
        $massEditControls .= '</select>';
        $massEditControls .= '<input type="submit" value="' . esc_attr__('Apply', 'gwolle-gb') . '" name="doaction" id="doaction" class="button-secondary action" />';
        $empty_button = '';
        if ($show == 'spam') {
            $empty_button = '<input type="submit" name="delete_all" id="delete_all" class="button apply" value="' . esc_attr__('Empty Spam', 'gwolle-gb') . '"  />';
        } else {
            if ($show == 'trash') {
                $empty_button = '<input type="submit" name="delete_all" id="delete_all" class="button apply" value="' . esc_attr__('Empty Trash', 'gwolle-gb') . '"  />';
            }
        }
        // Only show controls when there are entries
        if (is_array($entries) && !empty($entries)) {
            echo $massEditControls_select . $massEditControls . $empty_button;
        }
        ?>
					</div>

					<?php 
        $pagination = gwolle_gb_pagination_admin($pageNum, $countPages, $count, $show);
        echo $pagination;
        ?>
				</div>

				<div>
					<table class="widefat">
						<thead>
							<tr>
								<th scope="col" class="manage-column column-cb check-column"><input name="check-all-top" id="check-all-top" type="checkbox"></th>
								<th scope="col"><?php 
        _e('Book', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('ID', 'gwolle-gb');
        ?>
</th>
								<?php 
        if (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') {
            ?>
									<th scope="col">&nbsp;</th><!-- this is the icon-column -->
								<?php 
        }
        ?>
								<th scope="col"><?php 
        _e('Date', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('Author', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('Entry (excerpt)', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('Action', 'gwolle-gb');
        ?>
</th>
							</tr>
						</thead>

						<tfoot>
							<tr>
								<th scope="col" class="manage-column column-cb check-column"><input name="check-all-bottom" id="check-all-bottom" type="checkbox"></th>
								<th scope="col"><?php 
        _e('Book', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('ID', 'gwolle-gb');
        ?>
</th>
								<?php 
        if (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') {
            ?>
									<th scope="col">&nbsp;</th><!-- this is the icon-column -->
								<?php 
        }
        ?>
								<th scope="col"><?php 
        _e('Date', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('Author', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('Entry (excerpt)', 'gwolle-gb');
        ?>
</th>
								<th scope="col"><?php 
        _e('Action', 'gwolle-gb');
        ?>
</th>
							</tr>
						</tfoot>


						<tbody>
							<?php 
        $rowOdd = true;
        $html_output = '';
        if (!is_array($entries) || empty($entries)) {
            $colspan = get_option('gwolle_gb-showEntryIcons', 'true') === 'true' ? 8 : 7;
            $html_output .= '
									<tr>
										<td colspan="' . $colspan . '" align="center">
											<strong>' . __('No entries found.', 'gwolle-gb') . '</strong>
										</td>
									</tr>';
        } else {
            foreach ($entries as $entry) {
                // rows have a different color.
                if ($rowOdd) {
                    $rowOdd = false;
                    $class = ' alternate';
                } else {
                    $rowOdd = true;
                    $class = '';
                }
                // Attach 'spam' to class if the entry is spam
                if ($entry->get_isspam() === 1) {
                    $class .= ' spam';
                } else {
                    $class .= ' nospam';
                }
                // Attach 'trash' to class if the entry is in trash
                if ($entry->get_istrash() === 1) {
                    $class .= ' trash';
                } else {
                    $class .= ' notrash';
                }
                // Attach 'checked/unchecked' to class
                if ($entry->get_ischecked() === 1) {
                    $class .= ' checked';
                } else {
                    $class .= ' unchecked';
                }
                // Attach 'visible/invisible' to class
                if ($entry->get_isspam() === 1 || $entry->get_istrash() === 1 || $entry->get_ischecked() === 0) {
                    $class .= ' invisible';
                } else {
                    $class .= ' visible';
                }
                // Add admin-entry class to an entry from an admin
                $author_id = $entry->get_author_id();
                $is_moderator = gwolle_gb_is_moderator($author_id);
                if ($is_moderator) {
                    $class .= ' admin-entry';
                }
                // Checkbox and ID columns
                $html_output .= '
										<tr id="entry_' . $entry->get_id() . '" class="entry ' . $class . '">
											<td class="check">
												<input name="check-' . $entry->get_id() . '" id="check-' . $entry->get_id() . '" type="checkbox">
											</td>
											<td class="book">
												<span class="book-icon" title="' . __('Book ID', 'gwolle-gb') . ' ' . $entry->get_book_id() . '">' . $entry->get_book_id() . '</span>
											</td>
											<td class="id">' . $entry->get_id() . '</td>';
                // Optional Icon column where CSS is being used to show them or not
                if (get_option('gwolle_gb-showEntryIcons', 'true') === 'true') {
                    $html_output .= '
											<td class="entry-icons">
												<span class="visible-icon" title="' . __('Visible', 'gwolle-gb') . '"></span>
												<span class="invisible-icon" title="' . __('Invisible', 'gwolle-gb') . '"></span>
												<span class="spam-icon" title="' . __('Spam', 'gwolle-gb') . '"></span>
												<span class="trash-icon" title="' . __('Trash', 'gwolle-gb') . '""></span>';
                    $admin_reply = gwolle_gb_sanitize_output($entry->get_admin_reply());
                    if (strlen(trim($admin_reply)) > 0) {
                        $html_output .= '
												<span class="admin_reply-icon" title="' . __('Admin Replied', 'gwolle-gb') . '"></span>';
                    }
                    $html_output .= '
												<span class="gwolle_gb_ajax" title="' . __('Wait...', 'gwolle-gb') . '"></span>
											</td>';
                }
                // Date column
                $html_output .= '
										<td class="entry-date">' . date_i18n(get_option('date_format'), $entry->get_datetime()) . ', ' . date_i18n(get_option('time_format'), $entry->get_datetime()) . '</td>';
                // Author column
                $author_name_html = gwolle_gb_get_author_name_html($entry);
                $html_output .= '
										<td class="entry-author-name"><span class="author-name">' . $author_name_html . '</span><br />' . '<span class="author-email">' . $entry->get_author_email() . '</span>' . '</td>';
                // Excerpt column
                $html_output .= '
										<td class="entry-content">
											<label for="check-' . $entry->get_id() . '">';
                $entry_content = gwolle_gb_get_excerpt($entry->get_content(), 17);
                if (get_option('gwolle_gb-showSmilies', 'true') === 'true') {
                    $entry_content = convert_smilies($entry_content);
                }
                $html_output .= $entry_content . '</label>
										</td>';
                // Actions column
                $html_output .= '
										<td class="gwolle_gb_actions">
											<span class="gwolle_gb_edit">
												<a href="admin.php?page=' . GWOLLE_GB_FOLDER . '/editor.php&entry_id=' . $entry->get_id() . '" title="' . __('Edit entry', 'gwolle-gb') . '">' . __('Edit', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_check">&nbsp;|&nbsp;
												<a id="check_' . $entry->get_id() . '" href="#" class="vim-a" title="' . __('Check entry', 'gwolle-gb') . '">' . __('Check', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_uncheck">&nbsp;|&nbsp;
												<a id="uncheck_' . $entry->get_id() . '" href="#" class="vim-u" title="' . __('Uncheck entry', 'gwolle-gb') . '">' . __('Uncheck', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_spam">&nbsp;|&nbsp;
												<a id="spam_' . $entry->get_id() . '" href="#" class="vim-s vim-destructive" title="' . __('Mark entry as spam.', 'gwolle-gb') . '">' . __('Spam', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_unspam">&nbsp;|&nbsp;
												<a id="unspam_' . $entry->get_id() . '" href="#" class="vim-a" title="' . __('Mark entry as not-spam.', 'gwolle-gb') . '">' . __('Not spam', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_trash">&nbsp;|&nbsp;
												<a id="trash_' . $entry->get_id() . '" href="#" class="vim-d vim-destructive" title="' . __('Move entry to trash.', 'gwolle-gb') . '">' . __('Trash', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_untrash">&nbsp;|&nbsp;
												<a id="untrash_' . $entry->get_id() . '" href="#" class="vim-d" title="' . __('Recover entry from trash.', 'gwolle-gb') . '">' . __('Untrash', 'gwolle-gb') . '</a>
											</span>
											<span class="gwolle_gb_ajax">&nbsp;|&nbsp;
												<a id="ajax_' . $entry->get_id() . '" href="#" class="ajax vim-d vim-destructive" title="' . __('Please wait...', 'gwolle-gb') . '">' . __('Wait...', 'gwolle-gb') . '</a>
											</span>
										</td>
									</tr>';
            }
        }
        echo $html_output;
        ?>
						</tbody>
					</table>
				</div>

				<div class="tablenav">
					<div class="alignleft actions">
						<?php 
        $massEditControls_select = '<select name="massEditAction2">';
        $empty_button = '';
        if ($show == 'spam') {
            $empty_button = '<input type="submit" name="delete_all2" id="delete_all2" class="button apply" value="' . esc_attr__('Empty Spam', 'gwolle-gb') . '"  />';
        } else {
            if ($show == 'trash') {
                $empty_button = '<input type="submit" name="delete_all2" id="delete_all2" class="button apply" value="' . esc_attr__('Empty Trash', 'gwolle-gb') . '"  />';
            }
        }
        // Only show controls when there are entries
        if (is_array($entries) && !empty($entries)) {
            echo $massEditControls_select . $massEditControls . $empty_button;
        }
        ?>
					</div>

					<?php 
        echo $pagination;
        ?>

				</div>

			</form>

		</div>

		<?php 
    }
}
예제 #15
0
파일: mail.php 프로젝트: RainGrid/site
function gwolle_gb_mail_author_on_admin_reply($entry)
{
    $isspam = $entry->get_isspam();
    if (!$isspam) {
        // Set the Mail Content
        $mailTags = array('user_email', 'user_name', 'blog_name', 'blog_url', 'admin_reply');
        $mail_body = gwolle_gb_sanitize_output(get_option('gwolle_gb-mail_admin_replyContent', false));
        if (!$mail_body) {
            $mail_body = __("\nHello,\n\nAn admin has just added or changed a reply message to your guestbook entry at '%blog_name%'.\n\nHave a nice day.\nThe editors at %blog_name%.\n\n\nWebsite address: %blog_url%\nAdmin Reply:\n%admin_reply%\n", 'gwolle-gb');
        }
        // Set the Mail Headers
        $subject = '[' . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . '] ' . __('Admin Reply', 'gwolle-gb');
        $header = "";
        if (get_option('gwolle_gb-mail-from', false)) {
            $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . gwolle_gb_sanitize_output(get_option('gwolle_gb-mail-from')) . ">\r\n";
        } else {
            $header .= "From: " . gwolle_gb_format_values_for_mail(get_bloginfo('name')) . " <" . get_bloginfo('admin_email') . ">\r\n";
        }
        $header .= "Content-Type: text/plain; charset=UTF-8\r\n";
        // Encoding of the mail
        // Replace the tags from the mailtemplate with real data from the website and entry
        $info['user_name'] = gwolle_gb_sanitize_output($entry->get_author_name());
        $info['user_email'] = $entry->get_author_email();
        $info['blog_name'] = get_bloginfo('name');
        $postid = gwolle_gb_get_postid();
        if ($postid) {
            $info['blog_url'] = get_bloginfo('wpurl') . '?p=' . $postid;
        } else {
            $info['blog_url'] = get_bloginfo('wpurl');
        }
        $info['admin_reply'] = gwolle_gb_format_values_for_mail(gwolle_gb_sanitize_output($entry->get_admin_reply()));
        for ($tagNum = 0; $tagNum < count($mailTags); $tagNum++) {
            $mail_body = str_replace('%' . $mailTags[$tagNum] . '%', $info[$mailTags[$tagNum]], $mail_body);
            $mail_body = gwolle_gb_format_values_for_mail($mail_body);
        }
        wp_mail($entry->get_author_email(), $subject, $mail_body, $header);
    }
}
예제 #16
0
 public function get_content()
 {
     return gwolle_gb_sanitize_output($this->content);
 }