summaryrefslogtreecommitdiffstats
path: root/phpa.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-12-21 20:57:09 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-12-21 20:57:09 +0100
commit6605810da359b36f22ae3ee3f0a4ffa9eb1aa33d (patch)
tree5173b535c2853de329d2a67cd2f47038e3460e0c /phpa.php
parente9815a7602bc4ad1a3b3624b5d695de459132269 (diff)
downloadbin-6605810da359b36f22ae3ee3f0a4ffa9eb1aa33d.tar.gz
bin-6605810da359b36f22ae3ee3f0a4ffa9eb1aa33d.tar.xz
misc changes
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'phpa.php')
-rwxr-xr-xphpa.php152
1 files changed, 0 insertions, 152 deletions
diff --git a/phpa.php b/phpa.php
deleted file mode 100755
index 48a1df9..0000000
--- a/phpa.php
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/usr/bin/php -qCn
-<?
-/*
- $Id: phpa.php 2008/04/28 $
-
- David Phillips <david@acz.org>
-*/
-
- __phpa__setup();
- __phpa__print_info();
-
- for (;;)
- {
- readline_completion_function("__phpa__rl_complete");
- $__phpa__line = readline(">>> ");
- if ($__phpa__line === false)
- {
- echo "\n";
- break;
- }
- if (strlen($__phpa__line) == 0)
- continue;
- if ((!isset($__phpa__hist)) || (($__phpa__line != $__phpa__hist)))
- {
- readline_add_history($__phpa__line);
- $__phpa__hist = $__phpa__line;
- }
-
- if (__phpa__is_immediate($__phpa__line))
- $__phpa__line = "return ($__phpa__line)";
-
- ob_start();
- $ret = eval("unset(\$__phpa__line); $__phpa__line;");
- if (ob_get_length() == 0)
- {
- if (is_bool($ret))
- echo ($ret ? "true" : "false");
- else if (is_string($ret))
- echo "'" . addcslashes($ret, "\0..\37\177..\377") . "'";
- else if (!is_null($ret))
- print_r($ret);
- }
- unset($ret);
- $out = ob_get_contents();
- ob_end_clean();
- if ((strlen($out) > 0) && (substr($out, -1) != "\n"))
- $out .= "\n";
- echo $out;
- unset($out);
- }
-
- function __phpa__rl_complete($line, $pos, $cursor)
- {
- $const = array_keys(get_defined_constants());
- $var = array_keys($GLOBALS);
-
- $func = get_defined_functions();
- $s = "__phpa__";
- foreach ($func["user"] as $i)
- if (substr($i, 0, strlen($s)) != $s)
- $func["internal"][] = $i;
- $func = $func["internal"];
-
- return array_merge($const, $var, $func);
- }
-
- function __phpa__is_immediate($line)
- {
- $skip = array("class", "declare", "die", "echo", "exit", "for",
- "foreach", "function", "global", "if", "include",
- "include_once", "print", "require", "require_once",
- "return", "static", "switch", "unset", "while");
- $okeq = array("===", "!==", "==", "!=", "<=", ">=");
- $code = "";
- $sq = false;
- $dq = false;
- for ($i = 0; $i < strlen($line); $i++)
- {
- $c = $line{$i};
- if ($c == "'")
- $sq = !$sq;
- else if ($c == '"')
- $dq = !$dq;
- else if (($sq) || ($dq))
- {
- if ($c == "\\")
- $i++;
- }
- else
- $code .= $c;
- }
- $code = str_replace($okeq, "", $code);
- if (strcspn($code, ";{=") != strlen($code))
- return false;
- $kw = split("[^A-Za-z0-9_]", $code);
- foreach ($kw as $i)
- if (in_array($i, $skip))
- return false;
- return true;
- }
-
- function __phpa__print_info()
- {
- $ver = phpversion();
- $sapi = php_sapi_name();
- $date = __phpa__build_date();
- $os = PHP_OS;
- echo "PHP $ver ($sapi) ($date) [$os]\n";
- }
-
- function __phpa__build_date()
- {
- ob_start();
- phpinfo(INFO_GENERAL);
- $x = ob_get_contents();
- ob_end_clean();
- $x = strip_tags($x);
- $x = explode("\n", $x);
- $s = array("Build Date => ", "Build Date ");
- foreach ($x as $i)
- foreach ($s as $j)
- if (substr($i, 0, strlen($j)) == $j)
- return trim(substr($i, strlen($j)));
- return "???";
- }
-
- function __phpa__setup()
- {
- if (version_compare(phpversion(), "4.3.0", "<"))
- {
- echo "PHP 4.3.0 or above is required.\n";
- exit(111);
- }
- if (!extension_loaded("readline"))
- {
- $prefix = (PHP_SHLIB_SUFFIX == "dll") ? "php_" : "";
- if (!@dl($prefix . "readline." . PHP_SHLIB_SUFFIX))
- {
- echo "The 'readline' module is required.\n";
- exit(111);
- }
- }
- error_reporting(E_ALL | E_STRICT);
- ini_set("error_log", NULL);
- ini_set("log_errors", 1);
- ini_set("html_errors", 0);
- ini_set("display_errors", 0);
- while (ob_get_level())
- ob_end_clean();
- ob_implicit_flush(true);
- }
-?>