<?php //-->-->-->-->-->-->-->--> require '/usr50/home/retrovox/public_html/manage/php-lib/fnRetrovoxParseXml.php'; $sDataPath = "/usr50/home/retrovox/public_html/product-data"; $sProductId = $_POST["product-id"]; $sFilePath = "$sDataPath/product-$sProductId.xml"; if ($sProductId == '') { echo " <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'> <html> <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'> <META HTTP-EQUIV='Keywords' CONTENT='Retrovox Products'> <META HTTP-EQUIV='Description' CONTENT='Retrovox Product, no item'> <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'> <head><title>Retrovox Product Display, (No product specified)</title> </head> <body> ${S-RETROVOX-TITLE-IMAGE-HTML} <center><h1>No product was specified</h1></center> <p> You did not specify any product to update (using the product-id) </p> This situation probably indicates an error in the script edit-product-form.php <br> <a href = '/product-data/'>View All Product Files (XML)</a> </body> </html>"; exit; } //-- if no product if (file_exists($sFilePath)) { echo " <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'> <html> <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'> <META HTTP-EQUIV='Keywords' CONTENT='Retrovox'> <META HTTP-EQUIV='Description' CONTENT='Retrovox notepad, item doesnt exist'> <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'> <head><title>Retrovox Product Edit, (The item already exists)</title> </head> <body> ${S-RETROVOX-TITLE-IMAGE-HTML} <center><h1>The item already exists</h1></center> <p>There is already a product on the Retrovox site with the product-id which you just specified. </p> <br>This probably indicates an error is the script file add-product-form.php <br>To edit an existing product you should use the script edit-product-form.php <a href = '/product-data/'>View All Products</a> </body> </html>"; exit; } //-- if product already exists if (!is_writable(dirname($sFilePath))) { echo " <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'> <html> <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'> <META HTTP-EQUIV='Keywords' CONTENT='Retrovox'> <META HTTP-EQUIV='Description' CONTENT='Retrovox, product file not writable'> <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'> <head> <title> Retrovox Product Display, (The product directory is not writable)</title> </head> <body> ${S-RETROVOX-TITLE-IMAGE-HTML} <center><h1>The product directory is not writeable</h1></center> <p>The directory containing the data for the product which you specified is not writable. The permissions for this file will need to be altered by the system administrator </p> <br> </body> </html>"; //-- exit; } //-- if product directory not writeable //-- Construct the XML and write the data to file // $sProductData = "<product> \n"; foreach ($_POST as $key => $value) { $sProductData = $sProductData."<$key>".htmlspecialchars($value)."</$key> \n"; } $sProductData = $sProductData."</product> \n"; $fileHandle = fopen($sFilePath, "w"); fwrite($fileHandle, $sProductData); fclose($fileHandle); $aaProductData = fnRetrovoxParseXml($sProductData); //--<--<--<--<--< ?> <HTML> <HEAD> <TITLE>Retrovox Add a Product</TITLE> </HEAD> <body> <?=${S-RETROVOX-TITLE-IMAGE-HTML}?> <center> <img src="/Images/retrovox150.jpg" width=150 height=81 align=bottom><br> <h2>The new product was added to the database</h2> </center> <table border = "1"> <tr><td colspan = '2'><em>The following data was saved</em></td></tr> <?php //-->-->-->-->-->-->-->--> //-- for debugging // <pre><?=htmlspecialchars($sProductData)?</pre> foreach ($aaProductData as $key => $value) { echo "<tr><td><strong><em>$key</em></strong></td><td>$value</td></tr> \n"; } //-- foreach //--<--<--<--<--<--<--<--< ?> </table> </center> <ol type = 'a'> <li><a href = '/product-data/display-product.php?product=<?=$sProductId?>'> View the web-page for this product</a></li> <li><a href = '/product-data/product-<?=$sProductId?>.xml'> View the raw XML data for this product</a></li> <li><a href = '/product-data/display-product-xml.php?product=<?=$sProductId?>'> View the XML data for this product in a web-page</a></li> <li><a href = 'edit-product-form.php?product=<?=$sProductId?>'> Edit the data for this product</a> (Administrators Only)</li> </ol> </body> </html>