colorizestring

Gesponsorde koppelingen

PHP script bestanden

  1. colorizestring

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
///////////////
//index.php//
///////////////
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Colorizer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
body,td,th {
    font-family: Courier New, Courier, mono;
    font-size: 12px;
    color: #000000;
}
form {
    display: inline;
}
-->
</style>
</head>
<?
include('colorizer.php');
$str = "<script language=\"c#\" type=\"text/javascript\">
 function dir(){
   var map= prompt('Please enter the name of the map', ' ');
   var page=\"<? echo $page;?>\";
   if ( (map==' ') || (map==null) ){}else{
top.location.href=\"make.php?dir=\"+map+\"&page=\"+page;
   }
 }
function Start() {
  document.getElementById('edit').contentWindow.document.designMode = \"on\";
  try {
document.getElementById('edit').contentWindow.document.execCommand(\"undo\", false, null);
  }  catch (e) {
alert(\"This demo is not supported on your level of Mozilla.\");
  }
}
function editor() {
  return document.getElementById('edit').contentWindow
}

function tobody(){
    var html = editor().document.body.ownerDocument.createRange();
    html.selectNodeContents(editor().document.body);
    editor().document.body.innerHTML = html.toString();
}
var string = 0;
function csspreg(){
     var html = editor().document.body.innerHTML;
/*
hier zit dus nog 1 fout
var reg = /(.*)[{]/g;
*/
     var reg = /(.*)[{]/g;
     var nieuwe = '<i> $1 {</i>';
     html = html.replace(reg, nieuwe);
     var reg = /}/g;
     var nieuwe = '<i>}</i>';
    //var reg = /(.*?)\{/;
    //var nieuwe = '<span class=\"head\">$1 {</span>';
    //html = html.replace(reg, nieuwe);
    //var reg = /(.*)\:/;
    //var nieuwe = '<span class=\"tag\">$1</span><span class=\"head\">:</span>';
editor().document.body.innerHTML = html;
}
</script>
tralallalallal
<style type=\"text/css\">
<!--
/*
#header {margin-bottom:3em;}
html>body #header {margin-bottom:1em}
*/
#header {margin-bottom:3em;}
html>body #header {margin-bottom:1em}

#header {padding: 2em; border: 0.5em; width: 15em; voice-family: \"lo\\\"l\\\"lol\"; voice-family:inherit; width: 10em;}

#header {
margin-bottom:3em;
background-image: url(\'phplogo.png\');
}

@import url(cssfile.css);
@import url(cssfile.css);
@import hgcfjghjfghj;

body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    color: #000000;
    font-size: 11px;
}
<!--FOUT REGELS-->
a:head {
 font:asdf;
}
<!--EINDE FOUT REGELS-->
body {
    background-color: #FFFFFF;
}
link {
    color: #000000;
    text-decoration: none;
}
visited {
    text-decoration: none;
    color: #000000;
}
hover {
    text-decoration: underline;
    color: #000000;
}
active {
    text-decoration: none;
    color: #000000;
}
.width {
    width:205px;
}
h1 {
    color:#666666;
    font-size:24px;
    font-weight:bold;
}
form {
display:inline;
}
.textarea {
    width: 100%;
    height: 100%;
}
.div {
    font-family: Arial;
    font-size: 9px;
}
.img {
background-color: #CCCCCC;
}
.name {
background-color: #F1F1EB;
padding-left: 5px;
}
-->
</style>
tralallala
<?
    echo \"owned\".\$zekers;
?>
tralalallala
<?php
    echo \"owned\".\$zekers;?>
tralalallala
<?PHP
    echo \"owned\".\$zekers;
?>
einde"
;
$colorize = colorize_string($str);
if(isset($_POST['Submit'])){
    $colorize = colorize_string($_POST['code']);
}

?>

<form name="form1" id="form1" method="post" action="">
  <textarea name="code" rows="20" style="width:100%; "><?=$str;?></textarea>
  <input type="submit" name="Submit" value="Colorize" />
  <input name="Reset" type="reset" id="Reset" value="Reset" />
</form>
<fieldset>
<legend>Code</legend>
<?=$colorize; ?>
</fieldset>
</body>
</html>

///////////////////
//colorizer.php//
///////////////////
<?php
function colorize_string($input){
////javascript////////////////////////////////////////////////////////////////////
    preg_match_all('#(<\s*script.*?>.*?<\s*/\s*script\s*>)#is', $input, $matches);
        for ($i = 1; $i <= count($matches[0]); $i++) {
            $replacer = colorize_javascript($matches[0][$i-1]);
            $input = str_replace($matches[0][$i-1], $replacer, $input);
        }

////css/////////////////////////////////////////////////////////////////////////
    preg_match_all('#(<\s*style.*?>
.*?<\s*/\s*style\s*>)#is', $input, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$replacer = colorize_css($matches[0][$i-1]);
$input = str_replace($matches[0][$i-1], $replacer, $input);
}

////php/////////////////////////////////////////////////
preg_match_all('#(<\?.*?\?>)#is', $input, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$replacer = colorize_php($matches[0][$i-1]);
$input = str_replace($matches[0][$i-1], $replacer, $input);
}

////Return///////////////////////////////////////
$input = preg_replace('#\n#','<br/>',$input);
return $input;
}


