Skip to content

Commit

Permalink
several bug-fixes;
Browse files Browse the repository at this point in the history
added feeds
added feed-icons
out-sourced login-data from config.inc.php to login.inc.php
added $pref table-prefix-variable to login.inc.php
added support for $global_config_arr[pref] as table-prefix
=> look into feeds/rss091.php etc. for usage

git-svn-id: http://svn.xp-dev.com/svn/Sweil_fs2/src@52 b49b0359-402e-0410-ad19-9fd90e479030
  • Loading branch information
Sweil authored and Sweil committed Aug 30, 2007
1 parent 14181b1 commit 0832843
Show file tree
Hide file tree
Showing 14 changed files with 761 additions and 302 deletions.
595 changes: 305 additions & 290 deletions frogsystem.sql

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inc/adminfunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function create_templatepage($template_arr, $go)
// Design ermittlen
$return_template .= '
<div align="left">
<form action="'.$PHP_SELF.'" method="post">
<form action="" method="post">
<input type="hidden" value="'.$go.'" name="go">
<input type="hidden" value="'.session_id().'" name="PHPSESSID">
<select name="design" onChange="this.form.submit();">
Expand Down Expand Up @@ -251,7 +251,7 @@ function create_templatepage($template_arr, $go)

$return_template .= '
<input type="hidden" value="" name="editwhat">
<form action="'.$_SERVER[PHP_SELF].'" method="post">
<form action="" method="post">
<input type="hidden" value="'.$go.'" name="go">
<input type="hidden" value="'.$_POST[design].'" name="design">
<input type="hidden" value="'.session_id().'" name="PHPSESSID">
Expand Down Expand Up @@ -918,4 +918,4 @@ function fillsession($uid)
}
}

?>
?>
17 changes: 8 additions & 9 deletions inc/config.inc.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?php

///////////////////////
//// DB Login Data ////
///////////////////////

$host = "localhost"; //Hostname
$user = "frogsystem"; //Database User
$data = "frogsystem"; //Database Name
$pass = "frogsystem"; //Password
include("login.inc.php");

