oSc|Clan test Newsskript:
include("news_data/settings.php");
// Funktion um den Smiliy - Code umzuwandeln
function smilies($txt)
{
$smily_file = file("news_data/smilies.dat");
for ($i = 0; $i < sizeof($smily_file); $i++)
{
$akt_smily = explode("þ",$smily_file[$i]);
$txt = str_replace($akt_smily[0], "
", $txt);
}
return $txt;
}
function upb_code($txt)
{
$txt = preg_replace("#\[color=(\#[0-9a-f]{6}|[a-z]+)\](.*?)\[/color\]#si",'\2',$txt);
$txt = preg_replace("#\[b\](.*?)\[/b\]#si",'\1',$txt);
$txt = preg_replace("#\[u\](.*?)\[/u\]#si",'\1',$txt);
$txt = preg_replace("#\[i\](.*?)\[/i\]#si",'\1',$txt);
$txt = preg_replace("#\[s\](.*?)\[/s\]#si",'\1',$txt);
$txt = preg_replace("#\[center\](.*?)\[/center\]#si",'\1',$txt);
$txt = preg_replace("#\[marquee\](.*?)\[/marquee\]#si",'',$txt);
$txt = preg_replace('=\[img\](http:[^\[]*|[^\[:]*)\[/img\]=si','
',$txt);
$txt = preg_replace("#\[url\]([a-z]+?://)([^\[]*)\[/url\]#si",'\1\2',$txt);
$txt = preg_replace("#\[url\]([^\[]*)\[/url\]#si",'\1',$txt);
$txt = preg_replace("#\[url=([a-z]+?://)([^\]]*)\](.*?)\[/url\]#si",'\3',$txt);
$txt = preg_replace("#\[url=([^\]]*)\](.*?)\[/url\]#si",'\2',$txt);
$txt = preg_replace("#\[email\]([^\[]+@[^\[]+)\[/email\]#si",'\1',$txt);
return $txt;
}
function code($txt)
{
$txt = str_replace("þ","",$txt);
$txt = str_replace("\n","",$txt);
$txt = str_replace("<br />","
",$txt);
return $txt;
}
function demutate_breaks($txt)
{
$txt = str_replace("
","",$txt);
return $txt;
}
function my_implode($data)
{
$array = "";
foreach($data as $line){
if($line != ""){
$array .= trim($line)."\n";
}
}
return $array;
}
function my_fwrite($data, $to_write)
{
$file = fopen($data, "w");
fwrite($file, my_implode($to_write));
fclose($file);
}
$news_file = file("news_data/news.dat");
$news_file_size = sizeof($news_file);
if($HTTP_GET_VARS['action'] == ""){
$number_of_pages = ceil($news_file_size / $news_per_page);
if(!$z) $z = 1;
$y = $z * $news_per_page;
$x = $y - $news_per_page;
if($y > $news_file_size) $y = $news_file_size;
if ($number_of_pages == 1 || $number_of_pages == 0){ $show_pages = "";}
else {
for ($i = 0; $i < $number_of_pages; $i++) {
$i2 = $i + 1;
if ($i2 == $z){ $pages[$i] = $i2;}
else{ $pages[$i] = "$i2";}
}
$show_pages = "[ Seiten ".join(" ",$pages)." ]";
}
for ($i = $x; $i < $y; $i++)
{
$akt_news = explode("þ",$news_file[$i]);
if($allow_smilies == "yes") $akt_news[5] = smilies($akt_news[5]);
if($allow_upbcode == "yes") $akt_news[5] = upb_code($akt_news[5]);
if(file_exists("news_data/comments/$akt_news[0].dat")){
$number_of_comments = file("news_data/comments/$akt_news[0].dat");
$number_of_comments = sizeof($number_of_comments);
}
else{$number_of_comments = "0";}
if($number_of_comments == "0") $commenttext = "Keine Kommentare";
if($number_of_comments == "1") $commenttext = "1 Kommentar";
if($number_of_comments > "1") $commenttext = $number_of_comments." Kommentare";
include("news_data/template_news.dat");
}
echo $show_pages;
}
if($HTTP_GET_VARS['action'] == "show"){
$id = $HTTP_GET_VARS['id'];
$data_name = "news_data/comments/".$id.".dat";
$line = $HTTP_GET_VARS['line'];
$check_data_existence = file_exists($data_name);
echo "";
if(!isset($save)) $save ="";
if($save == "")
{
$akt_news = explode("þ", $news_file[$line]);
if($HTTP_GET_VARS['act'] != "comments") $akt_news[5] = $akt_news[6];
if($allow_smilies == "yes") $akt_news[5] = smilies($akt_news[5]);
if($allow_upbcode == "yes") $akt_news[5] = upb_code($akt_news[5]);
if(file_exists("$data_name")){
$number_of_comments = file($data_name);
$number_of_comments = sizeof($number_of_comments);
}
else{$number_of_comments = "0";}
if($number_of_comments == "0") $commenttext = "Keine Kommentare";
if($number_of_comments == "1") $commenttext = "1 Kommentar";
if($number_of_comments > "1") $commenttext = $number_of_comments." Kommentare";
include("news_data/template_news.dat");
if($HTTP_GET_VARS['act'] == "comments"){
if($check_data_existence == true){
$comments_file = file($data_name);
$comments_file_size = sizeof($comments_file);
$number_of_pages = ceil($comments_file_size / $comments_per_page);
if(!$z) $z = 1;
$y = $z * $comments_per_page;
$x = $y - $comments_per_page;
if($y > $comments_file_size) $y = $comments_file_size;
if ($number_of_pages == 1 || $number_of_pages == 0){ $show_pages = "";}
else {
for ($i = 0; $i < $number_of_pages; $i++) {
$i2 = $i + 1;
if ($i2 == $z){ $pages[$i] = $i2;}
else{ $pages[$i] = "$i2";}
}
$show_pages = "[ Seiten ".join(" ",$pages)." ]
";
}
if($comments_file_size == "0"){ echo "Es sind noch keine Kommentare vorhanden.
Schreibe den ersten!
";}
else{
for ($i = $x; $i < $y; $i++)
{
$akt_comments = explode("þ",$comments_file[$i]);
if($akt_comments[1] != ""){
if(strstr($akt_comments[1],"@")){
$akt_comments[0] = "".$akt_comments[0]."";
}
else{
if(strstr($akt_comments[1],"http://")){
$akt_comments[0] = "".$akt_comments[0]."";}
else{
$akt_comments[0] = "".$akt_comments[0]."";
}
}
}
if($allow_smilies == "yes") $akt_comments[3] = smilies($akt_comments[3]);
if($allow_upbcode == "yes") $akt_comments[3] = upb_code($akt_comments[3]);
include("news_data/template_comments.dat");
}
echo $show_pages;
}
}
else{ echo "Es sind noch keine Kommentare vorhanden.
Schreibe den ersten!
";}
?>
}}
else{
if(($name == "") or ($text == "") or ($titel == "")){ echo "Sie müssen mindestens ihren Nickname, einen Titel und ihren Kommentar eingeben!
« zurück";}
else{
// Erstellungsdatum- und Zeit ermitteln
$date = gmdate("j.m.y");
$time = date("G:i");
$name = code(htmlspecialchars(stripslashes($name)));
$email = code(htmlspecialchars($email));
$titel = code(htmlspecialchars(stripslashes($titel)));
$text = code(htmlspecialchars(stripslashes(nl2br($text))));
if($check_data_existence == false){$file = fopen($data_name, "w");}
$write_file = file($data_name);
$write_file[0] = $name."þ".$email."þ".$titel."þ".$text."þ".$date."þ".$time."\n".$write_file[0];
my_fwrite($data_name, $write_file);
echo "Vielen Dank für deinen Kommentar!
« zurück
";
}
}
?>
« zurück zur Newsübersicht
}
if($HTTP_GET_VARS['action'] == "admin"){
?>
News hinzufügen
News bearbeiten/löschen
if($HTTP_GET_VARS['act'] == "add_news"){
echo "";
if(!isset($save)) $save = "";
if($save == "")
{
$date_value = gmdate("j.m.y");
$time_value = date("G:i");
?>
}
else{
if(($add) && ((($name == $username_01) && ($password == $userpassword_01)) or (($name == $username_02) && ($password == $userpassword_02)))){
if(($text == "") or ($titel == "")){ echo "Sie müssen mindestens einen Titel sowie eine News Kurzversion eingeben!
« zurück";}
else{
// Erstellungsdatum- und Zeit ermitteln
$id = $name.time();
$titel = code(htmlspecialchars(stripslashes($titel)));
if($allow_html == "yes"){
$text = code(stripslashes(nl2br($text)));
$full_story = code(stripslashes(nl2br($full_story)));
}else{
$text = code(htmlspecialchars(stripslashes(nl2br($text))));
$full_story = code(htmlspecialchars(stripslashes(nl2br($full_story))));
}
if($name == $username_01){
$email = $usermail_01;
$ava = $userpic_01;
}
if($name == $username_02){
$email = $usermail_02;
$ava = $userpic_02;
}
$news_file[0] = $id."þ".$name."þ".$email."þ".$ava."þ".$titel."þ".$text."þ".$full_story."þ".$date."þ".$time."\n".$news_file[0];
my_fwrite("news_data/news.dat", $news_file);
echo "Die News wurden erfolgreich hinzugefügt!
« zurück
Zu den News";
}
}
else{ echo "Falscher Benutzername bzw. falsches Passwort!
« zurück";}
}
}
if($HTTP_GET_VARS['act'] == "admin_news_overview"){
$number_of_pages = ceil($news_file_size / $news_per_page);
if(!$z) $z = 1;
$y = $z * $news_per_page;
$x = $y - $news_per_page;
if($y > $news_file_size) $y = $news_file_size;
if ($number_of_pages == 1 || $number_of_pages == 0){ $show_pages = "";}
else {
for ($i = 0; $i < $number_of_pages; $i++) {
$i2 = $i + 1;
if ($i2 == $z){ $pages[$i] = $i2;}
else{ $pages[$i] = "$i2";}
}
$show_pages = "[ Seiten ".join(" ",$pages)." ]";
}
for ($i = $x; $i < $y; $i++)
{
$akt_news = explode("þ",$news_file[$i]);
if($allow_smilies == "yes") $akt_news[5] = smilies($akt_news[5]);
if($allow_upbcode == "yes") $akt_news[5] = upb_code($akt_news[5]);
if(file_exists("news_data/comments/$akt_news[0].dat")){
$number_of_comments = file("news_data/comments/$akt_news[0].dat");
$number_of_comments = sizeof($number_of_comments);
}
else{$number_of_comments = "0";}
if($number_of_comments == "0") $commenttext = "Keine Kommentare";
if($number_of_comments == "1") $commenttext = "1 Kommentar";
if($number_of_comments > "1") $commenttext = $number_of_comments." Kommentare";
include("news_data/template_news.dat");
echo "editieren/löschen";
}
echo $show_pages;
}
if($HTTP_GET_VARS['act'] == "edit_news"){
$line = $HTTP_GET_VARS['line'];
$akt_news = explode("þ", $news_file[$line]);
echo "";
if(!isset($save)) $save = "";
if($save == "")
{
?>
}
else{
if(($text == "") or ($titel == "")){ echo "Sie müssen mindestens einen Titel sowie eine News Kurzversion eingeben!
« zurück";}
else{
$titel = code(htmlspecialchars(stripslashes($titel)));
if($allow_html == "yes"){
$text = code(stripslashes(nl2br($text)));
$full_story = code(stripslashes(nl2br($full_story)));
}else{
$text = code(htmlspecialchars(stripslashes(nl2br($text))));
$full_story = code(htmlspecialchars(stripslashes(nl2br($full_story))));
}
// Nun werden die News zusammengestellt
$news_file[$line] = $akt_news[0]."þ".$akt_news[1]."þ".$akt_news[2]."þ".$akt_news[3]."þ".$titel."þ".$text."þ".$full_story."þ".$akt_news[7]."þ".$akt_news[8];
if($delete == true)
{
$news_file[$line] = "";
$data_name = "news_data/comments/".$akt_news[0].".dat";
if(file_exists($data_name)) @unlink($data_name);
}
my_fwrite("news_data/news.dat", $news_file);
echo "Die News wurden erfolgreich bearbeitet!
« zurück
Zu den News";
}
}
}
}
?>