smtamburrino Posted August 31, 2011 Share Posted August 31, 2011 Good Morning & Thanks in advance! I recently purchased a Testimonials Module with XML & PHP. It appears that my permissions are OK but the script does not write to the XML file. Here is a link to the current script w/ example I bought: http://activeden.net/item/testimonials-module-with-xml-php/144275 Here is a link to my website & script not working: http://www.thehotsounds.com/test.html I've called my server (GoDaddy & my permissions seem to be fine the xml & PHP file are (777) Could it be the difference of running PHP4 instead of PHP5? Here is the PHP script: <?php /** */ class Testimonials{ private $file; private $input; private $output; public function __construct($inputFile){ $this->file = $inputFile; } public function add($inputData){ $this->input = fopen($this->file,'r'); if(!$this->input){ throw new Exception('Can not open input file.'); } $currentFolder = dirname($this->file); $tempName = $currentFolder . 'temp.xml'; $outputFile =$currentFolder.'/output.xml'; $this->output = fopen($outputFile,'w'); if(!$this->output){ throw new Exception('Can not open output file.'); } #skip first line $firstLine = fgets($this->input); fputs($this->output,$firstLine); fputs($this->output,$inputData); $line = fgets($this->input); while (!feof($this->input)){ fputs($this->output,$line); $line = fgets($this->input); } fputs($this->output,$line); fclose($this->input); fclose($this->output); rename($outputFile,$this->file); echo "success=yes"; } } $name= $_POST["Name"]; $location= $_POST["Location"]; $age= $_POST["Age"]; $date= $_POST["Date"]; $full= $_POST["Full"]; $message='<message>'."\n".' <name>'.$name.'</name>'."\n".' <location>'.$location.'</location>'."\n".' <age>'.$age.'</age>'."\n".' <date>'.$date.'</date>'."\n".' <full>'.$full.'</full>'."\n".'</message>'."\n"; $test = new testimonials('./testimonials.xml'); $test->add($message); ?> Here is the XML code <messages TITLE_TXT="Testimonials"> <message> <name>John Doe</name> <location>New York</location> <age>51</age> <date>29 November 2010</date> <full>Great website. I like the idea of the TESTIMONIALS Page. Everyone can leave here his opinios about the restaurant food, services, ambiance and so on... Personally i've never been to the restaurant but after reading all these positive testimonials, on my first arrive to your town, i'll give a visit. Cheers!</full> </message> <message> <name>Jane Doe</name> <location>New York</location> <age>44</age> <date>28 November 2010</date> <full>Just to let you know I have included your software on my 'recommend software for small-medium businesses'. We are website solutions company. I thought you might like to know that your software has been an essential part of our business and comes highly recommended. All the best</full> </message> <message> <name>Chi Chun Tao</name> <location>Beijing</location> <age>31</age> <date>18 September 2010</date> <full>Thanks for some great software at a reasonable price. It's HARD to find software tailored to the small vacation rental business. We manage 11 homes, and can't afford the expensive and overbloated (for us) software that's out there. This works great!</full> </message> <message> <name>Gianluca Fuentes</name> <location>Milano</location> <age>55</age> <date>5 November 2010</date> <full>The food and service are amazing here! We have been coming here for years and have never once had a bad experience. Looking forward to our next visit!</full> </message> <message> <name>Anonimous</name> <location>Berlin</location> <age>27</age> <date>6 June 2010</date> <full>Not only is it one of the few sauces carried by my favorite Health Food stores, it definintely tastes far better than any of the dozens of brands carried in our local supermarkets. It seems lighter, more flavorful, and not heavy with sodium and other additives. You can definitely taste the difference! Many thanks for a great product!</full> </message> <message> <name>Jane Doe</name> <location>Amsterdam</location> <age>23</age> <date>31 May 2010</date> <full>Thank you for a wonderful night last Saturday at our engagement party. EVERYONE said that the meals and the service were excellent! We will definitely look forward to dining with you again. A big thank you to Dave as well for his brilliant service thoughout the evening.</full> </message> <message> <name>Andrew Douglas Jr.</name> <location>New York</location> <age>50</age> <date>1 Mars 2010</date> <full>We would like to thank you for helping make our evening a very special event when we celebrated my fiftieth birthday. The evening was a total success. Everything worked well and the professionalism shown by you and your staff really helped us enjoy the event tremendously. Our guests made lots of comments about the food and in particular the friendly attentive service. Your willingness to cater for the special needs of some of the guest was most appreciated</full> </message> <message> <name>Lost tourist</name> <location>Toronto</location> <age>34</age> <date>23 Feb 2010</date> <full>Can I find another excuse for eating there? This is the question I always ask. Since my first visit there, I've been impressed by the ambience of the place and the quality of the food. Under the guidance of my friends, it has the feel of a home to which you have been invited. The personally focussed service complements the fresh, regularly updated mix of the best of fresh chinese products cooked in a clean sharp manner that makes this the best restaurant.</full> </message> <message> <name>Vanessa Adams</name> <location>Toronto</location> <age>68</age> <date>12 January 2010</date> <full>Our friends were duly impressed and will no doubt be returning soon, perhaps with us for a weekend breakfast. </full> </message> <message> <name>Donna Moore</name> <location>Reno</location> <age>34</age> <date>5 January 2010</date> <full>First, I wanted to thank you once again for accommodating the gift certificate on New Year’s Eve. The meal was outstanding, my guests thought they we’re in a fancy restaurant and couldn’t believe how tender the filet was.</full> </message> <message> <name>Jacque Dominique</name> <location>Paris</location> <age>21</age> <date>15 December 2009</date> <full>My friend and I were at the restaurant last night for dinner. I want to thank you and the rest of the staff for the excellent food and service provided. It was our first visit and we both agreed that it was a wonderful experience. Thanks again for the hospitality.</full> </message> </messages> Lastly here is the .js file //v1.7 // Flash Player Version Detection // Detect Client Browser type // Copyright 2005-2007 Adobe Systems Incorporated. All rights reserved. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor version >= requested minor if (versionMajor > parseFloat(reqMajorVer)) { return true; } else if (versionMajor == parseFloat(reqMajorVer)) { if (versionMinor > parseFloat(reqMinorVer)) return true; else if (versionMinor == parseFloat(reqMinorVer)) { if (versionRevision >= parseFloat(reqRevision)) return true; } } return false; } } function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); else return src + ext; } function AC_Generateobj(objAttrs, params, embedAttrs) { var str = ''; if (isIE && isWin && !isOpera) { str += '<object '; for (var i in objAttrs) { str += i + '="' + objAttrs[i] + '" '; } str += '>'; for (var i in params) { str += '<param name="' + i + '" value="' + params[i] + '" /> '; } str += '</object>'; } else { str += '<embed '; for (var i in embedAttrs) { str += i + '="' + embedAttrs[i] + '" '; } str += '> </embed>'; } document.write(str); } function AC_FL_RunContent(){ var ret = AC_GetArgs ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" , "application/x-shockwave-flash" ); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); } function AC_SW_RunContent(){ var ret = AC_GetArgs ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000" , null ); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); } function AC_GetArgs(args, ext, srcParamName, classid, mimeType){ var ret = new Object(); ret.embedAttrs = new Object(); ret.params = new Object(); ret.objAttrs = new Object(); for (var i=0; i < args.length; i=i+2){ var currArg = args[i].toLowerCase(); switch (currArg){ case "classid": break; case "pluginspage": ret.embedAttrs[args[i]] = args[i+1]; break; case "src": case "movie": args[i+1] = AC_AddExtension(args[i+1], ext); ret.embedAttrs["src"] = args[i+1]; ret.params[srcParamName] = args[i+1]; break; case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblclick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": case "type": case "codebase": case "id": ret.objAttrs[args[i]] = args[i+1]; break; case "width": case "height": case "align": case "vspace": case "hspace": case "class": case "title": case "accesskey": case "name": case "tabindex": ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1]; break; default: ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1]; } } ret.objAttrs["classid"] = classid; if (mimeType) ret.embedAttrs["type"] = mimeType; return ret; } I've contacted the seller w/ no reply & I'm hoping someone can poit me in the right direction.... I've attached the zip w/ files in it. Thanks all, Scott T [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/246107-testimonials-module-with-xml-php/ Share on other sites More sharing options...
Maq Posted August 31, 2011 Share Posted August 31, 2011 1) In the future, please place OR tags around your code. 2) That's a lot of code... - What did you to try and isolate the problem? To be honest, not many people are going to go through all the code. Show us the add() function for the testimonials class. It looks like that's where the actual writing to the XML file starts. Quote Link to comment https://forums.phpfreaks.com/topic/246107-testimonials-module-with-xml-php/#findComment-1263942 Share on other sites More sharing options...
smtamburrino Posted August 31, 2011 Author Share Posted August 31, 2011 Sorry bout that Maq! I'm new to phpfreaks & still quite green w/ php. I attached the whole script because I was not sure where to start w/ the problem. here is the PHP again. Do you think the version I'm running would make a difference? PHP4 or PHP5? <?php /** */ class Testimonials{ private $file; private $input; private $output; public function __construct($inputFile){ $this->file = $inputFile; } public function add($inputData){ $this->input = fopen($this->file,'r'); if(!$this->input){ throw new Exception('Can not open input file.'); } $currentFolder = dirname($this->file); $tempName = $currentFolder . 'temp.xml'; $outputFile =$currentFolder.'/output.xml'; $this->output = fopen($outputFile,'w'); if(!$this->output){ throw new Exception('Can not open output file.'); } #skip first line $firstLine = fgets($this->input); fputs($this->output,$firstLine); fputs($this->output,$inputData); $line = fgets($this->input); while (!feof($this->input)){ fputs($this->output,$line); $line = fgets($this->input); } fputs($this->output,$line); fclose($this->input); fclose($this->output); rename($outputFile,$this->file); echo "success=yes"; } } $name= $_POST["Name"]; $location= $_POST["Location"]; $age= $_POST["Age"]; $date= $_POST["Date"]; $full= $_POST["Full"]; $message='<message>'."\n".' <name>'.$name.'</name>'."\n".' <location>'.$location.'</location>'."\n".' <age>'.$age.'</age>'."\n".' <date>'.$date.'</date>'."\n".' <full>'.$full.'</full>'."\n".'</message>'."\n"; $test = new testimonials('./testimonials.xml'); $test->add($message); ?> Quote Link to comment https://forums.phpfreaks.com/topic/246107-testimonials-module-with-xml-php/#findComment-1263975 Share on other sites More sharing options...
smtamburrino Posted August 31, 2011 Author Share Posted August 31, 2011 OK thanks again Maq for the etiquette tips & advice. I resolved my issue by updating to PHP5.2 on GoDaddy server. I had to rename the php.ini file as well to php5.ini All is working WOOT! Quote Link to comment https://forums.phpfreaks.com/topic/246107-testimonials-module-with-xml-php/#findComment-1264007 Share on other sites More sharing options...
Maq Posted August 31, 2011 Share Posted August 31, 2011 OK thanks again Maq for the etiquette tips & advice. I resolved my issue by updating to PHP5.2 on GoDaddy server. I had to rename the php.ini file as well to php5.ini All is working WOOT! Interesting, glad you got it working. Quote Link to comment https://forums.phpfreaks.com/topic/246107-testimonials-module-with-xml-php/#findComment-1264012 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.