<commit_before><?php
/*=========================================================================

  Program:   CDash - Cross-Platform Dashboard System
  Module:    $RCSfile: common.php,v $
  Language:  PHP
  Date:      $Date: 2008-02-04 14:19:42 -0500 (Mon, 04 Feb 2008) $
  Version:   $Revision: 430 $

  Copyright (c) 2002 Kitware, Inc.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
// Open the database connection
include("config.php");
include("common.php");

$db = mysql_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
mysql_select_db("$CDASH_DB_NAME",$db);

$apacheaccesslog = "/var/log/apache/access.log";
$contents = file_get_contents($apacheaccesslog);

// Loop through the sites
$site = mysql_query("SELECT name FROM site WHERE latitude='' AND longitude=''");
while($site_array = mysql_fetch_array($site))
{
  $sitename = $site_array["name"];
  $pos = strpos($contents,$sitename);
  if($pos !== FALSE)
    {  
    // Find the IP in the log
    $beginip = strrpos(substr($contents,$pos-500,500),"\n")+$pos-500+1;
    $endip = strpos($contents," ",$beginip);
    $ip = substr($contents,$beginip,$endip-$beginip);
    echo "IP=".$ip."*\n";
    $location = get_geolocation($ip);
    $latitude = $location['latitude'];
    $longitude = $location['longitude'];
  
    $sql = "UPDATE site SET latitude='$latitude',longitude='$longitude' WHERE name='$sitename'";
    mysql_query($sql);
    echo mysql_error();
    }
}

?>
<commit_msg>ENH: More fixes<commit_after><?php
/*=========================================================================

  Program:   CDash - Cross-Platform Dashboard System
  Module:    $RCSfile: common.php,v $
  Language:  PHP
  Date:      $Date: 2008-02-04 14:19:42 -0500 (Mon, 04 Feb 2008) $
  Version:   $Revision: 430 $

  Copyright (c) 2002 Kitware, Inc.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
// Open the database connection
include("config.php");
include("common.php");

$db = mysql_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
mysql_select_db("$CDASH_DB_NAME",$db);

$apacheaccesslog = "/var/log/apache/access.log";
$contents = file_get_contents($apacheaccesslog);

// Loop through the sites
//$site = mysql_query("SELECT name FROM site WHERE latitude='' AND longitude=''");
$site = mysql_query("SELECT name FROM site");
while($site_array = mysql_fetch_array($site))
{
  $sitename = $site_array["name"];
  $pos = strpos($contents,$sitename."__");
  if($pos !== FALSE)
    {  
    // Find the IP in the log
    $beginip = strrpos(substr($contents,$pos-500,500),"\n")+$pos-500+1;
    $endip = strpos($contents," ",$beginip);
    $ip = substr($contents,$beginip,$endip-$beginip);
    echo $ip."\n"; 
    $location = get_geolocation($ip);
    $latitude = $location['latitude'];
    $longitude = $location['longitude'];
  
    $sql = "UPDATE site SET ip='$ip',latitude='$latitude',longitude='$longitude' WHERE name='$sitename'";
    mysql_query($sql);
    echo mysql_error();
    }
}

?>

{'fraction_non_alphanumeric': 0.22615131578947367, 'fraction_numerical': 0.022478070175438597, 'mean_word_length': 4.631172839506172, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7529906', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1103, 'n_words': 269}