Ejemplo n.º 1
0
Archivo: Wddx.php Proyecto: blar/wddx
 /**
  * @param mixed $decoded
  *
  * @return string
  */
 public function encode($decoded) : string
 {
     if ($this->hasComment()) {
         return wddx_serialize_value($decoded, $this->getComment());
     }
     return wddx_serialize_value($decoded);
 }
 public static function useSlowPrinter()
 {
     if (!function_exists('wddx_serialize_value')) {
         return true;
     }
     // Some versions of PHP have a broken wddx_serialize_value, see
     // PHP bug 45314. Test encoding an affected character (U+00A0)
     // to avoid this.
     $expected = "<wddxPacket version='1.0'><header/><data><string> </string></data></wddxPacket>";
     if (wddx_serialize_value(" ") !== $expected) {
         return true;
     }
     // Some versions of HHVM don't correctly encode ampersands.
     $expected = "<wddxPacket version='1.0'><header/><data><string>&amp;</string></data></wddxPacket>";
     if (wddx_serialize_value('&') !== $expected) {
         return true;
     }
     // Some versions of HHVM don't correctly encode empty arrays as subvalues.
     $expected = "<wddxPacket version='1.0'><header/><data><array length='1'><array length='0'></array></array></data></wddxPacket>";
     if (wddx_serialize_value(array(array())) !== $expected) {
         return true;
     }
     // Some versions of HHVM don't correctly encode associative arrays with numeric keys.
     $expected = "<wddxPacket version='1.0'><header/><data><struct><var name='2'><number>1</number></var></struct></data></wddxPacket>";
     if (wddx_serialize_value(array(2 => 1)) !== $expected) {
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
function ftp_ErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    if ($errno != 2 && $errno != 8) {
        // timestamp for the error entry
        $dt = date("Y-m-d H:i:s (T)");
        // define an assoc array of error string
        // in reality the only entries we should
        // consider are 2,8,256,512 and 1024
        $errortype = array(1 => "Error", 2 => "Warning", 4 => "Parsing Error", 8 => "Notice", 16 => "Core Error", 32 => "Core Warning", 64 => "Compile Error", 128 => "Compile Warning", 256 => "User Error", 512 => "User Warning", 1024 => "User Notice");
        // set of errors for which a var trace will be saved
        $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
        $err = "<errorentry>\n";
        $err .= "\t<datetime>" . $dt . "</datetime>\n";
        $err .= "\t<errornum>" . $errno . "</errnumber>\n";
        $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n";
        $err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
        $err .= "\t<scriptname>" . $filename . "</scriptname>\n";
        $err .= "\t<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
        if (in_array($errno, $user_errors)) {
            $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
        }
        $err .= "</errorentry>\n\n";
        debug($err);
    }
}
Ejemplo n.º 4
0
function test()
{
    $v = new t1();
    $v->set();
    echo wddx_serialize_value($v);
    print "\n";
}
Ejemplo n.º 5
0
 /**
  * @param array $value
  * @return string
  */
 public function serialize($value)
 {
     if ($value === null || is_array($value) && count($value) == 0) {
         return '';
     }
     return wddx_serialize_value($value);
 }
Ejemplo n.º 6
0
 public function asXML()
 {
     $asArray = $this->asArray();
     $this->complete(&$asArray);
     $erg = wddx_serialize_value($asArray);
     return $erg;
 }
Ejemplo n.º 7
0
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    // timestamp for the error entry
    $dt = date("Y-m-d H:i:s (T)");
    // define an assoc array of error string
    // in reality the only entries we should
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    // E_USER_WARNING and E_USER_NOTICE
    $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
    // set of errors for which a var trace will be saved
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    $err .= "Errornummer:" . $errno . " ";
    $err .= "Errortyp" . $errortype[$errno] . " ";
    $err .= "Errormessage:" . $errmsg . " ";
    $err .= "Filename:" . $filename . " ";
    $err .= "on Line:" . $linenum . " ";
    if (in_array($errno, $user_errors)) {
        $err .= "Vartrace: " . wddx_serialize_value($vars, "Variables");
    }
    // for testing
    //echo $err;
    // save to the error log, and e-mail me if there is a critical user error
    /*    error_log($err, 3, "/usr/local/php4/error.log");
        if ($errno == E_USER_ERROR) {
            mail("*****@*****.**", "Critical User Error", $err);
        }*/
}
Ejemplo n.º 8
0
Archivo: Log.php Proyecto: webunion/log
 public function logError($errno, $errmsg, $filename, $linenum, $vars)
 {
     $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
     // set of errors for which a var trace will be saved
     $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
     $err = '<errorEntry>';
     $err .= '<dateTime>' . date('Y-m-d H:i:s') . '</dateTime>';
     $err .= '<errorNum>' . $errno . '</errorNum>';
     $err .= '<errorType>' . $errortype[$errno] . '</errorType>';
     $err .= '<errorMsg>' . $errmsg . '</errorMsg>';
     $err .= '<scriptName>' . $filename . '</scriptName>';
     $err .= '<scriptLineNum>' . $linenum . '</scriptLineNum>';
     $err .= '<uri>' . (php_sapi_name() === 'cli') ? __FILE__ : $_SERVER['REQUEST_URI'] . '</uri>';
     $err .= '<param>';
     $array = array_merge($_GET, $_POST);
     if (count($array) > 1) {
         foreach ($array as $key => $value) {
             $err .= '<var>' . $key . '=' . $value . '</var>';
         }
     }
     $err .= '</param>';
     if (in_array($errno, $user_errors)) {
         $err .= '<varTrace>' . wddx_serialize_value($vars, 'Variables') . '</varTrace>';
     }
     $err .= '</errorEntry>' . PHP_EOL;
     // save to the error log, and e-mail me if there is a critical user error
     error_log($err, 3, $this->path . $this->fileName);
     if ($errno == E_USER_ERROR) {
         //Helper::enviarEmail($err,'Erro critico '.date('Y-m-d H:i:s'));
     }
 }
