function init_operations() { $msg = ""; if (isset($_POST["gdsr_multi_review_form"]) && $_POST["gdsr_multi_review_form"] == "review") { $mur_all = $_POST['gdsrmulti']; foreach ($mur_all as $post_id => $data) { if ($post_id > 0) { foreach ($data as $set_id => $mur) { $set = gd_get_multi_set($set_id); $values = explode("X", $mur); $record_id = GDSRDBMulti::get_vote($post_id, $set_id, count($set->object)); GDSRDBMulti::save_review($record_id, $values); GDSRDBMulti::recalculate_multi_review($record_id, $values, $set); } } } $this->custom_actions('init_save_review'); wp_redirect_self(); exit; } if (isset($_POST["gdsr_editcss_rating"])) { $rating_css = STARRATING_XTRA_PATH . "css/rating.css"; if (is_writeable($rating_css)) { $newcontent = stripslashes($_POST['gdsr_editcss_contents']); $f = fopen($rating_css, 'w+'); fwrite($f, $newcontent); fclose($f); } wp_redirect_self(); exit; } if (isset($_POST['gdsr_debug_clean'])) { wp_gdsr_debug_clean(); wp_redirect_self(); exit; } if (isset($_POST['gdsr_cache_clean'])) { GDSRHelper::clean_cache(substr(STARRATING_CACHE_PATH, 0, strlen(STARRATING_CACHE_PATH) - 1)); $this->o["cache_cleanup_last"] = date("r"); update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_preview_scan'])) { $this->g = gdsrAdmFunc::gfx_scan(); update_option('gd-star-rating-gfx', $this->g); wp_redirect_self(); exit; } if (isset($_POST['gdsr_t2_import'])) { gdsrAdmDB::insert_extras_templates(STARRATING_XTRA_PATH, false); wp_redirect_self(); exit; } if (isset($_POST['gdsr_upgrade_tool'])) { require_once STARRATING_PATH . "/gdragon/gd_db_install.php"; gdDBInstallGDSR::delete_tables(STARRATING_PATH); gdDBInstallGDSR::create_tables(STARRATING_PATH); gdDBInstallGDSR::upgrade_tables(STARRATING_PATH); gdDBInstallGDSR::alter_tables(STARRATING_PATH); gdDBInstallGDSR::alter_tables(STARRATING_PATH, "idx.txt"); $this->o["database_upgrade"] = date("r"); update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_updatemultilog_tool'])) { GDSRDBMulti::recalculate_multi_rating_log(); wp_redirect_self(); exit; } if (isset($_POST['gdsr_mulitrecalc_tool'])) { $set_id = $_POST['gdsr_mulitrecalc_set']; if ($set_id > 0) { GDSRDBMulti::recalculate_set($set_id); } else { GDSRDBMulti::recalculate_all_sets(); } wp_redirect_self(); exit; } if (isset($_POST['gdsr_cleanup_tool'])) { if (isset($_POST['gdsr_tools_clean_invalid_log'])) { $count = gdsrTlsDB::clean_invalid_log_articles(); if ($count > 0) { $msg .= $count . " " . __("articles records from log table removed.", "gd-star-rating") . " "; } $count = gdsrTlsDB::clean_invalid_log_comments(); if ($count > 0) { $msg .= $count . " " . __("comments records from log table removed.", "gd-star-rating") . " "; } } if (isset($_POST['gdsr_tools_clean_invalid_trend'])) { $count = gdsrTlsDB::clean_invalid_trend_articles(); if ($count > 0) { $msg .= $count . " " . __("articles records from trends log table removed.", "gd-star-rating") . " "; } $count = gdsrTlsDB::clean_invalid_trend_comments(); if ($count > 0) { $msg .= $count . " " . __("comments records from trends log table removed.", "gd-star-rating") . " "; } } if (isset($_POST['gdsr_tools_clean_old_posts'])) { $count = gdsrTlsDB::clean_dead_articles(); if ($count > 0) { $msg .= $count . " " . __("dead articles records from articles table.", "gd-star-rating") . " "; } $count = gdsrTlsDB::clean_revision_articles(); if ($count > 0) { $msg .= $count . " " . __("post revisions records from articles table.", "gd-star-rating") . " "; } $count = gdsrTlsDB::clean_dead_comments(); if ($count > 0) { $msg .= $count . " " . __("dead comments records from comments table.", "gd-star-rating") . " "; } } if (isset($_POST['gdsr_tools_clean_old_posts'])) { $count = GDSRDBMulti::clean_dead_articles(); if ($count > 0) { $msg .= $count . " " . __("dead articles records from multi ratings tables.", "gd-star-rating") . " "; } $count = GDSRDBMulti::clean_revision_articles(); if ($count > 0) { $msg .= $count . " " . __("post revisions records from multi ratings tables.", "gd-star-rating") . " "; } } $this->o["database_cleanup"] = date("r"); $this->o["database_cleanup_msg"] = $msg; update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_post_lock'])) { $lock_date = $_POST['gdsr_lock_date']; gdsrAdmDB::lock_post_massive($lock_date); $this->o["mass_lock"] = $lock_date; update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_rules_set'])) { wp_gdsr_dump("POST", $_POST); gdsrAdmDB::update_settings_full($_POST["gdsr_article_moderation"], $_POST["gdsr_article_voterules"], $_POST["gdsr_comments_moderation"], $_POST["gdsr_comments_voterules"], $_POST["gdsr_artthumb_moderation"], $_POST["gdsr_artthumb_voterules"], $_POST["gdsr_cmmthumbs_moderation"], $_POST["gdsr_cmmthumbs_voterules"]); wp_redirect_self(); exit; } }
function settings_operations() { if (isset($_POST['widgets_saving'])) { $this->save_setting_checkbox("load_default_css"); $this->save_setting_checkbox("cache_data"); $this->save_setting_checkbox("debug_into_file"); $this->save_setting_checkbox("widgets_recent_comments"); $this->save_setting_checkbox("widgets_related_posts"); $this->save_setting_checkbox("widgets_recent_posts"); $this->save_setting_checkbox("widgets_most_commented"); $this->save_setting_checkbox("widgets_posts_authors"); $this->save_setting_checkbox("widgets_future_posts"); $this->save_setting_checkbox("widgets_popular_posts"); $this->save_setting_checkbox("widgets_random_posts"); $this->save_setting_checkbox("widgets_related_posts"); $this->save_setting_checkbox("widgets_simple_125_ads"); $this->save_setting_checkbox("default_recent_comments"); $this->save_setting_checkbox("default_recent_posts"); $this->save_setting_checkbox("default_random_posts"); update_option("gd-simple-widgets", $this->o); wp_redirect_self(); exit; } }
function init_operations() { $msg = ""; if ($_POST["gdsr_multi_review_form"] == "review") { $mur_all = $_POST['gdsrmulti']; $set_id = $this->o["mur_review_set"]; foreach ($mur_all as $post_id => $data) { $mur = $data[0]; $values = explode("X", $mur); $set = gd_get_multi_set($set_id); $record_id = GDSRDBMulti::get_vote($post_id, $set_id, count($set->object)); GDSRDBMulti::save_review($record_id, $values); GDSRDBMulti::recalculate_multi_review($record_id, $values, $set); } $this->custom_actions('init_save_review'); wp_redirect_self(); exit; } if (isset($_POST["gdsr_editcss_rating"])) { $rating_css = STARRATING_XTRA_PATH . "css/rating.css"; if (is_writeable($rating_css)) { $newcontent = stripslashes($_POST['gdsr_editcss_contents']); $f = fopen($rating_css, 'w+'); fwrite($f, $newcontent); fclose($f); } wp_redirect_self(); exit; } if (isset($_POST['gdsr_debug_clean'])) { wp_gdsr_debug_clean(); wp_redirect_self(); exit; } if (isset($_POST['gdsr_cache_clean'])) { GDSRHelper::clean_cache(substr(STARRATING_CACHE_PATH, 0, strlen(STARRATING_CACHE_PATH) - 1)); $this->o["cache_cleanup_last"] = date("r"); update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_preview_scan'])) { $this->g = $this->gfx_scan(); update_option('gd-star-rating-gfx', $this->g); wp_redirect_self(); exit; } if (isset($_POST['gdsr_t2_import'])) { GDSRDB::insert_extras_templates(STARRATING_XTRA_PATH, false); wp_redirect_self(); exit; } if (isset($_POST['gdsr_upgrade_tool'])) { gdDBInstallGDSR::delete_tables(STARRATING_PATH); gdDBInstallGDSR::create_tables(STARRATING_PATH); gdDBInstallGDSR::upgrade_tables(STARRATING_PATH); gdDBInstallGDSR::alter_tables(STARRATING_PATH); $this->o["database_upgrade"] = date("r"); update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_mulitrecalc_tool'])) { $set_id = $_POST['gdsr_mulitrecalc_set']; if ($set_id > 0) { GDSRDBMulti::recalculate_set($set_id); } else { GDSRDBMulti::recalculate_all_sets(); } wp_redirect_self(); exit; } if (isset($_POST['gdsr_cleanup_tool'])) { if (isset($_POST['gdsr_tools_clean_invalid_log'])) { $count = GDSRDBTools::clean_invalid_log_articles(); if ($count > 0) { $msg .= $count . " " . __("articles records from log table removed.", "gd-star-rating") . " "; } $count = GDSRDBTools::clean_invalid_log_comments(); if ($count > 0) { $msg .= $count . " " . __("comments records from log table removed.", "gd-star-rating") . " "; } } if (isset($_POST['gdsr_tools_clean_invalid_trend'])) { $count = GDSRDBTools::clean_invalid_trend_articles(); if ($count > 0) { $msg .= $count . " " . __("articles records from trends log table removed.", "gd-star-rating") . " "; } $count = GDSRDBTools::clean_invalid_trend_comments(); if ($count > 0) { $msg .= $count . " " . __("comments records from trends log table removed.", "gd-star-rating") . " "; } } if (isset($_POST['gdsr_tools_clean_old_posts'])) { $count = GDSRDBTools::clean_dead_articles(); if ($count > 0) { $msg .= $count . " " . __("dead articles records from articles table.", "gd-star-rating") . " "; } $count = GDSRDBTools::clean_revision_articles(); if ($count > 0) { $msg .= $count . " " . __("post revisions records from articles table.", "gd-star-rating") . " "; } $count = GDSRDBTools::clean_dead_comments(); if ($count > 0) { $msg .= $count . " " . __("dead comments records from comments table.", "gd-star-rating") . " "; } } if (isset($_POST['gdsr_tools_clean_old_posts'])) { $count = GDSRDBMulti::clean_dead_articles(); if ($count > 0) { $msg .= $count . " " . __("dead articles records from multi ratings tables.", "gd-star-rating") . " "; } $count = GDSRDBMulti::clean_revision_articles(); if ($count > 0) { $msg .= $count . " " . __("post revisions records from multi ratings tables.", "gd-star-rating") . " "; } } $this->o["database_cleanup"] = date("r"); $this->o["database_cleanup_msg"] = $msg; update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_post_lock'])) { $lock_date = $_POST['gdsr_lock_date']; GDSRDatabase::lock_post_massive($lock_date); $this->o["mass_lock"] = $lock_date; update_option('gd-star-rating', $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdsr_rules_set'])) { GDSRDatabase::update_settings_full($_POST["gdsr_article_moderation"], $_POST["gdsr_article_voterules"], $_POST["gdsr_comments_moderation"], $_POST["gdsr_comments_voterules"]); wp_redirect_self(); exit; } if (isset($_GET["deltpl"])) { $del_id = $_GET["deltpl"]; GDSRDB::delete_template($del_id); $url = remove_query_arg("deltpl"); wp_redirect($url); exit; } if (isset($_POST["gdsr_save_tpl"])) { $general = array(); $general["name"] = stripslashes(htmlentities($_POST['tpl_gen_name'], ENT_QUOTES, STARRATING_ENCODING)); $general["desc"] = stripslashes(htmlentities($_POST['tpl_gen_desc'], ENT_QUOTES, STARRATING_ENCODING)); $general["section"] = $_POST["tpl_section"]; $general["dependencies"] = $_POST["tpl_tpl"]; $general["id"] = $_POST["tpl_id"]; $general["preinstalled"] = '0'; $tpl_input = $_POST["tpl_element"]; $elements = array(); foreach ($tpl_input as $key => $value) { $elements[$key] = stripslashes(htmlentities($value, ENT_QUOTES, STARRATING_ENCODING)); } if ($general["id"] == 0) { GDSRDB::add_template($general, $elements); } else { GDSRDB::edit_template($general, $elements); } $url = remove_query_arg("tplid"); $url = remove_query_arg("mode", $url); wp_redirect($url); exit; } }
function init_operations() { if ($this->wp_version < 28 && isset($_GET["page"]) && $_GET["page"] == "index.php" && $this->script == "admin.php") { wp_redirect("index.php"); exit; break; } if (isset($_GET["proupgrade"]) && $_GET["proupgrade"] == "hide") { $this->o["upgrade_to_pro"] = 0; update_option("gd-press-tools", $this->o); wp_redirect(remove_query_arg("proupgrade")); exit; } if (isset($_GET["gda"])) { $gd_action = $_GET["gda"]; if ($gd_action != '') { switch ($gd_action) { case "unsevt": gd_unschedule_event($_GET['time'], $_GET['job'], $_GET['key']); wp_redirect(remove_query_arg(array('time', 'job', 'gda', 'key'), stripslashes($_SERVER['REQUEST_URI']))); exit; break; case "runevt": $job = $_GET['job']; if ($job == "wp_update_plugins") { delete_transient("update_plugins"); } if ($job == "wp_update_themes") { delete_transient("update_themes"); } if ($job == "wp_version_check") { delete_transient("update_core"); } do_action($job); wp_redirect(remove_query_arg(array('job', 'gda'), stripslashes($_SERVER['REQUEST_URI']))); exit; break; case "delrev": $post_id = $_GET["pid"]; $counter = gd_delete_revisions($post_id); $this->o["counter_total_revisions"] += $counter; wp_redirect(remove_query_arg(array('pid', 'gda'), stripslashes($_SERVER['REQUEST_URI']))); exit; break; case "duplicate": $post_id = $_GET["pid"]; $new_id = GDPTDB::duplicate_post($post_id); if ($new_id > 0) { wp_redirect(sprintf("post.php?action=edit&post=%s", $new_id)); } else { wp_redirect(remove_query_arg(array('pid', 'gda'), stripslashes($_SERVER['REQUEST_URI']))); } exit; break; case "tpldrp": $table = $_GET["name"]; gd_db_table_drop($table); wp_redirect(remove_query_arg(array('name', 'gda'), stripslashes($_SERVER['REQUEST_URI']))); exit; break; case "tblemp": $table = $_GET["name"]; gd_db_table_empty($table); wp_redirect(remove_query_arg(array('name', 'gda'), stripslashes($_SERVER['REQUEST_URI']))); exit; break; } } } if (isset($_POST['gdpt_tagger_forced'])) { $this->o["tagger_abort"] = 1; update_option("gd-press-tools", $this->o); $this->s["tagger"]["status"] = "idle"; $this->s["tagger"]["ended"] = time(); update_option("gd-press-tools-status", $this->s); wp_redirect_self(); exit; } if (isset($_POST['gdpt_tagger_stop'])) { $this->o["tagger_abort"] = 1; update_option("gd-press-tools", $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdpt_dbbackup_delete'])) { $files = gdFunctionsGDPT::scan_dir(WP_CONTENT_DIR . "/gdbackup/"); foreach ($files as $fl) { if (substr($fl, 0, 10) == "db_backup_") { unlink(WP_CONTENT_DIR . "/gdbackup/" . $fl); } } wp_redirect_self(); exit; } if (isset($_POST['gdpt_backup_run'])) { $gziped = isset($_POST["backup_compressed"]); $backup = new gdMySQLBackup(GDPTDB::get_tables_names(), WP_CONTENT_DIR . "/gdbackup/", $gziped); $backup->drop_tables = isset($_POST["backup_drop_exists"]); $backup->structure_only = isset($_POST["backup_structure_only"]); $backup->backup(); wp_redirect_self(); exit; } if (isset($_POST['gdpt_tagger_run'])) { if (!isset($this->s["tagger"]) || $this->s["tagger"]["status"] == "idle") { $this->s["tagger"]["status"] = "scheduled"; $this->s["tagger"]["limit"] = $_POST['gdpt_tagger_limit']; $this->s["tagger"]["posts"] = isset($_POST['gdpt_tagger_post']) ? 1 : 0; $this->s["tagger"]["pages"] = isset($_POST['gdpt_tagger_page']) ? 1 : 0; $this->s["tagger"]["start"] = $_POST['gdpt_tagger_start']; $this->s["tagger"]["end"] = $_POST['gdpt_tagger_end']; $this->o["tagger_abort"] = 0; update_option("gd-press-tools-status", $this->s); update_option("gd-press-tools", $this->o); wp_schedule_single_event(time() + 20, 'gdpt_auto_tagger'); wp_redirect_self(); exit; } } if (isset($_POST['gdpt_revisions_delete'])) { $counter = gd_delete_all_revisions(); $this->o["counter_total_revisions"] += $counter; $this->o["tool_revisions_removed"] = date("r"); update_option("gd-press-tools", $this->o); wp_redirect_self(); exit; } if (isset($_POST['gdpt_cmm_set'])) { $cmm_date = $_POST["gdpt_cmm_date"]; $cmm_comments = isset($_POST["gdpt_cmm_comments"]) ? 1 : 0; $cmm_pings = isset($_POST["gdpt_cmm_pings"]) ? 1 : 0; GDPTDB::set_posts_comments_status($cmm_date, $cmm_comments, $cmm_pings); wp_redirect_self(); exit; } if (isset($_POST['gdpt_db_clean'])) { $size = GDPTDB::get_tables_overhead_simple(); $this->o["counter_total_overhead"] += $size; update_option("gd-press-tools", $this->o); gd_optimize_db(); wp_redirect_self(); exit; } if (isset($_POST['gdpt_admin_rss_cache_reset'])) { if ($this->wp_version < 28) { gd_clear_rss_cache(); } else { gd_clear_rss_cache_transient(); } wp_redirect_self(); exit; } if (isset($_POST['gdpt_admin_widget_reset'])) { gd_reset_widgets(); wp_redirect_self(); exit; } if (isset($_POST['gdpt_admin_avatar_scan'])) { update_option('gd-press-tools-avatars', $this->gravatar_folder($this->g)); wp_redirect_self(); exit; } if (isset($_POST['gdpt_admin_rename'])) { $this->status = GDPTDB::rename_account($_POST['gdpt_admin_username']); if ($this->status == "OK") { } wp_redirect_self(); exit; } if (isset($_POST['gdpt_admin_folder_protect'])) { gd_create_protection_files(); wp_redirect_self(); exit; } if (isset($_POST['gdpt_posts_delete'])) { $results = GDPTDB::delete_posts($_POST['gdpt_delposts_date']); $this->status = sprintf(__("Deleted %s posts and %s comments.", "gd-press-tools"), $results["posts"], $results["comments"]); } }