PHP:Clients body

From distributed.net
Jump to: navigation, search
//

print '<table class="clients">';


$httpurl = "http://http.distributed.net/pub/dcti/current-client/";
$ftpurl = "ftp://ftp.distributed.net/pub/dcti/current-client/";

global $dnetClientsDBHostname, $dnetClientsDBUsername, $dnetClientsDBPassword, $dnetClientsDBName;
$db = mysql_pconnect($dnetClientsDBHostname, $dnetClientsDBUsername, $dnetClientsDBPassword);
mysql_select_db($dnetClientsDBName,$db);

$result = mysql_query("select S.ranking, S.description as s_description, C.releasedate, 
            C.build, C.description as c_description, C.urlpart, C.instruct, S.sectionid 
       from sections S, clients C 
       where C.sectionid=S.sectionid and C.visible='true' 
       order by S.ranking, S.description, C.releasedate Desc, C.build",$db);

$lastsection = "";
$instructions = array();
$nextnoteid = 1;
while ($clientrow = mysql_fetch_array($result))
{
   if ($clientrow['s_description'] != $lastsection) {

      if (count($instructions)) {
         print '<tr><td class="notation" colspan="5"><small><em>';
         foreach ($instructions as $id => $text)
            printf("%d. %s<br />", $id, htmlspecialchars($text));
         print "</em></small></td></tr>";
      }

      printf('<tr><td colspan="5"><strong><a name="%s" id="%s">%s</a></strong></td></tr>',
           $clientrow['sectionid'], $clientrow['sectionid'], $clientrow['s_description']);
      $lastsection = $clientrow['s_description'];
      $instructions = array();
   }
   $footnote = " ";
   if ($clientrow['instruct'] != "") {
      $noteid = array_search($clientrow['instruct'], $instructions);
      if (!$noteid) {
        $noteid = $nextnoteid++;
        $instructions[$noteid] = $clientrow['instruct'];
      }
      $footnote = "<small><em>$noteid</em></small>";
   }
   printf("<tr><td>%s</td>" .
           "<td>%s</td>" .
           "<td><b>%s </b></td>" .
           '<td nowrap="true">%s </td>' .
           '<td class="notation"> <a href="%s" onclick="javascript:urchinTracker(\'/download/clients-file\');">http</a> | <a href="%s" onclick="javascript:urchinTracker(\'/download/clients-file\');">ftp</a> </td>' .
           "</tr>", 
       $footnote, htmlspecialchars($clientrow['c_description']),
       htmlspecialchars($clientrow['build']),
       $clientrow['releasedate'], 
       htmlspecialchars($httpurl . $clientrow['urlpart']), 
       htmlspecialchars($ftpurl . $clientrow['urlpart']) );
}

if (count($instructions)) {
    print '<tr><td class="notation" colspan="5"><small><em>';
    foreach ($instructions as $id => $text)
        printf("%d. %s<br />", $id, htmlspecialchars($text));
    print "</em></small></td></tr>";
}

print "</table>\n";

//