| 1 | <?php |
|---|
| 2 | // PHP script to create Parsix watch file table rows. |
|---|
| 3 | // Coyright 2007 Alan Baghumian / GNU/GPL |
|---|
| 4 | // Based on Debian DEHS http://svn.debian.org/wsvn/dehs |
|---|
| 5 | |
|---|
| 6 | $vars=$_GET["vars"]; |
|---|
| 7 | uscan($vars); |
|---|
| 8 | |
|---|
| 9 | // Display warnings? |
|---|
| 10 | $show_warnings=false; |
|---|
| 11 | |
|---|
| 12 | function uscan($vars){ |
|---|
| 13 | $arrvars=explode("*", $vars); |
|---|
| 14 | $path = $arrvars[0]; |
|---|
| 15 | |
|---|
| 16 | $arrarchs=explode("-", $arrvars[1]); |
|---|
| 17 | |
|---|
| 18 | $spkg = $arrvars[2]; |
|---|
| 19 | |
|---|
| 20 | if(!empty($arrarchs[0])){ |
|---|
| 21 | $archs .= "<font color=red>".$arrarchs[0]."</font> "; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | if(!empty($arrarchs[1])){ |
|---|
| 25 | $archs .= "<font color=green>".$arrarchs[1]."</font> "; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | if(!empty($arrarchs[2])){ |
|---|
| 29 | $archs .= "<font color=blue>".$arrarchs[2]."</font>"; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | # work around the plus bug |
|---|
| 33 | $path=str_replace("KKK", "+", $path); |
|---|
| 34 | |
|---|
| 35 | $uscan_res=shell_exec("/usr/bin/uscan --report --dehs --check-dirname-level 0 ".$path); |
|---|
| 36 | |
|---|
| 37 | # work around the plus bug |
|---|
| 38 | $uscan_res=str_replace("+", "KKK", $uscan_res); |
|---|
| 39 | |
|---|
| 40 | $p = xml_parser_create(); |
|---|
| 41 | xml_parse_into_struct($p, $uscan_res, $vals, $index); |
|---|
| 42 | xml_parser_free($p); |
|---|
| 43 | |
|---|
| 44 | $pkg=$vals[$index['PACKAGE'][0]][value]; |
|---|
| 45 | |
|---|
| 46 | if(!empty($pkg)){ |
|---|
| 47 | $pkg=str_replace("KKK", "+", $pkg); |
|---|
| 48 | }else{ |
|---|
| 49 | $pkg = $spkg; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | $upstream=$vals[$index['UPSTREAM-VERSION'][0]][value]; |
|---|
| 53 | $up_url=$vals[$index['UPSTREAM-URL'][0]][value]; |
|---|
| 54 | $up_url=str_replace("KKK", "+", $up_url); |
|---|
| 55 | $parsix=$vals[$index['DEBIAN-UVERSION'][0]][value]; |
|---|
| 56 | $status=$vals[$index['STATUS'][0]][value]; |
|---|
| 57 | $warnings=$vals[$index['WARNINGS'][0]][value]; |
|---|
| 58 | if ($upstream=='') $upstream=null; |
|---|
| 59 | if ($up_url=='') $up_url=null; |
|---|
| 60 | if ($parsix=='') $parsix=null; |
|---|
| 61 | if ($status=='') $status=null; |
|---|
| 62 | if ($warnings=='') $warnings=null; |
|---|
| 63 | |
|---|
| 64 | if($upstream == $parsix){ |
|---|
| 65 | $color="green"; |
|---|
| 66 | }else{ |
|---|
| 67 | $color="red"; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | switch($status) |
|---|
| 71 | { |
|---|
| 72 | case "Up to date": |
|---|
| 73 | $bk_color="#00ff00"; |
|---|
| 74 | break; |
|---|
| 75 | case "Newer version available": |
|---|
| 76 | $bk_color="#ffff00"; |
|---|
| 77 | break; |
|---|
| 78 | case "Debian version newer than remote site": |
|---|
| 79 | $bk_color="#ffcc99"; |
|---|
| 80 | break; |
|---|
| 81 | default: |
|---|
| 82 | $status = "Watch file does not find" |
|---|
| 83 | $bk_color="#ffea99"; |
|---|
| 84 | break; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | if($pkg !='' || $pkg !=null){ |
|---|
| 88 | if($upstream != null){ |
|---|
| 89 | echo "<tr bgcolor=white><td><b>".$pkg."</b></td><td><a href=".$up_url.">".$upstream."</a></td><td><font color=".$color.">".$parsix."</font></td><td align=center>".$archs."</td><td bgcolor=".$bk_color.">".$status."</td></tr>"; |
|---|
| 90 | }else{ |
|---|
| 91 | if($show_warnings){ |
|---|
| 92 | echo "<tr bgcolor=white><td><b>".$pkg."</b></td><td colspan=4 bgcolor=#ff9966>".$warnings."</td></tr>"; |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | ?> |
|---|