<?php require_once '../../EzGA.php'; if (!EzGA::isLoggedIn()) { http_response_code(400); die("Please login before messing with this!"); } extract($_REQUEST, EXTR_PREFIX_ALL, 'posted'); if ($posted_validator) { // a server-side validator is specified $fun = "validate_{$posted_validator}"; if (method_exists('EzGA', $fun)) { $valid = EzGA::$fun($posted_value); } else { http_response_code(400); die("Unknown validator ({$posted_validator}) specified"); } if ($valid !== true) { http_response_code(400); die("{$valid}"); } } http_response_code(200);
static function update() { $posted_pk = $posted_name = $posted_value = $posted_validator = ""; if (!EzGA::isLoggedIn()) { http_response_code(400); die("Please login before changing options!"); } global $wpdb; if (empty($wpdb)) { http_response_code(400); die("Global variable wpdb not set!"); } $table = $wpdb->prefix . "ez_adsense_options"; $row = array(); extract($_POST, EXTR_PREFIX_ALL, 'posted'); if (empty($posted_pk)) { http_response_code(400); die("Empty primary key"); } if (empty($posted_name)) { http_response_code(400); die("Empty name ({$posted_name}) in data"); } if (!isset($posted_value)) { // Checkbox, unchecked $posted_value = 0; } if (is_array($posted_value)) { // Checkbox (from checklist), checked $posted_value = 1; } if (!empty($posted_validator)) { // a server-side validator is specified $fun = "validate_{$posted_validator}"; if (method_exists('EzGA', $fun)) { $valid = self::$fun($posted_value); } else { http_response_code(400); die("Unknown validator ({$posted_validator}) specified"); } if ($valid !== true) { http_response_code(400); die("{$valid}"); } } $row['name'] = $posted_pk; $row['value'] = $posted_value; foreach (array('plugin_slug', 'theme', 'provider', 'optionset') as $col) { $posted = "posted_{$col}"; if (!empty(${$posted})) { $row[$col] = ${$posted}; } else { $row[$col] = "All"; } } $status = $wpdb->replace($table, $row); if ($status === false) { http_response_code(400); die("Database Replace/Insert Error"); } http_response_code(200); exit; }
<?php require '../EzGA.php'; if (EzGA::isLoggedIn()) { if (!EzGA::isActive()) { $pluginsPage = admin_url('plugins.php'); wp_die("<h3>Plugin Not Active</h3><strong>Ads EZ Plugin for Google AdSense</strong> is not active.<br/ >Please activate it from your <a href='{$pluginsPage}'>plugin admin page</a> before accessing this page."); } return; } else { header("location: " . wp_login_url($_SERVER['PHP_SELF'])); exit; }