function colorize_php($input){
$temp = highlight_string(stripslashes($input), true);
$temp = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $temp);
$temp = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $temp);
$temp = str_replace('<span style="color: #007700">&lt;?', '<span style="color: #FF0000;font-weight:bold">&lt;?</span><span style="color: #007700">', $temp);
$temp = str_replace('<span style="color: #007700"></span>', '', $temp);
$temp = str_replace('&lt;?</span><span style="color: #0000BB">PHP', '<span style="color: #FF0000;font-weight:bold">&lt;?PHP</span>', $temp);
$temp = str_replace('&lt;?</span><span style="color: #0000BB">php', '<span style="color: #FF0000;font-weight:bold">&lt;?php</span>', $temp);
$temp = str_replace('<span style="color: #0000BB">?&gt;</span>', '<span style="color: #FF0000;font-weight:bold">?&gt;</span>', $temp);
return $temp;
}

function colorize_javascript($input){
include('javascript.php');
$temp = str_replace('<','&lt;',$input);
$temp = str_replace('>','&gt;',$temp);
$temp = str_replace(' ','&nbsp;',$temp);
$temp = preg_replace('#\n#','<br/>',$temp);
$temp = preg_replace('#\t#','&nbsp;&nbsp;&nbsp;',$temp);
$temp = preg_replace('#"(.*?)"#','<span style="color: #0402FC">"\\1"</span>',$temp);
$temp = preg_replace("#'(.*?)'#","<span style=\"color: #0402FC\">'\\1'</span>",$temp);
$temp = preg_replace('#&lt;script(.*?)&gt;#','<span style="color: #9C0204">&lt;script \\1\\2&gt;</span>',$temp);
$temp = preg_replace('#&lt;\/script&gt;#','<span style="color: #9C0204">&lt;/script&gt;</span>',$temp);
$temp = preg_replace($commands_purple,'<span style="color: #9C029C">$1</span>',$temp);
$temp = preg_replace($commands_green,'<span style="color: #049A9C">$1</span>',$temp);
$temp = preg_replace($commands_boldblue,'<span style="color: #04029C;font-weight:bold">$1</span>',$temp);
$temp = preg_replace($commands_small,'$1<span style="color: #0402FC">$2</span>$3',$temp);
$temp = preg_replace($commands_red,'<span style="color: #0000FF">$1</span>',$temp);
$temp = str_replace('language<span style="color: #0402FC">=</span>','language=',$temp);
$temp = str_replace('type<span style="color: #0402FC">=</span>','type=',$temp);
$temp = str_replace('--&gt;','<span style="color: #9C9A9C">--&gt;</span>',$temp);
$temp = str_replace('function','<strong>function</strong>',$temp);

preg_match_all("#\/\/(.*?)<br\/>#is", $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}
preg_match_all("#\/\*(.*?)\*<\/span>\/#is", $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}
preg_match_all("#&lt;!--(.*?)<br\/>#", $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}

preg_match_all("#'(.*?)'#", $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}

preg_match_all('#"(.*?)"#', $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}
$temp = preg_replace('#&lt;!--(.*?)(<br\/>)#','<span style="color: #9C9A9C">&lt;!--$1</span>$2',$temp);
$temp = preg_replace('#\/\*(.*?)\*\/#is','<span style="color: #9C9A9C">/*$1*/</span>',$temp);
$temp = preg_replace('#\/\/(.*?)<br\/>#','<span style="color: #9C9A9C">//$1</span><br/>',$temp);
return $temp;
}

