Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
 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;
     }
 }