login  Naam:   Wachtwoord: 
Registreer je!
 Forum

[php] php highlighten

Offline Yonell - 04/04/2006 15:37 (laatste wijziging 05/04/2006 16:42)
Avatar van YonellNieuw lid hey

ik heb een UBB script he

maar als ik een code invoeg word de pagina niet meer mooi

nu is het bij sitemasters zo dat er scrollbalken in komen

hoe doe je dat

mijn highlight functie is
  1. function color($code){
  2. $code = str_replace("<br>", "", $code);
  3. $code = str_replace("<br />", "", $code);
  4. $code = str_replace("&gt;", ">", $code);
  5. $code = str_replace("&lt;", "<", $code);
  6. $code = str_replace("&amp;", "&", $code);
  7. $code = str_replace("&quot;", "\"", $code);
  8. $code = str_replace('$', '\$', $code);
  9. $code = str_replace('\n', '\\\\n', $code);
  10. $code = str_replace('\r', '\\\\r', $code);
  11. $code = str_replace('\t', '\\\\t', $code);
  12. $code = trim($code);
  13. $code = stripslashes($code);
  14.  
  15. $regel = ob_get_contents();
  16. $regel = explode("<br />", $regel);
  17. $code = "";
  18. $code .= "<table border=\"0\" width=\"100\" cellspacing=\"0\" cellpadding=\"0\">";
  19. $code .= "<tr><td width=\"20\" align=\"right\"><code>";
  20. for($i = 0; $i < (count($regel)); $i++){
  21. $t = $i;
  22. $t++;
  23. $code .= $t."<br />";
  24. }
  25. $code .= "</code></td><td width=\"100\">";
  26. for($i = 0; $i < (count($regel)); $i++){
  27. $t = $i;
  28. $t++;
  29. $code .= $regel[$i]."<br />";
  30. }
  31. $code .= "</td></tr></table>";
  32. $code .= "</table>";
  33. return $code;
  34. }

het hele script:D
  1. <?
  2. // functie als er ergens op geklikt wordt, dan toevoegen
  3. function klik(){
  4. echo "<script language=\"JavaScript\">
  5. function addtext(veld,text) {
  6. text = ' '+text+' ';
  7. if (document.form.elements[veld].createTextRange) {
  8. document.form.elements[veld].focus();
  9. document.selection.createRange().duplicate().text = text;
  10. } else {
  11. document.form.elements[veld].focus();
  12. document.form.elements[veld].value += text;
  13. }
  14. }</script>
  15. ";
  16. }
  17. // functie om knopjes weer te geven
  18. function buttons(){
  19. echo "<input type=\"button\" value=\"I\" style=\"font-size: 14px; color: #FFFFFF; font-weight: bold; border: 1px solid #999999; background-color: #000000\" onClick=\"javascript:addtext('bericht','[i] [/i]')\">
  20. <input type=\"button\" value=\"U\" style=\"font-size: 14px; color: #FFFFFF; font-weight: bold; border: 1px solid #999999; background-color: #000000\" onClick=\"javascript:addtext('bericht','[u] [/u]')\">
  21. <input type=\"button\" value=\"URL\" style=\"font-size: 14px; color: #FFFFFF; font-weight: bold; border: 1px solid #999999; background-color: #000000\" onClick=\"javascript:addtext('bericht','[url=] [/url]')\">
  22. <input type=\"button\" value=\"CODE\" style=\"font-size: 14px; color: #FFFFFF; font-weight: bold; border: 1px solid #999999; background-color: #000000\" onClick=\"javascript:addtext('bericht','[code]
')\">
<input type=\"button\" value=\"Quote\" style=\"font-size: 14px; color: #FFFFFF; font-weight: bold; border: 1px solid #999999; background-color: #000000\" onClick=\"javascript:addtext('bericht','
Citaat:
')\">";
}
// functie om smilies weer te geven
function smileys(){
echo "<a href=\"javascript:addtext('bericht',':)')\"><img src=\"smileys/icon_smile.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':cry:')\"><img src=\"smileys/icon_cry.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':(')\"><img src=\"smileys/icon_frown.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',';)')\"><img src=\"smileys/icon_wink.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':D')\"><img src=\"smileys/icon_biggrin.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':S')\"><img src=\"smileys/icon_confused.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':P')\"><img src=\"smileys/icon_razz.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':B')\"><img src=\"smileys/icon_cool.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':$')\"><img src=\"smileys/icon_redface.gif\" border=\"0\"></a>
<a href=\"javascript:addtext('bericht',':O')\"><img src=\"smileys/icon_eek.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':sad:')\"><img src=\"smileys/icon_sad.gif\" border=0></a>
<a href=\"javascript:addtext('bericht','^^')\"><img src=\"smileys/icon_cheesygrin.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':!:')\"><img src=\"smileys/icon_exclaim.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':idea:')\"><img src=\"smileys/icon_idea.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':mad:')\"><img src=\"smileys/icon_mad.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':|')\"><img src=\"smileys/icon_neutral.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':?:')\"><img src=\"smileys/icon_question.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':roll:')\"><img src=\"smileys/icon_rolleyes.gif\" border=0></a>
<a href=\"javascript:addtext('bericht',':surprised:')\"><img src=\"smileys/icon_surprised.gif\" border=0></a>
";
}

