Skip to content

Commit

Permalink
[en] Makes compatible csstidy and php without ctype enabled (thanks t…
Browse files Browse the repository at this point in the history
…o 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
  • Loading branch information
kerphi committed Feb 20, 2007
1 parent 477fe58 commit 25e1c4b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/ctype/ctype.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

if (!function_exists('ctype_alpha')) {
function ctype_alpha($string)
{
return preg_match('/^[a-z]+$/i', $string);
}
}

if (!function_exists('ctype_xdigit')) {
function ctype_xdigit($string)
{
return preg_match('/^[0-9a-f]+$/i', $string);
}
}

if (!function_exists('ctype_space')) {
function ctype_space($string)
{
return preg_match('/^[\s]$/', $string);
}
}

?>
1 change: 1 addition & 0 deletions src/phpfreechat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ function loadStyles($theme = 'default', &$xml_reponse)
$js = '';//file_get_contents(dirname(__FILE__).'/client/createstylerule.js');
$js .= 'var c = $H();';
$path = $c->getFilePathFromTheme('style.css.php');
require_once dirname(__FILE__).'/../lib/ctype/ctype.php'; // to keep compatibility for php without ctype support
require_once dirname(__FILE__).'/../lib/csstidy-1.2/class.csstidy.php';
$css = new csstidy();
$css->set_cfg('preserve_css',false);
Expand Down
47 changes: 47 additions & 0 deletions testcase/ctype.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

//
// TO RUN THIS TESTCASE : PREFIX THE FUNCTIONS NAMES BY my_ IN lib/ctype/ctype.php
//

require_once dirname(__FILE__).'/../lib/ctype/ctype.php';

// examples for verifying
$test[] = "";
$test[] = "\t";
$test[] = "\r";
$test[] = "\n";
$test[] = " ";
$test[] = "\n-";
$test[] = " x";
$test[] = "12 3";
$test[] = ". abc";
$test[] = "abc";
$test[] = "AzEdFDe";
$test[] = "ABC9";
$test[] = "aBcF4";
$test[] = "0123456789ABCDEFabcdef";
$test[] = "034DEFa5612789ABCbcdef";
$test[] = "012djgfbbku3456789ABCDEFabcdef";


echo "ctype_space()"."<br />";
foreach ($test as $a)
{
echo $a . " : " . ((my_ctype_space($a)) ? "true" : "false") ." : " . ((ctype_space($a)) ? "true" : "false") ."<br />";
}


echo "ctype_xdigit()"."<br />";
foreach ($test as $a)
{
echo $a . " : " . ((my_ctype_xdigit($a)) ? "true" : "false"). " : " . ((ctype_xdigit($a)) ? "true" : "false") ."<br />";
}

echo "ctype_alpha()"."<br />";
foreach ($test as $a)
{
echo $a . " : " . ((my_ctype_alpha($a)) ? "true" : "false") ." : " . ((ctype_alpha($a)) ? "true" : "false") ."<br />";
}

?>

0 comments on commit 25e1c4b

Please sign in to comment.