function colorize_css($input){
//COLORS
$header = "#FF00FF";
$tags = "#000066";
$value = "#0000FF";
$important = "#FF0000";
$import = "#009999";
$quetes = "#006600";
$style_tags = "#990099";
$comments = "#9C9A9C";
//CODE
$temp = str_replace(':',': ',$input);
$temp = str_replace('<','&lt;',$temp);
$temp = str_replace('>','&gt;',$temp);
$temp = preg_replace('#\n#','<br/>',$temp);
$temp = preg_replace('#"(.*?)([^\\\])"#', '<span style="color:'.$quetes.'">"$1$2"</span>', $temp);
$temp = preg_replace("#'(.*?)([^\\\])'#", '<span style="color:'.$quetes.'">\'$1$2\'</span>', $temp);
$temp = preg_replace('#&lt;style(.*?)&gt;#', '<span style="color:'.$style_tags.'">&lt;style$1&gt;</span>', $temp);
$temp = preg_replace('#&lt;([ ]*)\/([ ]*)style([ ]*)&gt;#', '<span style="color:'.$style_tags.'">&lt;$1/$2style$3&gt;</span>', $temp);
$temp = preg_replace('#<br\/>([^<])([.|\#]*[a-zA-Z0-9 !@\#:;"\'\$%\^&\*\(\)-_=+<>\?\/\\{\}\[\]\~\`\|]{1,50}\{)#', '<br/><span style="color:'.$header.'">$1$2</span>', $temp);
$temp = preg_replace('#([a-zA-Z0-9-]{1,50}):[^\#]#', '<span style="color:'.$tags.'">$1</span>:', $temp);
$temp = preg_replace('#[^r]:(.*?)(;|<br\/>|\})#', '<span style="color:'.$header.'">:</span><span style="color:'.$value.'">$1</span><span style="color:'.$header.'">$2</span>', $temp);
$temp = preg_replace('#}#', '<span style="color:#FF00FF">}</span>', $temp);
$temp = str_replace('!important', '<span style="color:'.$important.';font-weight:bold">!important</span>', $temp);
$temp = str_replace('--&gt;','<span style="color:'.$comments.'">--&gt;</span>',$temp);

preg_match_all("#\/\*(.*?)\*\/#", $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}

preg_match_all("#&lt;!--(.*?)<br\/>#", $temp, $matches);
for ($i = 1; $i <= count($matches[0]); $i++) {
$find[] =$matches[0][$i-1];
$temp2 = preg_replace("#<span(.*?)>(.*?)#is","$2",$matches[0][$i-1]);
$temp2 = preg_replace("#<\/span:#",":",$temp2);
$back[] = preg_replace("#<\/span>#","",$temp2);
}
for ($i = 1; $i <= count($back); $i++) {
$temp = str_replace($find[$i-1],$back[$i-1],$temp);
}
$temp = preg_replace('#&lt;!--(.*?)<br\/>#','<span style="color:'.$comments.'">&lt;!--$1</span><br/>',$temp);
$temp = preg_replace("#\/\*(.*?)\*\/#",'<span style="color:'.$comments.'">/*$1*/</span>',$temp);
$temp = preg_replace('#@import(.*?);#', '<span style="color:'.$import.';font-weight:bold">@import$1;</span>', $temp);
$temp = preg_replace('#\t#','&emsp;&emsp;',$temp);
return $temp;
}
?>