Ejemplo n.º 9
0
 public function serialize($v)
 {
     if (!$this->len) {
         return wddx_serialize_value($v);
     }
     if (is_bool($v) || !is_scalar($v)) {
         return $this->prefix . wddx_serialize_value($v);
     }
     return $v;
 }
Ejemplo n.º 10
0
 public function execute()
 {
     if (function_exists('wddx_serialize_value')) {
         $this->printText(wddx_serialize_value($this->getResultData()));
     } else {
         $this->printText('<?xml version="1.0" encoding="utf-8"?>');
         $this->printText('<wddxPacket version="1.0"><header/><data>');
         $this->slowWddxPrinter($this->getResultData());
         $this->printText('</data></wddxPacket>');
     }
 }
Ejemplo n.º 11
0
function myErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    // timestamp for the error entry
    $dt = date("Y-m-d H:i:s ");
    // define an assoc array of error string
    // in reality the only entries we should
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    // E_USER_WARNING and E_USER_NOTICE
    $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice");
    // set of errors for which a var trace will be saved
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    $err = "<errorentry>\n";
    $err .= "\t<datetime>" . $dt . "</datetime>\n";
    $err .= "\t<errornum>" . $errno . "</errornum>\n";
    if (isset($errortype[$errno])) {
        $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n";
    }
    $err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
    $err .= "\t<scriptname>" . $filename . "</scriptname>\n";
    $err .= "\t<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $err .= "\t<user-agent>" . $_SERVER['HTTP_USER_AGENT'] . "</user-agent>\n";
    }
    if (MOBIKAR_LOGGING_WDDX == TRUE && in_array($errno, $user_errors)) {
        $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
    }
    $err .= "</errorentry>\n\n";
    $err_line = $dt;
    if (isset($errortype[$errno])) {
        $err_line .= "[" . $errortype[$errno] . "]";
    }
    $err_line .= $errmsg . " " . $filename . " " . $linenum . "\n";
    // for testing
    // echo $err;
    // save to the error log, and e-mail me if there is a critical user error
    if ($errno == E_USER_ERROR) {
        error_log($err, 3, MOBIKAR_LOGGING_E_USER_ERROR);
        if (MOBIKAR_LOGGING_EMAIL != NULL) {
            mail(MOBIKAR_LOGGING_EMAIL, "Critical User Error", $err);
        }
    } else {
        if ($errno == E_USER_WARNING) {
            error_log($err, 3, MOBIKAR_LOGGING_E_USER_WARNING);
        } else {
            if ($errno == E_USER_NOTICE) {
                error_log($err, 3, MOBIKAR_LOGGING_E_USER_NOTICE);
            } else {
                error_log($err, 3, MOBIKAR_LOGGING_E_SYS);
            }
        }
    }
    error_log($err_line, 3, MOBIKAR_LOGGING_LOG);
}
Ejemplo n.º 12
0
function errorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    $errorReporting = ini_get('error_reporting');
    if ($errorReporting === 0 || !($errorReporting & $errno)) {
        return FALSE;
    }
    $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
    $err = sprintf("%s -- ", $errortype[$errno], wddx_serialize_value($vars, "Variables"));
    print "<pre>";
    var_dump($vars);
    print "</pre>";
    error_log($err);
}
Ejemplo n.º 13
0
function xpress_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
    $module_dirpath = dirname(dirname(__FILE__));
    $root_path = dirname(dirname(dirname(dirname(__FILE__))));
    $show_backtrace = true;
    // Time stamp of error entry
    $dt = date("Y-m-d H:i:s (T)");
    // define an assoc array of error string
    // in reality the only entries we should
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    // E_USER_WARNING and E_USER_NOTICE
    $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice", E_STRICT => "Runtime Notice");
    if (strstr($errstr, 'Use of undefined constant xpress_debug_message - assumed') !== false) {
        return;
    }
    // set of errors for which a var trace will be saved
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    $err = "<errorentry>\n";
    $err .= "\t<datetime>" . $dt . "</datetime>\n";
    $err .= "\t<errornum>" . $errno . "</errornum>\n";
    $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n";
    $err .= "\t<errormsg>" . $errstr . "</errormsg>\n";
    $err .= "\t<scriptname>" . $errfile . "</scriptname>\n";
    $err .= "\t<scriptlinenum>" . $errline . "</scriptlinenum>\n";
    $err .= "\t<errcontext>" . $errcontext . "</errcontext>\n";
    if (in_array($errno, $user_errors)) {
        $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
    }
    $err .= "</errorentry>\n\n";
    $err_trace = '';
    if ($show_backtrace) {
        $backtraces = array_reverse(debug_backtrace());
        $err_trace .= "BACK TRACE\n";
        foreach ($backtraces as $backtrace) {
            $trace = @$backtrace['file'] . "\tLINE(" . @$backtrace['line'] . ")\t" . @$backtrace['function'] . "()\n";
            $trace = str_replace($root_path, "", $trace);
            $trace = str_replace("\\", "/", $trace);
            $trace = str_replace($root_path, "", $trace);
            $trace = "\t" . $trace;
            $err_trace .= $trace;
        }
    }
    $head = "\n***** XPressME ERROR LOG ****************************************************************************************************\n";
    $message = $head . $err . $err_trace;
    $_debug_file = $module_dirpath . '/wp-content/xpress_error.log';
    if ($errno != E_STRICT) {
        $_fp = fopen($_debug_file, 'a');
        fwrite($_fp, $message);
        fclose($_fp);
    }
}
Ejemplo n.º 14
0
 /**
  * Handle & log errors
  *
  * @return void
  * @see http://php.net/manual/en/errorfunc.examples.php
  */
 public static function errorHandler($errno, $errmsg, $filename, $linenum, $vars)
 {
     // set of errors for which a var trace will be saved
     $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
     $err = "<errorentry>\n";
     $err .= "\t<errortype>" . self::errorType($errno) . "</errortype>\n";
     $err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
     if (in_array($errno, $user_errors)) {
         $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
     }
     $err .= "</errorentry>\n\n";
     Logger::Log("ERROR", $err, $filename, $linenum);
     self::viewError();
 }
