//(Listing 3. Biblioteka funkcji - fnews.inc)
==============================================
function newsHeader(){
global $PHP_SELF, $HTTP_ENV_VARS, $newsy, $cfg;
?>
Administracja
}
function LiczMaxL(){
global $id, $newsy;
$content = file($newsy["newsFile"]);
$size = count($content);
$maxID = 0;
for($line=1; $line<=$size; $line++){
$tmpLINE = explode("|",$content[$line-1]);
$tmpID = $tmpLINE[0];
if($tmpID > $maxID) $maxID = $tmpID;
}
return $maxID;
}
/* wykaz wpisów */
function ListNewsAdm(){
global $PHP_SELF, $PHP_AUTH_USER, $newsy, $pos;
$count = 5;
$content = file($newsy["newsFile"]);
$size = count($content);
echo " ";
for($i=0; $i
$tmp = $size-$pos-1;
for($i=$tmp; $i>($tmp-$count); $i--){
if(($content[$i] != '') && ($myLINES[$i][0] != "#")){
$viewADR = basename($PHP_SELF)."?cmd=view&id=".$myLINES[$i][0];
$nameADR = stripslashes($myLINES[$i][2]);
$editADR = basename($PHP_SELF)."?cmd=edit&id=".$myLINES[$i][0];
$delADR = basename($PHP_SELF)."?cmd=del&id=".$myLINES[$i][0];
echo "";
echo ""
.$myLINES[$i][1]." "; ?>
echo $nameADR; ?>
Edytuj |
Kasuj
}
}
?>
for($i=0; $i<$size; $i++){
if(!($i % $count)) $pages++;
}
?>
for($i=0; $i<$pages; $i++){
if($pos == $i*$count){
echo "".($i+1)." ";
} else {
?>" style="font-size: 8pt"> echo $i+1; ?>
}
} ?>
Dostępnych jest
echo $size; ?> pozycji.
if ($pos > 0){
?> <<
}
if($size > $pos+$count){
?> >>
}
?>
}
/* przeglądanie wiadomości */
function viewNews(){
global $id, $newsy;
$content = file($newsy["newsFile"]);
for($i=0; $i".$id." ";
?>
echo stripslashes($myLINES[$i][1])." - "
.stripslashes($myLINES[$i][5]); ?>
echo stripslashes($myLINES[$i][2]); ?>
echo stripslashes($myLINES[$i][3]); ?>
echo stripslashes($myLINES[$i][4]); ?>
">Edytuj | Powrót
}
}
/* uruchom formularz do edycji wybranego wpisu */
function editNews(){
global $PHP_SELF, $newsy, $id;
if($id != ""){
$content = file($newsy["newsFile"]);
for($i=0; $i", "\n", $myLINES[$i][3]);
$tmp2 = str_replace(" ", "\n", $myLINES[$i][4]);
$tmp1 = stripslashes($tmp1);
$tmp2 = stripslashes($tmp2);
?>
}
}
/* wyslij formularz ze zmodyfikowanymi danymi */
function modifyNews(){
global $id, $newsDate, $intro, $tytul, $text, $autor, $newsy;
$content = file($newsy["newsFile"]);
if($newsDate == ""){
$newsDate = date("d.m.Y");
}
$intro = str_replace("|", "/", $intro);
$text = str_replace("|", "/", $text);
$tytul = str_replace("|", "/", $tytul);
$autor = str_replace("|", "/", $autor);
$tmp = $id."|".$newsDate."|".$tytul."|".$intro."|".$text."|".$autor;
$tmp = str_replace("\n", " ", $tmp);
$tmp = str_replace("\r", "", $tmp);
$content = file($newsy["newsFile"]);
$size = count($content);
$fp = @fopen($newsy["newsFile"].".tmp", "w+");
for($line=0; $line
}
/* dodawanie nowej pozycji */
function addNews(){
global $newsDate, $tytul, $intro, $text, $autor, $publish, $newsy;
if($newsDate == "") $newsDate = date("d.m.Y");
$content = file($newsy["newsFile"] );
$size = count($content);
$id = LiczMaxL()+1; // nowy numer
$intro = str_replace("|", "/", $intro);
$text = str_replace("|", "/", $text);
$tytul = str_replace("|", "/", $tytul);
$autor = str_replace("|", "/", $autor);
$tmp = $id."|".$newsDate."|".$tytul."|".$intro."|".$text."|".$autor;
$tmp = addslashes($tmp);
$tmp = str_replace("\n", " ", $tmp);
$tmp = str_replace("\r", "", $tmp);
$fp=@fopen($newsy["newsFile"], "a");
if($fp <= 0){
echo "Błąd otwarcia zbioru";
}
fputs($fp, $tmp."\n");
fclose($fp);
}
/* kasowanie */
function delNews(){
global $newsy, $id;
$content = file($newsy["newsFile"] );
$size = count($content);
$fp = @fopen($newsy["newsFile"].".tmp", "w+");
for($i=0; $i
}
?>