Example #1
0
/**
 * Get post or posts views for user.
 *
 * @param int $id user ID to get data for, or leave 0 for current user
 * @param bool $all_posts true to get for all posts, false for current or specified
 * @param int $post_id specify the post ID, or leave 0 to get current
 * @return int|array|WP_Error number of views for post, all posts or error if input is invalid. array has post_id as key and views as values.
 */
function presstools_get_user_views($id = 0, $all_posts = false, $post_id = 0)
{
    if ($id == 0) {
        global $user_ID;
        if (intval($user_ID) == 0) {
            return new WP_Error("presstools_get_user_views", __("Given user ID is invalid.", "gd-press-tools"));
        }
        $id = $user_ID;
    }
    if (!$all_posts && $post_id == 0) {
        global $post;
        $post_id = $post->ID;
    }
    if (!$all_posts) {
        if ($post_id > 0) {
            $results = GDPTDB::count_user_views_for_post($id, $post_id);
            if (is_object($results) && !is_null($results)) {
                return intval($results->views);
            } else {
                return 0;
            }
        } else {
            return new WP_Error("presstools_get_user_views", __("Given post ID is invalid.", "gd-press-tools"));
        }
    } else {
        $results = GDPTDB::count_user_views($id);
        $output = array();
        if (is_array($results) && !empty($results)) {
            foreach ($results as $row) {
                $output[$row->post_id] = $row->views;
            }
        }
        return $output;
    }
}
Example #2
0
File: db.php Project: hewu/blogwp
 function get_tables_overhead()
 {
     $size = GDPTDB::get_tables_overhead_simple();
     return gdFunctionsGDPT::size_format($size);
 }
Example #3
0
        <table><tbody>
<?php 
$constants = @get_defined_constants();
ksort($constants);
$first = true;
foreach ($constants as $key => $value) {
    echo sprintf('<tr%s><td class="first b">%s:</td><td class="t">%s</td></tr>', $first ? ' class="first"' : '', $key, $value);
    $first = false;
}
?>
        </tbody></table>
    </div>
</div>
<div id="fragment-3" class="gdrgrid">
    <div class="table">
        <table><tbody>
<?php 
$mysql_info = GDPTDB::get_mysql_server_info();
$first = true;
foreach ($mysql_info as $info) {
    echo sprintf('<tr%s><td class="first b">%s:</td><td class="t">%s</td></tr>', $first ? ' class="first"' : '', $info->Variable_name, htmlspecialchars($info->Value));
    $first = false;
}
?>
        </tbody></table>
    </div>
</div>
</div>

</div></div>
Example #4
0
    $span = sprintf('<span class="handler %s" id="gdpt-hndl-%s" onclick="gdpt_dashboard_element(this, \'%s\', \'%s\', \'%s\')">[ %s ]</span>', $state ? "shown" : "hiden", $id, $tx_show, $tx_hide, PRESSTOOLS_URL . "ajax.php", $state ? $tx_hide : $tx_show);
    echo $span;
}
?>

<p class="sub">
    <?php 
gdpt_render_handler("info", $options["dashboard_handler_info"] == 1);
?>
    <?php 
_e("Additional Statistics Info", "gd-press-tools");
?>
    <?php 
$cnt_revisions = gd_count_revisions_total();
$cnt_spam = gd_count_spam_total();
$cnt_overhead = GDPTDB::get_tables_overhead();
?>
</p>
<div class="table" id="gdpt-table-info" style="<?php 
echo $options["dashboard_handler_info"] == 1 ? "" : "display: none";
?>
">
    <table><tbody>
        <tr class="first">
            <td class="first b"><?php 
echo $cnt_revisions;
?>
</td>
            <td class="t"><?php 
_e("Revisions for all published posts", "gd-press-tools");
?>
Example #5
0
    <div class="gdpt-table-split-edit"></div>
    <div class="gdpt-table-robots<?php 
echo $meta_robots["active"] == 1 ? " gdpt-disabled" : "";
?>
">
        <table width="100%" style="">
            <tr>
                <td>
                    <label style="font-size: 12px;" for="gdsr_review"><?php 
_e("Standard", "gd-press-tools");
?>
:</label>
                </td>
                <td align="right" valign="baseline">
                    <?php 
GDPTDB::render_meta_robots("gdpt_meta_robots_standard", isset($meta_robots["standard"]) ? $meta_robots["standard"] : "", $disabled);
?>
                </td>
            </tr>
            <tr>
                <td>
                    <input<?php 
echo $disabled;
?>
 type="checkbox" class="gdpt_check" name="gdpt_meta_robots_extra[noydir]" id="gdpt_meta_robots_noydir"<?php 
if (isset($meta_robots["noydir"]) && $meta_robots["noydir"] == 1) {
    echo " checked";
}
?>
 /><label style="margin-left: 5px;" for="gdpt_meta_robots_noydir"><?php 
_e("No Yahoo", "gd-press-tools");
Example #6
0
                        <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 
_e("WordPress Tables Size", "gd-press-tools");
?>
:</td>
                        <td class="t options"><?php 
echo GDPTDB::get_tables_size();
?>
</td>
                    </tr>
                </tbody></table>
            </div>
        </div>
    </div>
</div>
Example #7
0
?>
</th>
        </tr>
    </thead>
    <tbody>
    <?php 
$tables = GDPTDB::get_tables_status();
$col_id = 0;
foreach ($tables as $t) {
    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 '/';
    }
Example #8
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"]);
     }
 }