Changeset 31456 for trunk/www


Ignore:
Timestamp:
Nov 24, 2007, 6:43:09 PM (12 years ago)
Author:
jmpp@…
Message:

Standardize db variables naming with those found on the base/portmgr/jobs/PortIndex2MySQL script.

Location:
trunk/www
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/includes/common.inc

    r31371 r31456  
    1010
    1111# Ports database connection parameters:
    12 $portsdb = 'macports';
    1312$portsdb_host = 'localhost';
     13$portsdb_name = 'macports';
    1414$portsdb_user = 'www';
    1515$portsdb_passwd = '';
     
    8888# Total count of currently available ports:
    8989function ports_count() {
    90     global $portsdb;
     90    global $portsdb_name;
    9191
    92     $result = mysql_query("SELECT count(name) FROM $portsdb.portfiles") or die("Error: " . mysql_error());
     92    $result = mysql_query("SELECT count(name) FROM $portsdb_name.portfiles") or die("Error: " . mysql_error());
    9393    if ($result) {
    9494        $row = mysql_fetch_array($result);
     
    105105# Total count of port categories:
    106106function categories_count() {
    107     global $portsdb;
     107    global $portsdb_name;
    108108
    109     $result = mysql_query("SELECT COUNT(DISTINCT category) FROM $portsdb.categories") or die ("Error: " . mysql_error());
     109    $result = mysql_query("SELECT COUNT(DISTINCT category) FROM $portsdb_name.categories") or die ("Error: " . mysql_error());
    110110    if ($result) {
    111111        $row = mysql_fetch_array($result);
  • trunk/www/ports.php

    r31443 r31456  
    2222        <i>Index last updated: </i>
    2323<?php
    24         $sql = "SELECT UNIX_TIMESTAMP(activity_time) FROM $portsdb.log ORDER BY UNIX_TIMESTAMP(activity_time) DESC";
     24        $sql = "SELECT UNIX_TIMESTAMP(activity_time) FROM $portsdb_name.log ORDER BY UNIX_TIMESTAMP(activity_time) DESC";
    2525        $result = mysql_query($sql);
    2626        if ($result && $row = mysql_fetch_row($result)) {
     
    5555                <tr><th colspan="4" align="left">View By Category:</th></tr>
    5656<?php
    57                 $query = "SELECT DISTINCT category FROM $portsdb.categories ORDER BY category";
     57                $query = "SELECT DISTINCT category FROM $portsdb_name.categories ORDER BY category";
    5858                $result = mysql_query($query);
    5959                if ($result) {
     
    7373        $fields = "name, path, version, description";
    7474        $query = "1";
    75         $tables = "$portsdb.portfiles p";
     75        $tables = "$portsdb_name.portfiles p";
    7676        if ($by == "name") {
    7777            $query .= " AND p.name LIKE '%" . mysql_real_escape_string($substr) . "%'";
     
    8484        }
    8585        if ($by == "cat") {
    86             $tables .= ", $portsdb.categories c";
     86            $tables .= ", $portsdb_name.categories c";
    8787            $query .= " AND c.portfile=p.name AND c.category='" . mysql_real_escape_string($substr) . "'";
    8888        }
    8989        if ($by == "variant") {
    90             $tables .= ", $portsdb.variants v";
     90            $tables .= ", $portsdb_name.variants v";
    9191            $query .= " AND v.portfile=p.name AND v.variant='" . mysql_real_escape_string($substr) . "'";
    9292        }
    9393        if ($by == "platform") {
    94             $tables .= ", $portsdb.platforms pl";
     94            $tables .= ", $portsdb_name.platforms pl";
    9595            $query .= " AND pl.portfile=p.name AND pl.platform ='" . mysql_real_escape_string($substr) . "'";
    9696        }
    9797        if ($by == "maintainer") {
    98             $tables .= ", $portsdb.maintainers m";
     98            $tables .= ", $portsdb_name.maintainers m";
    9999            $query .= " AND m.portfile=p.name AND m.maintainer LIKE '%" . mysql_real_escape_string($substr) . "%'";
    100100        }
     
    115115<?php
    116116/* MAINTAINERS */
    117                     $nquery = "SELECT maintainer FROM $portsdb.maintainers WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY is_primary DESC, maintainer";
     117                    $nquery = "SELECT maintainer FROM $portsdb_name.maintainers WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY is_primary DESC, maintainer";
    118118                    $nresult = mysql_query($nquery);
    119119                    if ($nresult) {
     
    133133
    134134/* CATEGORIES */
    135                     $nquery = "SELECT category FROM $portsdb.categories WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY is_primary DESC, category";
     135                    $nquery = "SELECT category FROM $portsdb_name.categories WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY is_primary DESC, category";
    136136                    $nresult = mysql_query($nquery);
    137137                    if ($nresult) {
     
    152152
    153153/* PLATFORMS */
    154                     $nquery = "SELECT platform FROM $portsdb.platforms WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY platform";
     154                    $nquery = "SELECT platform FROM $portsdb_name.platforms WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY platform";
    155155                    $nresult = mysql_query($nquery);
    156156                    if ($nresult && mysql_num_rows($nresult) > 0) {
     
    168168
    169169/* DEPENDENCIES */
    170                     $nquery = "SELECT library FROM $portsdb.dependencies WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY library";
     170                    $nquery = "SELECT library FROM $portsdb_name.dependencies WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY library";
    171171                    $nresult = mysql_query($nquery);
    172172                    if ($nresult && mysql_num_rows($nresult) > 0) {
     
    186186
    187187/* VARIANTS */
    188                     $nquery = "SELECT variant FROM $portsdb.variants WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY variant";
     188                    $nquery = "SELECT variant FROM $portsdb_name.variants WHERE portfile='" . mysql_real_escape_string($row['name']) . "' ORDER BY variant";
    189189                    $nresult = mysql_query($nquery);
    190190                    if ($nresult && mysql_num_rows($nresult) > 0) {
Note: See TracChangeset for help on using the changeset viewer.