示例#1
0
 /**
  * @param  string
  * @return PObject  uninitialized object
  */
 protected static function referenceObj($class)
 {
     if (!isset(self::$refObjs[$class])) {
         self::$refObjs[$class] = PHP::classcast(new stdClass(), $class);
     }
     return self::$refObjs[$class];
 }
 static function log($data)
 {
     $GLOBALS['%s']->push("PHP::log");
     $__hx__spos = $GLOBALS['%s']->length;
     PHP::logFirePHP($data);
     $GLOBALS['%s']->pop();
 }
示例#3
0
 public function exec($functionName, $params, $silent, $indent = 0)
 {
     $params = preg_split('/ *, */', $params);
     foreach ($params as $key => $param) {
         if ($param[0] == ':') {
             $params[$key] = '"' . substr($param, 1) . '"';
         }
     }
     $result = $functionName . '(' . implode(', ', $params) . ');';
     return self::_indent($indent) . PHP::createEmbededPHP($result, $silent);
 }
示例#4
0
 public function send()
 {
     //For Developpement
     //return false;
     try {
         if (!$this->mail->Send()) {
             echo "Mailer Error: " . $this->mail->ErrorInfo;
         } else {
             echo "Message sent!";
         }
     } catch (Exception $e) {
         print_r($e);
     }
 }
示例#5
0
function generate_class_tests($file, $dest_path, $class)
{
    global $verbose;
    include_once $file;
    $x = new ReflectionClass("{$class}");
    if ($x->isAbstract() || $x->isInternal() || $x->isInterface()) {
        if ($verbose) {
            echo "Class {$class} is internal, abstract, or an interface ... skipping.\n";
        }
        return;
    }
    $class_test_file = true;
    $old_dest_file = path($dest_path, "class.{$class}.phpt");
    $dest_file = path($dest_path, "{$class}.phpt");
    if (file_exists($old_dest_file) && !file_exists($dest_file)) {
        echo "svn mv {$old_dest_file} {$dest_file}\n";
        return;
    }
    if (file_exists($dest_file)) {
        if (zesk::getb('force-create') || zesk::getb('force-create-classes')) {
            if ($verbose) {
                echo "Overwriting destination file {$dest_file} due to force flags...\n";
            }
        } else {
            if ($verbose) {
                echo "Skipping because destination file {$dest_file} exists ...\n";
            }
            // Set flag so file is not generated, but static function tests are
            $class_test_file = false;
        }
    }
    $contents = test_file_header($file, $dest_file, false);
    $functions = extract_class_functions($x, $class);
    $exclude_functions = array();
    $has_non_static_methods = false;
    foreach ($functions as $method => $params) {
        if (in_array($method, $exclude_functions)) {
            continue;
        }
        $param_list = array();
        foreach ($params as $k => $v) {
            $param_list[] = '$' . $k;
            $contents[] = '$' . $k . ' = ' . PHP::dump($v) . ";";
        }
        if (begins($method, "new ")) {
            $prefix = '$testx = ';
            $has_non_static_methods = true;
        } else {
            if (begins($method, "::")) {
                $method_name = str_replace('::', '', $method);
                $method_object = $x->getMethod($method_name);
                $methodParams = $method_object->getParameters();
                generate_static_class_method_test($file, $dest_path, $class, $method_name, $methodParams);
                continue;
            } else {
                if (begins($method, "->")) {
                    $prefix = '$testx';
                    $has_non_static_methods = true;
                } else {
                    continue;
                }
            }
        }
        $contents[] = $prefix . $method . '(' . implode(", ", $param_list) . ');';
        $contents[] = "";
    }
    if (!$class_test_file) {
        return;
    }
    if (!$has_non_static_methods) {
        return;
    }
    $contents[] = "echo basename(__FILE__) . \": success\\n\";";
    if (!zesk::getb('dry-run')) {
        file_put_contents($dest_file, implode("\n", $contents));
        chmod($dest_file, 0775);
        echo "Wrote {$dest_file} ...\n";
    } else {
        echo "Would write {$dest_file} ...\n";
    }
}
示例#6
0
文件: php.php 项目: cbsistem/nexos
 private static function runAs()
 {
     /* aolserver apache apache2filter apache2handler caudium cgi cgi-fcgi cli continuity
        embed isapi milter nsapi phttpd pi3web roxen thttpd tux webjames */
     if (defined('STDIN') && stripos(php_sapi_name(), 'cgi')) {
         self::$sapi = 'cli-cgi';
     } elseif (defined('STDIN')) {
         self::$sapi = 'cli';
     } elseif (false !== stripos(php_sapi_name(), 'cgi')) {
         self::$sapi = 'http-cgi';
     } else {
         self::$sapi = 'http';
     }
     self::$run_as = 0 === strpos(self::$sapi, 'cli') && !isset($_SERVER['REQUEST_METHOD']) ? 'cli' : 'http';
     self::$safe_mode = ini_get('safe_mode');
 }
示例#7
0
<?php

/**
 * PHP Polyfill
 *
 * @author    Greg Roach <*****@*****.**>
 * @copyright (c) 2016 Greg Roach
 * @license   MIT or GPLv3+
 */
