.01
.02
.03
.04
.05
.06
.07
.08
.09
.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
|
|
<?php
/******************************************************************************/
/* */
/* __ ____ */
/* ___ / / ___ / __/__ __ _____________ ___ */
/* / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-< */
/* / .__/_//_/ .__/___/\___/\_,_/_/ \__/\__/___/ */
/* /_/ /_/ */
/* */
/* */
/******************************************************************************/
/* */
/* Titre : Colorer n'importe quel langage avec geshi à la... */
/* */
/* URL : http://www.phpsources.org/scripts418-PHP.htm */
/* Auteur : zaknaou */
/* Date édition : 21 Juin 2008 */
/* Website auteur : www.france-webmaster.fr */
/* */
/******************************************************************************/
include_once('geshi/geshi.php');
$source = $_POST['source'];
$offset = 0;
$exploded = array();
$continue = TRUE;
while ($continue)
{
$Nb = preg_match('@[code=([^]]*)]@', $source, $result, PREG_OFFSET_CAPTURE, $offset);
$continue = ($Nb == 1);
if ($continue)
{
$langage = $result[1][0];
$avancee = $result[0][1] - $offset;
if ($avancee > 0)
{
$exploded[] = array('text', substr($source, $offset, $avancee));
}
$offset = $result[1][1] + strlen($result[1][0]) + 1;
$Nb = preg_match('@[/code]@', $source, $result, PREG_OFFSET_CAPTURE, $offset);
//-->> CONTENU DES BALISES //-->> COLORATION DU code VIA GESHI
if ($Nb == 1)
{
$exploded[] = array($langage, substr($source, $offset, $result[0][1] - $offset));
$offset = $result[0][1] + strlen('[/code]');
}
}
else
{
$reste = strlen($source) - $offset;
if ($reste > 0)
{
$exploded[] = array('text', substr($source, $offset, $reste));
}
}
}
foreach($exploded as $data)
{
//-->> MET EN MINUSCULE LE TYPE DE BALISE (HTML, PHP, CSS -->> html, php, css)
$data[0] = strtolower($data[0]);
//-->> CONDITION DU LANGAGE
if($data[0] == "actionscript") {$type_code = "actionscript";}
elseif($data[0] == "actionscript-fr") {$type_code = "actionscript-french";}
elseif($data[0] == "ada") {$type_code = "ada";}
elseif($data[0] == "applescript") {$type_code = "applescript";}
elseif($data[0] == "asm") {$type_code = "asm";}
elseif($data[0] == "asp") {$type_code = "asp";}
elseif($data[0] == "autoit") {$type_code = "autoit";}
elseif($data[0] == "bash") {$type_code = "bash";}
elseif($data[0] == "blitzbasic") {$type_code = "blitzbasic";}
elseif($data[0] == "c") {$type_code = "c";}
elseif($data[0] == "c-mac") {$type_code = "c_mac";}
elseif($data[0] == "c#") {$type_code = "csharp";}
elseif($data[0] == "c++") {$type_code = "cpp";}
elseif($data[0] == "cad-dcl") {$type_code = "caddcl";}
elseif($data[0] == "cadlisp") {$type_code = "cadlisp";}
elseif($data[0] == "cfdg") {$type_code = "cfdg";}
elseif($data[0] == "coldfusion") {$type_code = "cfm";}
elseif($data[0] == "css") {$type_code = "css";}
elseif($data[0] == "delphi") {$type_code = "delphi";}
elseif($data[0] == "dev") {$type_code = "dev";}
elseif($data[0] == "dos") {$type_code = "dos";}
elseif($data[0] == "eiffel") {$type_code = "eiffel";}
elseif($data[0] == "fortran") {$type_code = "fortran";}
elseif($data[0] == "freebasic") {$type_code = "freebasic";}
elseif($data[0] == "gml") {$type_code = "gml";}
elseif($data[0] == "html") {$type_code = "html4strict";}
elseif($data[0] == "inno") {$type_code = "inno";}
elseif($data[0] == "java") {$type_code = "java";}
elseif($data[0] == "java-5") {$type_code = "java5";}
elseif($data[0] == "javascript") {$type_code = "javascript";}
elseif($data[0] == "lisp") {$type_code = "lisp";}
elseif($data[0] == "lua") {$type_code = "lua";}
elseif($data[0] == "microprocessor-asm") {$type_code = "mpasm";}
elseif($data[0] == "mysql") {$type_code = "mysql";}
elseif($data[0] == "nsis") {$type_code = "nsis";}
elseif($data[0] == "objective-c") {$type_code = "objc";}
elseif($data[0] == "ocaml") {$type_code = "ocaml";}
elseif($data[0] == "openoffice-basic") {$type_code = "oobas";}
elseif($data[0] == "oracle-8-sql") {$type_code = "oracle8";}
elseif($data[0] == "pascal") {$type_code = "pascal";}
elseif($data[0] == "perl") {$type_code = "perl";}
elseif($data[0] == "php") {$type_code = "php";}
elseif($data[0] == "python") {$type_code = "python";}
elseif($data[0] == "quick-basic") {$type_code = "qbasic";}
elseif($data[0] == "robots-txt") {$type_code = "robots";}
elseif($data[0] == "ruby") {$type_code = "ruby";}
elseif($data[0] == "sas") {$type_code = "sas";}
elseif($data[0] == "scheme") {$type_code = "scheme";}
elseif($data[0] == "sdlbasic") {$type_code = "sdlbasic";}
elseif($data[0] == "smarty") {$type_code = "smarty";}
elseif($data[0] == "sql") {$type_code = "sql";}
elseif($data[0] == "t-sql") {$type_code = "tsql";}
elseif($data[0] == "vbnet") {$type_code = "vbnet";}
elseif($data[0] == "vb") {$type_code = "vb";}
elseif($data[0] == "visual-fox-pro") {$type_code = "visualfoxpro";}
elseif($data[0] == "xml") {$type_code = "xml";}
elseif($data[0] == "dhtml") {$type_code = "html4strict";}
elseif($data[0] == "xhtml") {$type_code = "html4strict";}
elseif($data[0] == "autre") {$type_code = "autre";}
else {$type_code = "aucun";}
if($type_code != "autre" AND $type_code != "aucun")
{
//-->> SUPPRIME LES ESPACES DEVANT ET DERIERRE
$data[1] = trim($data[1]);
//-->> SUPPRIME LES SLASHES
$data[1] = stripslashes($data[1]);
//-->> GESHI
$geshi_1 =& new GeSHi($data[1], $type_code);
$geshi_1->set_keyword_group_style(1, 'color: #006600; background-color:#EAF4FE');
$geshi_1->set_keyword_group_style(2, 'color: #CC0000; background-color:#EAF4FE');
$geshi_1->set_keyword_group_style(3, 'color: #003399; background-color:#EAF4FE');
$geshi_1->set_keyword_group_style(4, 'color: #336699; background-color:#EAF4FE');
$geshi_1->set_comments_style('1', 'color:FF9D00; font-variant:small-caps;');
$geshi_1->set_symbols_style('font-weight:bold; size:24px;');
$geshi_1->set_strings_style('color:#CC0000;');
$geshi_1->set_numbers_style('font-size:16px;');
$geshi_1->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 1);
$geshi_1->set_line_style('color: #CC0000;');
$geshi_1->set_header_type(GESHI_HEADER_PRE);
$data[1] = $geshi_1->parse_code();
}
if($data[0] != "text" AND $data[1] != "" AND $type_code != "aucun" AND $type_code != "autre")
{
echo'
<table border="1" cellpadding="0" style="border-collapse: collapse" width="100%" bgcolor="#EAF4FF" bordercolor="#99CCFF">
<tr>
<td bordercolor="#D5EAFF" height="12">
<font face="Verdana" size="2" color="#3366CC">Langage : '.$data[0].'</font></td>
</tr>
<tr>
<td bordercolor="#D5EAFF" height="11"><p> </p><p><pre>'.$data[1].'</pre></p>
<p> </td>
</tr>
</table>
';
}
elseif($data[0] == "text" AND $data[1] != "")
{
echo''.$data[1].'';
}
else
{
}
}
?>
|