| 29 |
dir_ctrl($dirs); |
dir_ctrl($dirs); |
| 30 |
if (!function_exists('file_get_contents')) { |
if (!function_exists('file_get_contents')) { |
| 31 |
function file_get_contents($filename) { |
function file_get_contents($filename) { |
| 32 |
if (!($file = fopen($filename,"rb"))) return false; |
if (!($file = fopen($filename,"r"))) return false; |
| 33 |
else { |
else { |
| 34 |
$contents = ""; |
$contents = ""; |
| 35 |
do { |
do { |
| 54 |
elseif (in_array("-update_all",$argv)) update_all(); |
elseif (in_array("-update_all",$argv)) update_all(); |
| 55 |
elseif (in_array("-check_db",$argv)) check_db(); |
elseif (in_array("-check_db",$argv)) check_db(); |
| 56 |
elseif (in_array("-db_up_error",$argv)) db_up_error(); |
elseif (in_array("-db_up_error",$argv)) db_up_error(); |
| 57 |
elseif (in_array("-watchf",$argv)) watch_fill(); |
elseif (in_array("-up_changes",$argv)) up_changes($argv[2]); |
| 58 |
|
elseif (in_array("-watchf",$argv)) watch_fill($argv[2]); |
| 59 |
elseif (in_array("-kb_total",$argv)) print "Diff |
elseif (in_array("-kb_total",$argv)) print "Diff |
| 60 |
#stat_up_error(); |
#stat_up_error(); |
| 61 |
#stat_up_error();to download Kb => " . kb_total($argv[2]) . "\n" ; |
#stat_up_error();to download Kb => " . kb_total($argv[2]) . "\n" ; |
| 86 |
else return NULL; |
else return NULL; |
| 87 |
} |
} |
| 88 |
function ftp_cn($login,$password,$ftp_server) { |
function ftp_cn($login,$password,$ftp_server) { |
| 89 |
$conn_id = ftp_connect($ftp_server); |
$conn_id = @ftp_connect($ftp_server) or DIE("Error: Cannot contact ftp server $ftp_server\n"); |
| 90 |
// login con user name e password |
// login con user name e password |
| 91 |
ftp_pasv($conn_id,1); |
ftp_pasv($conn_id,1); |
| 92 |
$login_result = ftp_login($conn_id, "anonymous","bo@bo.org"); |
$login_result = ftp_login($conn_id, "anonymous","bo@bo.org"); |
| 151 |
global $dirs,$dists,$dbconn; |
global $dirs,$dists,$dbconn; |
| 152 |
check_db(); |
check_db(); |
| 153 |
keep_source(); |
keep_source(); |
| 154 |
$db = pg_connect($dbconn) or die(pg_result_error($db)); |
$db = pg_connect($dbconn) or die(pg_errormessage($db)); |
| 155 |
pg_exec($db, "CREATE TEMP TABLE pkgs_atsrc (name text,dist text)") or die('Error creating temp table pkgs_atsrc'); |
pg_exec($db, "CREATE TEMP TABLE pkgs_atsrc (name text,dist text)") or die('Error creating temp table pkgs_atsrc'); |
| 156 |
pg_exec($db, "CREATE UNIQUE INDEX idxdis on pkgs_atsrc (name,dist)") or die('Error creating index on temp table'); |
pg_exec($db, "CREATE UNIQUE INDEX idxdis on pkgs_atsrc (name,dist)") or die('Error creating index on temp table'); |
| 157 |
pg_exec($db, "CREATE TEMP TABLE bin_atsrc (name text,bin_name text, dist text)") or die('Error creating temp table pkgs_atsrc'); |
pg_exec($db, "CREATE TEMP TABLE bin_atsrc (name text,bin_name text, dist text)") or die('Error creating temp table pkgs_atsrc'); |
| 161 |
$filename=$dirs[sources_dir] . "/$dist/$section/Sources.gz"; |
$filename=$dirs[sources_dir] . "/$dist/$section/Sources.gz"; |
| 162 |
print "\nI'm parsing $dist/$section => Sources.gz\n"; |
print "\nI'm parsing $dist/$section => Sources.gz\n"; |
| 163 |
# 1 Pacchetto - 2 versione - 3 np - 4 Directory - 5 md5 |
# 1 Pacchetto - 2 versione - 3 np - 4 Directory - 5 md5 |
| 164 |
$regexp="/Package:\s($initial.*)[^a]Binary:\s(.+)[^a]Version:\s(\d+:)?(.+)[^a]Priority.+Directory:\s(.+)[^a]Files:.+\s(\S+)\s(\d+)\s" . '\1\S+' . "\.diff\.gz/Ssi"; |
$regexp="/Package:\s($initial.*)[^a]Binary:\s(.+)[^a]Version:\s(\d+:)?(.+)[^a]Priority.+Maintainer:.+<([^>]+)>[^a].+Directory:\s(.+)[^a]Files:.+\s(\S+)\s(\d+)\s" . '\1\S+' . "\.diff\.gz/Ssi"; |
| 165 |
$zp = gzopen($filename, "r") or die("Could not open $filename"); |
$zp = gzopen($filename, "r") or die("Could not open $filename"); |
| 166 |
$extracted="/tmp/$dist_$section_Sources.gz"; |
$extracted="/tmp/$dist_$section_Sources.gz"; |
| 167 |
exec("gzip -c -d $filename > $extracted"); |
exec("gzip -c -d $filename > $extracted"); |
| 177 |
# print("Pacchetto => $matches[1]\nVersione => $matches[4]\nDirectory => $matches[5]\nMD5 => $matches[6]\n"); |
# print("Pacchetto => $matches[1]\nVersione => $matches[4]\nDirectory => $matches[5]\nMD5 => $matches[6]\n"); |
| 178 |
# print "REPLACE INTO pkgs (name,version,dir,md5_diff) VALUES ($matches[1],$matches[3],$matches[4],$matches[5])"; |
# print "REPLACE INTO pkgs (name,version,dir,md5_diff) VALUES ($matches[1],$matches[3],$matches[4],$matches[5])"; |
| 179 |
@pg_exec($db,"INSERT INTO pkgs_atsrc (name,dist) VALUES ('$matches[1]','$dist')") OR DIE("Temp table pkgs_atsrc query error"); |
@pg_exec($db,"INSERT INTO pkgs_atsrc (name,dist) VALUES ('$matches[1]','$dist')") OR DIE("Temp table pkgs_atsrc query error"); |
| 180 |
$rst=@pg_exec($db, "INSERT INTO pkgs (name,version,dir,md5_atsource,bytes,dist,section) VALUES ('$matches[1]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$dist','$section')") ; |
$rst=@pg_exec($db, "INSERT INTO pkgs (name,version,maint,dir,md5_atsource,bytes,dist,section) VALUES ('$matches[1]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$matches[8]','$dist','$section')") ; |
| 181 |
if (!$rst) { |
if (!$rst) { |
| 182 |
$rst=@pg_exec($db, "UPDATE pkgs SET name='$matches[1]',version='$matches[4]',dir='$matches[5]',md5_atsource='$matches[6]',bytes='$matches[7]',dist='$dist',section='$section' WHERE name='$matches[1]' AND dist='$dist'") OR DIE ("\nDb adding error =>" . pg_errormessage() . "\n"); |
$rst=@pg_exec($db, "UPDATE pkgs SET name='$matches[1]',version='$matches[4]',maint='$matches[5]',dir='$matches[6]',md5_atsource='$matches[7]',bytes='$matches[8]',dist='$dist',section='$section' WHERE name='$matches[1]' AND dist='$dist'") OR DIE ("\nDb adding error =>" . pg_errormessage() . "\n"); |
| 183 |
# if ($rst) print "\rUpdated $matches[1]" ." "; |
# if ($rst) print "\rUpdated $matches[1]" ." "; |
| 184 |
} |
} |
| 185 |
$bin_names=split(",", $matches[2]); |
$bin_names=split(",", $matches[2]); |
| 213 |
} |
} |
| 214 |
function db_query($pkg,$dist) { |
function db_query($pkg,$dist) { |
| 215 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 216 |
$db = pg_pconnect($dbconn ) or die(pg_result_error($db)); |
$db = pg_pconnect($dbconn ) or die(pg_errormessage($db)); |
| 217 |
$rsql=pg_exec($db, "SELECT pkgs.* ,mpop_inst FROM (SELECT name,MAX(binpkgs.pop_inst) AS mpop_inst FROM binpkgs GROUP BY name) |
$rsql=pg_exec($db, "SELECT pkgs.* ,mpop_inst FROM (SELECT name,MAX(binpkgs.pop_inst) AS mpop_inst FROM binpkgs GROUP BY name) |
| 218 |
AS binpkgs INNER JOIN pkgs ON pkgs.name=binpkgs.name |
AS binpkgs INNER JOIN pkgs ON pkgs.name=binpkgs.name |
| 219 |
WHERE pkgs.name='$pkg' AND dist='$dist';"); |
WHERE pkgs.name='$pkg' AND dist='$dist';"); |
| 286 |
} |
} |
| 287 |
function check_db() { |
function check_db() { |
| 288 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 289 |
$db = pg_connect($dbconn) or die(pg_result_error($db)); |
$db = @pg_connect($dbconn) or die(pg_last_notice()); |
| 290 |
if (!pg_table_exists($db,"pkgs")){ |
if (!pg_table_exists($db,"pkgs")){ |
| 291 |
pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text,dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,watch_warn text,updated bool, wwiz text,wwiz_version text, wwiz_type text)") or die('Error creating table pkgs\n'); |
pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text,maint text, dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,up_changes text, up_url text,watch_warn text,updated bool, keep_changes bool, wwiz text,wwiz_version text, wwiz_type text)") or die('Error creating table pkgs\n'); |
| 292 |
pg_exec($db, "CREATE UNIQUE INDEX idxname on pkgs (name,dist)") or die('Errore creating index - ' . pg_last_error($db)); |
pg_exec($db, "CREATE UNIQUE INDEX idxname on pkgs (name,dist)") or die('Errore creating index - ' . pg_last_error($db)); |
| 293 |
$sw=true; |
$sw=true; |
| 294 |
} |
} |
| 318 |
|
|
| 319 |
function watch_stat() { |
function watch_stat() { |
| 320 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 321 |
$db = pg_pconnect($dbconn) or die(pg_result_error($db)); |
$db = pg_pconnect($dbconn) or die(pg_errormessage($db)); |
| 322 |
$rsql=pg_exec ($db,"Select count(name) as totwatch FROM pkgs WHERE watch!=''"); |
$rsql=pg_exec ($db,"Select count(name) as totwatch FROM pkgs WHERE watch!=''"); |
| 323 |
$tot_watch=pg_fetch_array($rsql); |
$tot_watch=pg_fetch_array($rsql); |
| 324 |
print "Total packages with Watch =>$tot_watch[0]\n"; |
print "Total packages with Watch =>$tot_watch[0]\n"; |
| 346 |
} |
} |
| 347 |
function db_popcon($initial='') { |
function db_popcon($initial='') { |
| 348 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 349 |
$db = pg_pconnect($dbconn) or die(pg_result_error($db)); |
$db = pg_pconnect($dbconn) or die(pg_errormessage($db)); |
| 350 |
$filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz"; |
$filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz"; |
| 351 |
$regexp="/Package:\s($initial\S*)\s+(\d+)\s+(\d+)/iS"; |
$regexp="/Package:\s($initial\S*)\s+(\d+)\s+(\d+)/iS"; |
| 352 |
$zp = gzopen($filename, "r") or die("Could not open $filename"); |
$zp = gzopen($filename, "r") or die("Could not open $filename"); |
| 378 |
} |
} |
| 379 |
function db_popcon_test() { |
function db_popcon_test() { |
| 380 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 381 |
$db = pg_pconnect($dbconn) or die(pg_result_error($db)); |
$db = pg_pconnect($dbconn) or die(pg_errormessage($db)); |
| 382 |
$filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz"; |
$filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz"; |
| 383 |
$regexp="/Package:\s(\S+)\s+(\d+)\s+(\d+)/"; |
$regexp="/Package:\s(\S+)\s+(\d+)\s+(\d+)/"; |
| 384 |
$zp = gzfile($filename, "r") or die("Could not open $filename"); |
$zp = gzfile($filename, "r") or die("Could not open $filename"); |
| 407 |
$remotefile="http://popcon.debian.org/all-popcon-results.txt.gz"; |
$remotefile="http://popcon.debian.org/all-popcon-results.txt.gz"; |
| 408 |
@file_put_contents($localfile,file_get_contents($remotefile),'w') or die("Errore nello scaricare il file popcon\n"); |
@file_put_contents($localfile,file_get_contents($remotefile),'w') or die("Errore nello scaricare il file popcon\n"); |
| 409 |
} |
} |
| 410 |
function db_upstream($initial='') { |
function is_updated ($up_vers,$debian_vers) { |
| 411 |
|
if ($up_vers=='') return 0; |
| 412 |
|
passthru("dpkg --compare-versions '$up_vers' gt '" . vers_conv($debian_vers) . "'",$great); |
| 413 |
|
if ($great==0) return 1; |
| 414 |
|
else return 0; |
| 415 |
|
} |
| 416 |
|
function db_upstream($initial='%') { |
| 417 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 418 |
check_db(); |
check_db(); |
| 419 |
$db = pg_connect($dbconn) ; |
$db = pg_connect($dbconn) ; |
| 423 |
$uscan_res=uscan_foo($res_array['name'],$res_array['version'],$res_array['watch']); |
$uscan_res=uscan_foo($res_array['name'],$res_array['version'],$res_array['watch']); |
| 424 |
if($uscan_res[1] !=null) $uscan_res[1]=addslashes($uscan_res[1]); |
if($uscan_res[1] !=null) $uscan_res[1]=addslashes($uscan_res[1]); |
| 425 |
#print $uscan_res[0] . "\n Name => $res_array[name]\n"; |
#print $uscan_res[0] . "\n Name => $res_array[name]\n"; |
| 426 |
if ($uscan_res[0]!='') { |
$updated=is_updated($uscan_res[0],$res_array[version]); |
| 427 |
passthru("dpkg --compare-versions '$uscan_res[0]' gt '" . vers_conv($res_array[version]) . "'",$great); |
if ($uscan_res[0]!=$res_array[up_version]) ($keep_changes=1); |
| 428 |
#echo "dpkg --compare-versions '" . $uscan_res[0] . "' gt '" . vers_conv($res_array[version]) . "' $great\n"; |
else $keep_changes=0; |
| 429 |
if ($great==0) $updated=1; |
pg_exec($db, "UPDATE pkgs SET up_version='" . $uscan_res[0] . "',up_url='" . $uscan_res[2] . "', watch_warn='" . $uscan_res[1] . "',keep_changes='$keep_changes', updated='$updated' WHERE name='$res_array[name]' AND dist='$res_array[dist]'") or Die("Error in update pkgs upstream"); |
| 430 |
else $updated=0; |
#print "\rUpdated " . $res_array['name'] . " => $updated Up Version => ". $uscan_res[0]; |
| 431 |
} |
print "\rUpstream left => " . $tot --; |
| 432 |
else $updated=0; |
# } |
|
# $sql= "INSERT INTO upstream (name,dist,up_version,watch_warn,updated) |
|
|
# VALUES ('" . $res_array['name'] . "','" . $res_array['dist'] . "','" . $uscan_res[0] . "','" . $uscan_res[1] . "','$updated')"; |
|
|
# $rst=@pg_exec($db,$sql) ; |
|
|
# if (!$rst) { |
|
|
#print "UPDATE upstream SET up_version='" . $uscan_res[0] . "',watch_warn='" . $uscan_res[1] . "',updated='$updated' WHERE name='$res_array[name]' AND dist='$res_array[dist]'\n"; |
|
|
pg_exec($db, "UPDATE pkgs SET up_version='" . $uscan_res[0] . "',watch_warn='" . $uscan_res[1] . "',updated='$updated' WHERE name='$res_array[name]' AND dist='$res_array[dist]'") or Die("Error in update pkgs upstream"); |
|
|
#print "\rUpdated " . $res_array['name'] . " => $updated Up Version => ". $uscan_res[0]; |
|
|
print "\rUpstream left => " . $tot --; |
|
|
# } |
|
| 433 |
# else print "Added ". $res_array['name'] ."\n"; |
# else print "Added ". $res_array['name'] ."\n"; |
| 434 |
# if ($great==0) { |
# if ($great==0) { |
| 435 |
|
|
| 442 |
print "\n"; |
print "\n"; |
| 443 |
pg_close($db); |
pg_close($db); |
| 444 |
} |
} |
| 445 |
|
function keep_remote ($localfile,$remotefile) { |
| 446 |
|
# $url_p = parse_url ($remotefile); |
| 447 |
|
# if (isset ($url_p["host"])) |
| 448 |
|
# { $host = $url_p["host"]; } |
| 449 |
|
# else return false; |
| 450 |
|
# preg_match("/(http|ftp)/",$host,$matches); |
| 451 |
|
# if ($matches[1]=='http') $fp = fsockopen ($host, 80, $errno, $errstr, 10); |
| 452 |
|
# elseif ($matches[1]=='ftp') $fp2 = fsockopen ($host, 21, $errno, $errstr, 10); |
| 453 |
|
# if (!$fp AND !$fp2) return false; |
| 454 |
|
$rfp = @fopen ($remotefile, "rb"); |
| 455 |
|
if (!$rfp) { |
| 456 |
|
return false; |
| 457 |
|
} |
| 458 |
|
$lfp = fopen ($localfile, "w"); |
| 459 |
|
ini_set ( "memory_limit", "100M"); |
| 460 |
|
while ($data = fread($rfp, 1024*8)) { |
| 461 |
|
$bytes+=1024*8; |
| 462 |
|
print "Downlaoding $remotefile: $bytes\r"; |
| 463 |
|
fwrite($lfp, $data); |
| 464 |
|
} |
| 465 |
|
ini_set ( "memory_limit", "15M"); |
| 466 |
|
fclose($lfp); |
| 467 |
|
fclose($rfp); |
| 468 |
|
|
| 469 |
|
return true; |
| 470 |
|
} |
| 471 |
|
function up_changes($src_name='%') { |
| 472 |
|
global $dbconn; |
| 473 |
|
$changes_files=array("CHANGES","NEWS","Changelog","ChangeLog","changelog"); |
| 474 |
|
$db = pg_connect($dbconn) ; |
| 475 |
|
$rsql=pg_exec($db, "SELECT id,up_url FROM pkgs WHERE up_url!='' AND keep_changes='t' AND name LIKE '$src_name%'"); |
| 476 |
|
$tot=pg_numrows($rsql); |
| 477 |
|
while ($res_array=pg_fetch_array($rsql)) { |
| 478 |
|
$localfile="/tmp/dehs-" . $res_array[id] . ".tar.gz"; |
| 479 |
|
#print "I'm downloading $res_array[up_url]\r"; |
| 480 |
|
$res=keep_remote($localfile,$res_array['up_url']); |
| 481 |
|
#print "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]"; |
| 482 |
|
if (!$res) { |
| 483 |
|
pg_exec($db, "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]"); |
| 484 |
|
$notdown++; |
| 485 |
|
$tot--; |
| 486 |
|
print "Packages Left: " . $tot-- . " Found: $found Not found: $notfound Not Down: $notdown\r"; |
| 487 |
|
#print "\n Not Downlaoded: $res_array[up_url]\n"; |
| 488 |
|
continue; |
| 489 |
|
} |
| 490 |
|
foreach($changes_files as $filename) { |
| 491 |
|
$command="tar -zxOf " . $localfile . " *$filename 2>/dev/null"; |
| 492 |
|
exec($command,$up_changes,$cmdres); |
| 493 |
|
$up_changes=rtrim(implode("\n",$up_changes)); |
| 494 |
|
if ($cmdres==0 AND strlen($up_changes)>20) { |
| 495 |
|
$sw=true; |
| 496 |
|
$up_changes=addslashes($up_changes); |
| 497 |
|
$conv_res=iconv("ISO-8859-1","UTF-8",$up_changes); |
| 498 |
|
if ($conv_res) $up_changes=$conv_res; |
| 499 |
|
$up_changes_sql="UPDATE pkgs SET up_changes='$up_changes', keep_changes='f' WHERE id=$res_array[id]"; |
| 500 |
|
pg_exec($db,$up_changes_sql); |
| 501 |
|
#print "\nFounded $filename on $res_array[up_url]\n"; |
| 502 |
|
$found++; |
| 503 |
|
break; |
| 504 |
|
} |
| 505 |
|
} |
| 506 |
|
if (!$sw) { |
| 507 |
|
pg_exec($db, "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]"); |
| 508 |
|
#print "\n Not Founded any on $res_array[up_url]\n"; |
| 509 |
|
$notfound++; |
| 510 |
|
} |
| 511 |
|
unlink($localfile); |
| 512 |
|
print "Packages Left: " . $tot-- . " Found: $found Not found: $notfound Not Down: $notdown\r"; |
| 513 |
|
} |
| 514 |
|
pg_close($db); |
| 515 |
|
} |
| 516 |
function uscan_foo($name,$version,$watch){ |
function uscan_foo($name,$version,$watch){ |
| 517 |
$fw=fopen("/tmp/$name" . "_watch","w"); |
$fw=fopen("/tmp/$name" . "_watch","w"); |
| 518 |
fwrite($fw,$watch); |
fwrite($fw,$watch); |
| 519 |
fclose($fw); |
fclose($fw); |
| 520 |
$uscan_res=shell_exec("perl uscan3.pl $name " . vers_conv($version) . " /tmp/$name" . "_watch 2>&1"); |
$uscan_res=shell_exec("perl uscan3.pl $name " . vers_conv($version) . " /tmp/$name" . "_watch 2>/dev/null 2>&1"); |
| 521 |
unlink("/tmp/$name" . "_watch"); |
unlink("/tmp/$name" . "_watch"); |
| 522 |
preg_match("/\+\+(.+)\+\+/",$uscan_res, $matches); |
preg_match("/\+\+(.+)\+\+\s\+-(.+)-\+/",$uscan_res, $matches); |
| 523 |
if ($matches[1]!='') $upstream=$matches[1]; |
if ($matches[1]!='') $upstream=$matches[1]; |
| 524 |
else $upstream=null; |
else $upstream=null; |
| 525 |
$uscan_res=preg_replace("/(\+\+.+\+\+)/", "", $uscan_res); |
if ($matches[2]!='') $up_url=$matches[2]; |
| 526 |
|
else $up_url=null; |
| 527 |
|
$uscan_res=preg_replace("/(\+\+.+-\+)/", "", $uscan_res); |
| 528 |
if ($uscan_res=='') $uscan_res=null; |
if ($uscan_res=='') $uscan_res=null; |
| 529 |
return array($upstream,$uscan_res); |
return array($upstream,$uscan_res,$up_url); |
| 530 |
} |
} |
| 531 |
function db_up_error() { |
function db_up_error() { |
| 532 |
global $dbconn; |
global $dbconn; |
| 561 |
} |
} |
| 562 |
pg_close($db); |
pg_close($db); |
| 563 |
} |
} |
| 564 |
function watch_fill(){ |
function watch_fill($src_name='%'){ |
| 565 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 566 |
$db = pg_connect($dbconn) ; |
$db = pg_pconnect($dbconn) or DIE ("Db error"); |
| 567 |
$checked=$errors=$notfound=$verok=$notmatch=0; |
$checked=$errors=$notfound=$verok=$notmatch=0; |
| 568 |
$sqlstring="SELECT mpop_inst,name,pkgs.version,pkgs.section,pkgs.dist,tot_up_error, tot_avg_error_date FROM pkgs INNER JOIN |
$sqlstring="SELECT mpop_inst,name,pkgs.version,pkgs.section,pkgs.dist,tot_up_error, tot_avg_error_date, wwiz_version FROM pkgs INNER JOIN |
| 569 |
(Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist HAVING max(pop_inst) IS NOT NULL) as binpkgs using(name,dist) |
(Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist HAVING max(pop_inst) IS NOT NULL) as binpkgs using(name,dist) |
| 570 |
WHERE watch IS NULL OR watch='' ORDER BY mpop_inst DESC"; |
WHERE (watch IS NULL OR watch='') AND name LIKE '$src_name%' ORDER BY mpop_inst DESC"; |
| 571 |
$rsql=pg_exec($db, $sqlstring); |
$rsql=pg_exec($db, $sqlstring); |
| 572 |
while ($res_array=pg_fetch_array($rsql)) { |
while ($res_array=pg_fetch_array($rsql)) { |
| 573 |
if (substr($res_array["name"],0,3)=='lib') $initial=substr($res_array["name"],0,4); |
if (substr($res_array["name"],0,3)=='lib') $initial=substr($res_array["name"],0,4); |
| 579 |
$res_array["name"] . "_" . |
$res_array["name"] . "_" . |
| 580 |
$res_array["version"] . "/copyright"; |
$res_array["version"] . "/copyright"; |
| 581 |
$contents=@file_get_contents($url) or ''; |
$contents=@file_get_contents($url) or ''; |
| 582 |
|
$space=''; |
| 583 |
if (!$contents) { |
if (!$contents) { |
| 584 |
$notfound++; |
$notfound++; |
| 585 |
pg_exec($db, "UPDATE pkgs SET wwiz_type='no_cright' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
pg_exec($db, "UPDATE pkgs SET wwiz_type='no_cright' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
|
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-nocright_" . $res_array["dist"]; |
|
|
#file_put_contents($filename,"","w"); |
|
| 586 |
} |
} |
| 587 |
else { |
else { |
| 588 |
$res=preg_match ('/((ftp:\/\/|http:\/\/)\S+(html|htm|\/(?(?=.+tar)|[^>\s)]+)))/',$contents,$matches); |
$res=preg_match ('/(sf\.net|sourceforge\.net)/',$contents,$matches); |
| 589 |
print $res_array["name"] . " => " . $matches[1] . "\n"; |
if ($res) $matches[1]="ftp://ftp2.sf.net/pub/sourceforge/" . substr($res_array["name"],0,1) . "/" . substr($res_array["name"],0,2) . "/" . $res_array["name"] . "/"; |
| 590 |
$final=substr($matches[1],-1); |
else { |
| 591 |
#print "$final\n"; |
unset($matches); |
| 592 |
if ($matches[3]=="html" or $matches[3]=="htm") $space=' '; |
$res=preg_match ('/((ftp:\/\/|http:\/\/)\S+(html|htm|\/(?(?=.+(tar|tgz))|[^>\s\)\.\a]+)))/',$contents,$matches); |
| 593 |
if ($final=='.') $matches[1]=substr_replace($matches[1],'',-1); |
$final=substr($matches[1],-1); |
| 594 |
if ($final!='/' AND $space!=' ') $matches[1].='/'; |
if ($matches[3]=="html" or $matches[3]=="htm") $space=' '; |
| 595 |
#print $res_array["name"] . " => " . $matches[1] . "\n"; |
if ($final!='/' AND $space!=' ') $matches[1].='/'; |
| 596 |
|
$matches[1]=preg_replace("/(http:\/\/.+):/",'$1', $matches[1],1); |
| 597 |
|
} |
| 598 |
if (!$res) { |
if (!$res) { |
| 599 |
$notmatch++; |
$notmatch++; |
| 600 |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($contents) . "', wwiz_type='notmatch' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($contents) . "', wwiz_type='notmatch', up_url='', up_changes='' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
|
# $filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-notmatch_" . $res_array["dist"]; |
|
|
# file_put_contents($filename,$contents,"w"); |
|
| 601 |
} |
} |
| 602 |
else { |
else { |
| 603 |
$watch="version=2\n" . |
$watch="version=2\n" . |
| 604 |
$matches[1] . $space . $res_array["name"] . ".*-([\d+\.]+|\d+)\.tar(\.gz|\.bz2) debian uupdate"; |
$matches[1] . $space . $res_array["name"] . "-([\d+\.]+|\d+)\.tar(\.gz|\.bz2) debian uupdate"; |
|
#file_put_contents('/tmp/dehs/' . $res_array["name"] . "-watch_" . $res_array["dist"],$watch); |
|
| 605 |
$uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$watch); |
$uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$watch); |
| 606 |
if ($uscan_res[1] AND !$uscan_res[0]) { |
if ($uscan_res[1] AND !$uscan_res[0]) { |
| 607 |
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-error_" . $res_array["dist"]; |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($uscan_res[1]) . "', wwiz_type='error', up_url='', up_changes='' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
|
#file_put_contents($filename,$uscan_res[1],"w"); |
|
|
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($uscan_res[1]) . "', wwiz_type='error' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
|
| 608 |
$errors++; |
$errors++; |
| 609 |
} |
} |
| 610 |
else { |
else { |
| 611 |
$verok++; |
$verok++; |
| 612 |
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-watch_" . $res_array["dist"]; |
if ($uscan_res[0]!=$res_array[wwiz_version]) ($keep_changes=1); |
| 613 |
#file_put_contents($filename,$watch,"w"); |
else $keep_changes=0; |
| 614 |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($watch) ."', wwiz_type='watch', wwiz_version='" . $uscan_res[0] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($watch) ."', wwiz_type='watch', wwiz_version='" . $uscan_res[0] . "', up_url='" . $uscan_res[2] . "', keep_changes='$keep_changes' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
| 615 |
} |
} |
| 616 |
} |
} |
| 617 |
} |
} |
| 618 |
print "Package checked: " . $checked++ . |
print "Package checked: " . $checked++ . |
| 619 |
" OK: $verok Error: $errors Not Matched: $notmatch\r"; |
" OK: $verok Error: $errors Not Matched: $notmatch\r"; |
| 620 |
} |
} |
| 621 |
print "Copyright files not founded: $notfound\n"; |
print "\nCopyright files not founded: $notfound\n"; |
| 622 |
print "Automatic genereted watch file failure: $errors\n"; |
print "Automatic genereted watch file failure: $errors\n"; |
| 623 |
pg_close($db); |
pg_close($db); |
| 624 |
} |
} |
| 632 |
db_up_error(); |
db_up_error(); |
| 633 |
db_upstream(); |
db_upstream(); |
| 634 |
watch_fill(); |
watch_fill(); |
| 635 |
|
up_changes(); |
| 636 |
$endtime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2); |
$endtime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2); |
| 637 |
$messaggio="Dehs executed successful\nBegin: $intime\nEnd: $endtime"; |
$messaggio="Dehs executed successful\nBegin: $intime\nEnd: $endtime"; |
| 638 |
mail($email, "DEHS report", $messaggio, |
mail($email, "DEHS report", $messaggio, |