コード例 #1
0
ファイル: regress.php プロジェクト: enlite93/drawshield
function runTest($data)
{
    global $rebuild;
    if (array_key_exists('format', $data)) {
        $output = file('http://server1/include/shield/drawshield?format=' . $data['format'] . '&blazon=' . urlencode($data['blazon']));
    } else {
        $output = file('http://server1/include/shield/drawshield?blazon=' . urlencode($data['blazon']));
    }
    $outfile = 'regress\\' . $data['name'] . '.out';
    $difffile = 'regress\\' . $data['name'] . '.diff';
    if (!$rebuild and file_exists($outfile)) {
        $output = explode("\n", rtrim(formatXML($output)));
        $previous = file($outfile);
        $diff =& new Text_Diff($output, $previous);
        $renderer =& new Text_Diff_Renderer();
        $diffString = $renderer->render($diff);
        if ($diffString) {
            $back = 'red';
            $diffCell = '<pre>' . htmlentities($diffString) . '</pre>';
        } else {
            $back = 'green';
            $diffCell = 'No changes';
        }
    } else {
        $back = 'yellow';
        $diffCell = 'Output created';
        writeFile($outfile, $output);
    }
    echo '<tr>';
    echo '<td style="background-color:' . $back . '">' . $data['name'] . '</td>';
    echo '<td>' . $data['desc'] . '</td>';
    echo '<td>' . $diffCell . '</td>';
    echo '</tr>';
    return !($back == 'red');
}
コード例 #2
0
function addToPlaylist($mpdFilePath)
{
    global $baseurl, $playlistxml;
    $attr = $baseurl . $mpdFilePath;
    $playlistpath = "/home/cs5248-15/team06/public_html/upl/playlist.xml";
    if (file_exists($playlistpath)) {
        $playlist = simplexml_load_file($playlistpath);
    } else {
        try {
            $playlist = new SimpleXMLElement($playlistxml);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
    $mpdchild = $playlist->addChild("mpd");
    $mpdchild->addAttribute("path", $attr);
    $fp = fopen($playlistpath, "w") or die("Unable to open playlist file");
    fwrite($fp, formatXML($playlist));
    fclose($fp);
}
コード例 #3
0
function insertarEnXML($question, $answer, $complejidad, $subject)
{
    $xml = simplexml_load_file('XML/preguntas.xml');
    $assessmentItem = $xml->addChild('assessmentItem');
    if ($_REQUEST['complejidad'] == 0) {
        $assessmentItem->addAttribute('complexity', 'sin complejidad');
    } else {
        $assessmentItem->addAttribute('complexity', $complejidad);
    }
    $assessmentItem->addAttribute('subject', $subject);
    $itemBody = $assessmentItem->addChild('itemBody');
    $itemBody->addChild('p', $question);
    $correctResponse = $assessmentItem->addChild('correctResponse');
    $correctResponse->addChild('value', $answer);
    $xml = formatXML($xml);
    $return = $xml->asXML('XML/preguntas.xml');
    if ($return == 1) {
        echo 'Pregunta insertada correctamente en preguntas.xml<br/>';
        echo '<br/><a href="verPreguntasXML.php"> Ver Preguntas </a>';
    } else {
        echo 'La pregunta no se ha insertado en preguntas.xml';
    }
}
コード例 #4
0
ファイル: util.php プロジェクト: Nektro/RoundTable
function rt_create_user($a)
{
    $sxe = new SimpleXMLElement(file_get_contents('gen/users.xml'));
    $user = $sxe->addChild('u');
    $user->addAttribute('id', $a['id']);
    // user id
    $user->addAttribute('u', $a['u']);
    // username
    $user->addAttribute('e', $a['e']);
    // email
    $user->addAttribute('p', $a['p']);
    // password hash
    $user->addAttribute('n', $a['n']);
    // display name
    $user->addAttribute('b', $a['b']);
    // unix birthday date
    $user->addAttribute('j', time());
    // unix joined date
    $user->addAttribute('pp', $a['pp']);
    // proifle picture url
    $user->addAttribute('ba', $a['ba']);
    // banner picture url
    $user->addAttribute('l', $a['l']);
    // location
    $user->addAttribute('w', $a['w']);
    // website
    $user->addAttribute('ab', $a['ab']);
    // about bio
    $user->addAttribute('ac', $a['ac']);
    // achievements / badges array
    $user->addAttribute('tl', 0);
    // trust level (https://meta.discourse.org/t/4924)
    $user->addAttribute('ad', $a['ad']);
    // places where this user is an admin / moderator
    file_put_contents('rt-content/hidden/users.xml', formatXML($sxe));
}
コード例 #5
0
ファイル: state.php プロジェクト: rvaidya/FlexGIS
        die;
    }
    $user_id = $qresult[1]['user_id'];
    if ((int) $qresult[1]['state_size'] == 0) {
        postgis_query("INSERT INTO {$postgis_table_states}(user_id,state) VALUES({$user_id},'{$state}');");
    } else {
        postgis_query("UPDATE {$postgis_table_states} SET state='{$state}' WHERE user_id={$user_id};");
    }
    echo '<?xml version="1.0"?>
		<state_response result="OK" token="' . $token . '"/>';
    die;
} else {
    if (strtolower($xml->getName()) == "state_load") {
        $token = $xml['token'];
        $qresult = postgis_query("SELECT s.user_id,state FROM {$postgis_table_sessions} AS s,{$postgis_table_states} AS t WHERE s.user_id=t.user_id AND s.token='{$token}';");
        if (count($qresult) < 2) {
            echo '<?xml version="1.0"?>
		<state_response result="EMPTY" reason="No state exists."/>';
            die;
        }
        $xmlresponse = new SimpleXMLElement("<state_response />");
        $xmlresponse->addAttribute("result", "OK");
        $xmlresponse->addAttribute("token", $token);
        $xmlresponse->addChild("state", $qresult[1]['state']);
        echo formatXML($xmlresponse);
    } else {
        echo '<?xml version="1.0"?>
		<state_response result="ERROR" reason="Invalid state request."/>';
        die;
    }
}
コード例 #6
0
function addToPlaylist($mpdFilePath)
{
    echo "123";
    global $baseurl, $playlistxml;
    echo "q23";
    $attr = $baseurl . $mpdFilePath;
    echo "w23";
    $playlistpath = "upload/playlist.xml";
    echo "e23";
    if (file_exists($playlistpath)) {
        echo "fi43423";
        $playlist = simplexml_load_file($playlistpath);
        echo "d3423";
    } else {
        try {
            echo "z23";
            $playlist = new SimpleXMLElement($playlistxml);
            echo "rhf23";
        } catch (Exception $e) {
            echo "In exception";
            echo $e->getMessage();
        }
    }
    echo "f23";
    $mpdchild = $playlist->addChild("mpd");
    echo "d23";
    $mpdchild->addAttribute("path", $attr);
    echo "s23";
    $fp = fopen($playlistpath, "w") or die("Unable to open playlist file");
    echo "g23";
    fwrite($fp, formatXML($playlist));
    echo "t23";
    fclose($fp);
    echo "end2";
}
コード例 #7
0
ファイル: query.php プロジェクト: rvaidya/FlexGIS
@($result = pg_query($pgc, $qtext));
pg_close($pgc);
if (!$result) {
    echo '<?xml version="1.0"?>
  <query_result result="ERROR" reason="Error performing query: Query failed in database."/>';
    die;
}
$xml = new SimpleXMLElement("<query_result/>");
$xml->addAttribute("table", pg_field_table($result, 0));
$xml->addAttribute("token", $query_token);
if ($query_limit == "0") {
    $xml->addAttribute("result", "FIELDS");
    for ($i = 0; $i < pg_num_fields($result); $i++) {
        $field = $xml->addChild("field");
        $field->addAttribute("name", pg_field_name($result, $i));
        $field->addAttribute("type", pg_field_type($result, $i));
    }
} else {
    $xml->addAttribute("result", "ROWS");
}
while ($row = pg_fetch_row($result)) {
    $rowXML = $xml->addChild("row");
    for ($i = 0; $i < count($row); $i++) {
        $field = $rowXML->addChild("field", $row[$i]);
        $field->addAttribute("name", pg_field_name($result, $i));
        $field->addAttribute("type", pg_field_type($result, $i));
    }
}
pg_free_result($result);
echo formatXML($xml);
コード例 #8
0
ファイル: layers.php プロジェクト: rvaidya/FlexGIS
############################################################################################
# This class takes care of getting and creating layers
# XML (SOAP) layers are implemented as tables that are deleted when the user deletes them, and can only be refreshed explicitly.
# Metalayers are implemented as SQL views on other tables.
require_once "include.php";
header("Content-type: text/xml");
$post = trim(file_get_contents('php://input'));
global $xml;
try {
    $xml = new SimpleXMLElement($post);
} catch (Exception $e) {
    echo '<?xml version="1.0"?>
	<layers_response result="ERROR" reason="Unable to parse layer request XML."/>';
    die;
}
if (strtolower($xml->getName()) == "layers_request") {
    $token = $xml['token'];
    $array = getLayersForToken($token);
    $response = new SimpleXMLElement("<layers_response/>");
    $response->addAttribute("token", $token);
    $response->addAttribute("result", "OK");
    $keys = array_keys($array[0]);
    for ($i = 1; $i < count($array); $i++) {
        $layer = $response->addChild("layer");
        for ($j = 0; $j < count($keys); $j++) {
            $layer->addAttribute($keys[$j], $array[$i][$keys[$j]]);
        }
    }
    echo formatXML($response);
}