Add cms table, and move the 'index' pagetext to cms

Add .htaccess rules for the cms
Add cms page display code and convert index.php to pull from the cms
If no page title is passed to send_header(), output the fair name in the <title> tag
This commit is contained in:
james 2008-08-19 21:13:29 +00:00
parent 597a21da3a
commit 7e84ab0222
6 changed files with 62 additions and 8 deletions

View File

@ -1 +1,8 @@
php_flag register_globals off
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-l
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^web/(.*)$ cms.php?f=$1 [L]

View File

@ -373,7 +373,7 @@ function send_header($title="", $nav=null)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head><title><?=i18n($title)?></title>
<head><title><? if($title) echo i18n($title); else echo i18n($config['fairname']); ?></title>
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/sfiab.css" type="text/css" media="all" />
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type="text/css" media="all" />
</head>
@ -1008,6 +1008,34 @@ function output_page_text($textname)
echo $r->text;
}
function output_page_cms($filename)
{
global $config;
$q=mysql_query("SELECT * FROM cms WHERE filename='".mysql_escape_string($filename)."' AND lang='".$_SESSION['lang']."' ORDER BY dt DESC LIMIT 1");
if(mysql_num_rows($q))
{
$r=mysql_fetch_object($q);
send_header($r->title);
if(file_exists("data/logo-200.gif") && $r->showlogo==1)
echo "<img align=\"right\" src=\"data/logo-200.gif\" border=\"0\">";
//if it looks like we have HTML content, dont do a nl2br, if there's no html, then do the nl2br
if(strlen($r->text)==strlen(strip_tags($r->text)))
echo nl2br($r->text);
else
echo $r->text;
}
else {
send_header(i18n("Error: File not found"));
echo error(i18n("The file you have requested (%1), does not exist on the server.",array($filename)));
return;
//not defined, lets grab the default text
}
send_footer();
}
function generatePassword($pwlen=8)
{
//these are good characters that are not easily confused with other characters :)

View File

@ -1 +1 @@
110
111

14
db/db.update.111.php Normal file
View File

@ -0,0 +1,14 @@
<?
function db_update_111_post()
{
global $config;
//grab the index page
$q=mysql_query("SELECT * FROM pagetext WHERE textname='index' AND year='{$config['FAIRYEAR']}'");
while($r=mysql_fetch_object($q)) {
//insert it into the CMS under index.html
mysql_query("INSERT INTO cms (filename,dt,lang,text,showlogo) VALUES ('index.html','$r->lastupdate','$r->lang','".mysql_escape_string($r->text)."','1')");
}
//and remove it from the pagetext
mysql_query("DELETE FROM pagetext WHERE textname='index' AND year='{$config['FAIRYEAR']}'");
}
?>

10
db/db.update.111.sql Normal file
View File

@ -0,0 +1,10 @@
CREATE TABLE `cms` (
`id` INT NOT NULL AUTO_INCREMENT ,
`filename` VARCHAR( 128 ) NOT NULL ,
`dt` DATETIME NOT NULL ,
`lang` VARCHAR( 2 ) NOT NULL ,
`title` VARCHAR( 128 ) NOT NULL ,
`text` TEXT NOT NULL ,
`showlogo` BOOL DEFAULT '0' NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;

View File

@ -23,10 +23,5 @@
?>
<?
include "common.inc.php";
send_header();
if(file_exists("data/logo-200.gif"))
echo "<img align=\"right\" src=\"data/logo-200.gif\" border=\"0\">";
output_page_text("index");
send_footer();
output_page_cms("index.html");
?>