Ejemplo n.º 15
0
 /**
  * Serialize PHP to WDDX
  * 
  * @param  mixed $value 
  * @param  array $opts 
  * @return string
  * @throws Zend\Serializer\Exception on wddx error
  */
 public function serialize($value, array $opts = array())
 {
     $opts = $opts + $this->_options;
     if (isset($opts['comment']) && $opts['comment']) {
         $wddx = wddx_serialize_value($value, (string) $opts['comment']);
     } else {
         $wddx = wddx_serialize_value($value);
     }
     if ($wddx === false) {
         $lastErr = error_get_last();
         throw new RuntimeException($lastErr['message']);
     }
     return $wddx;
 }
Ejemplo n.º 16
0
Archivo: Wddx.php Proyecto: raZ3l/zf2
 /**
  * Serialize PHP to WDDX
  *
  * @param  mixed $value
  * @return string
  * @throws Exception\RuntimeException on wddx error
  */
 public function serialize($value)
 {
     $comment = $this->getOptions()->getComment();
     ErrorHandler::start();
     if ($comment !== '') {
         $wddx = wddx_serialize_value($value, $comment);
     } else {
         $wddx = wddx_serialize_value($value);
     }
     $error = ErrorHandler::stop();
     if ($wddx === false) {
         throw new Exception\RuntimeException('Serialization failed', 0, $error);
     }
     return $wddx;
 }
