Solved

PG4WP is wrongly wrappling the SQL statement in the visitor maps plugin

Posted on 2014-02-02
1
441 Views
Last Modified: 2014-02-04
I have wordpress 3.8.1 with postgres, I have modified the php in visitors-maps.php for the create table part however for the rest of the queries (insert and update) the query is sent to the database with an additional keyword at the end, for example
The query in the visitors-maps.php looks:

        $query = "INSERT INTO " . $wo_table_wo . "
        (session_id,
        ip_address,
        user_id,
        name,
        country_name,
        country_code,
        city_name,
        state_name,
        state_code,
        latitude,
        longitude,
        last_page_url,
        http_referer,
        user_agent,
        hostname,
        time_entry,
        time_last_click,
        num_visits)
        values (
                '" . esc_sql($ip_address) . "',
                '" . esc_sql($ip_address) . "',
                '" . esc_sql($wo_user_id) . "',
                '" . esc_sql($name) . "',
                '" . esc_sql($country_name) . "',
                '" . esc_sql($country_code) . "',
                '" . esc_sql($city_name) . "',
                '" . esc_sql($state_name) . "',
                '" . esc_sql($state_code) . "',
                '" . esc_sql($latitude) . "',
                '" . esc_sql($longitude) . "',
                '" . esc_sql($last_page_url) . "',
                '" . esc_sql($http_referer) . "',
                '" . esc_sql($user_agent) . "',
                '" . esc_sql($hostname) . "',
                '" . esc_sql($current_time) . "',
                '" . esc_sql($current_time) . "',
                '1');";

Open in new window


But in the postgres log I can see it sent to the DB as:
STATEMENT:  INSERT INTO wp_visitor_maps_wo
               (session_id,
               ip_address,
               user_id,
               name,
               country_name,
               country_code,
               city_name,
               state_name,
               state_code,
               latitude,
               longitude,
               last_page_url,
               http_referer,
               user_agent,
               hostname,
               time_entry,
               time_last_click,
               num_visits)
               values (
                       '0.0.0.0',
                       '0.0.0.0',
                       '1',
                       'Me',
                       'Home',
                       'HO',
                       'CITY',
                       'AREA',
                       '00',
                       '0000',
                       '0000',
                       '/wp-admin/?loggedout=true',
                       'http://www.mydomain.com',
                       'Client',
                       'ISP',
                       '000',
                       '000',
                       '1'); VALUES

Open in new window


It has added the word VALUES at the end.

Also Query is in the visitors-maps.php looks:

 $wpdb->query("UPDATE " . $wo_table_st . "
  SET
  count = '" . absint($visitors_count) . "',
  time = '".$mysql_now."'
  WHERE (time !='".$mysql_now."' 
     OR count < '" . absint($visitors_count) . "') AND type = 'day';");

Open in new window


But in the postgres log I can see it sent to the DB as:

STATEMENT:  UPDATE wp_visitor_maps_st
         SET
         count = '0',
         time = '2014-02-02 12:47:50'
         WHERE (time !='2014-02-02 12:47:50'
            OR count < '0') AND type = 'day'; SET

Open in new window

It has added the word SET at the end.

Is there a way to correct this issue?
0
Comment
Question by:Ashraf Hassanein
1 Comment
 

Accepted Solution

by:
Ashraf Hassanein earned 0 total points
ID: 39832292
PG4WP is not working properly if values is written in lower case and for the update all the command has to be written in one line.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
In Part I (http://www.experts-exchange.com/Web_Development/Blogs/WordPress/A_8410-Getting-Started-In-WordPress-Part-I.html), I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now