Ignore:
Timestamp:
07/28/08 17:17:11 (4 years ago)
Author:
hverton
Message:

added checking and updating of the country code in the posts table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/tools/update_geoip_database.php

    r1516 r1555  
    117117                        display("  * Updating country code for user '".$data['user_name']."'."); 
    118118                        $result2 = dbquery("UPDATE ".$db_prefix."users SET user_cc_code = '".$cc."' WHERE user_id = '".$data['user_id']."'"); 
     119                    } else { 
     120                        display("  * No country code found for user '".$data['user_name']."'."); 
    119121                    } 
    120122                } 
    121123            } 
     124 
     125            // update the posts table 
     126            display("* Updating posts with an unknown country code."); 
     127            $result = dbquery("SELECT * FROM ".$db_prefix."posts WHERE post_cc = ''"); 
     128            while ($data = dbarray($result)) { 
     129                if ($data['post_ip'] != "X") { 
     130                    $cc = GeoIP_IP2Code($data['post_ip']); 
     131                    if ($cc != "") {  
     132                        display("  * Updating country code for post '".$data['post_id']."'."); 
     133                        $result2 = dbquery("UPDATE ".$db_prefix."posts SET post_cc = '".$cc."' WHERE post_id = '".$data['post_id']."'"); 
     134                    } else { 
     135                        display("  * No country code for found  post '".$data['post_id']."'."); 
     136                    } 
     137                } 
     138            } 
     139 
    122140            // update the statistics ip table (if it exists) 
    123141            if (dbtable_exists($db_prefix."dlstats_ips")) { 
     
    129147                        display("  * Updating country code for statistics record '".$data['dlsi_id']."'."); 
    130148                        $result2 = dbquery("UPDATE ".$db_prefix."dlstats_ips SET dlsi_ccode = '".$cc."' WHERE dlsi_id = '".$data['dlsi_id']."'"); 
     149                    } else { 
     150                        display("  * No country code found for statistics record '".$data['dlsi_id']."'."); 
    131151                    } 
    132152                } 
Note: See TracChangeset for help on using the changeset viewer.