Ejemplo n.º 17
0
 /**
  * Serialize PHP to WDDX
  *
  * @param  mixed $value
  * @param  array $opts
  * @return string
  * @throws Zend_Serializer_Exception on wddx error
  */
 public function serialize($value, array $opts = array())
 {
     $opts = $opts + $this->_options;
     if (isset($opts['comment']) && $opts['comment']) {
         $wddx = wddx_serialize_value($value, (string) $opts['comment']);
     } else {
         $wddx = wddx_serialize_value($value);
     }
     if ($wddx === false) {
         $lastErr = error_get_last();
         require_once 'Zend/Serializer/Exception.php';
         throw new Zend_Serializer_Exception($lastErr['message']);
     }
     return $wddx;
 }
Ejemplo n.º 18
0
 /**
  * @param $date
  * @param $errno
  * @param $errType
  * @param $errMsg
  * @param $file
  * @param $line
  * @param $vars
  * @param null $stackTrace
  * @return string
  */
 public static function xml($date, $errno, $errType, $errMsg, $file, $line, $vars, $stackTrace = null)
 {
     $user_errors = array(E_ERROR, E_WARNING, E_PARSE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
     $err = "<errorentry>\n";
     $err .= "\t<datetime>" . $date . "</datetime>\n";
     $err .= "\t<errornum>" . $errno . "</errornum>\n";
     $err .= "\t<errortype>" . $errType . "</errortype>\n";
     $err .= "\t<errormsg>" . $errMsg . "</errormsg>\n";
     $err .= "\t<scriptname>" . $file . "</scriptname>\n";
     $err .= "\t<scriptlinenum>" . $line . "</scriptlinenum>\n";
     if (in_array($errno, $user_errors)) {
         $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
     }
     $err .= "</errorentry>\n\n";
     return $err;
 }
Ejemplo n.º 19
0
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    $dt = date("Y-m-d H:i:s");
    $errortype = array(1 => "Error", 2 => "Warning", 4 => "Parsing Error", 8 => "Notice", 16 => "Core Error", 32 => "Core Warning", 64 => "Compile Error", 128 => "Compile Warning", 256 => "User Error", 512 => "User Warning", 1024 => "User Notice");
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    $err = array("datetime" => $dt, "errornum" => $errno, "errortype" => $errortype[$errno], "errormsg" => $errmsg, "scriptname" => $filename, "scriptlinenum" => $linenum);
    if (in_array($errno, $user_errors)) {
        $err["vartrace"] = wddx_serialize_value($vars, "Variables");
    }
    echo '<pre>';
    foreach ($err as $k => $v) {
        echo "{$k}: \t {$v}\n";
    }
    echo '</pre>';
    exit;
}
Ejemplo n.º 20
0
 function metallopdb()
 {
     /*{{{*/
     if (!$_REQUEST['metal']) {
         echo "<b>ERROR: Missing parameters.</b>\n";
         return false;
     }
     $metal = strtolower($_REQUEST['metal']);
     $mode = isset($_REQUEST['mode']) ? strtolower($_REQUEST['mode']) : 'first';
     $count = isset($_REQUEST['count']) ? intval($_REQUEST['count']) : 5;
     $format = isset($_REQUEST['format']) ? strtolower($_REQUEST['format']) : 'csv';
     $result = getPDBFromMetal($metal, $mode, $count);
     if (is_object($result) && DB::isError($result)) {
         echo "<b>ERROR " . $result->getCode() . ": " . $result->getMessage() . "</b>\n";
         return false;
     }
     if ($result == false) {
         echo "";
         return false;
     }
     switch ($format) {
         case "wddx":
             header("Content-type: text/xml");
             echo wddx_serialize_value($result);
             break;
         case "serialize":
             header("Content-type: text/plain");
             echo serialize($result);
             break;
         case "rss":
             header("Content-type: text/xml");
             echo toRSS($result, $GLOBALS['server_remote']);
             break;
         case "csv":
         default:
             header("Content-type: text/plain");
             $fields = array_keys($result[0]);
             $out = toCSV($fields);
             for ($i = 0; $i < count($result); $i++) {
                 $out .= toCSV(array_values($result[$i]));
             }
             echo $out;
             break;
     }
     return true;
 }
