get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE ".$table_name." ( id mediumint(255) NOT NULL KEY AUTO_INCREMENT, stat ENUM('P','X') NOT NULL, type VARCHAR(255) NOT NULL, company VARCHAR(255) NOT NULL, fname VARCHAR(255) NOT NULL, lname VARCHAR(255) NOT NULL, address1 VARCHAR(255) NOT NULL, address2 VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, state VARCHAR(255) NOT NULL, zip VARCHAR(255) NOT NULL, country VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, rating VARCHAR(255) NOT NULL, num_ratings MEDIUMINT(255) NOT NULL );"; require_once(ABSPATH . './wp-admin/upgrade-functions.php'); dbDelta($sql); } // create "ibot_rating" table $table_name = $table_prefix ."ibot_rating"; if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE ".$table_name." ( id mediumint(255) NOT NULL KEY AUTO_INCREMENT, co_id MEDIUMINT(255) NOT NULL, stat ENUM('P','X') NOT NULL, name VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, state VARCHAR(255) NOT NULL, country VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, rating MEDIUMINT(255) NOT NULL, comments TEXT NOT NULL );"; require_once(ABSPATH . './wp-admin/upgrade-functions.php'); dbDelta($sql); } } // insert admin ui // =-=-=-=-=-=-=-= function ibot_review_admin_ui() { if (function_exists('add_management_page')) { add_management_page('Reviews', 'Reviews', 8, basename(__FILE__), 'ibot_review_subpanel'); } } // update ratings and comments // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ibot_check_ratings($rid) { global $wpdb, $table_prefix; // grab company id $co_id = $wpdb->get_var("SELECT `co_id` FROM `".$table_prefix."ibot_rating` WHERE id='$rid' LIMIT 1"); // sum totals $total = $wpdb->get_var("SELECT SUM(`rating`) FROM `".$table_prefix."ibot_rating` WHERE stat='X' AND co_id='$co_id'"); $wpdb->get_results("SELECT `id` FROM `".$table_prefix."ibot_rating` WHERE stat='X' AND co_id='$co_id'"); $num = $wpdb->num_rows; // average $avg = round(($total/$num),2); // update $wpdb->query("UPDATE `".$table_prefix."ibot_company` SET rating='$avg', num_ratings='$num' WHERE id='$co_id' LIMIT 1"); } // generate admin ui // =-=-=-=-=-=-=-=-= function ibot_review_subpanel() { global $table_prefix, $wpdb; // check for installation ibot_install(); // save changes If($_GET["save"]=="YES") { // new company If(!empty($_POST["new"])) {foreach($_POST["new"] as $key=>$val) { // approve If($val=="approve") {$wpdb->query("UPDATE `".$table_prefix."ibot_company` SET stat='X' WHERE id='".$key."' LIMIT 1");} // delete If($val=="delete") {$wpdb->query("DELETE FROM `".$table_prefix."ibot_company` WHERE id='".$key."' LIMIT 1");} }} // new reviews If(!empty($_POST["rev"])) {foreach($_POST["rev"] as $key=>$array) { // save changes $wpdb->query("UPDATE `".$table_prefix."ibot_rating` SET name='".db_safe($array[name])."', city='".db_safe($array[city])."', state='".db_safe($array[state])."', country='".db_safe($array[country])."', email='".db_safe($array[email])."', comments='".db_safe($array[comments])."', rating='".db_safe($array[rating])."' WHERE id='".$key."' LIMIT 1"); // approve If($array[act]=="approve") {$wpdb->query("UPDATE `".$table_prefix."ibot_rating` SET stat='X' WHERE id='".$key."' LIMIT 1"); ibot_check_ratings($key);} // delete If($array[act]=="delete") {$wpdb->query("DELETE FROM `".$table_prefix."ibot_rating` WHERE id='".$key."' LIMIT 1");} }} print "

These changes have been saved!

"; } // grab new companies $new_cos = $wpdb->get_results("SELECT * FROM `".$table_prefix."ibot_company` WHERE stat='P' ORDER BY id ASC"); // grab new reviews $new_reviews = $wpdb->get_results("SELECT * FROM `".$table_prefix."ibot_rating` WHERE stat='P' ORDER BY id ASC"); ?>

