FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

UBB script werkt niet

 


stienoo
Ik heb een ubb script maar het werkt niet, het is als volg:

Code:

<?php

    /* UBB SCRIPT © TOPPE! */
    /*   VERSION V1 BETA   */
   
    function strip($input){
        $return = stripslashes(htmlspecialchars($input));
    return $return;
    }
   
    function lengte($input, $lengte){
        if(strlen($input) > $lengte){
            $input = substr($input,0,17)."...";
        } else {
            $input = $input;
        }
    return $input;
    }
   
   
    function opmaak($input){
        $input = preg_replace('![b](.*?)[/b]!', "<b>\\1</b>", $input);
        $input = preg_replace('![u](.*?)[/u]!', "<u>\\1</u>", $input);
        $input = preg_replace('![i](.*?)[/i]!', "<i>\\1</i>", $input);
        $input = preg_replace('![s](.*?)[/s]!', "<s>\\1</s>", $input);
       
        $input = str_replace("[quote]", "<blockquote class=\"quote\">", $input);
        $input = str_replace("[/quote]", "</blockquote>", $input);
        $input = preg_replace('![quote=((w)*?)]!', "<blockquote class=\"quote\"><i>Quote van: \\1</i><br><br>", $input);
        $input = preg_replace ("#\[code\](.*)\[/code\]#", "highlight('\\1')", $input);
        $input = preg_replace("!javascript:!i", "", $string);
        $input = preg_replace("!script!i", "", $string);
        $input = preg_replace("#[size=([-+]?[1-2]?[0-9])](.*?)[/size]#si", "<font size='\\1'>\\2</font>", $input);
        $input = preg_replace("#[color=(#[0-9A-F]{6}|[a-z-]+)](.*?)[/color]#si", "<font color='\\1'>\\2</font>", $input);
        $input = eregi_replace("[url][[:space:]]*(http://)?([^[]*)[[:space:]]*[/url]", "<a href=\"http://\\2/\">\\2</a>", $input);
        $input = eregi_replace("[url=([^[]*)]([^[]*)[/url]","<a href=\"\\1\" target=_blank>\\2</a>",$input);
        $input = eregi_replace("(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank>", $input);
        $input = eregi_replace("(\[img=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank><img src=\"\\2\" border=\"0\"></a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\\2://\\3\\4 target=_blank>\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
       
        $input = str_replace("[list]", "<ul>", $input);
        $input = str_replace("[ulist]", "<ul>", $input);
        $input = str_replace("[*]", "<li>", $input);
        $input = str_replace("[li]", "<li>", $input);
        $input = str_replace("[/list]", "</ul>", $input);
        $input = str_replace("[/li]", "</ol>", $input);
        $input = str_replace("[/ulist]", "</ul>", $input);
        $input = str_replace("[/listo]", "</ol>", $input);
        $input = preg_replace("/[list=([a1])]/si", "<ol type=\"\\1\">", $input);
       
        $input = str_replace("kanker", "***", $input);
        $input = str_replace("hoer", "***", $input);
        $input = str_replace("slet", "***", $input);
        $input = str_replace("pijpen", "***", $input);
       
        $input = str_replace("1", "2", $input); //Voor smilies, Vervang 1 door je snel code en vervang 2 door het URL
   
    return strip($input);
    }
?>


Ik hoop dat jullie weten waar de fout is.
rvec
  1. laat de strip functie z'n werk doen aan het begin ipv aan het eind.
  2. in de eerste 4 regels vergeet je voor de [ en ] tekens een \ te zetten
  3. zelfde bij de quote op regel 30,url op 37, de 2e "#" bij color op 35, size op regel34 en de list op regel 53
  4. Wat is de bedoeling van dit ((w)*?) een "." ipv de "w" zou logischer zijn (quote= reg 30)
  5. $string op regel 32 en 33 moet volgens mij $input zijn


Dat was het denk ik wel.

Wat ik daarna over houd:
Code:
<?php

    /* UBB SCRIPT © TOPPE! */
    /*   VERSION V1 BETA   */
   
    function strip($input){
        $return = stripslashes(htmlspecialchars($input));
    return $return;
    }
   
    function lengte($input, $lengte){
        if(strlen($input) > $lengte){
            $input = substr($input,0,17)."...";
        } else {
            $input = $input;
        }
    return $input;
    }
   
   
    function opmaak($input){
      $input = strip($input);
        $input = preg_replace('!\[b\](.*?)\[/b\]!', "<b>\\1</b>", $input);
        $input = preg_replace('!\[u\](.*?)\[/u\]!', "<u>\\1</u>", $input);
        $input = preg_replace('!\[i\](.*?)\[/i\]!', "<i>\\1</i>", $input);
        $input = preg_replace('!\[s\](.*?)\[/s\]!', "<s>\\1</s>", $input);
     
        $input = str_replace("[quote]", "<blockquote class=\"quote\">", $input);
        $input = str_replace("[/quote]", "</blockquote>", $input);
        $input = preg_replace('!\[quote=((.)*?)\]!', "<blockquote class=\"quote\"><i>Quote van: \\1</i><br><br>", $input);
         $input = preg_replace ("#\[code\](.*)\[/code\]#", "highlight('\\1')", $input);
        $input = preg_replace("!javascript:!i", "", $input);
        $input = preg_replace("!script!i", "", $input);
         $input = preg_replace("#\[size=([-+]?[1-2]?[0-9])\](.*?)\[/size\]#si", "<font size='\\1'>\\2</font>", $input);
       $input = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z-]+)\](.*?)\[/color\]#si", "<font color='\\1'>\\2</font>", $input);
       $input = eregi_replace("[url][[:space:]]*(http://)?([^[]*)[[:space:]]*\[/url]", "<a href=\"http://\\2/\">\\2</a>", $input);
        $input = eregi_replace("\[url=([^[]*)\]([^[]*)\[/url\]","<a href=\"\\1\" target=_blank>\\2</a>",$input);
        $input = eregi_replace("(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank>", $input);
        $input = eregi_replace("(\[img=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank><img src=\"\\2\" border=\"0\"></a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\\2://\\3\\4 target=_blank>\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
     
        $input = str_replace("[list]", "<ul>", $input);
        $input = str_replace("[ulist]", "<ul>", $input);
        $input = str_replace("[*]", "<li>", $input);
        $input = str_replace("[li]", "<li>", $input);
        $input = str_replace("[/list]", "</ul>", $input);
        $input = str_replace("[/li]", "</ol>", $input);
        $input = str_replace("[/ulist]", "</ul>", $input);
        $input = str_replace("[/listo]", "</ol>", $input);
        $input = preg_replace("/\[list=([a1])\]/si", "<ol type=\"\\1\">", $input);
       
        $input = str_replace("kanker", "***", $input);
        $input = str_replace("hoer", "***", $input);
        $input = str_replace("slet", "***", $input);
        $input = str_replace("pijpen", "***", $input);
       
        $input = str_replace("1", "2", $input); //Voor smilies, Vervang 1 door je snel code en vervang 2 door het URL
   
    return $input;
    }