////////////////////////
////// DB Connect //////
Expand All @@ -18,16 +11,22 @@
{
mysql_select_db($data,$db);

unset($host);
unset($user);
unset($pass);

////////////////////////
//// Seitenvariablen ///
////////////////////////


// Allgemeine Config + Infos
$index = mysql_query("SELECT * FROM fs_global_config", $db);
$index = mysql_query("SELECT * FROM ".$pref."global_config", $db);
$global_config_arr = mysql_fetch_assoc($index);

//write $pref into $global_config_arr[pref]
$global_config_arr[pref] = $pref;

if (isset ($_GET['design_id']) AND $global_config_arr[allow_other_designs] == 1)
{
$index2 = mysql_query("SELECT * FROM fs_template WHERE id = $_GET[design_id]", $db);
Expand Down
38 changes: 38 additions & 0 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,33 @@ function point_number ($zahl)
return $zahl;
}

/////////////////////////////////////////
// String kürzen ohne Wort zuzerstören //
/////////////////////////////////////////
function truncate_string ($string, $maxlength, $extension) {

// Set the replacement for the "string break" in the wordwrap function
$cutmarker = "**F3rVRB,YQFrK6qpE**cut_here**cc3Z,7L,jVy9bDWY**";

// Checking if the given string is longer than $maxlength
if (strlen($string)+strlen($$extension) > $maxlength) {

// Using wordwrap() to set the cutmarker
// NOTE: wordwrap (PHP 4 >= 4.0.2, PHP 5)
$string = wordwrap($string, $maxlength, $cutmarker);

// Exploding the string at the cutmarker, set by wordwrap()
$string = explode($cutmarker, $string);

// Adding $extension to the first value of the array $string, returned by explode()
$string = $string[0] . $extension;
}

// returning $string
return $string;

}

////////////////////////////////
///// Download Categories //////
////////////////////////////////
Expand Down Expand Up @@ -651,6 +678,17 @@ function fscode($text, $all=true, $html=false, $para=false, $do_b=0, $do_i=0, $d
return $parsedtext;
}

//////////////////////////
// kill FS Code in text //
//////////////////////////

function killfs($text)
{
$text = fscode($text);
$text = strip_tags($text);
return $text;
}

///////////////////////////////////////////////////////////////
// Check if the visitor has already voted in the given poll //
///////////////////////////////////////////////////////////////
Expand Down
12 changes: 12 additions & 0 deletions inc/login.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

///////////////////////
//// DB Login Data ////
///////////////////////
$host = "localhost"; //Hostname
$user = "frogsystem"; //Database User
$data = "frogsystem"; //Database Name
$pass = "frogsystem"; //Password
$pref = "fs_"; //Password

?>
93 changes: 93 additions & 0 deletions www/feeds/atom10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

header("Content-type: application/atom+xml");

include("login.inc.php");

@$db = mysql_connect($host, $user, $pass);
if ($db)
{
include("functions.php");
mysql_select_db($data,$db);

// Allgemeine Config + Infos
$index = mysql_query("SELECT * FROM ".$pref."global_config", $db);
$global_config_arr = mysql_fetch_assoc($index);
if ($global_config_arr[virtualhost] == "") {
$global_config_arr[virtualhost] = "http://notfound.com/";
}

// News Config + Infos
$index = mysql_query("SELECT * FROM ".$pref."news_config", $db);
$news_config_arr = mysql_fetch_assoc($index);

$index = mysql_query("SELECT news_date
FROM ".$pref."news
ORDER BY news_date DESC
LIMIT 1");

$last_date[news_date] = mysql_result($index,0,"news_date");
$last_date[old_time_zone] = date("O",$last_date[news_date]);
$last_date[time_zone] = substr($last_date[old_time_zone],0,strlen($last_date[old_time_zone]-2))
.":".substr($last_date[old_time_zone],-2,2);
$last_date[news_updated] = date("Y-m-d\TH:i:s",$last_date[news_date]);
$last_date[news_updated] .= $last_date[time_zone];

//Feed Header ausgeben
echo'<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>'.$global_config_arr[virtualhost].'</id>
<title>'.htmlspecialchars($global_config_arr[title]).'</title>
<updated>'.$last_date[news_updated].'</updated>
<link rel="self" href="atom10.php" />
';

$index = mysql_query("SELECT news_id, news_text, news_title, news_date, user_id
FROM ".$pref."news
ORDER BY news_date DESC
LIMIT $news_config_arr[num_news]");

while ($news_arr = mysql_fetch_assoc($index))
{
$index2 = mysql_query("SELECT user_name FROM ".$pref."user WHERE user_id = $news_arr[user_id]");
$news_arr[user_name] = mysql_result($index2,0,"user_name");

$news_arr[old_time_zone] = date("O",$news_arr[news_date]);
$news_arr[time_zone] = substr($news_arr[old_time_zone],0,2).":".substr($news_arr[old_time_zone],2,2);
$news_arr[time_zone] = substr($news_arr[old_time_zone],0,strlen($news_arr[old_time_zone]-2))
.":".substr($news_arr[old_time_zone],-2,2);
$news_arr[news_updated] = date("Y-m-d\TH:i:s",$news_arr[news_date]);
$news_arr[news_updated] .= $news_arr[time_zone];

// Item ausgeben
echo'
<entry>
<id>'.$global_config_arr[virtualhost].'?go=comments&amp;id='.$news_arr[news_id].'</id>
<title>'.utf8_encode(htmlspecialchars($news_arr[news_title])).'</title>
<updated>'.$news_arr[news_updated].'</updated>
<author>
<name>'.$news_arr[user_name].'</name>
</author>
<content>'.utf8_encode(killfs($news_arr[news_text])).'</content>
<link rel="alternate" href="'.$global_config_arr[virtualhost].'#'.$news_arr[news_id].'" />
</entry>
';
}

echo'
</feed>
';
}
else
{
//"Keine Verbindung"-Feed
echo'<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>http://notfound.com/</id>
<title>Fehler</title>
<updated>'.date("r").'</updated>
</feed>
';
}

?>
75 changes: 75 additions & 0 deletions www/feeds/rss091.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

header("Content-type: application/rss+xml");

include("login.inc.php");

@$db = mysql_connect($host, $user, $pass);
if ($db)
{
include("functions.php");
mysql_select_db($data,$db);

// Allgemeine Config + Infos
$index = mysql_query("SELECT * FROM ".$pref."global_config", $db);
$global_config_arr = mysql_fetch_assoc($index);
if ($global_config_arr[virtualhost] == "") {
$global_config_arr[virtualhost] = "http://notfound.com";
}

// News Config + Infos
$index = mysql_query("SELECT * FROM ".$pref."news_config", $db);
$news_config_arr = mysql_fetch_assoc($index);

//Feed Header ausgeben
echo'<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<language>de</language>
<description>'.htmlspecialchars($global_config_arr[description]).'</description>
<link>'.$global_config_arr[virtualhost].'</link>
<title>'.htmlspecialchars($global_config_arr[title]).'</title>
';

$index = mysql_query("SELECT news_id, news_text, news_title, news_date
FROM ".$pref."news
ORDER BY news_date DESC
LIMIT $news_config_arr[num_news]");
while ($news_arr = mysql_fetch_assoc($index))
{


// Item ausgeben
echo'
<item>
<title>'.utf8_encode(htmlspecialchars($news_arr[news_title])).'</title>
<link>'.$global_config_arr[virtualhost].'#'.$news_arr[news_id].'</link>
<pubDate>'.date("r",$news_arr[news_date]).'</pubDate>
<description>'.truncate_string(utf8_encode(killfs($news_arr[news_text])),500," ...").'</description>
</item>
';
}

echo'
</channel>
</rss>
';
}
else
{
//"Keine Verbindung"-Feed
echo'<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<language>de</language>
<description>Fehler: Keine Verbindung zur Datenbank</description>
<link>http://notfound.com</link>
<title>Fehler</title>
</channel>
</rss>
';
}

?>
94 changes: 94 additions & 0 deletions www/feeds/rss10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

header("Content-type: application/rss+xml");

include("login.inc.php");

@$db = mysql_connect($host, $user, $pass);
if ($db)
{
include("functions.php");
mysql_select_db($data,$db);

// Allgemeine Config + Infos
$index = mysql_query("SELECT * FROM ".$pref."global_config", $db);
$global_config_arr = mysql_fetch_assoc($index);
if ($global_config_arr[virtualhost] == "") {
$global_config_arr[virtualhost] = "http://notfound.com/";
}

// News Config + Infos
$index = mysql_query("SELECT * FROM ".$pref."news_config", $db);
$news_config_arr = mysql_fetch_assoc($index);

//Feed Header ausgeben
echo'<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
>
<channel rdf:about="'.$global_config_arr[virtualhost].'feeds/rss10.php">
<title>'.htmlspecialchars($global_config_arr[title]).'</title>
<link>'.$global_config_arr[virtualhost].'</link>
<description>'.htmlspecialchars($global_config_arr[description]).'</description>
<items>
<rdf:Seq>
';

$index = mysql_query("SELECT news_id, news_text, news_title, news_date
FROM ".$pref."news
ORDER BY news_date DESC
LIMIT $news_config_arr[num_news]");

while ($news_arr = mysql_fetch_assoc($index))
{
// <items> ausgeben
echo'
<rdf:li resource="'.$global_config_arr[virtualhost].'?go=comments&amp;id='.$news_arr[news_id].'" />
';
}

echo'
</rdf:Seq>
</items>
</channel>
';




while ($news_arr = mysql_fetch_assoc($index))
{
// Item ausgeben
echo'
<item rdf:about="'.$global_config_arr[virtualhost].'?go=comments&amp;id='.$news_arr[news_id].'">
<title>'.utf8_encode(htmlspecialchars($news_arr[news_title])).'</title>
<link>'.$global_config_arr[virtualhost].'#'.$news_arr[news_id].'</link>
<description>'.truncate_string(utf8_encode(killfs($news_arr[news_text])),500," ...").'</description>
</item>
';
}

echo'
</rdf:RDF>
';
}
else
{
//"Keine Verbindung"-Feed
echo'<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
>
<channel>
<language>de</language>
<description>Fehler: Keine Verbindung zur Datenbank</description>
<link>http://notfound.com/</link>
<title>Fehler</title>
</channel>
</rdf:RDF>
';
}

?>
Loading

0 comments on commit 0832843

Please sign in to comment.