Ejemplo n.º 21
0
 public function execute()
 {
     if (function_exists('wddx_serialize_value') && !$this->getIsHtml()) {
         $this->printText(wddx_serialize_value($this->getResultData()));
     } else {
         // Don't do newlines and indentation if we weren't asked
         // for pretty output
         $nl = $this->getIsHtml() ? "" : "\n";
         $indstr = " ";
         $this->printText("<?xml version=\"1.0\"?>{$nl}");
         $this->printText("<wddxPacket version=\"1.0\">{$nl}");
         $this->printText("{$indstr}<header/>{$nl}");
         $this->printText("{$indstr}<data>{$nl}");
         $this->slowWddxPrinter($this->getResultData(), 4);
         $this->printText("{$indstr}</data>{$nl}");
         $this->printText("</wddxPacket>{$nl}");
     }
 }
Ejemplo n.º 22
0
 public function execute()
 {
     // Some versions of PHP have a broken wddx_serialize_value, see
     // PHP bug 45314. Test encoding an affected character (U+00A0)
     // to avoid this.
     $expected = "<wddxPacket version='1.0'><header/><data><string> </string></data></wddxPacket>";
     if (function_exists('wddx_serialize_value') && !$this->getIsHtml() && wddx_serialize_value(" ") == $expected) {
         $this->printText(wddx_serialize_value($this->getResultData()));
     } else {
         // Don't do newlines and indentation if we weren't asked
         // for pretty output
         $nl = $this->getIsHtml() ? '' : "\n";
         $indstr = ' ';
         $this->printText("<?xml version=\"1.0\"?>{$nl}");
         $this->printText("<wddxPacket version=\"1.0\">{$nl}");
         $this->printText("{$indstr}<header/>{$nl}");
         $this->printText("{$indstr}<data>{$nl}");
         $this->slowWddxPrinter($this->getResultData(), 4);
         $this->printText("{$indstr}</data>{$nl}");
         $this->printText("</wddxPacket>{$nl}");
     }
 }
Ejemplo n.º 23
0
 /**
  * Serialize data.
  *
  * @param mixed $data    The data to be serialized.
  * @param mixed $mode    The mode of serialization. Can be
  *                       either a single mode or array of modes.
  *                       If array, will be serialized in the
  *                       order provided.
  * @param mixed $params  Any additional parameters the serialization method
  *                       requires.
  *
  * @return string  A serialized string.
  * @throws Horde_Serialize_Exception
  */
 protected static function _serialize($data, $mode, $params = null)
 {
     switch ($mode) {
         case self::NONE:
             break;
             // $params['level'] = Level of compression (default: 3)
             // $params['workfactor'] = How does compression phase behave when given
             //                         worst case, highly repetitive, input data
             //                         (default: 30)
         // $params['level'] = Level of compression (default: 3)
         // $params['workfactor'] = How does compression phase behave when given
         //                         worst case, highly repetitive, input data
         //                         (default: 30)
         case self::BZIP:
             $data = bzcompress($data, isset($params['level']) ? $params['level'] : 3, isset($params['workfactor']) ? $params['workfactor'] : 30);
             if (is_integer($data)) {
                 $data = false;
             }
             break;
         case self::WDDX:
             $data = wddx_serialize_value($data);
             break;
         case self::IMAP8:
             $data = Horde_Mime::quotedPrintableEncode($data);
             break;
         case self::IMAPUTF7:
             $data = Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap(Horde_String::convertCharset($data, 'ISO-8859-1', 'UTF-8'));
             break;
         case self::IMAPUTF8:
             $data = Horde_Mime::decode($data);
             break;
             // $params['level'] = Level of compression (default: 3)
         // $params['level'] = Level of compression (default: 3)
         case self::GZ_DEFLATE:
             $data = gzdeflate($data, isset($params['level']) ? $params['level'] : 3);
             break;
         case self::BASIC:
             $data = serialize($data);
             break;
             // $params['level'] = Level of compression (default: 3)
         // $params['level'] = Level of compression (default: 3)
         case self::GZ_COMPRESS:
             $data = gzcompress($data, isset($params['level']) ? $params['level'] : 3);
             break;
         case self::BASE64:
             $data = base64_encode($data);
             break;
             // $params['level'] = Level of compression (default: 3)
         // $params['level'] = Level of compression (default: 3)
         case self::GZ_ENCODE:
             $data = gzencode($data, isset($params['level']) ? $params['level'] : 3);
             break;
         case self::RAW:
             $data = rawurlencode($data);
             break;
         case self::URL:
             $data = urlencode($data);
             break;
             // $params = Source character set
         // $params = Source character set
         case self::UTF7:
             $data = Horde_String::convertCharset($data, $params, 'UTF-7');
             break;
             // $params = Source character set
         // $params = Source character set
         case self::UTF7_BASIC:
             $data = self::serialize($data, array(self::UTF7, self::BASIC), $params);
             break;
         case self::JSON:
             $tmp = json_encode($data);
             /* Basic error handling attempts.
              * TODO: JSON_ERROR_UTF8 = 5; available as of PHP 5.3.3 */
             if (json_last_error() === 5) {
                 $data = json_encode(Horde_String::convertCharset($data, $params, 'UTF-8', true));
             } else {
                 $data = $tmp;
             }
             break;
         case self::LZF:
             $data = lzf_compress($data);
             break;
     }
     if ($data === false) {
         throw new Horde_Serialize_Exception('Serialization failed.');
     }
     return $data;
 }