?>
stienoo
Ik heb dat script ijgelijk niet helemaal zelf gemaakt, maar van een site, ik zal het zo eens proberen, maar ik ben nu op school Very Happy (Ik ben in de bib).
Ik zal laten weten of het werkt of niet.
rvec
stienoo wrote:
Ik heb dat script ijgelijk niet helemaal zelf gemaakt, maar van een site, ik zal het zo eens proberen, maar ik ben nu op school Very Happy (Ik ben in de bib).
Ik zal laten weten of het werkt of niet.

Dat dacht ik al. Er waren wat fouten die alleen in het 2e gedeelte werden gemaakt en andersom. Het lijkt een beetje van meerdere plekken te komen.
stienoo
Dit script heb ik van 1 site gehaalt, maar het kan goed zijn dat die persoon het van ergens anders heeft gehaalt en dan gezegt dat hij het heeft gemaakt (stelen dus)

Ik ga het zometeen uitproberen.
stienoo
Het werkt nog steeds niet, ik post even het hele script

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<link href="http://stijnsallets.frih.net/stijl.css" rel="stylesheet" type="text/css" />
<title>gastenboek bericht verwerken</title>
</head>
<body>
<?php
mysql_connect("localhost", "****", "***");
mysql_select_db("****");
?>
<center>
<h1><b><u>bericht verwerken</u></b></h1>