////////////////////
//javascript.php//
////////////////////
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?
$commands_boldblue
= array(
    '#(\bbreak\b)#','#(\bcase\b)#','#(\bcontinue\b)#','#(\bdefault\b)#','#(\bdelete\b)#','#(\bdo\b)#','#(\belse\b)#','#(\bexport\b)#','#(\bfalse\b)#',
    '#(\bfor\b)#','#(\bif\b)#','#(\bimport\b)#','#(\bin\b)#','#(\bitem\b)#','#(\bnew\b)#','#(\bnull\b)#','#(\breturn\b)#','#(\bswitch\b)#','#(\bthis\b)#','#(\btrue\b)#',
    '#(\bvar\b)#','#(\bvoid\b)#','#(\bwhile\b)#','#(\bwith\b)#','#(\))#','#(\()#','#({)#','#(])#','#(\[)#','#(})#'
);

$commands_green = array(
    '#(\babs\b)#','#(\bacos\b)#','#(\bArray\b)#','#(\basin\b)#','#(\batan\b)#','#(\batan2\b)#','#(\bwatch\b)#','#(\bwrite\b)#','#(\bwriteln\b)#','#(\bvalueOf\b)#',
    '#(\bBoolean\b)#','#(\bceil\b)#','#(\bcharAt\b)#','#(\bcharCodeAt\b)#','#(\bconcat\b)#','#(\bcos\b)#','#(\bDate\b)#','#(\beval\b)#','#(\bfloor\b)#',
    '#(\bexp\b)#','#(\bfromCharCode\b)#','#(\bFunction\b)#','#(\bgetDate\b)#','#(\bgetDay\b)#','#(\bgetFullYear\b)#','#(\bgetHours\b)#',
    '#(\bgetMilliseconds\b)#','#(\bgetMinutes\b)#','#(\bgetMonth\b)#','#(\bgetSeconds\b)#','#(\bgetSelection\b)#',
    '#(\bgetTime\b)#','#(\bgetTimezoneOffset\b)#','#(\bgetUTCDate\b)#','#(\bgetUTCDay\b)#','#(\bgetUTCFullYear\b)#',
    '#(\bgetUTCHours\b)#','#(\bgetUTCMilliseconds\b)#','#(\bgetUTCMinutes\b)#','#(\bgetUTCMonth\b)#','#(\bshift\b)#',
    '#(\bgetUTCSeconds\b)#','#(\bgetYear\b)#','#(\bImage\b)#','#(\bindexOf\b)#','#(\bisNaN\b)#','#(\bjoin\b)#','#(\blastIndexOf\b)#',
    '#(\blog\b)#','#(\bmatch\b)#','#(\bMath\b)#','#(\bmax\b)#','#(\bmin\b)#','#(\bNumber\b)#','#(\bObject\b)#','#(\bparse\b)#','#(\bparseFloat\b)#',
    '#(\bparseInt\b)#','#(\bpop\b)#','#(\bpow\b)#','#(\bpreference\b)#','#(\bprint\b)#','#(\bpush\b)#','#(\brandom\b)#','#(\bRegExp\b)#','#(\breplace\b)#',
    '#(\breset\b)#','#(\bresizeBy\b)#','#(\bresizeTo\b)#','#(\breverse\b)#','#(\bround\b)#','#(\bsearch\b)#','#(\bselect\b)#','#(\bsetDate\b)#',
    '#(\bsetFullYear\b)#','#(\bsetHours\b)#','#(\bsetMilliseconds\b)#','#(\bsetInterval\b)#','#(\bsetMinutes\b)#','#(\bsetMonth\b)#',
    '#(\bsetSeconds\b)#','#(\bsetTime\b)#','#(\bsetTimeout\b)#','#(\bsetUTCDate\b)#','#(\bsetUTCFullYear\b)#','#(\bsetUTCHours\b)#',
    '#(\bsetUTCMilliseconds\b)#','#(\bsetUTCMinutes\b)#','#(\bsetUTCMonth\b)#','#(\bsetUTCSeconds\b)#','#(\bsetYear\b)#',
    '#(\bsin\b)#','#(\bslice\b)#','#(\bsort\b)#','#(\bsplice\b)#','#(\bsplit\b)#','#(\bsqrt\b)#','#(\bString\b)#','#(\bsubstr\b)#','#(\bsubstring\b)#',
    '#(\btan\b)#','#(\btoGMTString\b)#','#(\btoLocaleString\b)#','#(\btoLowerCase\b)#','#(\btoString\b)#','#(\btoUpperCase\b)#',
    '#(\btoUTCString\b)#','#(\bunshift\b)#','#(\bunwatch\b)#','#(\bUTC\b)#'
);

