Пример #1
0
 function gdptStats()
 {
     if (function_exists("memory_get_usage")) {
         $this->memory = gdFunctionsGDPT::size_format(memory_get_usage());
     }
     $this->queries = get_num_queries();
     $this->timer = timer_stop(1);
 }
Пример #2
0
 /**
  * Scans folder and adds all folders to array.
  *
  * @param string $path folder path
  * @return array founded folders in array
  */
 function get_folders($path)
 {
     $folders = gdFunctionsGDPT::scan_dir($path);
     $import = array();
     foreach ($folders as $folder) {
         if (substr($folder, 0, 1) != ".") {
             if (is_dir($path . $folder . "/")) {
                 $import[] = $folder;
             }
         }
     }
     return $import;
 }
Пример #3
0
Файл: db.php Проект: hewu/blogwp
 function get_tables_overhead()
 {
     $size = GDPTDB::get_tables_overhead_simple();
     return gdFunctionsGDPT::size_format($size);
 }
Пример #4
0
/**
 * Deletes revisions for selected post.
 *
 * @global WPDB $wpdb wordpress database object
 * @global string $table_prefix prefix used for database tables
 * @param int $post_id post id to delete revisions from
 * @return int number of deleted revisions
 */
function gd_delete_revisions($post_id)
{
    global $wpdb, $table_prefix;
    $sql = sprintf("delete %s, %s, %s from %sposts p left join %sterm_relationships t on t.object_id = p.ID left join %spostmeta m on m.post_id = p.ID where p.post_type = 'revision' and p.post_parent = %s", gdFunctionsGDPT::mysql_pre_4_1() ? sprintf("%sposts", $table_prefix) : "p", gdFunctionsGDPT::mysql_pre_4_1() ? sprintf("%sterm_relationships", $table_prefix) : "t", gdFunctionsGDPT::mysql_pre_4_1() ? sprintf("%spostmeta", $table_prefix) : "m", $table_prefix, $table_prefix, $table_prefix, $post_id);
    $wpdb->query($sql);
    wp_gdpt_log_sql("DELETE_REVISIONS_FOR_POST", $sql);
    return $wpdb->rows_affected;
}
Пример #5
0
    </div>
    <div id="gdpt_server" class="postbox gdrgrid frontleft">
        <h3 class="hndle"><span><?php 
_e("mySQL Status", "gd-press-tools");
?>
</span></h3>
        <div class="inside">
            <div class="table">
                <table><tbody>
                    <tr class="first">
                        <td class="first b"><?php 
_e("Version", "gd-press-tools");
?>
:</td>
                        <td class="t options"><?php 
echo gdFunctionsGDPT::mysql_version(true);
?>
</td>
                    </tr>
                    <tr>
                        <td class="first b"><?php 
_e("Full Database Size", "gd-press-tools");
?>
:</td>
                        <td class="t options"><?php 
echo GDPTDB::get_database_size();
?>
</td>
                    </tr>
                    <tr>
                        <td class="first b"><?php 
Пример #6
0
 echo '<tr>';
 echo '<td style="padding: 0 4px;">';
 echo '<div class="gdptdbtoggle on" id="ct' . $col_id . '"><img src="' . PRESSTOOLS_URL . 'gfx/blank.gif" height="16" width="16" /></div>';
 echo '</td>';
 echo '<td><strong>' . $t->Name . '</strong></td>';
 echo '<td>';
 $status = GDPTDB::check_table($t->Name);
 echo $status->Msg_type . ": " . $status->Msg_text;
 echo '</td>';
 echo '<td>' . $t->Collation . '</td>';
 echo '<td style="text-align: right;">' . $t->Rows . '</td>';
 echo '<td style="text-align: right;">' . gdFunctionsGDPT::size_format($t->Data_length) . '</td>';
 echo '<td style="text-align: right;">';
 if ($t->Data_free > 0) {
     echo '<strong style="color: red">';
     echo gdFunctionsGDPT::size_format($t->Data_free);
     if ($t->Data_free > 0) {
         echo '</strong>';
     }
 } else {
     echo '/';
 }
 echo '</td>';
 echo '<td style="text-align: right;">';
 if (!in_array(strtolower($t->Name), $wp_tables)) {
     echo '<a onclick="return confirmDrop()" href="admin.php?page=gd-press-tools-database&gda=tpldrp&name=' . $t->Name . '">' . __("drop", "gd-press-tools") . '</a> | <a onclick="return confirmEmpty()" href="admin.php?page=gd-press-tools-database&gda=tblemp&name=' . $t->Name . '">' . __("empty", "gd-press-tools") . '</a>';
 }
 echo '</td>';
 echo '</tr>';
 echo '<tr id="cl' . $col_id . '" style="display: none"><td></td><td colspan="6">';
 ?>
Пример #7
0
 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"]);
     }
 }
Пример #8
0
Файл: db.php Проект: hewu/blogwp
    return confirm("<?php 
_e("Are you sure taht you want to EMPTY this table? Operation is not reversible.", "gd-press-tools");
?>
");
}
</script>
<div class="gdsr"><div class="wrap">
<h2 class="gdptlogopage">GD Press Tools: <?php 
_e("Database", "gd-press-tools");
?>
</h2>
<?php 
gdpt_upgrade_notice();
$files = $backups = array();
if (is_dir(WP_CONTENT_DIR . "/gdbackup/")) {
    $files = gdFunctionsGDPT::scan_dir(WP_CONTENT_DIR . "/gdbackup/");
    foreach ($files as $fl) {
        if (substr($fl, 0, 10) == "db_backup_") {
            $backups[$fl] = WP_CONTENT_URL . "/gdbackup/" . $fl;
        }
    }
}
global $gdpt;
$gdpt->backup_folder();
if (!is_dir(WP_CONTENT_DIR . "/gdbackup/")) {
    ?>
<div id="gdnotice" class="gderror">
    <p><?php 
    _e("For backup to work, plugin must be able to access backup folder. Plugin has tried to create folders needed and failed. Until you resolved this issue backup will not work.", "gd-press-tools");
    ?>
    <?php