<?php
if(empty($_POST['naam'] ) )
{
$error="Je moet eerst je naam invullen.<br>";
}
if(strlen($_POST['bericht']) < 5 )
{
$error.="Je moet een bericht van minimaal 6 tekens invullen.<br>";
}
if(!ereg("^http:////",$_post['website']))
 {
 $_POST['website']="http://" .$_POST['website'];
 }
if(isset($error))
{
echo $error;
}
else{
$input = $_POST['bericht'];
$website = strip_tags($_POST['website']);
$naam = strip_tags($_POST['naam']);

/*$query="INSERT INTO reacties (naam, website, bericht, datum) VALUES ('$naam', '$website', '$input', NOW())";  */
/*mysql_query($query) or die (mysql_error()); */

    /* UBB SCRIPT © TOPPE! */
    /*   VERSION V1 BETA   */
   
    function strip($input){
        $return = stripslashes(htmlspecialchars($input));
    return $return;
    }
   
    function lengte($input, $lengte){
        if(strlen($input) > $lengte){
            $input = substr($input,0,17)."...";
        } else {
            $input = $input;
        }
    return $input;
    }
   
   
    function opmaak($input){
      $input = strip($input);
        $input = preg_replace('!\[b\](.*?)\[/b\]!', "<b>\\1</b>", $input);
        $input = preg_replace('!\[u\](.*?)\[/u\]!', "<u>\\1</u>", $input);
        $input = preg_replace('!\[i\](.*?)\[/i\]!', "<i>\\1</i>", $input);
        $input = preg_replace('!\[s\](.*?)\[/s\]!', "<s>\\1</s>", $input);
     
        $input = str_replace("[quote]", "<blockquote class=\"quote\">", $input);
        $input = str_replace("[/quote]", "</blockquote>", $input);
        $input = preg_replace('!\[quote=((.)*?)\]!', "<blockquote class=\"quote\"><i>Quote van: \\1</i><br><br>", $input);
         $input = preg_replace ("#\[code\](.*)\[/code\]#", "highlight('\\1')", $input);
        $input = preg_replace("!javascript:!i", "", $input);
        $input = preg_replace("!script!i", "", $input);
         $input = preg_replace("#\[size=([-+]?[1-2]?[0-9])\](.*?)\[/size\]#si", "<font size='\\1'>\\2</font>", $input);
       $input = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z-]+)\](.*?)\[/color\]#si", "<font color='\\1'>\\2</font>", $input);
       $input = eregi_replace("[url][[:space:]]*(http://)?([^[]*)[[:space:]]*\[/url]", "<a href=\"http://\\2/\">\\2</a>", $input);
        $input = eregi_replace("\[url=([^[]*)\]([^[]*)\[/url\]","<a href=\"\\1\" target=_blank>\\2</a>",$input);
        $input = eregi_replace("(\[url=)([A-Za-z0-9_~&Speak to the hand\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank>", $input);
        $input = eregi_replace("(\[img=)([A-Za-z0-9_~&Speak to the hand\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank><img src=\"\\2\" border=\"0\"></a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\\2://\\3\\4 target=_blank>\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
     
        $input = str_replace("[list]", "<ul>", $input);
        $input = str_replace("[ulist]", "<ul>", $input);
        $input = str_replace("[*]", "<li>", $input);
        $input = str_replace("[li]", "<li>", $input);
        $input = str_replace("[/list]", "</ul>", $input);
        $input = str_replace("[/li]", "</ol>", $input);
        $input = str_replace("[/ulist]", "</ul>", $input);
        $input = str_replace("[/listo]", "</ol>", $input);
        $input = preg_replace("/\[list=([a1])\]/si", "<ol type=\"\\1\">", $input);
       
        $input = str_replace("kanker", "***", $input);
        $input = str_replace("hoer", "***", $input);
        $input = str_replace("slet", "***", $input);
        $input = str_replace("pijpen", "***", $input);
       
        $input = str_replace("1", "2", $input); //Voor smilies, Vervang 1 door je snel code en vervang 2 door het URL
   
    return $input;
    }

