forked from science-ation/science-ation
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:
parent
597a21da3a
commit
7e84ab0222
@ -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]
|
||||
|
||||
|
@ -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 :)
|
||||
|
@ -1 +1 @@
|
||||
110
|
||||
111
|
||||
|
14
db/db.update.111.php
Normal file
14
db/db.update.111.php
Normal 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
10
db/db.update.111.sql
Normal 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 ;
|
Loading…
Reference in New Issue
Block a user