source: trunk/www/includes/common.inc @ 29011

Last change on this file since 29011 was 29011, checked in by jmpp@…, 13 years ago

Rework the URL abstraction variables and extend their usage to the remaining pages.
Also correct some href's to reflect the flat directory layout we now have for all
our pages (that is, no more hardcoded 'macports' dir).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1<?php
2
3# $Id: common.inc 29011 2007-09-13 05:41:18Z jmpp@macports.org $
4# Copyright (c) 2003, OpenDarwin
5# Copyright (c) 2003-2007, MacPorts Team.
6
7#####################################################################
8
9# Ports database connection parameters:
10$portsdb = 'macports_ports';
11$portsdb_host = 'localhost';
12$portsdb_user = 'www';
13$portsdb_passwd = '';
14$portsdb_connect = mysql_connect($portsdb_host, $portsdb_user, $portsdb_passwd) or die("Can't connect to the ports database!");
15
16
17######################################################################
18
19# print the current MacPorts version:
20$mp_version_major = '1.5.0';
21$mp_version_latest = '1.5.2';
22
23
24######################################################################
25
26# Some useful URL abstractions:
27$trac_url = 'http://trac.macports.org/projects/macports/';
28$svn_url = 'http://svn.macports.org/repository/macports/';
29$downloads = $svn_url . 'downloads/MacPorts-' . $mp_version_major . '/';
30$tiger_dmg = $downloads . 'MacPorts-' . $mp_version_major .'-10.4.dmg';
31$panther_dmg = $downloads . 'MacPorts-' . $mp_version_major .'-10.3.dmg';
32$bz2_tarball = $downloads . 'MacPorts-' . $mp_version_major . '.tar.bz2';
33$gz_tarball = $downloads . 'MacPorts-' . $mp_version_major . '.tar.gz';
34$checksums = $downloads .  'MacPorts-' . $mp_version_major . '.chk.txt';
35
36
37######################################################################
38
39# print the page header
40function print_header($title, $encoding) {
41    global $MPWEB;
42?>
43<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
44                      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
45<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
46    <head>
47        <title><?php echo("$title"); ?></title>
48        <meta http-equiv="Content-type" content="application/xhtml+xml; charset=<?php echo("$encoding"); ?>" />
49        <meta name="author" content="Jim Mock (mij@macports.org)" />
50        <meta name="author" content="Juan Manuel Palacios (jmpp@macports.org)" />
51        <meta name="author" content="Chris Pickel (sfiera@macports.org)" />
52        <meta name="copyright" content="2003, OpenDarwin" />
53        <meta name="copyright" content="2007, MacPorts Team" />
54        <meta name="robots" content="all" />
55        <link rel="stylesheet" type="text/css" href="macports.css" />
56        <link rel="alternate" type="application/rss+xml" href="macports_news.xml" />
57        <script type="text/javascript" src="mootools.v1.11.js"></script>
58        <script type="text/javascript" src="language.js"></script>
59    </head>
60<body>
61<?php
62    include("$MPWEB/includes/header.inc");
63    check_referer();
64}
65
66######################################################################
67
68# print the page footer
69function print_footer() {
70    global $MPWEB;
71
72    include("$MPWEB/includes/footer.inc");
73
74    echo "  </body>\n";
75    echo "</html>\n";
76}
77
78######################################################################
79
80# Print a total count of currently available ports:
81function ports_count() {
82    global $portsdb;
83
84    $result = mysql_query("SELECT count(*) FROM $portsdb.portfiles") or die("Error: " . mysql_error());
85    if ($result) {
86        $row = mysql_fetch_array($result);
87        $count = $row[0];
88    } else {
89        $count = 0;
90    }
91    return $count;
92}
93
94######################################################################
95
96# Warn against darwinports.com leach!
97function check_referer() {
98    global $_SERVER;
99
100    if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'darwinports.com') !== false) {
101?>
102        <div class="warning">
103            <p>You have arrived at the <b>Official MacPorts Web Site</b> from <i>darwinports.com</i>.</p>
104            <p><i>darwinports.com</i> <b>is not the official MacPorts Web Site</b>, nor is it a mirror of
105            the <i>Official MacPorts Web Site</i>.  There is <b>no relationship</b> between the <i>MacPorts
106            Project</i> and <i>darwinports.com</i>.</p>
107
108            <p>The information you may have been presented with on <i>darwinports.com</i> may be incorrect
109            or outdated and is not endorsed in any way by the <i>MacPorts Project</i>. For the most accurate
110            information about MacPorts, please bookmark this site, <a href="http://www.macports.org">http://www.macports.org</a>.</p>
111        </div>
112<?php
113    }
114}
115?>
Note: See TracBrowser for help on using the repository browser.