<?php include 'mdp_css.php'; $mdpWebmasterTools = new mdpWebmasterTools(); if ($_POST['get']) { $mdpWebmasterTools->mdp_gwt_query_function(); } ?> <div class="wrap"> <h2>Keywords</h2> <p>It is not necessary to always update your keywords. It will update automatically update every hour by the wp_cron().</p> <form action="" method="post"><input type="submit" value="Update Keywords" name="get" class="button"></form> <table style="width:100%; margin:20px 0 20px 0; border:1px solid #ddd;"> <tr style="background:#EFEFEF;"> <td style="width:15%;font-size:13px; padding:5px 2px 5px 2px;"><a href="<?php echo $mdpWebmasterTools->full_url($_SERVER['REQUEST_URI']); ?> &s=query">Keyword</a> </td> <td style="width:5%;font-size:13px; padding:5px 2px 5px 2px;"><a href="<?php echo $mdpWebmasterTools->full_url($_SERVER['REQUEST_URI']); ?> &s=occurrences">Impressions</a> </td> <td style="width:10%;font-size:13px; padding:5px 2px 5px 2px;"><a
/** function/mdp_gwt_query_function * Usage: download csv from google and insert data into wp_mdp_gwt_queries table * also attached to the wp_cron by mdp_gwt_hook * Arg(0): null * Return: void */ public static function mdp_gwt_query_function() { global $wpdb; $mdpWebmasterTools = new mdpWebmasterTools(); $dir = MDP_GWT_DIR . 'csv/' . get_current_blog_id() . '/'; // test directory exists if not create if (!file_exists($dir)) { if (!mkdir($dir, 0775, true)) { echo 'Error making directory check your permissions'; } } include MDP_GWT_DIR . 'gwt_data.php'; //erase old files to keep directory clean if (count(glob("{$dir}*.csv")) > 0) { array_map('unlink', glob("{$dir}*.csv")); } //download the csv files from google try { /* If hardcoded, don't forget trailing slash! */ $gdata = new GWTdata(); if ($gdata->LogIn(get_option('mdp_gwt_email'), get_option('mdp_gwt_password')) === true) { $sites = $gdata->GetSites(); if (get_option('mdp_gwt_recency')) { $gdata->SetDaterange(array(date('Y-m-d', time() - 86400 * get_option('mdp_gwt_recency')), date('Y-m-d', time()))); } foreach ($sites as $site) { $gdata->DownloadCSV($site, $dir); } /* uncomment to see downloaded files $files = $gdata->GetDownloadedFiles(); foreach ($files as $file) { print "Saved $file\n"; } */ } } catch (Exception $e) { die($e->getMessage()); } //assign the table name $table_name_queries = $wpdb->base_prefix . "mdp_gwt_query"; $table_name_pages = $wpdb->base_prefix . "mdp_gwt_pages"; $table_name_keywords = $wpdb->base_prefix . "mdp_gwt_keywords"; $table_name_external_links = $wpdb->base_prefix . "mdp_gwt_external_links"; $table_name_internal_links = $wpdb->base_prefix . "mdp_gwt_internal_links"; //scan the csv directory for files if ($files = scandir($dir)) { //iterate through the file line by line foreach ($files as $file) { if (preg_match('#QUERIES#is', $file)) { $mdpWebmasterTools->mdp_truncate($table_name_queries); $thistype = 'queries'; } elseif (preg_match('#PAGES#is', $file)) { $mdpWebmasterTools->mdp_truncate($table_name_pages); $thistype = 'pages'; } elseif (preg_match('#KEYWORDS#is', $file)) { $mdpWebmasterTools->mdp_truncate($table_name_keywords); $thistype = 'keywords'; } elseif (preg_match('#EXTERNAL_LINKS#is', $file)) { $mdpWebmasterTools->mdp_truncate($table_name_external_links); $thistype = 'external'; } elseif (preg_match('#INTERNAL_LINKS#is', $file)) { $mdpWebmasterTools->mdp_truncate($table_name_internal_links); $thistype = 'internal'; } else { continue; } $query_file = $dir . $file; $row_query = 1; if (($handle_query = fopen($query_file, "r")) !== FALSE) { while (($data_query = fgetcsv($handle_query, 2000, ",")) !== FALSE) { if ($row_query++ === 1) { $allrows = count($data_query) > 6; continue; } switch ($thistype) { case 'queries': $mdpWebmasterTools->mdp_replace_table_pages_query($data_query, $table_name_queries, $allrows); break; case 'pages': $mdpWebmasterTools->mdp_replace_table_pages_query($data_query, $table_name_pages, $allrows); break; case 'keywords': $mdpWebmasterTools->mdp_replace_table_keywords($data_query, $table_name_keywords); break; case 'external': $mdpWebmasterTools->mdp_replace_table_external_links($data_query, $table_name_external_links); break; case 'internal': $mdpWebmasterTools->mdp_replace_table_internal_links($data_query, $table_name_internal_links); break; } } } fclose($handle_query); } } }
<?php include 'mdp_css.php'; $mdpWebmasterTools = new mdpWebmasterTools(); if ($_POST['get']) { $mdpWebmasterTools->mdp_gwt_query_function(); } ?> <div class="wrap"> <h2>Top Pages</h2> <p>It is not necessary to always update your queries. It will update automatically update every hour by the wp_cron().</p> <form action="" method="post"><input type="submit" value="Update Top Pages" name="get" class="button"></form> <table style="width:100%; margin:20px 0 20px 0; border:1px solid #ddd;"> <tr style="background:#EFEFEF;"> <td style="width:40%;font-size:13px; padding:5px 2px 5px 2px;"><a href="<?php echo $_SERVER['REQUEST_URI']; ?> &s=query">Query</a></td> <td style="width:5%;font-size:13px; padding:5px 2px 5px 2px;"><a href="<?php echo $mdpWebmasterTools->full_url($_SERVER['REQUEST_URI']); ?> &s=impressions">Impressions</a> </td> <td style="width:5%;font-size:13px; padding:5px 2px 5px 2px;"><a href="<?php
<?php global $mdpWebmasterTools; $mdpWebmasterTools = new mdpWebmasterTools(); $mdpimgdir = plugins_url('', __FILE__); if ($_POST['get']) { $mdpWebmasterTools->mdp_gwt_query_function(); } ?> <script src='<?php echo plugins_url('', __FILE__); ?> /jquery.tablesorter.js'></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("table.tablesorter").tablesorter({emptyTo: 'bottom'}); }); </script> <style> .mdp_table { min-width: 800px; max-width: 1080px; border: 1px solid #EEEEEE; padding: 5px 5px 5px 5px; margin: 5px 5px 5px 5px; } .mdp_table tr { border: 1px solid #EEEEEE; }