コード例 #1
0
ファイル: Myna.php プロジェクト: myna/myna-php
 public static function var_dump_to_string($var, &$output, $prefix = "")
 {
     if (is_string($var)) {
         $output .= $prefix . $var;
     } elseif (is_numeric($var)) {
         $output .= $prefix . strval($var);
     } elseif (is_bool($var)) {
         $output .= $prefix . ($var ? "true" : "false");
     } elseif (is_object($var)) {
         $output .= $prefix . get_class($var);
     } elseif (is_null($var)) {
         $output .= $prefix . "NULL";
     } else {
         foreach ($var as $key => $value) {
             if (is_array($value)) {
                 $output .= $prefix . $key . ": \n";
                 var_dump_to_string($value, $output, "  " . $prefix);
             } else {
                 $output .= $prefix . $key . ": " . $value . "\n";
             }
         }
     }
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: shayanyi/CRM
 /**
  * Error printing.
  *
  * This is the action to handle external exceptions.
  */
 public function actionError()
 {
     function var_dump_to_string($var)
     {
         $output = "<pre>";
         _var_dump_to_string($var, $output);
         $output .= "</pre>";
         return $output;
     }
     function _var_dump_to_string($var, &$output, $prefix = "")
     {
         foreach ($var as $key => $value) {
             if (is_array($value)) {
                 $output .= $prefix . $key . ": \n";
                 _var_dump_to_string($value, $output, "  " . $prefix);
             } else {
                 $output .= $prefix . $key . ": " . $value . "\n";
             }
         }
     }
     function is_disabled($function)
     {
         $disabled_functions = explode(',', str_replace(" ", "", ini_get('disable_functions')));
         return in_array($function, $disabled_functions);
     }
     if ($error = Yii::app()->errorHandler->error) {
         if (Yii::app()->request->isAjaxRequest) {
             echo $error['message'];
         } else {
             $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
             $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
             if ($error['code'] == '404') {
                 $request = Yii::app()->request->requestUri;
                 if (preg_match('/opportunity/', $request)) {
                     $request = preg_replace('/opportunity/', 'opportunities', $request);
                     $this->redirect($request);
                 }
                 if (empty($referer)) {
                     $this->render('errorDisplay', $error);
                     Yii::app()->end();
                 }
             }
             if (in_array($error['code'], array('403', '400', '503'))) {
                 $this->render('errorDisplay', $error);
                 Yii::app()->end();
             }
             $request = Yii::app()->request->requestUri;
             if (!is_disabled('phpinfo')) {
                 $info = $this->phpinfo_array(true);
             } else {
                 $info = '';
             }
             if (!empty(Yii::app()->settings->emailFromAddr)) {
                 $email = Yii::app()->settings->emailFromAddr;
             } else {
                 $email = "";
             }
             $get = var_dump_to_string($_GET);
             $post = var_dump_to_string($_POST);
             $phpversion = phpversion();
             $x2version = Yii::app()->params->version;
             unset($error['traces']);
             $error['trace'] = CHtml::encode($error['trace']);
             $phpInfoErrorReport = base64_encode(CJSON::encode(array_merge($error, array('request' => $request, 'phpinfo' => $info, 'referer' => $referer, 'get' => $get, 'post' => $post, 'phpversion' => $phpversion, 'x2version' => $x2version, 'adminEmail' => $email, 'user' => Yii::app()->user->getName(), 'isAdmin' => Yii::app()->params->isAdmin, 'userAgent' => $userAgent))));
             $errorReport = base64_encode(CJSON::encode(array_merge($error, array('request' => $request, 'referer' => $referer, 'get' => $get, 'post' => $post, 'phpversion' => $phpversion, 'x2version' => $x2version, 'adminEmail' => $email, 'user' => Yii::app()->user->getName(), 'isAdmin' => Yii::app()->params->isAdmin, 'userAgent' => $userAgent))));
             $this->render('error', array_merge($error, array('request' => $request, 'info' => $info, 'referer' => $referer, 'get' => $get, 'post' => $post, 'phpversion' => $phpversion, 'x2version' => $x2version, 'errorReport' => $errorReport, 'phpInfoErrorReport' => $phpInfoErrorReport)));
         }
     }
 }
コード例 #3
0
function parse_events($time, $object)
{
    //debugger("Memory Usage: parse_events: " . memory_get_usage() . "\n");
    $result = array();
    foreach ($object as $object_key => $event) {
        $event_parameters = array();
        foreach ($event as $event_key => $event_value) {
            switch ($event_key) {
                case 'e':
                    $event_name = strtolower($event_value);
                    break;
                case 'o':
                    $event_time = $time + round($event_value / 100);
                    break;
                case 'p':
                    $event_parameters = $event_value;
                    break;
            }
        }
        //Now we have the event and the event time
        $datetime = new DateTime("@{$event_time}", new DateTimeZone('EST'));
        $result[] = array('event' => $event_name, 'time' => $datetime->format("Y-m-d H:i:s"), 'parameters' => $event_parameters);
    }
    unset($datetime);
    debugger("EVENT OBJECT: " . var_dump_to_string($object));
    debugger("EVENT RESULT: " . var_dump_to_string($result));
    return $result;
}