| 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 | // Updated: 2008-03-17 08:36 +0100 GMT |
|---|
| 7 | |
|---|
| 8 | $vars=$_GET["vars"]; |
|---|
| 9 | $dist_name="viola"; |
|---|
| 10 | uscan($vars); |
|---|
| 11 | |
|---|
| 12 | // Display warnings? |
|---|
| 13 | $show_warnings=false; |
|---|
| 14 | |
|---|
| 15 | function uscan($vars){ |
|---|
| 16 | $svn_url="http://svn.debian.org/svn/pkg-parsix/pkg/".$dist_name; |
|---|
| 17 | $arrvars=explode("*", $vars); |
|---|
| 18 | $path = $arrvars[0]; |
|---|
| 19 | |
|---|
| 20 | $arrarchs=explode("-", $arrvars[1]); |
|---|
| 21 | |
|---|
| 22 | $spkg = $arrvars[2]; |
|---|
| 23 | $parsix_ver = $arrvars[3]; |
|---|
| 24 | |
|---|
| 25 | $parsix_rev = $arrvars[4]; |
|---|
| 26 | $component = $arrvars[5]; |
|---|
| 27 | $parsix_spec = $arrvars[6]; |
|---|
| 28 | |
|---|
| 29 | if(!empty($parsix_rev)){ |
|---|
| 30 | $parsix_rev = "-".$parsix_rev; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | if(!empty($arrarchs[0])){ |
|---|
| 34 | $archs .= "<font color=red>".$arrarchs[0]."</font> "; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | if(!empty($arrarchs[1])){ |
|---|
| 38 | $archs .= "<font color=green>".$arrarchs[1]."</font> "; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | if(!empty($arrarchs[2])){ |
|---|
| 42 | $archs .= "<font color=blue>".$arrarchs[2]."</font>"; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | # work around the plus bug |
|---|
| 46 | $path=str_replace("KKK", "+", $path); |
|---|
| 47 | |
|---|
| 48 | $uscan_res=shell_exec("/usr/bin/uscan --report --dehs --check-dirname-level 0 ".$path); |
|---|
| 49 | |
|---|
| 50 | # work around the plus bug |
|---|
| 51 | $uscan_res=str_replace("+", "KKK", $uscan_res); |
|---|
| 52 | |
|---|
| 53 | $p = xml_parser_create(); |
|---|
| 54 | xml_parse_into_struct($p, $uscan_res, $vals, $index); |
|---|
| 55 | xml_parser_free($p); |
|---|
| 56 | |
|---|
| 57 | $pkg=$vals[$index['PACKAGE'][0]][value]; |
|---|
| 58 | |
|---|
| 59 | if(!empty($pkg)){ |
|---|
| 60 | $pkg=str_replace("KKK", "+", $pkg); |
|---|
| 61 | }else{ |
|---|
| 62 | $pkg = $spkg; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | $upstream=$vals[$index['UPSTREAM-VERSION'][0]][value]; |
|---|
| 66 | $up_url=$vals[$index['UPSTREAM-URL'][0]][value]; |
|---|
| 67 | $up_url=str_replace("KKK", "+", $up_url); |
|---|
| 68 | $parsix=$vals[$index['DEBIAN-UVERSION'][0]][value]; |
|---|
| 69 | $status=$vals[$index['STATUS'][0]][value]; |
|---|
| 70 | $warnings=$vals[$index['WARNINGS'][0]][value]; |
|---|
| 71 | if ($upstream=='') $upstream=null; |
|---|
| 72 | if ($up_url=='') $up_url=null; |
|---|
| 73 | if ($parsix=='') $parsix=null; |
|---|
| 74 | if ($status=='') $status=null; |
|---|
| 75 | if ($warnings=='') $warnings=null; |
|---|
| 76 | |
|---|
| 77 | if($upstream == $parsix){ |
|---|
| 78 | $color="green"; |
|---|
| 79 | }else{ |
|---|
| 80 | $color="red"; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | switch($status) |
|---|
| 84 | { |
|---|
| 85 | case "up to date": |
|---|
| 86 | $bk_color="#00ff00"; |
|---|
| 87 | break; |
|---|
| 88 | case "Newer version available": |
|---|
| 89 | $bk_color="#ffff00"; |
|---|
| 90 | break; |
|---|
| 91 | case "Debian version newer than remote site": |
|---|
| 92 | $bk_color="#ffcc99"; |
|---|
| 93 | break; |
|---|
| 94 | default: |
|---|
| 95 | $status = "Watch file does not find"; |
|---|
| 96 | $bk_color="#1bffe8"; |
|---|
| 97 | break; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | if($pkg !='' || $pkg !=null){ |
|---|
| 101 | if($upstream != null){ |
|---|
| 102 | 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>"; |
|---|
| 103 | }else{ |
|---|
| 104 | if(strstr($spkg, 'parsix') != null){ |
|---|
| 105 | $upstream = "<a href=".$svn_url."/".$component."/".$spkg."/trunk/>".$parsix_ver."</a>"; |
|---|
| 106 | $status = "up to date"; |
|---|
| 107 | $bk_color="#00ff00"; |
|---|
| 108 | }else{ |
|---|
| 109 | if($parsix_spec > 0){ |
|---|
| 110 | $upstream = "<a href=".$svn_url."/".$component."/".$spkg."/trunk/>".$parsix_ver."</a>"; |
|---|
| 111 | $status = "up to date"; |
|---|
| 112 | $bk_color="#00ff00"; |
|---|
| 113 | }else{ |
|---|
| 114 | $upstream = "N/A"; |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | if($show_warnings){ |
|---|
| 119 | echo "<tr bgcolor=white><td><b>".$pkg."</b></td><td colspan=5 bgcolor=#ff9966>".$warnings."</td><td>"; |
|---|
| 120 | }else{ |
|---|
| 121 | echo "<tr bgcolor=white><td><b>".$spkg."</b></td><td>".$upstream."</td><td><font color=".$color.">".$parsix_ver."</font></td><td align=center>".$archs."</td><td bgcolor=".$bk_color.">".$status."</td>"; |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | ?> |
|---|