[31629] trunk/www
wsiegrist at apple.com
wsiegrist at apple.com
Fri Nov 30 17:09:35 PST 2007
Revision: 31629
http://trac.macosforge.org/projects/macports/changeset/31629
Author: wsiegrist at apple.com
Date: 2007-11-30 17:09:33 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
various initial tweaks to install on MacOSForge. Added graceful degradation when mysql is unavailable.
Modified Paths:
--------------
trunk/www/includes/common.inc
trunk/www/includes/footer.inc
trunk/www/index.php
trunk/www/ports.php
Modified: trunk/www/includes/common.inc
===================================================================
--- trunk/www/includes/common.inc 2007-12-01 01:09:02 UTC (rev 31628)
+++ trunk/www/includes/common.inc 2007-12-01 01:09:33 UTC (rev 31629)
@@ -33,10 +33,9 @@
# Ports database connection parameters:
$portsdb_host = 'localhost';
$portsdb_name = 'macports';
-$portsdb_user = 'www';
-$portsdb_passwd = '';
+$portsdb_user = 'macports';
+$portsdb_passwd = trim(file_get_contents('/opt/local/share/macports/resources/portmgr/script_data'));
-
######################################################################
# Page header:
@@ -99,7 +98,7 @@
# Obfuscate e-mail addresses:
function obfuscate_email($email) {
- $IMGDIR = dirname($_SERVER['SCRIPT_NAME']) . '/img';
+ $IMGDIR = '/img';
return "<span class='email'>" . str_replace('@', "<img src='$IMGDIR/at.gif' alt='at' />", $email) . "</span>";
}
@@ -113,3 +112,17 @@
include("$MPWEB/includes/footer.inc");
}
+
+######################################################################
+
+function print_db_error() {
+ print "
+ <div id='content'>
+ <h2 class='hdr'>MacPorts Portfiles</h2>
+ <p>Our database is currently unavailable. We hope to have it back soon!</p>
+ </div>
+ ";
+ print_footer();
+ die();
+}
+
Modified: trunk/www/includes/footer.inc
===================================================================
--- trunk/www/includes/footer.inc 2007-12-01 01:09:02 UTC (rev 31628)
+++ trunk/www/includes/footer.inc 2007-12-01 01:09:33 UTC (rev 31629)
@@ -3,7 +3,7 @@
/* $Id$ */
/* Copyright (c) 2004, OpenDarwin. */
/* Copyright (c) 2004-2007, The MacPorts Project. */
- $IMGDIR = dirname($_SERVER['SCRIPT_NAME']) . '/img/';
+ $IMGDIR = '/img/';
?>
Modified: trunk/www/index.php
===================================================================
--- trunk/www/index.php 2007-12-01 01:09:02 UTC (rev 31628)
+++ trunk/www/index.php 2007-12-01 01:09:33 UTC (rev 31629)
@@ -5,7 +5,14 @@
$MPWEB = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['SCRIPT_NAME']);
include_once("$MPWEB/includes/common.inc");
print_header('The MacPorts Project -- Home', 'utf-8');
- $portsdb_connect = mysql_pconnect($portsdb_host, $portsdb_user, $portsdb_passwd) or die("Can't connect to the MacPorts database!");
+ $portsdb_connect = mysql_connect($portsdb_host, $portsdb_user, $portsdb_passwd);
+ if ($portsdb_connect !== false) {
+ $port_count = 'a lot of';
+ $cat_count = 'many';
+ } else {
+ $port_count = ports_count();
+ $cat_count = categories_count();
+ }
?>
@@ -23,7 +30,7 @@
<p>We provide a single software tree that attempts to track the latest release of every software title (port) we distribute,
without splitting them into “stable” Vs. “unstable” branches, targetting mainly the current Mac OS
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">
- <b><?php print ports_count(); ?></b> ports</a> in our tree, distributed among <?php print categories_count(); ?> different
+ <b><?= $port_count ?></b> ports</a> in our tree, distributed among <?= $cat_count ?> different
categories, and more are being added on a regular basis.</p>
@@ -70,4 +77,5 @@
<?php
print_footer();
+ mysql_close($portsdb_connect);
?>
Modified: trunk/www/ports.php
===================================================================
--- trunk/www/ports.php 2007-12-01 01:09:02 UTC (rev 31628)
+++ trunk/www/ports.php 2007-12-01 01:09:33 UTC (rev 31629)
@@ -7,7 +7,8 @@
$MPWEB = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['SCRIPT_NAME']);
include_once("$MPWEB/includes/common.inc");
print_header('The MacPorts Project -- Available Ports', 'utf-8');
- $portsdb_connect = mysql_pconnect($portsdb_host, $portsdb_user, $portsdb_passwd) or die("Can't connect to the MacPorts database!");
+ $portsdb_connect = mysql_connect($portsdb_host, $portsdb_user, $portsdb_passwd) or print_db_error();
+
$num_categories = categories_count();
$by = isset($_GET['by']) ? $_GET['by'] : '';
$substr = isset($_GET['substr']) ? $_GET['substr'] : '';
@@ -263,4 +264,5 @@
<?php
print_footer();
+ mysql_close($portsdb_connect);
?>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071130/f68fdf45/attachment.html
More information about the macports-changes
mailing list