Exemple #1
0
 function star_menu_settings()
 {
     if (isset($_POST['gdsr_preview_scan'])) {
         $this->g->g = gdsrAdmFunc::gfx_scan();
         update_option('gd-star-rating-gfx', $this->g->g);
     }
     $recalculate_articles = $recalculate_comment = $recalculate_reviews = $recalculate_cmm_reviews = false;
     $gdsr_options = $this->g->o;
     $gdsr_bots = $this->g->bots;
     $gdsr_root_url = $this->g->plugin_url;
     $gdsr_gfx = $this->g->g;
     $gdsr_wpr8 = $this->g->wpr8_available;
     $extra_folders = $this->g->extra_folders;
     $safe_mode = $this->g->safe_mode;
     $wpv = $this->g->wp_version;
     $ginc_sizes = $this->g->ginc[0];
     $ginc_stars = $this->g->ginc[1];
     $wpr8 = $this->g->wpr8;
     include STARRATING_PATH . 'options/settings.php';
     if ($recalculate_articles) {
         gdsrAdmDB::recalculate_articles($gdsr_oldstars, $gdsr_newstars);
     }
     if ($recalculate_comment) {
         gdsrAdmDB::recalculate_comments($gdsr_cmm_oldstars, $gdsr_cmm_newstars);
     }
     if ($recalculate_reviews) {
         gdsrAdmDB::recalculate_reviews($gdsr_review_oldstars, $gdsr_review_newstars);
     }
     if ($recalculate_cmm_reviews) {
         gdsrAdmDB::recalculate_comments_reviews($gdsr_cmm_review_oldstars, $gdsr_cmm_review_newstars);
     }
 }
Exemple #2
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;
     }
 }