summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2017-09-07 08:06:36 +0200
committerRemi Collet <remi@remirepo.net>2017-09-07 08:06:36 +0200
commit81bfbc7d251db1a18af5a2caf30fa96f9e1394e5 (patch)
tree64f6c03e92b853bc2294c1e8913aab6b96cc7011
parent8c93f53ed5a1f3e566933d914fbcbdc52f910154 (diff)
refresh comptage
-rwxr-xr-xcomptage45
1 files changed, 40 insertions, 5 deletions
diff --git a/comptage b/comptage
index 0b33cbb..6412480 100755
--- a/comptage
+++ b/comptage
@@ -33,18 +33,50 @@ function TraiteFile ($db, $table, $path, $Verb) {
$fic=fopen($path, "r");
if ($fic) {
while ($tab=fgetcsv($fic, 4000, ' ', '"')) {
- if (count($tab)==10 && $tab[6]==200) {
+ if (count($tab)>=10 && $tab[6]==200) {
# 0:IP, 3:Date, 5:URL, 6:Status, 7:Size, 9:Agent
list($ordre,$name,$prot)=explode(' ', $tab[5]);
$time=substr($tab[3],1)." ".substr($tab[4],0,-1);
$time=date("Y-m-d H:i:s", strtotime($time));
-
+ $size=$tab[7];
} else if (count($tab)==11 && $tab[7]==200) {
# 0:IP, 3:Date, 5:Host, 6:URL, 7:Status, 8:Size, 10:Agent
list($ordre,$name,$prot)=explode(' ', $tab[6]);
$time=substr($tab[3],1)." ".substr($tab[4],0,-1);
$time=date("Y-m-d H:i:s", strtotime($time));
+ $size=$tab[8];
+ } else if (count($tab)==8 && $tab[6]==200) {
+ # 0:IP, 3:Date, 5:URL, 6:Status, 7:Size
+ list($ordre,$name,$prot)=explode(' ', $tab[5]);
+ $time=substr($tab[3],1)." ".substr($tab[4],0,-1);
+ $time=date("Y-m-d H:i:s", strtotime($time));
+ $size=$tab[7];
+ } else if (count($tab)==10 && $tab[7]==200) {
+ # http://mirror.cedia.org.ec/.remilogs/
+ # 0:IP, 3:Date, 5:URL, 6:Size, 7:Status
+ list($ordre,$name,$prot)=explode(' ', $tab[5]);
+ $time=substr($tab[3],1)." ".substr($tab[4],0,-1);
+ $time=date("Y-m-d H:i:s", strtotime($time));
+ $size=$tab[6];
+ } else if (count($tab)==9 && $tab[7]==200) {
+ # http://ftp.arnes.si/mirrors/remi/.mirrorlogs/
+ # 0:CLIENTIP, 4:Date, 6:URL, 8:Size, 7:Status
+ list($ordre,$name,$prot)=explode(' ', $tab[6]);
+ $time=substr($tab[4],1)." ".substr($tab[5],0,-1);
+ $time=date("Y-m-d H:i:s", strtotime($time));
+ $size=$tab[8];
+ } else if (count($tab)==9 && $tab[6]==200) {
+ # http://remi.mirrors.cu.be/.logs/
+ # 0:CLIENTIP, 3:Date, 5:URL, 7:Size, 6:Status
+ list($ordre,$name,$prot)=explode(' ', $tab[5]);
+ $time=substr($tab[3],1)." ".substr($tab[4],0,-1);
+ $time=date("Y-m-d H:i:s", strtotime($time));
+ $size=$tab[7];
} else {
+ if ($Verb>3) {
+ echo "Ignored (".count($tab)."):";
+ print_r($tab);
+ }
continue;
}
if ($Verb>3 && substr($name,-4)==".rpm") echo "+ $ordre: ".$name."\n";
@@ -54,6 +86,7 @@ function TraiteFile ($db, $table, $path, $Verb) {
$ok=0;
if ($ordre != "GET") {
+ if ($verb>3) echo "+ Ignored (!GET)\n";
$ok=0;
} else if (preg_match('@^.*/(.*)-(.*)-(.*)\.((fc|el)[0-9]*)\.[a-z\.0-9]*\.(i.86|x86_64|ppc64|ppc|noarch|src)\.rpm$@',$name,$regs)) {
$ok=1;
@@ -86,7 +119,9 @@ function TraiteFile ($db, $table, $path, $Verb) {
} else if ($Verb>3 && substr($name,-4)==".rpm")
echo "+ rejected \n";
- if ($ok) {
+ if ($ok && $Verb<4) {
+ $rpm = urldecode($rpm); // ++ in name
+ $ver = urldecode($ver); // ~ in version
$sql = sprintf("SELECT ref FROM %s WHERE `name`='%s' AND `version`='%s' AND `release`='%s' AND `distro`='%s' AND `arch`='%s'",
$table, $rpm, $ver, $rel, $dis, $arc);
@@ -94,7 +129,7 @@ function TraiteFile ($db, $table, $path, $Verb) {
$Res=$db->query($sql) or die ("** SQL error\n** ".$db->error."\n");
if ($Row=$Res->fetch_object()) {
- $sql = sprintf("UPDATE %s SET cpt=cpt+1, last='%s', size=size+%d WHERE ref=%d", $table, $time, $tab[7], $Row->ref);
+ $sql = sprintf("UPDATE %s SET cpt=cpt+1, last='%s', size=size+%d WHERE ref=%d", $table, $time, $size, $Row->ref);
if ($Verb>3) echo "+ SQL: $sql\n";
$db->query($sql) or die ("** SQL error\n** ".$db->error."\n");
} else {
@@ -103,7 +138,7 @@ function TraiteFile ($db, $table, $path, $Verb) {
if ($Verb>3) echo "+ SQL: $sql\n";
$db->query($sql) or die ("** SQL error\n** ".$db->error."\n");
}
- }
+ } else if ($ok) echo "+ Accepted\n";
}
fclose($fic);
} else {