Changeset 35220 for trunk/www


Ignore:
Timestamp:
Mar 21, 2008, 5:22:47 AM (12 years ago)
Author:
eridius@…
Message:

Clean up ports.php some more by converting to double quotes & variable interpolation where appropriate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/ports.php

    r35219 r35220  
    1111   
    1212    $portsdb_info = portsdb_connect($portsdb_host, $portsdb_user, $portsdb_passwd);
    13     $sql = 'SELECT UNIX_TIMESTAMP(activity_time) FROM ' . $portsdb_name . '.log ORDER BY UNIX_TIMESTAMP(activity_time) DESC';
     13    $sql = "SELECT UNIX_TIMESTAMP(activity_time) FROM $portsdb_name.log ORDER BY UNIX_TIMESTAMP(activity_time) DESC";
    1414    $result = mysql_query($sql);
    1515    if ($result && $row = mysql_fetch_row($result)) {
     
    5959     as possible searches */
    6060    if (!$by || ($by != 'all' && !$substr)) {
    61         $query = 'SELECT DISTINCT category FROM ' . $portsdb_name . '.categories ORDER BY category';
     61        $query = "SELECT DISTINCT category FROM $portsdb_name.categories ORDER BY category";
    6262        $result = mysql_query($query);
    6363        if ($result) {
     
    6969                print '<li><ul>';
    7070                while ($row = mysql_fetch_assoc($result)) {
    71                     print '<li><a href="' . $_SERVER['PHP_SELF'] . '?by=category&amp;substr=' . urlencode($row['category']) . '">'
     71                    print "<li><a href=\"$_SERVER[PHP_SELF]?by=category&amp;substr=" . urlencode($row['category']) . '">'
    7272                    . htmlspecialchars($row['category']) . '</a></li>';
    7373                    if ($entries_per_colum == $max_entries_per_column) break;
     
    8787        switch ($by) {
    8888        case 'name':
    89             $criteria = 'p.name LIKE \'%' . mysql_real_escape_string($substr) . '%\'';
     89            $criteria = "p.name LIKE '%" . mysql_real_escape_string($substr) . "%'";
    9090            break;
    9191        case 'category':
    9292            $tables .= ", $portsdb_name.categories AS c";
    93             $criteria = 'c.portfile = p.name AND c.category = \'' . mysql_real_escape_string($substr) . '\'';
     93            $criteria = "c.portfile = p.name AND c.category = '" . mysql_real_escape_string($substr) . "'";
    9494            break;
    9595        case 'maintainer':
    9696            $tables .= ", $portsdb_name.maintainers AS m";
    97             $criteria = 'm.portfile = p.name AND m.maintainer LIKE \'%' . mysql_real_escape_string($substr) . '%\'';
     97            $criteria = "m.portfile = p.name AND m.maintainer LIKE '%" . mysql_real_escape_string($substr) . "%'";
    9898            break;
    9999        case 'library':
    100             $criteria = 'p.name = \'' . mysql_real_escape_string($substr) . '\'';
     100            $criteria = "p.name = '" . mysql_real_escape_string($substr) . "'";
    101101            break;
    102102        case 'variant':
    103103            $tables .= ", $portsdb_name.variants AS v";
    104             $criteria = 'v.portfile = p.name AND v.variant = \'' . mysql_real_escape_string($substr) . '\'';
     104            $criteria = "v.portfile = p.name AND v.variant = '" . mysql_real_escape_string($substr) . "'";
    105105            break;
    106106        case 'platform':
    107107            $tables .= ", $portsdb_name.platforms AS pl";
    108             $criteria = 'pl.portfile = p.name AND pl.platform = \'' . mysql_real_escape_string($substr) . '\'';
     108            $criteria = "pl.portfile = p.name AND pl.platform = '" . mysql_real_escape_string($substr) . "'";
    109109            break;
    110110        case 'all':
     
    126126
    127127                /* Port name and Portfile URL */
    128                 print '<dt><b><a href="' . $trac_url . 'browser/trunk/dports/' . $row['path'] . '/Portfile">' . htmlspecialchars($row['name'])
     128                print "<dt><b><a href=\"${trac_url}browser/trunk/dports/$row[path]/Portfile\">" . htmlspecialchars($row['name'])
    129129                . '</a></b> ' . htmlspecialchars($row['version']) . '</dt>';
    130130               
     
    134134               
    135135                /* Maintainers */
    136                 $nquery = 'SELECT maintainer FROM ' . $portsdb_name . '.maintainers WHERE portfile=\'' . mysql_real_escape_string($row['name']) .
    137                 '\' ORDER BY is_primary DESC, maintainer';
     136                $nquery = "SELECT maintainer FROM $portsdb_name.maintainers WHERE portfile='" . mysql_real_escape_string($row['name']) .
     137                "' ORDER BY is_primary DESC, maintainer";
    138138                $nresult = mysql_query($nquery);
    139139                if ($nresult) {
     
    150150
    151151                /* Categories */
    152                 $nquery = 'SELECT category FROM ' . $portsdb_name . '.categories WHERE portfile=\'' . mysql_real_escape_string($row['name']) .
    153                 '\' ORDER BY is_primary DESC, category';
     152                $nquery = "SELECT category FROM $portsdb_name.categories WHERE portfile='" . mysql_real_escape_string($row['name']) .
     153                "' ORDER BY is_primary DESC, category";
    154154                $nresult = mysql_query($nquery);
    155155                if ($nresult) {
     
    159159                        if ($primary) { print ' <b>'; }
    160160                        else { print ' '; }
    161                         print '<a href="' . $_SERVER['PHP_SELF'] . '?by=category&amp;substr=' . urlencode($nrow[0]) . '">'
     161                        print "<a href=\"$_SERVER[PHP_SELF]?by=category&amp;substr=" . urlencode($nrow[0]) . '">'
    162162                        . htmlspecialchars($nrow[0]) . '</a>';
    163163                        if ($primary) { print '</b>'; }
     
    167167
    168168                /* Platforms */
    169                 $nquery = 'SELECT platform FROM ' . $portsdb_name . '.platforms WHERE portfile=\'' . mysql_real_escape_string($row['name']) .
    170                 '\' ORDER BY platform';
     169                $nquery = "SELECT platform FROM $portsdb_name.platforms WHERE portfile='" . mysql_real_escape_string($row['name']) .
     170                "' ORDER BY platform";
    171171                $nresult = mysql_query($nquery);
    172172                if ($nresult) {
    173173                    print '<br /><i>Platforms:</i> ';
    174174                    while ($nrow = mysql_fetch_row($nresult)) {
    175                         print '<a href="' . $_SERVER['PHP_SELF'] . '?by=platform&amp;substr=' . urlencode($nrow[0]) . '">'
     175                        print "<a href=\"$_SERVER[PHP_SELF]?by=platform&amp;substr=" . urlencode($nrow[0]) . '">'
    176176                        . htmlspecialchars($nrow[0]) . '</a> ';
    177177                    }
     
    179179
    180180                /* Dependencies */
    181                 $nquery = 'SELECT library FROM ' . $portsdb_name . '.dependencies WHERE portfile=\'' . mysql_real_escape_string($row['name']) .
    182                 '\' ORDER BY library';
     181                $nquery = "SELECT library FROM $portsdb_name.dependencies WHERE portfile='" . mysql_real_escape_string($row['name']) .
     182                "' ORDER BY library";
    183183                $nresult = mysql_query($nquery);
    184184                if ($nresult && mysql_num_rows($nresult) > 0) {
     
    186186                    while ($nrow = mysql_fetch_row($nresult)) {
    187187                        $library = eregi_replace('^([^:]*:[^:]*:|[^:]*:)', '', $nrow[0]);
    188                         print '<a href="' . $_SERVER['PHP_SELF'] . '?by=library&amp;substr=' . urlencode($library) . '">'
     188                        print "<a href=\"$_SERVER[PHP_SELF]?by=library&amp;substr=" . urlencode($library) . '">'
    189189                        . htmlspecialchars($library) . '</a> ';
    190190                    }
     
    192192
    193193                /* Variants */
    194                 $nquery = 'SELECT variant FROM ' . $portsdb_name . '.variants WHERE portfile=\'' . mysql_real_escape_string($row['name']) .
    195                 '\' ORDER BY variant';
     194                $nquery = "SELECT variant FROM $portsdb_name.variants WHERE portfile='" . mysql_real_escape_string($row['name']) .
     195                "' ORDER BY variant";
    196196                $nresult = mysql_query($nquery);
    197197                if ($nresult && mysql_num_rows($nresult) > 0) {
    198198                    print '<br /><i>Variants:</i> ';
    199199                    while ($nrow = mysql_fetch_row($nresult)) {
    200                         print '<a href="' . $_SERVER['PHP_SELF'] . '?by=variant&amp;substr=' . urlencode($nrow[0]) . '">'
     200                        print "<a href=\"$_SERVER[PHP_SELF]?by=variant&amp;substr=" . urlencode($nrow[0]) . '">'
    201201                        . htmlspecialchars($nrow[0]) . '</a> ';
    202202                    }
Note: See TracChangeset for help on using the changeset viewer.