use Fisharebest\PhpPolyfill\Php;
use Fisharebest\PhpPolyfill\Php54;
if (PHP_VERSION_ID < 50400) {
    // Magic quotes were removed in PHP 5.4
    if (get_magic_quotes_gpc()) {
        Php54::removeMagicQuotes();
    }
    // The global session variable bug/feature was removed in PHP 5.4
    if (ini_get('session.bug_compat_42')) {
        ini_set('session.bug_compat_42', '0');
    }
    // Add features that were introduced in PHP 5.4
    if (!function_exists('http_response_code')) {
        function http_response_code($reponse_code = null)
        {
            return Php54::httpResponseCode($reponse_code);
        }
    }
}
if (!defined('INF')) {
    define('INF', PHP::inf());
}
示例#8
0
文件: TEXT.php 项目: kidaa30/redcat
 function textInject($text)
 {
     if (strpos($text, '<?php ') === false) {
         $this->innerHead($text);
     } else {
         $open = 0;
         $php = '';
         $xml = '';
         $tokens = token_get_all($text);
         foreach ($tokens as $token) {
             if (is_array($token)) {
                 switch ($token[0]) {
                     case T_OPEN_TAG:
                         $open = 1;
                         if ($xml) {
                             $textNode = new TEXT();
                             $textNode->setParent($this);
                             $textNode->setBuilder($this);
                             $textNode->parse($xml);
                             $this->childNodes[] = $textNode;
                         }
                         $xml = '';
                         $php = '<?php ';
                         break;
                     case T_OPEN_TAG_WITH_ECHO:
                         $open = 2;
                         if ($xml) {
                             $textNode = new TEXT();
                             $textNode->setParent($this);
                             $textNode->setBuilder($this);
                             $textNode->parse($xml);
                             $this->childNodes[] = $textNode;
                         }
                         $xml = '';
                         $php = '<?php echo ';
                         break;
                     case T_CLOSE_TAG:
                         $open = 0;
                         $phpNode = new PHP();
                         $phpNode->setParent($this);
                         $phpNode->setBuilder($this->constructor);
                         $phpNode->parse($php . ($open === 2 && substr(trim($php), -1) != ';' ? ';' : '') . '?>');
                         $this->childNodes[] = $phpNode;
                         $php = '';
                         break;
                     default:
                         if ($open) {
                             $php .= $token[1];
                         } else {
                             $xml .= $token[1];
                         }
                         break;
                 }
             } else {
                 if ($open) {
                     $php .= $token;
                 } else {
                     $xml .= $token;
                 }
             }
         }
         if ($php) {
             $phpNode = new PHP();
             $phpNode->setParent($this);
             $phpNode->setBuilder($this->constructor);
             $phpNode->parse($php . ($open === 2 ? ';' && substr(trim($php), -1) != ';' : '') . '?>');
             $this->childNodes[] = $phpNode;
         }
         if ($xml) {
             $textNode = new TEXT();
             $textNode->setParent($this);
             $textNode->setBuilder($this);
             $textNode->parse($xml);
             $this->childNodes[] = $textNode;
         }
     }
 }
示例#9
0
文件: php_error.php 项目: rsms/phpab
}
$fileLine = "on line {$line} in ";
if (isset($_SERVER['DOCUMENT_ROOT'])) {
    $fileLine .= File::relativePath($file, $_SERVER['DOCUMENT_ROOT']);
} elseif (isset($GLOBALS['argv'][0])) {
    $fileLine .= File::relativePath($file, dirname($GLOBALS['argv'][0]));
} else {
    $fileLine .= $file;
}
switch ($errno) {
    case E_PARSE:
    case E_USER_ERROR:
    case E_ERROR:
        break;
    case E_NOTICE:
    case E_USER_NOTICE:
        if (PHP::isCLI()) {
            IO::writeError("{$GLOBALS['argv'][0]}: WARNING: {$str} {$fileLine}\n");
        } else {
            error_log("WARNING: {$str} {$fileLine}");
        }
        return;
}
if (PHP::isCLI()) {
    IO::writeError("{$GLOBALS['argv'][0]}: FATAL: {$str} {$fileLine}\n\t" . str_replace("\n", "\n\t", ABException::formatTrace(new Exception(), false, array('__errhandler'))) . "\n");
} else {
    $s = ABException::formatTrace(new Exception(), true, array('__errhandler'));
    error_log("FATAL: {$str} ({$fileLine}) {$s}");
    print "<div class=\"err\"><b>FATAL:</b> {$str} <span class=\"file\">{$fileLine}</span>\n" . '<div class="trace">' . $s . '</div>' . '</div>';
}
exit(1);
示例#10
0
文件: UnitTest.php 项目: rsms/phpab
 /** @return void */
 private function importFilesInDir($path, $recursive, $filenameFilterRE = null, $checkClasses = false)
 {
     foreach (scandir($path) as $file) {
         if ($file[0] == '.') {
             continue;
         }
         $filepath = $path . '/' . $file;
         if (strrchr($file, '.') == '.php') {
             if ($filenameFilterRE && !preg_match($filenameFilterRE, $file)) {
                 continue;
             }
             if ($checkClasses) {
                 $guessedClass = substr($file, 0, -4);
                 if (class_exists($guessedClass)) {
                     continue;
                 }
             }
             require_once $filepath;
         } elseif ($recursive && is_dir($filepath) && is_readable($filepath)) {
             PHP::addClasspath($filepath);
             $this->importFilesInDir($filepath, $recursive, $filenameFilterRE, $checkClasses);
         }
     }
 }
示例#11
0
文件: Utils.php 项目: rsms/phpab
 /**
  * @param  mixed
  * @param  string Any string value accepted by PHP settype()
  * @return bool   Success
  * @deprecated	Use {@link PHP::typecast()} instead
  */
 public static function typecast($v, $type)
 {
     PHP::typecast($v, $type);
 }