/[gentoo-src]/glep15/functions.php
Gentoo

Contents of /glep15/functions.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Oct 30 21:52:52 2003 UTC (11 years, 1 month ago) by lisa
Branch: MAIN
CVS Tags: HEAD
Inital checkin.  Happy Hacking.

1 <?php
2 /***************************************************************************
3 * functions.php
4 *
5 * Sat Oct 18 14:21:54 2003
6 * Copyright 2003 lisa seelye
7 * Copyright 2003 Gentoo Technologies, Inc.
8 * lisa@gentoo.org - www.gentoo.org
9 *
10 * $Header: /home/cvsroot/scripts/functions.php,v 1.1 2003/10/18 18:35:58 lisa Exp $
11 ***************************************************************************
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 **************************************************************************/
26
27 /* This file contains a bunch of useful functions, such as:
28 * norm(str) - returns mysql_escape_string($str)
29 * printHeader($title,array $css) - Prints the proper page header and <title>, and a
30 * css include to each file in the array $css (if present). This function also auto-
31 * detects whether or not the user can accept various content-types for xhtml.
32 * If $language is null it will assume UTF-8
33 * printFooter() - Prints a footer, copyright, </body></html>, etc.
34 *
35 */
36
37 @require_once("cookie.php");
38
39
40 function norm($str) { return mysql_escape_string($str); }
41 function printHeader($title, $language = "UTF-8", $css = NULL) {
42 _printContentType();
43 ob_end_flush();
44 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n",$this->encoding);
45 printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
46 printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"%s\">\n",$language);
47 printf("<head>\n");
48 printf("\t<title>%s</title>\n",$title);
49 if ( !is_null($css) && is_array($css) ) {
50 // Print style sheets
51 printf("\t<style type=\"text/css\" media=\"all\">\n");
52 foreach ($css as $sheet) {
53 printf("\t\t@import \"%s\";\n",$sheet);
54 }
55 printf("\t</style>\n");
56 }
57 printf("</head>\n");
58 }
59 function printFooter() {
60 _printCopyright();
61 printf("</body>\n</html>\n");
62 }
63 function _printCopyright() {
64 printf("Copyright 2003 Lisa Seelye, Gentoo Technologies, Inc.\n");
65 }
66 function _printContentType() {
67 if (strpos($_SERVER['HTTP_ACCEPT'],"application/xhtml+xml")) {
68 header("Content-type: application/xhtml+xml\n");
69 }
70 elseif (strpos($_SERVER['HTTP_ACCEPT'],"application/xml")) {
71 header("Content-type: application/xml\n");
72 }
73 elseif (strpos($_SERVER['HTTP_ACCEPT'],"text/xml")) {
74 header("Content-type: text/xml\n");
75 }
76 else {
77 header("Content-type: text/html\n");
78 }
79 }
80 ?>

  ViewVC Help
Powered by ViewVC 1.1.20