New Companies

Approve Delete Company First Name Last Name Address1 Address2 City State Zip Country Phone '; foreach($new_cos as $co) { ?> company?> fname?> lname?> address1?> address2?> city?> state?> zip?> country?> phone?> '; } else {print 'No records found...';} ?>



New Reviews

Approve Delete Name Loss Location State Country Email Rating Comments '; foreach($new_reviews as $review) { ?> '; } else {print 'No records found...';} ?>



query("UPDATE `".$table_prefix."ibot_company` SET company='".db_safe($_POST["company"])."', address1='".db_safe($_POST["address1"])."', address2='".db_safe($_POST["address2"])."', city='".db_safe($_POST["city"])."', state='".db_safe($_POST["state"])."', zip='".db_safe($_POST["zip"])."', country='".db_safe($_POST["country"])."', phone='".db_safe($_POST["phone"])."' WHERE id='$id'"); $error = 'These changes have been saved.'; } $row = $wpdb->get_row("SELECT * FROM `".$table_prefix."ibot_company` WHERE id='$id' LIMIT 1"); ?>

Edit company?>:

" method="post">
Company Name:
Address 1:
Address 2:
City:
State/Province:
Zip:
Country:
Phone:

user_level>9)) {ibot_edit_company($_GET["id"]); return;} else { If(empty($_POST["stype"]) && empty($_POST["sloc"]) && empty($_POST["sibot"])) {$rows = $wpdb->get_results("SELECT * FROM `".$table_prefix."ibot_company` WHERE stat='X' ORDER BY type ASC, company ASC LIMIT 10"); $rows_limit = $wpdb->num_rows;} else { $sql = "SELECT * FROM `".$table_prefix."ibot_company` WHERE "; If(!empty($_POST["sibot"])) {$sql .= "(company LIKE '%".db_safe($_POST["sibot"])."%' OR fname LIKE '%".db_safe($_POST["sibot"])."%' OR lname LIKE '%".db_safe($_POST["sibot"])."%') AND ";} If(!empty($_POST["sloc"])) {$sql .= "(city LIKE '%".db_safe($_POST["sloc"])."%' OR state LIKE '%".db_safe($_POST["sloc"])."%' OR country LIKE '%".db_safe($_POST["sloc"])."%') AND ";} $sql .= "type LIKE '%".$_POST["stype"]."%' AND stat='X' ORDER BY type ASC, company ASC"; $rows = $wpdb->get_results($sql); $rows_limit = $wpdb->num_rows; } ?>

Search:

" method="post">
Look for:
Last Name:">
Location:">

Why View Ratings?

Add your own: [">Adjuster] [">Attorney] [">Body Shop] [">Contractor] [">Insurer]

No results found...

'; return;} print '

Showing '.$rows_limit.' items:

'; ?>
Company or Individual:    Name: Service Area: Average Rating & Comments:
company?>user_level>9) {?>
id);?>">edit
fname?> lname?> city?>, state?>, country?> /wp-content/plugins/ibot_review/rating)?>stars.gif">
id);?>">num_ratings?> comments
id);?>">rate it!
get_row("SELECT * FROM `".$table_prefix."ibot_company` WHERE id='$id' LIMIT 1"); $revs = $wpdb->get_results("SELECT * FROM `".$table_prefix."ibot_rating` WHERE co_id='$id' ORDER BY id DESC"); ?>

company?> Ratings

Namefname?> lname?>
Addressaddress1?>
address1?>
Citycity?>
Phonephone?>


city)) {$rev->city = "somewhere";}?>
name?> from city?> state?> country?> wrote: /wp-content/plugins/ibot_review/rating)?>stars.gif">
comments?>
 
