| 280 |
} |
} |
| 281 |
|
|
| 282 |
function vers_conv($debvers) { |
function vers_conv($debvers) { |
| 283 |
preg_match("/(.+)-/",$debvers,$matches); |
preg_match("/(.+)(ds-|-)/",$debvers,$matches); |
| 284 |
return $matches[1]; |
return $matches[1]; |
| 285 |
} |
} |
| 286 |
function check_db() { |
function check_db() { |
| 287 |
global $dirs,$dbconn; |
global $dirs,$dbconn; |
| 288 |
$db = pg_connect($dbconn) or die(pg_result_error($db)); |
$db = pg_connect($dbconn) or die(pg_result_error($db)); |
| 289 |
if (!pg_table_exists($db,"pkgs")){ |
if (!pg_table_exists($db,"pkgs")){ |
| 290 |
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_type text)") or die('Error creating table pkgs\n'); |
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'); |
| 291 |
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)); |
| 292 |
$sw=true; |
$sw=true; |
| 293 |
} |
} |
| 448 |
$fw=fopen("/tmp/$name" . "_watch","w"); |
$fw=fopen("/tmp/$name" . "_watch","w"); |
| 449 |
fwrite($fw,$watch); |
fwrite($fw,$watch); |
| 450 |
fclose($fw); |
fclose($fw); |
| 451 |
$uscan_res=shell_exec("perl uscan3.pl $name $name " . vers_conv($version) . " /tmp/$name" . "_watch 2>&1"); |
$uscan_res=shell_exec("perl uscan3.pl $name " . vers_conv($version) . " /tmp/$name" . "_watch 2>&1"); |
| 452 |
unlink("/tmp/$name" . "_watch"); |
unlink("/tmp/$name" . "_watch"); |
| 453 |
preg_match("/\+\+(.+)\+\+/",$uscan_res, $matches); |
preg_match("/\+\+(.+)\+\+/",$uscan_res, $matches); |
| 454 |
if ($matches[1]!='') $upstream=$matches[1]; |
if ($matches[1]!='') $upstream=$matches[1]; |
| 515 |
#file_put_contents($filename,"","w"); |
#file_put_contents($filename,"","w"); |
| 516 |
} |
} |
| 517 |
else { |
else { |
| 518 |
$res=preg_match ('/((ftp:\/\/|http:\/\/).+(\/|\.tar\|\.gz\|\.bz2|html))/',$contents,$matches); |
$res=preg_match ('/((ftp:\/\/|http:\/\/)\S+(html|htm|\/(?(?=.+tar)|[^>\s)]+)))/',$contents,$matches); |
| 519 |
|
print $res_array["name"] . " => " . $matches[1] . "\n"; |
| 520 |
|
$final=substr($matches[1],-1); |
| 521 |
|
#print "$final\n"; |
| 522 |
|
if ($matches[3]=="html" or $matches[3]=="htm") $space=' '; |
| 523 |
|
if ($final=='.') $matches[1]=substr_replace($matches[1],'',-1); |
| 524 |
|
if ($final!='/' AND $space!=' ') $matches[1].='/'; |
| 525 |
#print $res_array["name"] . " => " . $matches[1] . "\n"; |
#print $res_array["name"] . " => " . $matches[1] . "\n"; |
| 526 |
if (!$res) { |
if (!$res) { |
| 527 |
$notmatch++; |
$notmatch++; |
| 531 |
} |
} |
| 532 |
else { |
else { |
| 533 |
$watch="version=2\n" . |
$watch="version=2\n" . |
| 534 |
$matches[1] . $res_array["name"] . ".*-([\d\.\d]+\d+|\d+)\.tar(\.gz|\.bz2)"; |
$matches[1] . $space . $res_array["name"] . ".*-([\d+\.]+|\d+)\.tar(\.gz|\.bz2) debian uupdate"; |
| 535 |
#file_put_contents('/tmp/dehs/' . $res_array["name"] . "-watch_" . $res_array["dist"],$watch); |
#file_put_contents('/tmp/dehs/' . $res_array["name"] . "-watch_" . $res_array["dist"],$watch); |
| 536 |
$uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$watch); |
$uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$watch); |
| 537 |
if ($uscan_res[1]) { |
if ($uscan_res[1] AND !$uscan_res[0]) { |
| 538 |
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-error_" . $res_array["dist"]; |
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-error_" . $res_array["dist"]; |
| 539 |
#file_put_contents($filename,$uscan_res[1],"w"); |
#file_put_contents($filename,$uscan_res[1],"w"); |
| 540 |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($uscan_res[1]) . "', wwiz_type='error' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($uscan_res[1]) . "', wwiz_type='error' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
| 544 |
$verok++; |
$verok++; |
| 545 |
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-watch_" . $res_array["dist"]; |
#$filename=$dirs["watchfill_dir"] . "/" . $res_array["name"] . "-watch_" . $res_array["dist"]; |
| 546 |
#file_put_contents($filename,$watch,"w"); |
#file_put_contents($filename,$watch,"w"); |
| 547 |
pg_exec($db, "UPDATE pkgs SET wwiz='" . addslashes($watch) ."', wwiz_type='watch' 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] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'"); |
| 548 |
} |
} |
| 549 |
} |
} |
| 550 |
} |
} |