echo $input;
}
?>

</center>

</body>
</html>


Ik heb het ook al geprobeert met het script in een ander bestand te zetten en het dan te includen.
Ik heb om het te testen op mij site de mysql regels als komentaar gescheren zodat er niet echt altijd een nieuw bericht word verzonden.

*edit*

sory dat ik mijn vorige post niet heb geedit maar ik had perongeluk op quote geklikt.
rvec
Ik noem de php bestanden even a.php en b.php je kan de namen veranderen of alles in een bestand stoppen maar 2 bestanden is wat overzichtelijker.

a.php
Code:
/* UBB SCRIPT © TOPPE! */
    /*   VERSION V1 BETA   */
   
    function strip($input){
        $return = stripslashes(htmlspecialchars($input));
    return $return;
    }
   
    function lengte($input, $lengte){
        if(strlen($input) > $lengte){
            $input = substr($input,0,17)."...";
        } else {
            $input = $input;
        }
    return $input;
    }
   
   
    function opmaak($input){
      $input = strip($input);
        $input = preg_replace('!\[b\](.*?)\[/b\]!', "<b>\\1</b>", $input);
        $input = preg_replace('!\[u\](.*?)\[/u\]!', "<u>\\1</u>", $input);
        $input = preg_replace('!\[i\](.*?)\[/i\]!', "<i>\\1</i>", $input);
        $input = preg_replace('!\[s\](.*?)\[/s\]!', "<s>\\1</s>", $input);
     
        $input = str_replace("[quote]", "<blockquote class=\"quote\">", $input);
        $input = str_replace("[/quote]", "</blockquote>", $input);
        $input = preg_replace('!\[quote=((.)*?)\]!', "<blockquote class=\"quote\"><i>Quote van: \\1</i><br><br>", $input);
         $input = preg_replace ("#\[code\](.*)\[/code\]#", "highlight('\\1')", $input);
        $input = preg_replace("!javascript:!i", "", $input);
        $input = preg_replace("!script!i", "", $input);
         $input = preg_replace("#\[size=([-+]?[1-2]?[0-9])\](.*?)\[/size\]#si", "<font size='\\1'>\\2</font>", $input);
       $input = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z-]+)\](.*?)\[/color\]#si", "<font color='\\1'>\\2</font>", $input);
       $input = eregi_replace("[url][[:space:]]*(http://)?([^[]*)[[:space:]]*\[/url]", "<a href=\"http://\\2/\">\\2</a>", $input);
        $input = eregi_replace("\[url=([^[]*)\]([^[]*)\[/url\]","<a href=\"\\1\" target=_blank>\\2</a>",$input);
        $input = eregi_replace("(\[url=)([A-Za-z0-9_~&Speak to the hand\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank>", $input);
        $input = eregi_replace("(\[img=)([A-Za-z0-9_~&Speak to the hand\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"\\2\" target=_blank><img src=\"\\2\" border=\"0\"></a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
        $input = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)", "\\1<a href=\\2://\\3\\4 target=_blank>\\2://\\3\\4</a>\\5", $input);
        $input = eregi_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})", "<a href=\"mailto:\\1\">\\1</a>", $input);
     
        $input = str_replace("[list]", "<ul>", $input);
        $input = str_replace("[ulist]", "<ul>", $input);
        $input = str_replace("[*]", "<li>", $input);
        $input = str_replace("[li]", "<li>", $input);
        $input = str_replace("[/list]", "</ul>", $input);
        $input = str_replace("[/li]", "</ol>", $input);
        $input = str_replace("[/ulist]", "</ul>", $input);
        $input = str_replace("[/listo]", "</ol>", $input);
        $input = preg_replace("/\[list=([a1])\]/si", "<ol type=\"\\1\">", $input);
       
        $input = str_replace("kanker", "***", $input);
        $input = str_replace("hoer", "***", $input);
        $input = str_replace("slet", "***", $input);
        $input = str_replace("pijpen", "***", $input);
       
        $input = str_replace("1", "2", $input); //Voor smilies, Vervang 1 door je snel code en vervang 2 door het URL
   
    return $input;
    }


