function wprp_handle_reports() { global $wpdb, $wprp_message; // get Post PARAM $post_id = (int) $_POST['postID']; $report_as = $_POST['report_as']; $description = $_POST['description']; $ipaddress = get_ipaddress(); $nonce = $_POST['wpnonce']; // Get the Post $post = get_post($post_id); // Check for POST if (!$post_id || !$post) { echo "<strong>Invalid Post</strong>"; return; } // Security CHECK if (!wp_verify_nonce($nonce, $post_id)) { echo "<strong>Security Check Failed, Please Submit again...</strong>"; return; } include_once 'ReportPost.class.php'; $rp = new ReportPost($wpdb); if ($rp->add($post_id, $report_as, $description)) { $reported = true; } else { echo "! Sorry, Unable to Process your Request. Please contact Site Administrator via Email to Report this Issue"; } /* // tpValirable $reported=false; // Check for Existing Post Report $post_count=$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->reportpost WHERE post_id=%s",$post_id)); if(is_numeric($post_count) && $post_count>0) { // Update the Description $result=$wpdb->query( $wpdb->prepare("UPDATE $wpdb->reportpost SET description=CONCAT(description,%s) WHERE post_id=%s"," <br />[".$ipaddress."] : ".$report_as." | ".$description,$post_id)); $reported=true; }else{ // Do Report! $result=$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->reportpost(post_id,post_title,user_ip,description,stamp) VALUES(%s,%s,%s,%s,%s)",$post_id, $post->post_title, $ipaddress,"[".$ipaddress."] : ".$report_as." | ".$description,time())); $reported=true; // Send Mail $send_email=get_option("rp_send_email"); if($send_email==1) { // SEND EMAIL $mail_to=get_option("rp_email_address"); $mail_subject="[REPORT] : ".$post->post_title; $mail_body="Following Post has been Reported through ".get_option("blogname")."\n-----\n"; $mail_body.="POST ID: ".$post_id."\n"; $mail_body.="POST TITLE: ".$post->post_title."\n"; $mail_body.="Reported As: ".$report_as."\n"; $mail_body.="Description: \n".$description."\n"; $mail_body.="\n-----\nThank You"; $mail_header="From: Admin <".get_option("admin_email").">"; // Send mail // @ Prvent from Showing Any Error Message JUST in CASE @mail($mail_to,$mail_subject,$mail_body,$mail_header); } }*/ if ($reported) { // get thanks Option $thanksMsg = get_option('rp_thanks_msg'); if (empty($thanksMsg)) { $thanksMsg = "<strong>Thanks for Reporting [TITLE]</strong>"; } $thanksMsg = str_replace("[TITLE]", $post->post_title, $thanksMsg); echo $thanksMsg; echo "<br />Reported as : " . $report_as; if (!empty($description)) { echo "<br />Comments : " . $description; } } }
update_option("rp_send_email", "0"); if ($data != NULL && is_array($data) && count($data) > 0) { foreach ($data as $report) { // Split Data $comments = $report->description; $comments = split("<br />", $comments); # Split Different Contents foreach ($comments as $comment) { $comment_array = split(":", $comment, 2); # GETS IP $IP = $comment_array[0]; $IP = str_replace(array("[", "]"), "", trim($IP)); $comment_array = split('\\|', $comment_array[1], 2); # GETS Type & Actual Comment // Now we Start to INSERT into NEW $wprp->add($report->post_id, $comment_array[0], $comment_array[1], $report->stamp, $IP); } // comments // Update Archive Status if ($report->status == "1" && $wprp->insert_id > 0) { $wprp->archive($wprp->insert_id, $current_user->ID, "Converted during Upgrade"); } $wprp->insert_id = 0; // Just to be SAFE! } } // Delete OLD TABLE $wpdb->query($wpdb->prepare("DROP TABLE {$old_table}")); // Restore Email Option update_option("rp_send_email", $email_opt); $text = '<font color="green"> * successfully updated</font>';