function color($code){
$code = str_replace("<br>", "", $code);
$code = str_replace("<br />", "", $code);
$code = str_replace("&gt;", ">", $code);
$code = str_replace("&lt;", "<", $code);
$code = str_replace("&amp;", "&", $code);
$code = str_replace("&quot;", "\"", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = trim($code);
$code = stripslashes($code);
ob_start();

highlight_string($code);
$regel = ob_get_contents();
ob_end_clean();
$regel = explode("<br />", $regel);
$code = "";
$code .= "<table border=\"0\" width=\"100\" cellspacing=\"0\" cellpadding=\"0\">";
$code .= "<tr><td width=\"20\" align=\"right\"><code>";
for($i = 0; $i < (count($regel)); $i++){
$t = $i;
$t++;
$code .= $t."<br />";
}
$code .= "</code></td><td width=\"100\">";
for($i = 0; $i < (count($regel)); $i++){
$t = $i;
$t++;
$code .= $regel[$i]."<br />";
}
$code .= "</td></tr></table>";
$code .= "</table>";
return $code;
}
function ubb($bericht) {
$bericht = stripslashes($bericht);
$bericht = nl2br($bericht);
$bericht = eregi_replace("([a-zA-Z0-9_-]+)@([a-zA-Z0-9\._-]+)(\.[a-zA-Z]+)", "<a href=\"mailto:\\1@\\2\\3\">\\1@\\2\\3</a>", $bericht);
$bericht = str_replace("[img]","<img src=\"http://",$bericht);
$bericht = str_replace("[/img]","\">",$bericht);
$bericht = eregi_replace("\[url\]www.([^\[]*)","<a href=\"http://www.\\1\" target=_blank>\\1", $bericht);
$bericht = eregi_replace("\[url\]([^\[]*)","<a href=\"\\1\" target=_blank>\\1", $bericht);
$bericht = eregi_replace("(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"http://\\2\" target=_blank>", $bericht);
$bericht = eregi_replace("\[url](http://(.*))", "<a href=\"\\1\" target=\"_blank\">\\1", $bericht);
$bericht = eregi_replace("(\[/url\])", "</a>", $bericht);
$bericht = str_replace("http://http://", "http://", $bericht);

$bericht = str_replace("","<b>",$bericht);
$bericht = str_replace("
","</b>",$bericht);
$bericht = str_replace("","<i>",$bericht);
$bericht = str_replace("
","</i>",$bericht);
$bericht = str_replace("","<u>",$bericht);
$bericht = str_replace("
","</u>",$bericht);

//De smilies staan hierzo
$bericht = str_replace(":)","<img src=\"smileys/icon_smile.gif\">",$bericht);
$bericht = str_replace(":cry:","<img src=\"smileys/icon_cry.gif\">",$bericht);
$bericht = str_replace(":(","<img src=\"smileys/icon_frown.gif\">",$bericht);
$bericht = str_replace(";)","<img src=\"smileys/icon_wink.gif\">",$bericht);
$bericht = str_replace(":D","<img src=\"smileys/icon_biggrin.gif\">",$bericht);
$bericht = str_replace(":S","<img src=\"smileys/icon_confused.gif\">",$bericht);
$bericht = str_replace(":P","<img src=\"smileys/icon_razz.gif\">",$bericht);
$bericht = str_replace(":B","<img src=\"smileys/icon_cool.gif\">",$bericht);
$bericht = str_replace(":$","<img src=\"smileys/icon_redface.gif\">",$bericht);
$bericht = str_replace(":O","<img src=\"smileys/icon_eek.gif\">",$bericht);
$bericht = str_replace(":sad:","<img src=\"smileys/icon_sad.gif\">",$bericht);
$bericht = str_replace("^^","<img src=\"smileys/icon_cheesygrin.gif\">",$bericht);
$bericht = str_replace(":!:","<img src=\"smileys/icon_exclaim.gif\">",$bericht);
$bericht = str_replace(":idea:","<img src=\"smileys/icon_idea.gif\">",$bericht);
$bericht = str_replace(":mad:","<img src=\"smileys/icon_mad.gif\">",$bericht);
$bericht = str_replace(":|","<img src=\"smileys/icon_neutral.gif\">",$bericht);
$bericht = str_replace(":?:","<img src=\"smileys/icon_question.gif\">",$bericht);
$bericht = str_replace(":roll:","<img src=\"smileys/icon_rolleyes.gif\">",$bericht);
$bericht = str_replace(":surprised:","<img src=\"smileys/icon_surprised.gif\">",$bericht);

$bericht = preg_replace('_\[code\](.*?)\[/code\]_ise', "color(' \\1 ')", $bericht);

$bericht = str_replace("
Citaat:
","<table border="0" width="100%"><tr><td width="10">&nbsp;</td><td><font size="1">Quote:</font></td></tr><tr><td width="10">&nbsp;</td><td><hr>",$bericht);
$bericht = str_replace("
","<hr></td></tr></table>",$bericht);

$bericht = preg_replace("#\[B\](.*?)\[/B\]#si","<b>\\1</b>", $bericht);
$bericht = preg_replace("#\[I\](.*?)\[/I\]#si","<i>\\1</i>", $bericht);
$bericht = preg_replace("#\[U\](.*?)\[/U\]#si","<u>\\1</u>", $bericht);
$bericht = preg_replace("#\[CENTER\](.*?)\[/CENTER\]#si","<center>\\1</center>", $bericht);
$bericht = preg_replace("#\[L\](.*?)\[/L\]#si","<div align='left'>\\1</div>", $bericht);
$bericht = preg_replace("#\[R\](.*?)\[/R\]#si","<div align='right'>\\1</div>", $bericht);
$bericht = preg_replace("#\[UIT\](.*?)\[/UIT\]#si","<div align='justify'>\\1</div>", $bericht);

$bericht = preg_replace("#\[H1\](.*?)\[/H1\]#si","<h1>\\1</h1>", $bericht);
$bericht = preg_replace("#\[H2\](.*?)\[/H2\]#si","<h2>\\1</h2>", $bericht);
$bericht = preg_replace("#\[H3\](.*?)\[/H3\]#si","<h3>\\1</h3>", $bericht);
$bericht = preg_replace("#\[H3\](.*?)\[/H3\]#si","<h3>\\1</h3>", $bericht);

$bericht = preg_replace("#\[type=Arial\](.*?)\[/type\]#si","<span class='Arial'>\\1</span>", $bericht);
$bericht = preg_replace("#\[type=TRoman\](.*?)\[/type\]#si","<span class='TRoman'>\\1</span>", $bericht);
$bericht = preg_replace("#\[type=TMS\](.*?)\[/type\]#si","<span class='TMS'>\\1</span>", $bericht);
$bericht = preg_replace("#\[type=Verdana\](.*?)\[/type\]#si","<span class='Verdana'>\\1</span>", $bericht);

$bericht = preg_replace("#\[size=10\](.*?)\[/size\]#si","<div class='TT10'>\\1</div>", $bericht);
$bericht = preg_replace("#\[size=11\](.*?)\[/size\]#si","<div class='TT11'>\\1</div>", $bericht);
$bericht = preg_replace("#\[size=12\](.*?)\[/size\]#si","<div class='TT12'>\\1</div>", $bericht);
$bericht = preg_replace("#\[size=16\](.*?)\[/size\]#si","<div class='TT16'>\\1</div>", $bericht);
$bericht = preg_replace("#\[size=20\](.*?)\[/size\]#si","<div class='TT20'>\\1</div>", $bericht);

$bericht = preg_replace("#\[URL\](.*?)\[/URL\]#si","<a href='\"\\1\"'>\"\\1\"</a>", $bericht);
$bericht = preg_replace("#\[IMG\](.*?)\[/IMG\]#si","<img src=\"\\1\">", $bericht);

return $bericht;
}
?>[/code] 

2 antwoorden

Gesponsorde links
Offline rutgerp - 04/04/2006 15:41 (laatste wijziging 04/04/2006 15:55)
Avatar van rutgerp HTML interesse
  1. <div style="height: 5px; width: 100px;margin: 0;padding: 0;padding-left: 1px;border: 0;float: left;overflow: auto;">Hier je code :P</div>

zoiets...denk ik


EDIT: Ik weet het niet zeker hoor maar dit kan het worden:
  1. $code .= "</code></td><td width=\"100\">
  2. <div style=\"height: 5px; width: 100px;margin: 0;padding: 0;padding-left: 1px;border: 0;float: left;overflow: auto;\">";
  3. for($i = 0; $i < (count($regel)); $i++){
  4. $t = $i;
  5. $t++;
  6. $code .= $regel[$i]."<br />";
  7. }
  8. $code .= "</div>
  9. </td></tr></table>";
  10. $code .= "</table>";

EDIT2: Je moet zelf de hoogte en breedte aanpassen in het script...
Offline Yonell - 04/04/2006 15:51
Avatar van Yonell Nieuw lid en hoe zet ik zoiets in het script???


^^
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.274s