diff --git a/caca-php/examples/cacainfo.php b/caca-php/examples/cacainfo.php index f13c9fa..f983434 100755 --- a/caca-php/examples/cacainfo.php +++ b/caca-php/examples/cacainfo.php @@ -46,8 +46,9 @@ EOT; } -if (!posix_isatty(STDOUT)) +if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); +} just_for_fun(); diff --git a/caca-php/examples/demo.php b/caca-php/examples/demo.php index 4363566..f76b81a 100644 --- a/caca-php/examples/demo.php +++ b/caca-php/examples/demo.php @@ -361,8 +361,9 @@ function demo_render($cv, $bounds, $outline) { } -if (!posix_isatty(STDOUT)) +if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); +} main(); diff --git a/caca-php/examples/dithering.php b/caca-php/examples/dithering.php index ffb39a2..400b0e0 100755 --- a/caca-php/examples/dithering.php +++ b/caca-php/examples/dithering.php @@ -11,21 +11,25 @@ * http://sam.zoy.org/wtfpl/COPYING for more details. */ -if (!posix_isatty(STDOUT)) +if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); +} $img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png"); -if (!$img) +if (!$img) { die("Can not open image.\n"); +} $dither = caca_create_dither($img); -if (!$dither) +if (!$dither) { die("Can not create dither. Maybe you compiled caca-php without gd support.\n"); +} $canvas = caca_create_canvas(0, 0); $display = caca_create_display($canvas); -if (!$display) +if (!$display) { die("Can not create display.\n"); +} caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); caca_refresh_display($display); diff --git a/caca-php/examples/figfont.php b/caca-php/examples/figfont.php index 3519634..4fc5784 100755 --- a/caca-php/examples/figfont.php +++ b/caca-php/examples/figfont.php @@ -23,8 +23,9 @@ function unistr_to_ords($str, $encoding = 'UTF-8'){ return $result; } -if (!posix_isatty(STDOUT)) +if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); +} if ($argc < 3) { die("Too few arguments.\nUsage: cmd \n"); diff --git a/caca-php/examples/polyline.php b/caca-php/examples/polyline.php index 680950c..1b8f924 100755 --- a/caca-php/examples/polyline.php +++ b/caca-php/examples/polyline.php @@ -18,8 +18,9 @@ function transform($tbl, $tx, $ty, $sx, $sy) { return $result; } -if (!posix_isatty(STDOUT)) +if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); +} $canvas = caca_create_canvas(0, 0); $display = caca_create_display($canvas); diff --git a/caca-php/examples/text.php b/caca-php/examples/text.php index 8f5e8a0..87bae5d 100755 --- a/caca-php/examples/text.php +++ b/caca-php/examples/text.php @@ -15,8 +15,9 @@ * http://sam.zoy.org/wtfpl/COPYING for more details. */ -if (!posix_isatty(STDOUT)) +if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); +} $string = <<