示例#1
0
function outputXml($result)
{
    header("Content-type: text/xml");
    $str = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><table>";
    $row_count = count($result);
    for ($i = 0; $i < $row_count; $i++) {
        $str .= "<row>";
        $j = 0;
        foreach ($result[$i] as $key => $value) {
            if ($j % 2 == 1) {
                //echo "~".$value."!";
                if ($value instanceof DateTime) {
                    $value = $value->format('Y-m-d H:i:s');
                }
                $value = CovertSpecialChat($value);
                $value_change = array('&' => '&amp;', '#' => '&#35;', '<' => '&lt;', chr(0x0) => '', '>' => '&gt;', '\'' => '&apos;', '"' => '&quot;');
                $value = utf8_for_xml($value);
                $str .= "<{$key}>" . strtr($value, $value_change) . "</{$key}>";
            }
            $j++;
        }
        $str .= "</row>";
    }
    $str .= "</table>";
    echo $str;
    exit;
}
示例#2
0
 /**
  * format output
  */
 public function formatOutput($data, $format = 'json')
 {
     switch ($format) {
         case 'xml':
             $content_formated = $this->formatXML($data);
             break;
         case 'rss':
             $content_formated = $this->formatRSS($data);
             break;
         case 'csv':
             $content_formated = $this->formatCSV($data);
             break;
         case 'json':
         default:
             $content_formated = $this->formatJSON($data);
             break;
     }
     // clean invalid characters
     $content_formated = utf8_for_xml($content_formated);
     return $content_formated;
 }
示例#3
0
if ($CDASH_USE_COMPRESSION) {
    if ($CDASH_DB_TYPE == 'pgsql') {
        if (is_resource($testRow['output'])) {
            $testRow['output'] = base64_decode(stream_get_contents($testRow['output']));
        } else {
            $testRow['output'] = base64_decode($testRow['output']);
        }
    }
    @($uncompressedrow = gzuncompress($testRow['output']));
    if ($uncompressedrow !== false) {
        $test_response['output'] = utf8_for_xml($uncompressedrow);
    } else {
        $test_response['output'] = utf8_for_xml($testRow['output']);
    }
} else {
    $test_response['output'] = utf8_for_xml($testRow['output']);
}
$test_response['summaryLink'] = $summaryLink;
switch ($testRow['status']) {
    case 'passed':
        $test_response['status'] = 'Passed';
        $test_response['statusColor'] = '#00aa00';
        break;
    case 'failed':
        $test_response['status'] = 'Failed';
        $test_response['statusColor'] = '#aa0000';
        break;
    case 'notrun':
        $test_response['status'] = 'Not Run';
        $test_response['statusColor'] = '#ffcc66';
        break;
function addAnswer($ans, $questionId)
{
    $query = "INSERT INTO survey_question_choice (content, question_id) VALUES ('" . utf8_for_xml($ans) . "','" . (int) $questionId . "')";
    $result = mysql_query($query) or trigger_error(mysql_error() . " " . $query);
}
示例#5
0
if ($CDASH_USE_COMPRESSION) {
    if ($CDASH_DB_TYPE == "pgsql") {
        if (is_resource($testRow["output"])) {
            $testRow["output"] = base64_decode(stream_get_contents($testRow["output"]));
        } else {
            $testRow["output"] = base64_decode($testRow["output"]);
        }
    }
    @($uncompressedrow = gzuncompress($testRow["output"]));
    if ($uncompressedrow !== false) {
        $xml .= add_XML_value("output", utf8_for_xml($uncompressedrow));
    } else {
        $xml .= add_XML_value("output", utf8_for_xml($testRow['output']));
    }
} else {
    $xml .= add_XML_value("output", utf8_for_xml($testRow['output']));
}
$xml .= add_XML_value("summaryLink", $summaryLink);
switch ($testRow["status"]) {
    case "passed":
        $xml .= add_XML_value("status", "Passed");
        $xml .= add_XML_value("statusColor", "#00aa00");
        break;
    case "failed":
        $xml .= add_XML_value("status", "Failed");
        $xml .= add_XML_value("statusColor", "#aa0000");
        break;
    case "notrun":
        $xml .= add_XML_value("status", "Not Run");
        $xml .= add_XML_value("statusColor", "#ffcc66");
        break;