';
$ratings_tables = array($wpdb->ratings);
foreach($ratings_tables as $table) {
$wpdb->query("DROP TABLE {$table}");
echo '';
printf(__('Table "%s" Has Been Dropped.', 'wp-postratings'), "{$table}");
echo '
';
}
$ratings_settings = array('postratings_image', 'postratings_max', 'postratings_template_vote', 'postratings_template_text', 'postratings_template_none', 'postratings_logging_method', 'postratings_allowtorate', 'postratings_ratingstext', 'postratings_template_highestrated');
foreach($ratings_settings as $setting) {
$delete_setting = delete_option($setting);
if($delete_setting) {
echo '';
printf(__('Setting Key \'%s\' Has been Errased.', 'wp-postratings'), "{$setting}");
} else {
echo '';
printf(__('Error Deleting Setting Key \'%s\'.', 'wp-postratings'), "{$setting}");
}
echo '
';
}
$ratings_postmeta = array('ratings_users', 'ratings_score', 'ratings_average');
foreach($ratings_postmeta as $postmeta) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '$postmeta'");
echo '';
printf(__('Post Meta "%s" Has Been Deleted.', 'wp-postratings'), "$postmeta");
echo '
';
}
echo '
';
$mode = 'end-UNINSTALL';
}
break;
case __('Delete Data/Logs', 'wp-postratings'):
$post_ids = trim($_POST['delete_postid']);
$delete_datalog = intval($_POST['delete_datalog']);
$ratings_postmeta = array('ratings_users', 'ratings_score', 'ratings_average');
if(!empty($post_ids)) {
switch($delete_datalog) {
case 1:
if($post_ids == 'all') {
$delete_logs = $wpdb->query("DELETE FROM $wpdb->ratings");
if($delete_logs) {
$text = ''.__('All Post Ratings Logs Have Been Deleted.', 'wp-postratings').'';
} else {
$text = ''.__('An Error Has Occured While Deleting All Post Ratings Logs.', 'wp-postratings').'';
}
} else {
$delete_logs = $wpdb->query("DELETE FROM $wpdb->ratings WHERE rating_postid IN($post_ids)");
if($delete_logs) {
$text = ''.sprintf(__('All Post Ratings Logs For Post ID(s) %s Have Been Deleted.', 'wp-postratings'), $post_ids).'';
} else {
$text = ''.sprintf(__('An Error Has Occured While Deleting All Post Ratings Logs For Post ID(s) %s.', 'wp-postratings'), $post_ids).'';
}
}
break;
case 2:
if($post_ids == 'all') {
foreach($ratings_postmeta as $postmeta) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '$postmeta'");
$text .= ''.sprintf(__('Rating Data "%s" Has Been Deleted.', 'wp-postratings'), "$postmeta").'
';
}
} else {
foreach($ratings_postmeta as $postmeta) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '$postmeta' AND post_id IN($post_ids)");
$text .= ''.sprintf(__('Rating Data "%s" For Post ID(s) %s Has Been Deleted.', 'wp-postratings'), "$postmeta", $post_ids).'
';
}
}
break;
case 3:
if($post_ids == 'all') {
$delete_logs = $wpdb->query("DELETE FROM $wpdb->ratings");
if($delete_logs) {
$text = ''.__('All Post Ratings Logs Have Been Deleted.', 'wp-postratings').'
';
} else {
$text = ''.__('An Error Has Occured While Deleting All Post Ratings Logs.', 'wp-postratings').'
';
}
foreach($ratings_postmeta as $postmeta) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '$postmeta'");
$text .= ''.sprintf(__('Rating Data "%s" Has Been Deleted.', 'wp-postratings'), "$postmeta").'
';
}
} else {
$delete_logs = $wpdb->query("DELETE FROM $wpdb->ratings WHERE rating_postid IN($post_ids)");
if($delete_logs) {
$text = ''.sprintf(__('All Post Ratings Logs For Post ID(s) %s Have Been Deleted.', 'wp-postratings'), $post_ids).'
';
} else {
$text = ''.sprintf(__('An Error Has Occured While Deleting All Post Ratings Logs For Post ID(s) %s.', 'wp-postratings'), $post_ids).'
';
}
foreach($ratings_postmeta as $postmeta) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '$postmeta' AND post_id IN($post_ids)");
$text .= ''.sprintf(__('Rating Data "%s" For Post ID(s) %s Has Been Deleted.', 'wp-postratings'), "$postmeta", $post_ids).'
';
}
}
break;
}
}
break;
}
}
### Form Sorting URL
if(!empty($postratings_sortby)) {
$postratings_sort_url .= '&by='.$postratings_sortby;
}
if(!empty($postratings_sortorder)) {
$postratings_sort_url .= '&order='.$postratings_sortorder;
}
if(!empty($postratings_log_perpage)) {
$postratings_sort_url .= '&perpage='.$postratings_log_perpage;
}
### Get Order By
switch($postratings_sortby) {
case 'id':
$postratings_sortby = 'rating_id';
$postratings_sortby_text = __('ID', 'wp-postratings');
break;
case 'username':
$postratings_sortby = 'rating_username';
$postratings_sortby_text = __('Username', 'wp-postratings');
break;
case 'rating':
$postratings_sortby = 'rating_rating';
$postratings_sortby_text = __('Rating', 'wp-postratings');
break;
case 'postid':
$postratings_sortby = 'rating_postid';
$postratings_sortby_text = __('Post ID', 'wp-postratings');
break;
case 'posttitle':
$postratings_sortby = 'rating_posttitle';
$postratings_sortby_text = __('Post Title', 'wp-postratings');
break;
case 'ip':
$postratings_sortby = 'rating_ip';
$postratings_sortby_text = __('IP', 'wp-postratings');
break;
case 'host':
$postratings_sortby = 'rating_host';
$postratings_sortby_text = __('Host', 'wp-postratings');
break;
case 'date':
default:
$postratings_sortby = 'rating_timestamp';
$postratings_sortby_text = __('Date', 'wp-postratings');
}
### Get Sort Order
switch($postratings_sortorder) {
case 'asc':
$postratings_sortorder = 'ASC';
$postratings_sortorder_text = __('Ascending', 'wp-postratings');
break;
case 'desc':
default:
$postratings_sortorder = 'DESC';
$postratings_sortorder_text = __('Descending', 'wp-postratings');
}
### Determines Which Mode It Is
switch($mode) {
// Deactivating WP-PostRatings
case 'end-UNINSTALL':
echo '';
echo '
';
_e('Uninstall Ratings', 'wp-postratings');
echo'
';
echo '
';
$deactivate_url = "plugins.php?action=deactivate&plugin=postratings/postratings.php";
if(function_exists('wp_nonce_url')) {
$deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_postratings/postratingss.php');
}
printf(__('Click Here To Finish The Uninstallation And WP-PostRatings Will Be Deactivated Automatically.', 'wp-postratings'), $deactivate_url);
echo '';
echo '
';
echo '
';
break;
default:
// Get Post Ratings Logs Data
$total_ratings = $wpdb->get_var("SELECT COUNT(rating_id) FROM $wpdb->ratings");
$total_users = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = 'ratings_users'");
$total_score = $wpdb->get_var("SELECT SUM((meta_value+0.00)) FROM $wpdb->postmeta WHERE meta_key = 'ratings_score'");
if($total_users == 0) {
$total_average = 0;
} else {
$total_average = $total_score/$total_users;
}
// Checking $postratings_page and $offset
if(empty($postratings_page) || $postratings_page == 0) { $postratings_page = 1; }
if(empty($offset)) { $offset = 0; }
if(empty($postratings_log_perpage) || $postratings_log_perpage == 0) { $postratings_log_perpage = 20; }
// Determin $offset
$offset = ($postratings_page-1) * $postratings_log_perpage;
// Determine Max Number Of Ratings To Display On Page
if(($offset + $postratings_log_perpage) > $total_ratings) {
$max_on_page = $total_ratings;
} else {
$max_on_page = ($offset + $postratings_log_perpage);
}
// Determine Number Of Ratings To Display On Page
if (($offset + 1) > ($total_ratings)) {
$display_on_page = $total_ratings;
} else {
$display_on_page = ($offset + 1);
}
// Determing Total Amount Of Pages
$total_pages = ceil($total_ratings / $postratings_log_perpage);
// Get The Logs
$postratings_logs = $wpdb->get_results("SELECT * FROM $wpdb->ratings ORDER BY $postratings_sortby $postratings_sortorder LIMIT $offset, $postratings_log_perpage");
?>
'; } ?>
|
|
|
|
|
|
|
rating_id);
$postratings_username = stripslashes($postratings_log->rating_username);
$postratings_rating = intval($postratings_log->rating_rating);
$postratings_postid = intval($postratings_log->rating_postid);
$postratings_posttitle = stripslashes($postratings_log->rating_posttitle);
$postratings_date = gmdate("jS F Y", $postratings_log->rating_timestamp);
$postratings_time = gmdate("H:i", $postratings_log->rating_timestamp);
$postratings_ip = $postratings_log->rating_ip;
$postratings_host = $postratings_log->rating_host;
echo "\n";
echo "| $postratings_id | \n";
echo "$postratings_username | \n";
echo '';
if(file_exists(ABSPATH.'/wp-content/plugins/postratings/images/'.$ratings_image.'/rating_start.gif')) {
echo ' ';
}
for($j=1; $j <= $ratings_max; $j++) {
if($j <= $postratings_rating) {
echo ' ';
} else {
echo ' ';
}
}
if(file_exists(ABSPATH.'/wp-content/plugins/postratings/images/'.$ratings_image.'/rating_end.gif')) {
echo ' ';
}
echo ' | '."\n";
echo "$postratings_postid | \n";
echo "$postratings_posttitle | \n";
echo "$postratings_date, $postratings_time | \n";
echo "$postratings_ip / $postratings_host | \n";
echo '
';
$i++;
}
} else {
echo '| '.__('No Post Ratings Logs Found', 'wp-postratings').' |
';
}
?>
1) {
?>