Пример #1
0
function ar_settings_page()
{
    $options = get_option("allrewriters_settings");
    //print_r($options );
    if (empty($options)) {
        $options = ar_activate();
    }
    if ($_GET["c"] == 1) {
        echo allrewriters_sc_rewrite('<p>Libertarian-leaning Republicans in Congress, including <a target="new" href="https://twitter.com/RepThomasMassie/status/372358495439294464">Reps. Thomas Massie, R-Ky.</a> and <a target="new" href="https://twitter.com/repjustinamash/status/372352492061077504">Justin Amash, R-Mich.</a>, said via Twitter on Tuesday that any action without congressional approval would clearly be unconstitutional.</p>');
    }
    if ($_POST["save_options"]) {
        foreach ($options as $module => $moduledata) {
            if (2 != $moduledata["enabled"]) {
                $options[$module]["enabled"] = $_POST[$module . "_enabled"];
            }
            foreach ($moduledata["options"] as $option => $data) {
                if ($option != "title" && $option != "unique" && $option != "error" && $option != "unique_direct" && $option != "title_direct") {
                    $options[$module]["options"][$option]["value"] = $_POST[$module . "_" . $option];
                }
            }
        }
        $options["general"]["options"]["chain"][1] = $_POST["allrewriters_chain_1"];
        $options["general"]["options"]["chain"][2] = $_POST["allrewriters_chain_2"];
        $options["general"]["options"]["chain"][3] = $_POST["allrewriters_chain_3"];
        $result = update_option("allrewriters_settings", $options);
        if ($result) {
            echo '<div class="updated below-h2"><p>Options have been updated.</p></div>';
        } else {
            echo '<div class="updated below-h2"><p>Error: Options could not be updated.</p></div>';
        }
    }
    $rwactive = 0;
    foreach ($options as $module => $moduledata) {
        if (1 == $moduledata["enabled"]) {
            $rwactive = 1;
        }
    }
    if ($rwactive == 0) {
        $llist = array();
        foreach ($options as $module => $moduledata) {
            if (2 != $moduledata["enabled"]) {
                $llist[] = '<a href="' . $moduledata["link"] . '" target="_blank">' . $moduledata["name"] . '</a>';
            }
        }
        $last = array_pop($llist);
        $string = count($llist) ? implode(", ", $llist) . " and " . $last : $last;
    }
    ?>
<div class="wrap">
	<h2><?php 
    _e("All Rewriters Settings", "allrewriters");
    ?>
</h2>
	
	<?php 
    if ($rwactive == 0) {
        ?>
		<p><?php 
        _e("<strong>No rewriter activated.</strong> Check the rewriters you want to use and then enter your user details for authorization. Once set up rewriting will show up on the Wordpress 'Add New' screens.", "wprobot");
        ?>
</p>
		
		<p><?php 
        _e("All Rewriters supports", "wprobot");
        ?>
 <?php 
        echo $string;
        ?>
. <?php 
        _e("<strong>Tip</strong>: Use several rewriters together for the best results!", "wprobot");
        ?>
</p>
	<?php 
    }
    ?>

	<form method="post" name="allrewriter_options">	
	
				<?php 
    $num = 0;
    foreach ($options as $module => $moduledata) {
        $num++;
        ?>

					<?php 
        if (2 == $moduledata["enabled"]) {
            ?>
						<h3><?php 
            echo $moduledata["name"];
            ?>
</h3>
					<?php 
        } else {
            ?>
						<h3><input style="margin-right: 5px; margin-top: 2px;" onclick="toggle('#<?php 
            echo $module;
            ?>
', this)" class="button" type="checkbox" id="<?php 
            echo $module . "_enabled";
            ?>
" name="<?php 
            echo $module . "_enabled";
            ?>
" value="1" <?php 
            if (1 == $moduledata["enabled"]) {
                echo "checked";
            }
            ?>
/><label for="<?php 
            echo $module . "_enabled";
            ?>
"><?php 
            echo $moduledata["name"];
            ?>
</label> <?php 
            if (!empty($moduledata["link"])) {
                ?>
<a target="_blank" href="<?php 
                echo $moduledata["link"];
                ?>
">Sign Up &rarr;</a><?php 
            }
            ?>
</h3>
					<?php 
        }
        ?>
					
					<div id="<?php 
        echo $module;
        ?>
">					
					<table class="form-table">
						<tbody>				
					
							<?php 
        foreach ($moduledata["options"] as $option => $data) {
            if ($option != "title" && $option != "unique" && $option != "error" && $option != "unique_direct" && $option != "title_direct") {
                if ($data["type"] == "text") {
                    // Text Option
                    ?>
 
										<tr>
											<th scope="row"><label for="<?php 
                    echo $module . "_" . $option;
                    ?>
"><?php 
                    echo $data["name"];
                    ?>
</label></th>
											<td><input class="regular-text" type="text" name="<?php 
                    echo $module . "_" . $option;
                    ?>
" value="<?php 
                    echo $data["value"];
                    ?>
" />

												<!-- EXPLANATION DISPLAY -->	
												<?php 
                    if (!empty($optionsexpl[$module]["options"][$option]["explanation"])) {
                        ?>
													<span style="font-size: 90%;color: #666;"><?php 
                        if (!empty($optionsexpl[$module]["options"][$option]["link"])) {
                            echo '<a target="_blank" href="' . $optionsexpl[$module]["options"][$option]["link"] . '">';
                        }
                        echo $optionsexpl[$module]["options"][$option]["explanation"];
                        if (!empty($optionsexpl[$module]["options"][$option]["link"])) {
                            echo '</a>';
                        }
                        ?>
</span>
												<?php 
                    }
                    ?>
											</td>	
										</tr>
									<?php 
                } elseif ($data["type"] == "select") {
                    // Select Option
                    ?>
										<tr>	
											<th scope="row"><label for="<?php 
                    echo $module . "_" . $option;
                    ?>
"><?php 
                    echo $data["name"];
                    ?>
</label></th>
											<td><select name="<?php 
                    echo $module . "_" . $option;
                    ?>
">
												<?php 
                    foreach ($data["values"] as $val => $name) {
                        ?>
												<option value="<?php 
                        echo $val;
                        ?>
" <?php 
                        if ($val == $data["value"]) {
                            echo "selected";
                        }
                        ?>
><?php 
                        echo $name;
                        ?>
</option>
												<?php 
                    }
                    ?>
		
											</select></td>	
										</tr>
									<?php 
                } elseif ($data["type"] == "checkbox") {
                    // checkbox Option
                    ?>
		
										<tr>	
											<th scope="row"><label for="<?php 
                    echo $module . "_" . $option;
                    ?>
"><?php 
                    echo $data["name"];
                    ?>
</label></th>
											<td><input class="button" type="checkbox" name="<?php 
                    echo $module . "_" . $option;
                    ?>
" value="1" <?php 
                    if (1 == $data["value"]) {
                        echo "checked";
                    }
                    ?>
/>
											
													<!-- EXPLANATION DISPLAY -->	
												<?php 
                    if (!empty($optionsexpl[$module]["options"][$option]["explanation"])) {
                        ?>
													<span style="font-size: 90%;color: #666;"><?php 
                        if (!empty($optionsexpl[$module]["options"][$option]["link"])) {
                            echo '<a target="_blank" href="' . $optionsexpl[$module]["options"][$option]["link"] . '">';
                        }
                        echo $optionsexpl[$module]["options"][$option]["explanation"];
                        if (!empty($optionsexpl[$module]["options"][$option]["link"])) {
                            echo '</a>';
                        }
                        ?>
</span>
												<?php 
                    }
                    ?>
										
											
											</td>	
										</tr>									
									<?php 
                } elseif ($data["type"] == "textarea") {
                    // textarea Option
                    ?>
		
										<tr>	
											<th scope="row"><label for="<?php 
                    echo $module . "_" . $option;
                    ?>
"><?php 
                    echo $data["name"];
                    ?>
</label></th>
											
											<td>
													<!-- EXPLANATION DISPLAY -->	
												<?php 
                    if (!empty($optionsexpl[$module]["options"][$option]["explanation"])) {
                        ?>
													<span style="font-size: 90%;color: #666;"><?php 
                        if (!empty($optionsexpl[$module]["options"][$option]["link"])) {
                            echo '<a target="_blank" href="' . $optionsexpl[$module]["options"][$option]["link"] . '">';
                        }
                        echo $optionsexpl[$module]["options"][$option]["explanation"];
                        if (!empty($optionsexpl[$module]["options"][$option]["link"])) {
                            echo '</a>';
                        }
                        ?>
</span><br/>
												<?php 
                    }
                    ?>
												
											
											<textarea cols="80" rows="3" name="<?php 
                    echo $module . "_" . $option;
                    ?>
"><?php 
                    echo $data["value"];
                    ?>
</textarea>
											</td>	
										</tr>									
									<?php 
                }
                ?>
	
									
								<?php 
            }
            ?>
							<?php 
        }
        ?>
					
						</tbody>
					</table>								
					
					</div>	
				<?php 
    }
    ?>
				
				
				<h3><?php 
    _e("Rewriting Chain", "wprobot");
    ?>
</h3>
				<div>
					<table class="form-table">
						<tbody>					
							<tr class="odd">	
								<th scope="row"><label for=""><?php 
    _e("Rewriting Chain", "wprobot");
    ?>
</label></th>
								<td>
								Rewriter 1: <select name="allrewriters_chain_1">
									<option <?php 
    if (empty($options["general"]["options"]["chain"][1])) {
        echo "selected";
    }
    ?>
 value="">---</option>									
									<?php 
    foreach ($options as $module => $moduledata) {
        if ($module != "general") {
            ?>
									<option <?php 
            if ($options["general"]["options"]["chain"][1] == $moduledata["function"]) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $moduledata["function"];
            ?>
"><?php 
            echo $moduledata["name"];
            ?>
</option>									
									<?php 
        }
    }
    ?>
								</select>
								Rewriter 2: <select name="allrewriters_chain_2">
									<option <?php 
    if (empty($options["general"]["options"]["chain"][2])) {
        echo "selected";
    }
    ?>
 value="">---</option>									
									<?php 
    foreach ($options as $module => $moduledata) {
        if ($module != "general") {
            ?>
									<option <?php 
            if ($options["general"]["options"]["chain"][2] == $moduledata["function"]) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $moduledata["function"];
            ?>
"><?php 
            echo $moduledata["name"];
            ?>
</option>									
									<?php 
        }
    }
    ?>
								</select>
								Rewriter 3: <select name="allrewriters_chain_3">
									<option <?php 
    if (empty($options["general"]["options"]["chain"][3])) {
        echo "selected";
    }
    ?>
 value="">---</option>									
									<?php 
    foreach ($options as $module => $moduledata) {
        if ($module != "general") {
            ?>
									<option <?php 
            if ($options["general"]["options"]["chain"][3] == $moduledata["function"]) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $moduledata["function"];
            ?>
"><?php 
            echo $moduledata["name"];
            ?>
</option>									
									<?php 
        }
    }
    ?>
								</select>								
								</td>	
							</tr>				
						</tbody>
					</table>					
				</div>	
				<p class="submit"><input class="button-primary" type="submit" name="save_options" value="<?php 
    _e("Save All Settings", "wprobot");
    ?>
" /></p>	
	
<?php 
}
Пример #2
0
function wpr_sub_options()
{
    global $wpdb, $wpr_table_campaigns, $wpr_table_templates, $wpr_table_errors, $wpr_table_posts, $wpr_modules, $_wp_using_ext_object_cache, $wpr_loadedmodules;
    $_wp_using_ext_object_cache = false;
    $options = unserialize(get_option("wpr_options"));
    $wpr_disabledmodules = $options["disabled_modules"];
    if (!is_array($wpr_disabledmodules)) {
        $wpr_disabledmodules = array();
    }
    $rw_options = get_option("allrewriters_settings");
    if (empty($rw_options)) {
        $rw_options = ar_activate($options);
    }
    if ($_POST['wpr_disable_save']) {
        $wpr_disabledmodules = array();
        foreach ($wpr_loadedmodules as $lmodule) {
            if ($_POST['disable_' . $lmodule] == 1) {
            } else {
                $wpr_disabledmodules[] = $lmodule;
            }
        }
        $options["disabled_modules"] = $wpr_disabledmodules;
        update_option("wpr_options", serialize($options));
        echo '<div class="updated"><p>' . __('Your module selection has been saved.', 'wprobot') . '</p></div>';
    }
    if ($_POST['wpr_uninstall']) {
        $results = $wpdb->query("DROP TABLE {$wpr_table_posts},{$wpr_table_templates},{$wpr_table_campaigns},{$wpr_table_errors};");
        delete_option("wpr_options");
        delete_option("wpr_cron");
        delete_option("wpr_cloak");
        delete_option('wpr_db_ver');
        ar_deactivate();
        $options = "";
        echo '<div class="updated"><p>' . __('WP Robot has been uninstalled. You can now disable and delete the plugin.<br/><br/><strong>If you intend to reinstall WP Robot please first disable and reenable the plugin on your blogs "Plugins" page - otherwise the installation will not work!</strong>', 'wprobot') . '</p></div>';
    }
    if ($options['wpr_installed'] != "yes") {
        echo '<div class="wrap"><h2>WP Robot</h2><div class="updated"><h3>Installation</h3><p>' . __('Please go <a href="?page=wpr-campaigns">here</a> to finish the installation of WP Robot first.', 'wprobot') . '</p></div></div>';
        return false;
    }
    if ($_POST['wpr_options_default']) {
        $options = wpr_default_options(1);
        echo '<div class="updated"><p>' . __('Options have been reset.', 'wprobot') . '</p></div>';
    }
    if ($_POST['wpr_templates_default']) {
        $results = $wpdb->query("TRUNCATE TABLE {$wpr_table_templates};");
        $sql = unserialize(get_option("wpr_sql"));
        if (empty($sql)) {
            $sql = $options["wpr_sql"];
        }
        $results2 = $wpdb->query($sql);
        if ($results2) {
            echo '<div class="updated"><p>' . __('Templates have been reset.', 'wprobot') . '</p></div>';
        } else {
            echo '<div class="updated"><p>' . __('Templates could not be reset.', 'wprobot') . '</p></div>';
        }
    }
    if ($_POST['wpr_import']) {
        $options = wpr_import_options();
        echo '<div class="updated"><p>' . __('Settings have been imported.', 'wprobot') . '</p></div>';
    }
    if ($_POST['wpr_clear_log']) {
        $results = $wpdb->query("TRUNCATE TABLE {$wpr_table_errors};");
        echo '<div class="updated"><p>' . __('Log has been cleared.', 'wprobot') . '</p></div>';
    }
    if ($_POST['wpr_clear_posts']) {
        $results = $wpdb->query("TRUNCATE TABLE {$wpr_table_posts};");
        echo '<div class="updated"><p>' . __('History has been cleared.', 'wprobot') . '</p></div>';
    }
    if ($_POST['wpr_update_email']) {
        $options['wpr_email'] = wpr_update_email($options['wpr_email'], $_POST['wpr_email']);
    }
    if ($_POST['wpr_update_core']) {
        wpr_update_email($options['wpr_email'], $options['wpr_email'], 1);
    }
    if ($_POST['wpr_options_save']) {
        if ($_POST['wpr_cloak'] == "Yes" && get_option('wpr_cloak') != "Yes") {
            echo '<div class="updated"><p>' . __('<b>Warning:</b> Link cloaking has been enabled but <a href="http://wprobot.net/blog/how-to-set-up-wp-robot-link-cloaking/">additional steps</a> are required to finish the setup. If you do not follow these steps affiliate links on your blog will not work!', 'wprobot') . '</p></div>';
        }
        $options['wpr_resetcount'] = $_POST['wpr_resetcount'];
        $options['wpr_autotag'] = $_POST['wpr_autotag'];
        $options['wpr_badwords'] = $_POST['wpr_badwords'];
        $options['wpr_randomize'] = $_POST['wpr_randomize'];
        $options['wpr_randomize_comments'] = $_POST['wpr_randomize_comments'];
        $options['wpr_help'] = $_POST['wpr_help'];
        $options['wpr_poststatus'] = $_POST['wpr_poststatus'];
        $options['wpr_cb_affkey'] = $_POST['wpr_cb_affkey'];
        $options['wpr_cb_filter'] = $_POST['wpr_cb_filter'];
        $options['wpr_openlinks'] = $_POST['wpr_openlinks'];
        $options['wpr_authorid'] = $_POST['wpr_authorid'];
        $options['wpr_err_retries'] = $_POST['wpr_err_retries'];
        $options['wpr_err_maxerr'] = $_POST['wpr_err_maxerr'];
        $options['wpr_err_minmod'] = $_POST['wpr_err_minmod'];
        $options['wpr_err_disable'] = $_POST['wpr_err_disable'];
        $options["wpr_global_exclude"] = $_POST['wpr_global_exclude'];
        $options['wpr_check_unique_old'] = $_POST['wpr_check_unique_old'];
        $options['wpr_simple'] = $_POST['wpr_simple'];
        $options['wpr_save_images'] = $_POST['wpr_save_images'];
        $options['wpr_replace_keyword'] = $_POST['wpr_replace_keyword'];
        //$options['wpr_rewrite_active'] = $_POST['wpr_rewrite_active'];
        /*$options['wpr_rewrite_active_tbs'] = $_POST['wpr_rewrite_active_tbs'];
        		$options['wpr_rewrite_active_sc'] = $_POST['wpr_rewrite_active_sc'];
        		$options['wpr_rewrite_active_schimp'] = $_POST['wpr_rewrite_active_schimp'];
        		$options['wpr_rewrite_active_ucg'] = $_POST['wpr_rewrite_active_ucg'];	
        		$options['wpr_rewrite_active_sr'] = $_POST['wpr_rewrite_active_sr'];	
        		$options['wpr_rewrite_active_wai'] = $_POST['wpr_rewrite_active_wai'];			
        		$options['wpr_rewrite_email'] = $_POST['wpr_rewrite_email'];
        		$options['wpr_rewrite_key'] = $_POST['wpr_rewrite_key'];
        		$options['wpr_rewrite_level'] = $_POST['wpr_rewrite_level'];
        		$options['wpr_tbs_rewrite_email'] = $_POST['wpr_tbs_rewrite_email'];
        		$options['wpr_tbs_rewrite_pw'] = $_POST['wpr_tbs_rewrite_pw'];	
        		$options['wpr_tbs_spintxt'] = $_POST['wpr_tbs_spintxt'];	
        		$options['wpr_tbs_quality'] = $_POST['wpr_tbs_quality'];
        		$options['wpr_rewrite_protected'] = $_POST['wpr_rewrite_protected'];
        		$options['wpr_sc_rewrite_email'] = $_POST['wpr_sc_rewrite_email'];
        		$options['wpr_sc_rewrite_pw'] = $_POST['wpr_sc_rewrite_pw'];
        		$options['wpr_sc_quality'] = $_POST['wpr_sc_quality'];
        		$options['wpr_sc_port'] = $_POST['wpr_sc_port'];
        		$options['wpr_sc_thesaurus'] = $_POST['wpr_sc_thesaurus'];
        		$options['wpr_schimp_rewrite_email'] = $_POST['wpr_schimp_rewrite_email'];
        		$options['wpr_schimp_rewrite_pw'] = $_POST['wpr_schimp_rewrite_pw'];
        		$options['wpr_schimp_quality'] = $_POST['wpr_schimp_quality'];	
        		$options['wpr_sr_rewrite_email'] = $_POST['wpr_sr_rewrite_email'];	
        		$options['wpr_sr_rewrite_pw'] = $_POST['wpr_sr_rewrite_pw'];	
        		$options['wpr_sr_quality'] = $_POST['wpr_sr_quality'];	
        		$options['wpr_wai_rewrite_email'] = $_POST['wpr_wai_rewrite_email'];	
        		$options['wpr_wai_rewrite_pw'] = $_POST['wpr_wai_rewrite_pw'];	
        		$options['wpr_wai_quality'] = $_POST['wpr_wai_quality'];
        		$options['wpr_wai_sentence'] = $_POST['wpr_wai_sentence'];
        		$options['wpr_wai_paragraph'] = $_POST['wpr_wai_paragraph'];
        		$options['wpr_wai_nooriginal'] = $_POST['wpr_wai_nooriginal'];*/
        $options['wpr_tbs_rewrite_title'] = $_POST['wpr_tbs_rewrite_title'];
        $options['wpr_rewrite_use'] = $_POST['wpr_rewrite_use'];
        $options['wpr_trans_use_proxies'] = $_POST['wpr_trans_use_proxies'];
        $options['wpr_trans_proxies'] = $_POST['wpr_trans_proxies'];
        foreach ($wpr_modules as $module) {
            $function = "wpr_" . $module . "_options_default";
            if (function_exists($function)) {
                if (is_array($wpr_disabledmodules) && in_array($module, $wpr_disabledmodules)) {
                } else {
                    $moptions = $function();
                    foreach ($moptions as $moption => $default) {
                        $options[$moption] = $_POST[$moption];
                    }
                }
            }
        }
        update_option("wpr_options", serialize($options));
        update_option('wpr_cloak', $_POST['wpr_cloak']);
        echo '<div class="updated"><p>' . __('Options have updated.<br>', 'wprobot') . '</p></div>';
    }
    include "display-options.php";
}