| Posted By |
Discussion Topic: Quickie?
-- page:
1
2
|
|
glydrydr |
01-06-2006 @ 9:39 AM |
|
|
New Member
Posts: 6
Joined: Jan 2006
|
Anybody convert this...or start me in the right direction??? <?php $filename = "test.xml"; $raw_xml = file_get_contents("php://input"); print $raw_xml; $fp = fopen($filename, "w"); fwrite($fp, $raw_xml); fclose($fp); ?> TIA
|
Sivart |
01-06-2006 @ 9:58 AM |
|
|
Senior Member
Posts: 235
Joined: Apr 2004
|
<?php $filename = "test.xml"; $raw_xml = file_get_contents("php://input"); print $raw_xml; for this, i believe this is correct ----------------------------------------------- <cfset filename = "test.xml"> <cfset raw_xml = file_get_contents("php://input")> <cfoutput>#raw_xml#</cfoutput>
Thanks - Sivart
|
glydrydr |
01-06-2006 @ 10:00 AM |
|
|
New Member
Posts: 6
Joined: Jan 2006
|
Thanks Sivart for your prompt reply....i'll try it and let you know glydrydr
|
Webmaster |
01-06-2006 @ 10:27 AM |
|
|
Administrator
Posts: 4533
Joined: Jan 2002
|
<cfset raw_xml = file_get_contents("php://input")> ???
Pablo Varando Senior Application Architect EasyCFM.COM, LLC. 904.483.1457 \\ mobile webmaster@easycfm.com \\email
|
Sivart |
01-06-2006 @ 10:39 AM |
|
|
Senior Member
Posts: 235
Joined: Apr 2004
|
I prob should have left this alone. I know little php as you can tell. Thought those were just setting variables and displaying it.
Thanks - Sivart
|
glydrydr |
01-06-2006 @ 10:40 AM |
|
|
New Member
Posts: 6
Joined: Jan 2006
|
don't know what to tell you about this "php://input". I got an excellent example of a xml news ticker with editorzipped files. However, I must convert the php to cfm before I can use it on our server the $fp=fopen....seems similar to cffile
|
Webmaster |
01-06-2006 @ 11:36 AM |
|
|
Administrator
Posts: 4533
Joined: Jan 2002
|
No worries looks to me like you are simply trying to read a XML file. <cfset tFileName = "test.xml"> <cfset tXML = XMLParse("#ExpandPath(".")#\#tFileName#")> <cfdump var="#tXML#"> Pablo Varando Senior Application Architect EasyCFM.COM, LLC. 904.483.1457 \\ mobile webmaster@easycfm.com \\email
This message was edited by Webmaster on 1-6-06 @ 11:38 AM
|
glydrydr |
01-06-2006 @ 11:48 AM |
|
|
New Member
Posts: 6
Joined: Jan 2006
|
I believe that the xml file is read and updated(from the editor...... var xml_file = "xet.xml";// var save_script = "xet.php";)... code from xet.swi onLoad () { title=""; link=""; n=0; a=0; description=""; entries=0; title_element=""; link_element=""; description_element=""; max_news_items=10; title_txt=""; link_txt=""; description_txt=""; content_txt=""; } onFrame (1) { GetTitleText = function (news_xml, item_index){ var entries = news_xml.firstChild.childNodes; var title_element = entries[item_index].firstChild.firstChild; return(title_element.nodeValue);}; GetlinkText = function (news_xml, item_index){ var entries = news_xml.firstChild.childNodes; var link_element = entries[item_index].firstChild.nextSibling.firstChild; return(link_element.nodeValue);}; GetpubDateText = function (news_xml, item_index){ var entries = news_xml.firstChild.childNodes; var pubDate_element = entries[item_index].firstChild.nextSibling.nextSibling.firstChild; return(pubDate_element.nodeValue);}; GetdescriptionText = function (news_xml, item_index){ var entries = news_xml.firstChild.childNodes; var description_element = entries[item_index].firstChild.nextSibling.nextSibling.nextSibling.firstChild; return(description_element.nodeValue);}; Getitem = function (news_xml, index){ var entries = news_xml.firstChild.childNodes; return(entries[index]);}; GetNewsCount = function (news_xml){ var entries = news_xml.firstChild.childNodes; return(entries.length);}; ShowNews = function (news_xml){ if (!news_xml.firstChild.hasChildNodes()){ content_txt.text = "No news available."; return(0); } // end if var entries = news_xml.firstChild.childNodes; _root.a=entries.length; content_txt.text = ""; var i = 0; while (i < entries.length) { var title = GetTitleText(news_xml, i); var link = GetlinkText(news_xml, i); var pubDate = GetpubDateText(news_xml, i); var description = GetdescriptionText(news_xml, i); content_txt = content_txt + " ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯<br>"; content_txt = content_txt + ("<b>" + title + "</b><br>"); content_txt = content_txt + link + "<br>"; content_txt = content_txt + (pubDate + "<br>"); content_txt = content_txt + (description + "<br><br><br>"); i++; } // end while }; AddNewsitem = function (news_xml, title, link, pubDate, description){ var itemNode = news_xml.createElement("item"); if (title == "") { title = "(none)"; } // end if var titleNode = news_xml.createElement("title"); var titleText = news_xml.createTextNode(title); titleNode.appendChild(titleText); itemNode.appendChild(titleNode); if (link == ""){ link = "(none)"; } // end if var linkNode = news_xml.createElement("link"); var linkText = news_xml.createTextNode(link); linkNode.appendChild(linkText); itemNode.appendChild(linkNode); if (pubDate == ""){ pubDate = "(none)"; } // end if var pubDateNode = news_xml.createElement("pubDate"); var pubDateText = news_xml.createTextNode(pubDate); pubDateNode.appendChild(pubDateText); itemNode.appendChild(pubDateNode); if (description == "") { description = "(none)"; } // end if var descriptionNode = news_xml.createElement("description"); var descriptionText = news_xml.createTextNode(description); descriptionNode.appendChild(descriptionText); itemNode.appendChild(descriptionNode); if (news_xml.firstChild.hasChildNodes()) { news_xml.firstChild.insertBefore(itemNode, news_xml.firstChild.firstChild); } else { news_xml.firstChild.appendChild(itemNode); } // end if while (GetNewsCount(news_xml) > max_news_items) { news_xml.firstChild.lastChild.removeNode(); } // end while }; EditNewsitem = function (news_xml, node_index, title, link, pubDate, description) { var item = Getitem(news_xml, node_index); if (title == "" && description == "" && link == "" && pubDate == "") { item.removeNode(); return(0); } else { if (title == ""){ title = "(none)"; } // end if if (link == ""){ link = "(none)"; } // end if if (pubDate == ""){ pubDate = "(none)"; } // end if if (description == ""){ description = "(none)"; } // end if } // end if // item.attributes.date = new Date().toString(); var titleTextNode = item.firstChild.firstChild; var linkTextNode = item.firstChild.nextSibling.firstChild; var pubDateTextNode = item.firstChild.nextSibling.nextSibling.firstChild; var descriptionTextNode = item.firstChild.nextSibling.nextSibling.nextSibling.firstChild; titleTextNode.nodeValue = title; linkTextNode.nodeValue = link; pubDateTextNode.nodeValue = pubDate; descriptionTextNode.nodeValue = description; }; SaveNews = function (news_xml) { content_txt = "<i>Saving and Loading...</i><br>"; news_xml.xmlDecl = ""; news_xml.sendAndLoad(save_script, news_xml); }; RefreshNews = function (news_xml) { content_txt = "<i>Loading...</i><br>"; news_xml.load(xml_file + "?" + new Date().getTime()); }; var xml_file = "xet.xml";// var save_script = "xet.php"; var news_xml = new XML(); news_xml.ignoreWhite = true; news_xml.contentType = "text/xml"; news_xml.onLoad = function (success) { if (success) { ShowNews(this); } else { content_txt.text = "Error loading XML file"; } // end if }; RefreshNews(news_xml); } onFrame (2) { stop(); refresh_btn.onRelease = function () { RefreshNews(news_xml); }; edit_btn.onRelease = function () { if (news_xml.loaded) { nextFrame(); } // end if }; } onFrame (3) { var news_index = 0; UpdateIndexText = function () { if (!news_index) { index_txt.text = "*"; title_txt = "[ Enter new title ]"; link_txt = "[ Enter new link ]"; pubDate_txt = new Date().toString(); description_txt = "[ Enter new content ]"; } else { index_txt.text = news_index; title_txt = GetTitleText(news_xml, news_index - 1); link_txt = GetlinkText(news_xml, news_index - 1); pubDate_txt = GetpubDateText(news_xml, news_index - 1); description_txt = GetdescriptionText(news_xml, news_index - 1); } // end if } ; save_btn.onRelease = function () { if (!news_index) { AddNewsitem(news_xml, title_txt, link_txt, pubDate_txt, description_txt); } else { EditNewsitem(news_xml, news_index - 1, title_txt, link_txt, pubDate_txt, description_txt); } // end if prevFrame(); SaveNews(news_xml); }; cancel_btn.onRelease = function () { prevFrame(); ShowNews(news_xml); }; next_btn.onRelease = function () { news_index++; if (news_index > GetNewsCount(news_xml)) { news_index = 0; } // end if UpdateIndexText(); }; prev_btn.onRelease = function () { news_index--; if (news_index < 0) { news_index = GetNewsCount(news_xml); } // end if UpdateIndexText(); }; UpdateIndexText(); } onFrame (4) { stop(); }
This message was edited by glydrydr on 1-6-06 @ 11:53 AM
|
glydrydr |
01-30-2006 @ 10:44 AM |
|
|
New Member
Posts: 6
Joined: Jan 2006
|
any info on this part $fp = fopen($filename, "w"); fwrite($fp, $raw_xml); fclose($fp); ?> Sorry for all the actionscript but I wanted to show that there is a read and write going on......
|
ghetto-pixel |
02-26-2006 @ 9:45 PM |
|
|
New Member
Posts: 20
Joined: Feb 2006
|
Ok, what I got from your script is, your filtering input from somewhere, where this input is comming from i dont know because you didnt specify that for us, and then you are outputing it removing any sql based injection methods using PHP://INPUT filter, and then writing it to test.xml as raw data since it should be pre-formatted xml (im assuming).
I can give you an entire replacement script for what your wanting, but you are using an sql injection prevention filter provided in PHP5 I need to know what PHP://input is supposed to be filtering if you dont mind because without that somone cant provide you with anything .
Here is a basic example where I do it with a form field called raw_xml.
<CFSCRIPT> FUNCTION ANTI_INJECTION(INPUT) { INJECTIONLIST="-- ,'"; REPLACEMENTLIST="#chr(38)##chr(35)##chr(52)##chr(53)##chr(59)##chr(38)##chr(35)##chr(52)##chr(53)##chr(59)# , #chr(38)##chr(35)##chr(51)##chr(57)##chr(59)#"; INPUT=TRIM(REPLACELIST(INPUT,INJECTIONLIST,REPLACEMENTLIST)); RETURN INPUT; } </CFSCRIPT> <CFSET FILE=EXPANDPATH("TEST.XML")> <CFOUTPUT>#ANTI_INJECTION(FORM.RAW_XML)#</CFOUTPUT> <CFFILE ACTION="WRITE" FILE="#FILE#" OUTPUT="#ANTI_INJECTION(FORM.RAW_XML)#" MODE="666" ATTRIBUTES="NORMAL" CHARSET="UTF-8">
Basically this is the CFML version of what you are doing, but again need to know where PHP://input is comming from before I can filter it for you, I could pull PHP://input for Form fields, cookies and the whole 9 yards. Unlike PHP coldfusion uses scopes cookie.variablename form.fieldname session.variablename ---------- There are Ghetto Pixels everywhere, I just keep mine bundled in one place. [http://www.ghettopixel.com]
This message was edited by ghetto-pixel on 2-26-06 @ 9:46 PM
|