get_row("SELECT * FROM `".$table_prefix."ibot_company` WHERE id='$id' LIMIT 1"); If($_GET["submit"]=="YES") { // error checking $error = ibot_error_check_rate(); // no errors If(empty($error)) { ibot_new_rating($id); print '

Thank you for reviewing this company!

'; print '

Click here to continue

'; return; } } ?>

Review company?>:

Specific rating for: fname?> lname?>

(required fields)

" method="post">

Thank you for reviewing this company!

'; print '

Click here to continue

'; return; } } ?>

Add a New for Ratings

(required fields)

" method="post">
Company Name:
Enter the first then last name of the adjuster, attorney, or contractor.
Name: 
Address 1:
Address 2:
Service Area City:
(Suggestion - If the loss was in a smaller city, list both smaller city and the largest city within 60 miles. For example: "Hollywood, LA". You could also list a city and general area. For example: Chicago, Cook County, North Illinois, etc.)
State/Province:
Zip:
Country:
Phone:

Your Name:
(Does not have to be your real or full name.)
Loss Location City:
(Suggestion - If the loss was in a smaller city, list both smaller city and the largest city within 60 miles. For example: "Hollywood, LA")
State/Province:
Country:
Your Email:

(Your email address will not be posted)

Rating:

* "I declare that I or the person I speak for has actually conducted business in connection with the person or business being rated."

I Agree:
Comments:
(limit 1,000 characters)

* Postings may be delayed for review or subject to removal for inappropriate language such as profanity and inflammatory comments. The goal of this rating section is to help visitors avoid bad adjusters and their vendors and find the good ones. It is not necessary to use four letter swear words to achieve these results.

Your comments are not "libel" or "slander" if what you say is the truth. If you do not know if what you say is true or false, then you should add the words "it is my opinion that ..." or "I have heard that ...". It is not against the law to gossip or to have an opinion.

Please enter the company name...';} If(empty($_POST["city"])) {$error .= '
  • Please enter the company city...
  • ';} If(empty($_POST["state"])) {$error .= '
  • Please enter the company state...
  • ';} If(empty($_POST["country"])) {$error .= '
  • Please enter the company country...
  • ';} return $error; } // error checking: rating form // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ibot_error_check_rate(){ If(empty($_POST["rname"])) {$error .= '
  • Please enter your name...
  • ';} If(empty($_POST["email"])) {$error .= '
  • Please enter your email...
  • ';} If(empty($_POST["rating"])) {$error .= '
  • Please rate this company...
  • ';} If(empty($_POST["agree"])) {$error .= '
  • You must agree to our terms of service to post this review...
  • ';} return $error; } // add new company to MySQL // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ibot_new_company($type) { global $wpdb, $table_prefix, $notify_email; $wpdb->query("INSERT INTO `".$table_prefix."ibot_company` SET stat='P', type='$type', fname='".$_POST["cnamef"]."', lname='".$_POST["cnamel"]."', company='".db_safe($_POST["company"])."', address1='".db_safe($_POST["address1"])."', address2='".db_safe($_POST["address2"])."', city='".db_safe($_POST["city"])."', state='".db_safe($_POST["state"])."', zip='".db_safe($_POST["zip"])."', country='".db_safe($_POST["country"])."', phone='".db_safe($_POST["phone"])."'"); mail($notify_email, "New Company Waiting for Approval", "There is a new company waiting for your approval"); return $wpdb->insert_id; } // add new rating to MySQL // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ibot_new_rating($id) { global $wpdb, $table_prefix, $notify_email; $wpdb->query("INSERT INTO `".$table_prefix."ibot_rating` SET co_id='$id', stat='P', name='".db_safe($_POST["rname"])."', city='".db_safe($_POST["rcity"])."', state='".db_safe($_POST["rstate"])."', country='".db_safe($_POST["rcountry"])."', email='".db_safe($_POST["email"])."', rating='".db_safe($_POST["rating"])."', comments='".db_safe($_POST["comments"])."'"); mail($notify_email, "New Review Waiting for Approval", "There is a new review waiting for your approval"); } // make input db safe // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function db_safe($data) { return $data; } // generate link // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function ibot_link($url) { // return "&".$url; return "./?".$url; } // here are the WP hooks that call the above functions // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= add_action('admin_menu', 'ibot_review_admin_ui'); add_filter('the_content','ibot_show_plugin'); ?>