Changeset 31629 for trunk/www


Ignore:
Timestamp:
Dec 1, 2007, 1:09:33 AM (12 years ago)
Author:
wsiegrist@…
Message:

various initial tweaks to install on MacOSForge. Added graceful degradation when mysql is unavailable.

Location:
trunk/www
Files:
4 edited

Legend:

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

    r31516 r31629  
    3434$portsdb_host = 'localhost';
    3535$portsdb_name = 'macports';
    36 $portsdb_user = 'www';
    37 $portsdb_passwd = '';
    38 
     36$portsdb_user = 'macports';
     37$portsdb_passwd = trim(file_get_contents('/opt/local/share/macports/resources/portmgr/script_data'));
    3938
    4039######################################################################
     
    10099# Obfuscate e-mail addresses:
    101100function obfuscate_email($email) {
    102     $IMGDIR = dirname($_SERVER['SCRIPT_NAME']) . '/img';
     101    $IMGDIR = '/img';
    103102   
    104103    return "<span class='email'>" . str_replace('@', "<img src='$IMGDIR/at.gif' alt='at' />", $email) . "</span>";
     
    114113    include("$MPWEB/includes/footer.inc");
    115114}
     115
     116######################################################################
     117
     118function print_db_error() {
     119       print "
     120        <div id='content'>
     121          <h2 class='hdr'>MacPorts Portfiles</h2>
     122          <p>Our database is currently unavailable. We hope to have it back soon!</p>
     123        </div>
     124             ";
     125       print_footer();
     126       die();
     127}
     128
  • trunk/www/includes/footer.inc

    r31506 r31629  
    44    /* Copyright (c) 2004, OpenDarwin. */
    55    /* Copyright (c) 2004-2007, The MacPorts Project. */
    6     $IMGDIR = dirname($_SERVER['SCRIPT_NAME']) . '/img/';
     6    $IMGDIR = '/img/';
    77?>
    88
  • trunk/www/index.php

    r31516 r31629  
    66    include_once("$MPWEB/includes/common.inc");
    77    print_header('The MacPorts Project -- Home', 'utf-8');
    8     $portsdb_connect = mysql_pconnect($portsdb_host, $portsdb_user, $portsdb_passwd) or die("Can't connect to the MacPorts database!");
     8    $portsdb_connect = mysql_connect($portsdb_host, $portsdb_user, $portsdb_passwd);
     9    if ($portsdb_connect !== false) {
     10       $port_count = 'a lot of';
     11       $cat_count = 'many';
     12    } else {
     13       $port_count = ports_count();
     14       $cat_count = categories_count();
     15    }
    916?>
    1017
     
    2431    without splitting them into &ldquo;stable&rdquo; Vs. &ldquo;unstable&rdquo; branches, targetting mainly the current Mac OS
    2532    X release (10.5, A.K.A Leopard) and the immediately previous one (10.4, A.K.A. Tiger). There are currently <a href="ports.php">
    26     <b><?php print ports_count(); ?></b> ports</a> in our tree, distributed among <?php print categories_count(); ?> different
     33    <b><?= $port_count ?></b> ports</a> in our tree, distributed among <?= $cat_count ?> different
    2734    categories, and more are being added on a regular basis.</p>
    2835   
     
    7178<?php
    7279    print_footer();
     80    mysql_close($portsdb_connect);
    7381?>
  • trunk/www/ports.php

    r31599 r31629  
    88    include_once("$MPWEB/includes/common.inc");
    99    print_header('The MacPorts Project -- Available Ports', 'utf-8');
    10     $portsdb_connect = mysql_pconnect($portsdb_host, $portsdb_user, $portsdb_passwd) or die("Can't connect to the MacPorts database!");
     10    $portsdb_connect = mysql_connect($portsdb_host, $portsdb_user, $portsdb_passwd) or print_db_error();
     11   
    1112    $num_categories = categories_count();
    1213    $by = isset($_GET['by']) ? $_GET['by'] : '';
     
    264265<?php
    265266    print_footer();
    266 ?>
     267    mysql_close($portsdb_connect);
     268?>
Note: See TracChangeset for help on using the changeset viewer.