/*
--------------------------------------
questbook.forall by Peter Vámoš
©2003 www.forall.sk
--------------------------------------
web : http://www.forall.sk/questbook
mail : questbook@forall.sk
--------------------------------------
*/
?>
Questbook
include 'config.php';
?>
include 'objekt/objekt.php';
#uvrava $obsah
function pridaj_tag(&$retazec, $htmltag, $delete = false) {
$i = $size = 0;
$htmltag = strtolower($htmltag);
$nahrada = strtolower($retazec);
while (is_integer($startpos1 = strpos($nahrada, "[$htmltag", $i)) && $startpos1 >= 0) {
$i = $startpos1 + 1;
if (is_integer($startpos2 = strpos($nahrada, "]", $startpos1)) && $startpos2 >= 0) {
if (is_integer($endpos = strpos($nahrada, "[/$htmltag]", $startpos2)) && $endpos >= 0 && $endpos > $startpos2) {
$length = strlen($htmltag) + 1;
if (!$delete) {
switch (strtolower($htmltag)) {
case "link":
$url = trim(substr($retazec, $startpos1 + $length, $startpos2 - $startpos1 - $length));
$retazec = substr_replace($retazec, "", $startpos1, $startpos2 - $startpos1 + 1);
$endpos += 37 - ($startpos2 - $startpos1 - strlen($url) - 3);
$retazec = substr_replace($retazec, "", $endpos, $length + 2);
break;
case "mail":
$mail = trim(substr($retazec, $startpos1 + $length, $startpos2 - $startpos1 - $length));
$retazec = substr_replace($retazec, "", $startpos1, $startpos2 - $startpos1 + 1);
$endpos += 44 - ($startpos2 - $startpos1 - strlen($mail) - 3);
$retazec = substr_replace($retazec, "", $endpos, $length + 2);
break;
}
} else {
$retazec = substr_replace($retazec, "", $startpos1, $startpos2 - $startpos1 + 1);
$endpos -= ($startpos2 - $startpos1 + 1);
$retazec = substr_replace($retazec, "", $endpos, $length + 2);
}
}
}
$nahrada = strtolower($retazec);
}
}
if (isset($mail)){
$mail = str_replace ("\n","
",$mail);
$mail = strip_tags ($mail, "
");
}
if (isset($meno)){
$meno = str_replace ("\n","
",$meno);
$meno = strip_tags ($meno, "
");
}
if (isset($web)){
$web = str_replace ("\n","
",$web);
$web = strip_tags ($web, "
");
}
if (isset($obsah)){
$obsah = str_replace ("\n","
",$obsah);
$obsah = strip_tags ($obsah, "
");
for ($i = 1; $i < 61; ++$i) {
$obsah = str_replace ("$tag[$i]","$nahrada[$i]" ,$obsah);
}
}
pridaj_tag($obsah, "mail");
pridaj_tag($obsah, "link");
#kontrola $meno ci nie je admin
@$pomoc_meno = @$meno;
$admin_meno = strtoupper ($admin_meno);
@$meno = trim (@$meno);
@$meno = strtoupper ($meno);
if ($admin_meno <> $meno) {
@$meno = @$pomoc_meno;
}
#ak sa nezeda $web
if (@$web == "http://") {
$web = "";
}
#vytvorenie noveho riadku
$novy_riadok =
"" .
"" .
"" .
"Príspevok od : " . (@$meno) .
" | " .
"
" .
"" .
"" .
"E-mail : " . (@$mail) . "" .
" | " .
"
" .
"" .
"" .
"Web : " . (@$web) . "" .
" | " .
"
" .
"" .
"" .
"Dátum : " . date("d.m.Y H:i") .
" | " .
"
" .
"" .
""
. (@$obsah) .
" | " .
"
" .
"
" .
"
"
;
#zapis do suboru plus generovanie chyb
if (@$mozes == "1") {
$stare_riadky = join ('', file ('obsah.txt'));
$chyba[0] = 0;
if (ereg("^.+@.+\\..+$", @$mail)) {
$kontrol_mail = 1;
}
if ((@$obsah == "") or (@$meno == "")) {
if (@$obsah == ""){
$chyba[0] = 1;
$chyba[1] = "- zadajte prosím obsah príspevku";
}
if (@$meno == "") {
$chyba[0] = 1;
$chyba[2] = "- zadajte prosím Vaše meno";
}
} else {
if (@$mail != "") {
if (@$kontrol_mail == 1) {
if (@$meno == $admin_meno) {
$chyba[0] = 1;
$chyba[4] = "- nemáte povolenie používať toto meno";
} else {
$subor = fopen ('obsah.txt', 'w');
fputs ($subor, $novy_riadok . chr(13) . chr(10) . $stare_riadky);
fclose ($subor);
}
} else {
$chyba[0] = 1;
$chyba[3] = "- zadajte prosím korektný mail";
}
} else {
if (@$meno == $admin_meno) {
$chyba[0] = 1;
$chyba[4] = "- nemáte povolenie používať toto meno";
} else {
$subor = fopen ('obsah.txt', 'w');
fputs ($subor, $novy_riadok . chr(13) . chr(10) . $stare_riadky);
fclose ($subor);
}
}
}
}
#vypis chyb
if (@$chyba[0]) {
echo ("");
if (isset($chyba[1])){
echo ("$chyba[1] ");
}
if (isset($chyba[2])){
echo ("$chyba[2] ");
}
if (isset($chyba[3])){
echo ("$chyba[3] ");
}
if (isset($chyba[4])){
echo ("$chyba[4] ");
}
echo (" |
");
echo ("- späť");
echo (" |
");
}
#vypis pomoci
if (@$pomoc == 1){
echo ("");
echo ("Pomoc: ");
echo ("[link http://www.nieco.sk]odkaz[/link] ");
echo (" - zobrazí ako odkaz ");
echo ("[mail nieco@nieco.sk]pošta[/mail] ");
echo (" - zobrazí ako pošta ");
echo ("[img]http://nieco.sk/obrazok.jpg[/img] ");
echo (" |
");
}
#konecny vypis zo suboru
$subor = fopen ('obsah.txt', 'r');
$obsah = file ("obsah.txt");
$riadky = count($obsah);
fclose ($subor);
if (!isset($riadky)){
$riadky = 0;
}
if ($riadky > $pz){
if (!isset($riadok)){
$riadok = 0;
}
for ($i = $riadok; $i < ($riadok + $pz); ++$i){
if (isset($obsah[$i])){
echo ("$obsah[$i]");
}
}
echo ("");
} else {
for ($i = 0; $i < $riadky; ++$i){
echo ("$obsah[$i]");
}
}
echo (" |
");
echo ("Počet príspevkov: $riadky | ");
$od = $riadky - @$riadok - $pz + 1;
$po = $riadky - @$riadok ;
echo ("");
if ($po < $pz){
echo ("Zobrazené: 1 - $po");
} else {
echo ("Zobrazené: $od - $po");
}
echo (" |
");
if ($riadky > $pz) {
$zbytok = $riadky % $pz;
$r = $riadky - $zbytok;
if ($r <> $pz) {
if ($riadky % $pz == 0) {
$r = $r - $pz;
}
}
echo ("");
}
?>
[login]