| 743 | | case 'dump': |
| 744 | | // Make sure this is a POST |
| 745 | | if(!isset($_POST['dumpact'])) { |
| 746 | | die('Sorry, you can\'t access this via a GET'); |
| 747 | | } |
| 748 | | $tbl = array('"','"'); |
| 749 | | error_reporting(E_ALL); |
| 750 | | rss_require('schema.php'); |
| 751 | | $tables=getExpectedTables(); |
| 752 | | unset($tables['cache']); |
| 753 | | //$tables=array('channels','tag','config'); |
| 754 | | $bfr=''; |
| 755 | | $bfr .= '<'.'?xml version="1.0" encoding="UTF-8"?'.'>'."\n"; |
| 756 | | $bfr .= '<dump prefix="'.getTable('').'" date="'.date('r').'">'."\n"; |
| 757 | | foreach($tables as $table => $prefixed) { |
| 758 | | $rs = rss_query("select * from $prefixed"); |
| 759 | | $bfr .="<$table>\n"; |
| 760 | | while($row=rss_fetch_assoc($rs)) { |
| 761 | | $r="<row "; |
| 762 | | foreach($row as $key => $val) { |
| 763 | | $val=htmlspecialchars($val); |
| 764 | | $r.=" $key=\"$val\" "; |
| | 743 | case 'dump': |
| | 744 | // Make sure this is a POST |
| | 745 | if(!isset($_POST['dumpact'])) { |
| | 746 | die('Sorry, you can\'t access this via a GET'); |
| | 747 | } |
| | 748 | $tbl = array('"','"'); |
| | 749 | error_reporting(E_ALL); |
| | 750 | rss_require('schema.php'); |
| | 751 | $tables=getExpectedTables(); |
| | 752 | unset($tables['cache']); |
| | 753 | //$tables=array('channels','tag','config'); |
| | 754 | $bfr=''; |
| | 755 | $bfr .= '<'.'?xml version="1.0" encoding="UTF-8"?'.'>'."\n"; |
| | 756 | $bfr .= '<dump prefix="'.getTable('').'" date="'.date('r').'">'."\n"; |
| | 757 | foreach($tables as $table => $prefixed) { |
| | 758 | $rs = rss_query("select * from $prefixed"); |
| | 759 | $bfr .="<$table>\n"; |
| | 760 | while($row=rss_fetch_assoc($rs)) { |
| | 761 | $r="<row "; |
| | 762 | foreach($row as $key => $val) { |
| | 763 | $val=htmlspecialchars($val); |
| | 764 | $r.=" $key=\"$val\" "; |
| | 765 | } |
| | 766 | $r .= "/>\n"; |
| | 767 | $bfr .=$r; |
| 769 | | $bfr .="</$table>\n"; |
| 770 | | } |
| 771 | | $bfr .='</dump>'."\n"; |
| 772 | | $gzdata = gzencode($bfr, 9); |
| 773 | | $tempfname=tempnam("/tmp", "rss.dump").'.xml.gz'; |
| 774 | | $df=fopen($tempfname,'w'); |
| 775 | | fwrite($df, $gzdata); |
| 776 | | fclose($df); |
| 777 | | die($tempfname); |
| 778 | | break; |
| | 771 | $bfr .='</dump>'."\n"; |
| | 772 | $gzdata = gzencode($bfr, 9); |
| | 773 | |
| | 774 | |
| | 775 | // Delete the output buffer. This is probably a bad thing to do, if the ob'ing is turned off. |
| | 776 | // e.g. data was already sent to the brwoser. |
| | 777 | while (@ob_end_clean()); |
| | 778 | |
| | 779 | // Send the dump to the browser: |
| | 780 | header("Pragma: public"); // required |
| | 781 | header("Expires: 0"); |
| | 782 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
| | 783 | header("Connection: close"); |
| | 784 | header("Content-Transfer-Encoding: binary"); |
| | 785 | header("Content-Length: " . strlen($gzdata)); |
| | 786 | header('Content-type: application/x-gzip'); |
| | 787 | header('Content-disposition: inline; filename="gregarius.dump.'.date('MjSY').'.xml.gz"'); |
| | 788 | |
| | 789 | die($gzdata); |
| | 790 | |
| | 791 | break; |