en b.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<link href="http://stijnsallets.frih.net/stijl.css" rel="stylesheet" type="text/css" />
<title>gastenboek bericht verwerken</title>
</head>
<body>
<?php
require("a.php");
mysql_connect("localhost", "****", "***");
mysql_select_db("****");
?>
<center>
<h1><b><u>bericht verwerken</u></b></h1>

<?php
if(empty($_POST['naam'] ) )
{
$error="Je moet eerst je naam invullen.<br>";
}
if(strlen($_POST['bericht']) < 5 )
{
$error.="Je moet een bericht van minimaal 6 tekens invullen.<br>";
}
if(!ereg("^http:////",$_post['website']))
 {
 $_POST['website']="http://" .$_POST['website'];
 }
if(isset($error))
{
echo $error;
}
else{
$input = opmaak($_POST['bericht']);
$website = strip_tags($_POST['website']);
$naam = strip_tags($_POST['naam']);

/*$query="INSERT INTO reacties (naam, website, bericht, datum) VALUES ('$naam', '$website', '$input', NOW())";  */
/*mysql_query($query) or die (mysql_error()); */

   

echo $input;
}
?>

</center>

</body>
</html>

ipv require kan ook include. En ipv $input kan je de variabele in b.php ook een andere naam geven, als je hem maar door de functie haalt.
stienoo
Het werkt, heel hard bedankt, ik heb wel a.php nog de php begin en eindtag moeten geven.
Ik nog wel alle codes ook in hoofdleter moeten zetten (wat ook veel gebruikt word) ook ga ik de higlight functie er uit moeten halen omdat ik in het begin een stuk code heb gewist omdat hij error gaf.

Maar wat doet require ijgenlijk?
rvec
stienoo wrote:
Het werkt, heel hard bedankt, ik heb wel a.php nog de php begin en eindtag moeten geven.
Ik nog wel alle codes ook in hoofdleter moeten zetten (wat ook veel gebruikt word) ook ga ik de higlight functie er uit moeten halen omdat ik in het begin een stuk code heb gewist omdat hij error gaf.

Maar wat doet require ijgenlijk?


oh ja die tags was ik vergeten.
Alle codes in hoofdletter?
Code:
[B] en [b]
bedoel je?

higlight functie ?

require is bijna hetzelfde als include. Het enige verschil is hoe ze met fouten omgaan maar dat is hier niet echt belangrijk. Als je meer info over php functieswilt hebben moet je ze eens proberen op te zoeken op php.net. Daar staat alle info op die je nodig hebt.
stienoo
Ja dat bedoel ik met hoofdleters

highlight =
Code:
[code] en [/code]
tags.

Ok zal ik zeker doen Smile
Reply to topic    Frihost Forum Index -> Dutch -> Computers en Techniek

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.