$commands_red = array(
    '#(\bInfinity\b)#','#(\bNan\b)#'
);

$commands_purple = array(
    '#(\ball\b)#','#(\banchor\b)#','#(\bback\b)#','#(\bbig\b)#','#(\bblink\b)#','#(\bblur\b)#','#(\bbody\b)#','#(\bbold\b)#','#(\bbyteToString\b)#',
    '#(\bcaptureEvents\b)#','#(\bclearInterval\b)#','#(\bclearTimeout\b)#','#(\bclick\b)#','#(\bclose\b)#','#(\bconfirm\b)#',
    '#(\bdisableExternalCapture\b)#','#(\bdocument\b)#','#(\benableExternalCapture\b)#','#(\bevent\b)#','#(\bfind\b)#',
    '#(\bfixed\b)#','#(\bfocus\b)#','#(\bfontcolor\b)#','#(\bfontsize\b)#','#(\bforward\b)#','#(\bgetOptionValueCount\b)#',
    '#(\bgetOptionValue\b)#','#(\bgo\b)#','#(\bhandleEvent\b)#','#(\bhome\b)#','#(\bitalics\b)#','#(\bjavaEnabled\b)#','#(\balert\b)#',
    '#(\blink\b)#','#(\bload\b)#','#(\blog\b)#','#(\bmimeTypes\b)#','#(\bmoveAbove\b)#','#(\bmoveBelow\b)#','#(\bmoveBy\b)#','#(\bmoveTo\b)#',
    '#(\bmoveToAbsolute\b)#','#(\bnavigator\b)#','#(\bopen\b)#','#(\boptions\b)#','#(\bplugins\b)#','#(\bprompt\b)#','#(\brefresh\b)#',
    '#(\breleaseEvents\b)#','#(\breload\b)#','#(\brouteEvent\b)#','#(\bscreen\b)#','#(\bscroll\b)#','#(\bscrollBy\b)#','#(\bscrollTo\b)#',
    '#(\bsmall\b)#','#(\bstop\b)#','#(\bstrike\b)#','#(\bsub\b)#','#(\bsubmit\b)#','#(\bsup\b)#','#(\btaintEnabled\b)#','#(\bunit\b)#','#(\bwindow\b)#'
);

$commands_small = array(
    '#([a-z|A-Z|&nbsp;|>])(=+)([a-z|A-Z|&nbsp;|<])#',
    '#([a-z|A-Z|&nbsp;|>])(\++)([a-z|A-Z|&nbsp;|<]|)#',
    '#([a-z|A-Z|&nbsp;|>])(!+)([a-z|A-Z|&nbsp;|<]|)#',
    '#([a-z|A-Z|&nbsp;|>])(%+)([a-z|A-Z|&nbsp;|<]|)#',
    '#([a-z|A-Z|&nbsp;|>])(\^+)([a-z|A-Z|&nbsp;|<]|)#',
    '#([a-z|A-Z|&nbsp;|>])(\*+)([a-z|A-Z|&nbsp;|<]|)#',
    '#([a-z|A-Z|&nbsp;|>])(\|+)([a-z|A-Z|&nbsp;|<]|)#'
);
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.