Annotation of db/prgsrc/dbxml.php, revision 1.1

1.1     ! roma7       1: <?php
        !             2: $hostname   = "localhost";
        !             3: $database   = "chgk";
        !             4: $username   = "piataev";
        !             5: $password   = "";
        !             6: 
        !             7: $link = mysql_connect($hostname.':'.$port, $username, $password) or die("Can't connect to database");
        !             8: mysql_select_db($database,$link) or die ("Can't select to database");
        !             9: mysql_query ("SET NAMES 'utf8'");
        !            10: $tour = $_GET['tour'];
        !            11: 
        !            12: 
        !            13: if (preg_match('/\./',$tour))
        !            14: {
        !            15:        $temp = explode('.', $tour);
        !            16:        $fname=$temp[0];$n=$temp[1];
        !            17: 
        !            18: 
        !            19:        $sth = mysql_query(
        !            20:                $sql="SELECT t2.Id FROM Tournaments as t1, 
        !            21:                         Tournaments as t2 
        !            22:                        WHERE (t1.FileName = '$fname.txt' OR t1.FileName='$fname')
        !            23:                         AND t1.Id=t2.ParentId AND t2.Number=$n") or die(mysql_error().": $sql");
        !            24: }      
        !            25: else 
        !            26: {
        !            27:        $sth=mysql_query($sql="SELECT Id FROM Tournaments WHERE FileName = '$tour.txt' OR  FileName = '$tour'") or die (mysql_error().": $sql");
        !            28: }
        !            29: 
        !            30: $res = mysql_fetch_row ($sth);
        !            31: $id=$res[0];
        !            32: 
        !            33: $sth = mysql_query("SELECT * FROM Tournaments WHERE Id=$id") or die(mysql_error());
        !            34: $tournament = mysql_fetch_assoc($sth);
        !            35: $xw = new xmlWriter();
        !            36: $xw->openMemory();
        !            37: $xw->startDocument('1.0','utf8');
        !            38: $xw->startElement('tournament'); 
        !            39: foreach ($tournament as $key => $value)
        !            40: {
        !            41:        $xw->writeElement ($key, $value);
        !            42: }
        !            43: 
        !            44: $sth = mysql_query("SELECT * FROM Questions WHERE ParentId =$id");
        !            45: 
        !            46: while ($question = mysql_fetch_assoc($sth) )
        !            47: {
        !            48:        $xw->startElement('question');
        !            49:        foreach ($question as $key => $value)
        !            50:        {
        !            51:                $xw->writeElement($key, $value);
        !            52:        }
        !            53:        $xw->endElement('question');
        !            54: }
        !            55: 
        !            56: $xw->endElement('tournament'); 
        !            57: 
        !            58: $xmlResult = $xw->outputMemory(true);   
        !            59: $xmlResult = preg_replace('/\>\s*\</', ">\n<", $xmlResult);    
        !            60: 
        !            61: header("Content-Type: text/xml");
        !            62: 
        !            63: print $xmlResult;
        !            64: 
        !            65: 
        !            66: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>