jonosss Posted October 22, 2007 Share Posted October 22, 2007 Hello as a complete novice in PHP could someone be kind enough to check this PHP script and see if it has any obvious errors? It is a acript used on my website than produces back up order copies in xml file format. The problem is that although these xml are in fact being generated I cannot view them. When I try and open the xml file in IE I get the following error message "cannot view xml input using xsl style sheet a string literal was not closed" When I try and open the xml file in it in Excel I get the error message "file could not be opened a string literal was not closed" I hope you dont mind but I have pasted the PHP file contens below if anyone can spot any mistakes in it that would rectify the xml problem. Many thanks in advance. ?php //---------------------------------------------------------------------------------------------- // SmartStore.biz Save XML-Order (PHP) // Created by: Ralf Langebrake //---------------------------------------------------------------------------------------------- // Created Date: 31.05.2003 // Last Modified: 10.09.2003 //---------------------------------------------------------------------------------------------- $email = "[email protected]"; // eMail Storebetreiber //---------------------------------------------------------------------------------------------- // Functions //---------------------------------------------------------------------------------------------- function SetContent($mcnt,$mfile){ $topen = fopen($mfile,"w"); $twrte = fwrite($topen, $mcnt); $tclse = fclose($topen); }; function GetContent($mfile){ $fopn = fopen($mfile,"r"); $fcnt = trim(fread($fopn, filesize($mfile))); $fcls = fclose($fopn); return $fcnt; }; function CreateFolder($mdir){ mkdir($mdir, 0755); }; //---------------------------------------------------------------------------------------------- // Verzeichnis-/ Dateinamen und Inhalte bestimmen //---------------------------------------------------------------------------------------------- $orderid = $HTTP_POST_VARS["oid"]; $xmlcont = $HTTP_POST_VARS["strxml"]; $httpurl = str_replace("http://www.colletorto.com/shop/assets/own/", "", $HTTP_SERVER_VARS["SCRIPT_URI"]); $httpurl = str_replace("\\", "/", $httpurl); $httpurl = substr($httpurl, 0, strrpos($httpurl, "/")); $filepth = str_replace("http://www.colletorto.com/shop/assets/own", "", getcwd()); $fuldate = date("d.m.Y - H:m:s"); $actdate = date("d.m.Y"); $maindir = $filepth ."/orderbackup"; $subdir1 = $maindir . "/" . date("Y-m"); $subdir2 = $subdir1 . "/" . date("d"); $dateidx = $maindir . "/dateindex.txt"; $fidxnam = "_fileindex.txt"; $fileidx = $subdir2 . "/" . $fidxnam; $xslname = "showorder.xsl"; $xslfile = $maindir . "/" . $xslname; $xmlfile = $subdir2 . "/" . $orderid . ".xml"; $mcols = "" . "----------------------------------------------------------------------------------------\n" . "Datum - Uhrzeit | Bestellnummer | URL\n" . "----------------------------------------------------------------------------------------\n\n"; if(!$orderid or !$xmlcont or strlen($xmlcont) < 2000){ die(); }; //---------------------------------------------------------------------------------------------- // Verzeichnisstruktur aufbauen //---------------------------------------------------------------------------------------------- if(!is_dir($maindir)){ CreateFolder($maindir); }; if(!is_dir($subdir1)){ CreateFolder($subdir1); }; if(!is_dir($subdir2)){ CreateFolder($subdir2); }; //---------------------------------------------------------------------------------------------- // Datums-/ Bestellindex und XSLT-Datei erstellen //------------------------------------------------------------------------------------------------ if(!file_exists($dateidx)){ SetContent($actdate,$dateidx); }; if(!file_exists($fileidx)){ SetContent($mcols,$fileidx); }; //---------------------------------------------------------------------------------------------- // Aktuelles Datum (bzw. Verzeichnis) und Bestellindex auslesen, Bestellindex aktualisieren //---------------------------------------------------------------------------------------------- $dtidx = GetContent($dateidx); $flidx = GetContent($fileidx); $fdata = "" . $flidx . "\n" . $fuldate . " | " . $orderid . " | " . $httpurl . str_replace($filepth, "", $xmlfile); SetContent($fdata,$fileidx); //---------------------------------------------------------------------------------------------- // Bestelldaten als XML-Datei in aktuellem Verzeichnis speichern //---------------------------------------------------------------------------------------------- $xmldata = "" . "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" . "<?xml-stylesheet type=\"text/xsl\" href=\"" . $httpurl . "http://www.colletorto.com/shop/assets/own/" . $xslname . "\"?>\n" . stripslashes($xmlcont); SetContent($xmldata,$xmlfile); //---------------------------------------------------------------------------------------------- // Bestellindex vom Vortag zum Abgleich an Storebetreiber schicken und Datumsindex aktualisieren //---------------------------------------------------------------------------------------------- if($dtidx != $actdate){ $mpath = explode(".", $dtidx); $mfullpath = "" . $maindir . "/" . trim($mpath[2]) . "-" . trim($mpath[1]) . "/" . trim($mpath[0]) . "/" . $fidxnam; $orderlist = GetContent($mfullpath); $MailHead = "From: OnlineStore<" . $email . ">\n" . "X-Priority: 1\nX-MSMail-Priority: High\n"; if($email != ""){ $SendOrderList = mail(trim($email), "Bestellindex vom " . $dtidx, trim($orderlist), $MailHead); }; SetContent($actdate,$dateidx); }; ?> Link to comment https://forums.phpfreaks.com/topic/74286-help-to-check-php-script-producing-non-readable-xml-files/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.