Skip to content

Commit 25e1c4b

Browse files
committed
[en] Makes compatible csstidy and php without ctype enabled (thanks to Andreas) [0h40]
[fr] Rend compatible la librairie csstidy pour les installations de php n'ayant pas le module ctype (merci à Andreas) [0h40] git-svn-id: https://phpfreechat.svn.sourceforge.net/svnroot/phpfreechat/trunk@977 2772adf2-ac07-0410-9d30-e29d8120292e
1 parent 477fe58 commit 25e1c4b

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

lib/ctype/ctype.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
if (!function_exists('ctype_alpha')) {
4+
function ctype_alpha($string)
5+
{
6+
return preg_match('/^[a-z]+$/i', $string);
7+
}
8+
}
9+
10+
if (!function_exists('ctype_xdigit')) {
11+
function ctype_xdigit($string)
12+
{
13+
return preg_match('/^[0-9a-f]+$/i', $string);
14+
}
15+
}
16+
17+
if (!function_exists('ctype_space')) {
18+
function ctype_space($string)
19+
{
20+
return preg_match('/^[\s]$/', $string);
21+
}
22+
}
23+
24+
?>

src/phpfreechat.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ function loadStyles($theme = 'default', &$xml_reponse)
381381
$js = '';//file_get_contents(dirname(__FILE__).'/client/createstylerule.js');
382382
$js .= 'var c = $H();';
383383
$path = $c->getFilePathFromTheme('style.css.php');
384+
require_once dirname(__FILE__).'/../lib/ctype/ctype.php'; // to keep compatibility for php without ctype support
384385
require_once dirname(__FILE__).'/../lib/csstidy-1.2/class.csstidy.php';
385386
$css = new csstidy();
386387
$css->set_cfg('preserve_css',false);

testcase/ctype.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
//
4+
// TO RUN THIS TESTCASE : PREFIX THE FUNCTIONS NAMES BY my_ IN lib/ctype/ctype.php
5+
//
6+
7+
require_once dirname(__FILE__).'/../lib/ctype/ctype.php';
8+
9+
// examples for verifying
10+
$test[] = "";
11+
$test[] = "\t";
12+
$test[] = "\r";
13+
$test[] = "\n";
14+
$test[] = " ";
15+
$test[] = "\n-";
16+
$test[] = " x";
17+
$test[] = "12 3";
18+
$test[] = ". abc";
19+
$test[] = "abc";
20+
$test[] = "AzEdFDe";
21+
$test[] = "ABC9";
22+
$test[] = "aBcF4";
23+
$test[] = "0123456789ABCDEFabcdef";
24+
$test[] = "034DEFa5612789ABCbcdef";
25+
$test[] = "012djgfbbku3456789ABCDEFabcdef";
26+
27+
28+
echo "ctype_space()"."<br />";
29+
foreach ($test as $a)
30+
{
31+
echo $a . " : " . ((my_ctype_space($a)) ? "true" : "false") ." : " . ((ctype_space($a)) ? "true" : "false") ."<br />";
32+
}
33+
34+
35+
echo "ctype_xdigit()"."<br />";
36+
foreach ($test as $a)
37+
{
38+
echo $a . " : " . ((my_ctype_xdigit($a)) ? "true" : "false"). " : " . ((ctype_xdigit($a)) ? "true" : "false") ."<br />";
39+
}
40+
41+
echo "ctype_alpha()"."<br />";
42+
foreach ($test as $a)
43+
{
44+
echo $a . " : " . ((my_ctype_alpha($a)) ? "true" : "false") ." : " . ((ctype_alpha($a)) ? "true" : "false") ."<br />";
45+
}
46+
47+
?>

0 commit comments

Comments
 (0)