Ejemplo n.º 24
0
 /**
  * Returns a string for a field structure
  *
  * This function uses the following is the grammar to pack elements:
  * enum      => name;type=enum;domain=[element1,...]
  * set       => name;type=set;domain=[element1,...]
  * timestamp => name;type=timestamp;format=<string>;init=<num>
  * boolean   => name;type=bool;default=[true, false]
  * text      => name;type=text;default=<string>
  * varchar   => name;varchar;size=<num>;default=<string>
  * numeric   => name;[autoincrement];size=<num>;default=<string>
  *
  * @access  private
  * @param   array  $schema schema to pack
  * @return  string the packed schema
  */
 function _packSchema($schema, $format = 'php')
 {
     switch ($format) {
         case 'php':
             return serialize($schema);
         case 'wddx':
             if (!function_exists('wddx_serialize_value')) {
                 return $this->raiseError('wddx extension not found!');
             }
             return wddx_serialize_value($schema);
         default:
             return $this->raiseError('Unknown schema format: ' . $format);
     }
 }
 /**
  * Specific error handler in Normal mode
  *
  * @param $errno     integer  level of the error raised.
  * @param $errmsg    string   error message.
  * @param $filename  string   filename that the error was raised in.
  * @param $linenum   integer  line number the error was raised at.
  * @param $vars      array    that points to the active symbol table at the point the error occurred.
  **/
 static function userErrorHandlerNormal($errno, $errmsg, $filename, $linenum, $vars)
 {
     // Date et heure de l'erreur
     $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', 4096 => 'Catchable Fatal Error', 8192 => 'Deprecated function', 16384 => 'User deprecated function');
     // Les niveaux qui seront enregistrés
     $user_errors = array(E_USER_ERROR, E_USER_NOTICE, E_USER_WARNING);
     $err = '  *** PHP ' . $errortype[$errno] . "({$errno}): {$errmsg}\n";
     if (in_array($errno, $user_errors)) {
         $err .= "Variables:" . wddx_serialize_value($vars, "Variables") . "\n";
     }
     $skip = array('Toolbox::backtrace()');
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         $hide = "Toolbox::userErrorHandlerDebug()";
         $skip[] = "Toolbox::userErrorHandlerNormal()";
     } else {
         $hide = "Toolbox::userErrorHandlerNormal()";
     }
     $err .= self::backtrace(false, $hide, $skip);
     // Save error
     self::logInFile("php-errors", $err);
     return $errortype[$errno];
 }
