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

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

Separate ports and news into their own databases and abstract calls to them through appropriate variables in the code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1<?php
2
3# $Id: common.inc 28379 2007-08-30 01:36:17Z jmpp@macports.org $
4# Copyright (c) 2003, OpenDarwin
5
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 = "1.5.2";
21$mp_version_dmg = "1.5.0";
22
23######################################################################
24
25# print the page header
26function print_header($title, $encoding) {
27  global $DOCUMENT_ROOT;
28?>
29<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
30  "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
31<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
32  <head>
33    <title><?php echo("$title"); ?></title>
34    <meta http-equiv="Content-type" content="text/html; charset=<?php echo("$encoding"); ?>" />
35    <meta name="author" content="Jim Mock (mij@macports.org)" />
36    <meta name="copyright" content="2003, OpenDarwin" />
37    <meta name="author" content="Juan Manuel Palacios (jmpp@macports.org)" />
38    <meta name="copyright" content="2007, MacPorts Team" />
39    <meta name="robots" content="all" />
40    <link rel="stylesheet" type="text/css" href="/macports/mp.css" />
41    <link rel="alternate" type="application/rss+xml" href="/macports/mp_news.xml" />
42  </head>
43
44  <body>
45
46  <?php check_referer(); ?>
47 
48  <div id="main">
49
50<?php
51  include("$DOCUMENT_ROOT/macports/includes/header.inc");
52}
53
54######################################################################
55
56# print the page footer
57function print_footer() {
58  global $DOCUMENT_ROOT;
59
60  include("$DOCUMENT_ROOT/macports/includes/footer.inc");
61
62  echo "  </body>\n";
63  echo "</html>\n";
64}
65
66######################################################################
67
68# Print a total count of currently available ports:
69function ports_count() {
70         global $portsdb;
71
72         $result = mysql_query("SELECT count(*) FROM $portsdb.portfiles") or die("Error: " . mysql_error());
73         if ($result) {
74           $row = mysql_fetch_array($result);
75           $count = $row[0];
76         } else {
77           $count = 0;
78         }
79         return $count;
80}
81
82######################################################################
83
84# Warn against darwinports.com leach!
85function check_referer() {
86        global $_SERVER;
87        if (preg_match("/darwinports.com/", $_SERVER['HTTP_REFERER'])) {
88?>
89        <div class="referer_box">
90                <h1>The Official MacPorts Web Site, home of the project previously known as DarwinPorts</h1>
91               
92                <p>You have arrived at the <b>Official MacPorts Web Site</b> from <i>darwinports.com</i>.</p>
93         
94                <p><i>darwinports.com</i> <b>is not the official MacPorts Web Site</b>, nor is it a mirror of
95                the <i>Official MacPorts Web Site</i>.  There is <b>no relationship</b> between the <i>MacPorts
96                Project</i> and <i>darwinports.com</i>.</p>
97
98                <p>The information you may have been presented with on <i>darwinports.com</i> may be incorrect
99                or outdated and is not endorsed in any way by the <i>MacPorts Project</i>. For the most accurate
100                information about MacPorts, please bookmark this site, <a href="http://www.macports.org">http://www.macports.org</a>.</p>
101        </div>
102
103<?php
104        }
105}       
106?>
Note: See TracBrowser for help on using the repository browser.