Originally posted by Mincer
If someone can supply me with the code you’ve been working on to parse the LM XML, I can use it to populate a table for LM counters too.
PMM did the parsing XML section of the code, I’ve created the db and added the writing to db section on the end:
<?php
if(!include('./xmlize.php')){
$error = 'Error. Incorrect location for xmlize.php.<br />';
die($error);
}
$xmlfile = 'http://www.lifemapper.org/lm-individualmembers/lm-memberstats/FullMembersReport.xml';
$fp = fopen($xmlfile,"rb");
if($fp){
$xml = '';
while (!feof ($fp)) {
$xml .= fgets ($fp, 1024);
}
fclose ($fp);
}else{
$error = 'Error. File <b>'.$xmlfile.'</b> does not exist.<br />';
die($error);
}
$xml_array = xmlize($xml);
$xml = xmlize($xml);
$team_stats=$xml["xml"]["#"]["rs:data"]["0"]["#"]["z:row"];
for($i = 0; $i < sizeof($team_stats); $i++) {
$person = $team_stats[$i];
$statix = $person["#"];
$ID = $person["@"]["ID"];
$Name = addslashes($person["@"]["Name"]);
$AddressWWW = $person["@"]["AddressWWW"];
$TotCPUTime = $person["@"]["TotCPUTime"];
$JoinDate = $person["@"]["JoinDate"];
$EMail = $person["@"]["EMail"];
$TaxaComputed = $person["@"]["TaxaComputed"];
$NumOfJobs = $person["@"]["NumOfJobs"];
$Country = $person["@"]["Country"];
$PrefCountry = $person["@"]["PrefCountry"];
$CPUGroup = $person["@"]["CPUGroup"];
$CPUGroupID = $person["@"]["CPUGroupID"];
$PrefDataProvider = $person["@"]["PrefDataProvide"];
$GroupAddressWWW = $person["@"]["GroupAddressWWW"];
$PrefTaxonGroup = $person["@"]["PrefTaxonGroup"];
$link= mysql_connect("localhost", "username","password") or
die(mysql_error());
$db = mysql_select_db("new_dbase", $link) or die(mysql_error());
$query = "insert into lm_user (ID, Name, EMail, JoinDate, Country) values ('$ID', '$Name', '$EMail', '$JoinDate', '$Country')";
$result = @mysql_query($query) or die (mysql_error());
$query2 = "insert into lm_variablestats (ID, TotCPUTime, NumOfJobs, TaxaComputed) values ('$ID', '$TotCPUTime', '$NumOfJobs', '$TaxaComputed')";
$result2 = mysql_query($query2) or die (mysql_error());
}
?>
I’ve just been having a quick fiddle whilst working (……) but have created two tables so far, haven’t gotten round to the third yet:
lm_user - to hold fixed user details
fields: ID, Name, Email, JoinDate,Country
lm_variablestats - to hold variable stats details
fields:ID, TotCPUTime, NumOfJobs, TaxaCompleted
lm_preferences - to hold user preferences
fields: ID, PrefCountry, AddessWWW, CPUGroup, CPUGroupID, GroupAddressWWW, PrefTaxonGroup
The above is just a first thought, it’ll prob change as/when it develops further…
The thing is, we were thinking more than just counters - I’m looking at some web-based stats that will be self-sustaining (ie not having to be uploaded every day at 5am). Obviously not as in-depth as the Stat-O-Matic but will be something to keep the punters interested So… we have three choices:[ul]
[li]move the whole LM stats to barcode’s server
[/li][li]have a feed from the LM stats db to the counter db on barcode’s server
[/li][li]It’d be feasible enough to just link the counter script to feed from the db on my server…?
[/li][/ul]What do you reckon…? In theory we can host the stats pages on the current stats site and host the db on my www.riddlermarc.co.uk server, my bandwidth is easily enough to handle the calls…
The output of the table lm_variablestats can be seen here: http://www.riddlermarc.co.uk/dev/lm/show_variablestats.php should hold most of the necessary data for LM counters?