Ejemplo n.º 26
0
 function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
 {
     // timestamp for the error entry
     $dt = date("Y-m-d H:i:s (T)");
     // define an assoc array of error string
     // in reality the only entries we should
     // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
     // E_USER_WARNING and E_USER_NOTICE
     $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
     // set of errors for which a var trace will be saved
     $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
     $err = "<errorentry>\n";
     $err .= "\t<datetime>" . $dt . "</datetime>\n";
     $err .= "\t<errornum>" . $errno . "</errornum>\n";
     $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n";
     $err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
     $err .= "\t<scriptname>" . $filename . "</scriptname>\n";
     $err .= "\t<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
     if (in_array($errno, $user_errors)) {
         $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
     }
     $err .= "</errorentry>\n\n";
     // for testing
     echo $err;
     // save to the error log, and e-mail me if there is a critical user error
     error_log($err, 3, "../customError.log");
     if ($errno == E_USER_ERROR) {
         mail("*****@*****.**", "Critical User Error", $err);
     }
 }
Ejemplo n.º 27
0
/**
 * Use our own error handling function.
 */
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    if (PHP_VERSION >= 5) {
        if ($errno >= E_STRICT) {
            return;
        }
    }
    //if ($errno == E_NOTICE) return;
    // timestamp for the error entry
    $dt = date("Y-m-d H:i:s (T)");
    // define an assoc array of error string
    // in reality the only entries we should
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    // E_USER_WARNING and E_USER_NOTICE
    $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice");
    // set of errors for which a var trace will be saved
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    $err = "<ul>\n";
    $err .= "\t<li>" . $dt . "</li>\n";
    $err .= "\t<li>Errno: " . $errno . ', ' . $errortype[$errno] . "</li>\n";
    $err .= "\t<li>" . $errmsg . "</li>\n";
    $err .= "\t<li>" . $filename . ":" . $linenum . "</li>\n";
    if (in_array($errno, $user_errors)) {
        $err .= "\t<li>" . wddx_serialize_value($vars, "Variables") . "</li>\n";
    }
    $err .= "</ul>\n\n";
    // for testing
    echo $err;
    papersdb_backtrace();
    echo "include path: ", ini_get("include_path"), "\n";
    exit(1);
}
Ejemplo n.º 28
0
Archivo: XML.php Proyecto: b14/guid
 /** {@inheritdoc} */
 public function out($output, $options = array())
 {
     return wddx_serialize_value($output);
 }
Ejemplo n.º 29
0
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    // timestamp for the error entry.
    $dt = date('Y-m-d H:i:s (T)');
    // define an assoc array of error string
    // in reality the only entries we should
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    // E_USER_WARNING and E_USER_NOTICE.
    $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice');
    // set of errors for which a var trace will be saved.
    $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
    if ($errno != E_STRICT) {
        $err = $dt . "\t";
        $err .= $errno . ' ' . $errortype[$errno] . "\t";
        $err .= $errmsg . "\t";
        $err .= 'File: ' . basename($filename) . "\t";
        $err .= 'Line: ' . $linenum . "\t";
        if (in_array($errno, $user_errors)) {
            $err .= 'Trace: ' . wddx_serialize_value($vars, 'Variables') . "\t";
        }
        $err .= "\n";
        // save to the error log file, and e-mail me if there is a critical user error.
        error_log($err, 3, 'error.log');
    }
}
Ejemplo n.º 30
0
	PHP 5.4.3  + Windows XP SP3 Professional PL
	
Description:
wddx_serialize_value and wddx_serialize_vars functions fails to handle Variant 
object when it is given as a first argument. 
Registers: 
	EAX 00000000 
	ECX 1056AAE8 php5ts.1056AAE8
	EDX 100EFCE0 php5ts.100EFCE0
	EBX 01032AB0
	ESP 00C0FAE0
	EBP 00000000
	ESI 0121E478
	EDI 0121CB50
	EIP 1028F22E php5ts.1028F22E
Crash:
	1028F22E   8A45 25          MOV AL,BYTE PTR SS:[EBP+25] 
Situation looks pretty much the same for both wddx_serialize_vars and 
wddx_serialize_value. Also functions stream_bucket_prepend and stream_bucket_append 
have some problems with handling Variant object when given as a second argument:
stream_bucket_append(1, new Variant(1));
stream_bucket_prepend(1, new Variant(1));
PS : Variant object is only available in PHP for Windows OS and it was implemented 
in PHP > 4.1.0 and PHP 5. 
For more details check : http://php.net/manual/en/class.variant.php
PS2: After running this via webserver my Apache wasn't able to handle requests
anymore and I had to restart him :)
kthxbye
*/
wddx_serialize_value(new Variant(666));