[PHP] Parsing PHP variables in XML document
Hi, I have the following problem. I want to import data into my site via PHP XML Parser, but I also want to include php string variables into the .xml file and when the xml file is parsed the variables are replaced whit the corresponding string. So far all my attempts have been unsuccessful. Here is the parser i have used ?php class XMLParser { var $filename; var $xml; var $data; function XMLParser($xml_file) { $this-filename = $xml_file; $this-xml = xml_parser_create(); xml_set_object($this-xml, $this); xml_set_element_handler($this-xml, 'startHandler', 'endHandler'); xml_set_character_data_handler($this-xml, 'dataHandler'); $this-parse($xml_file); } function parse($xml_file) { if (!($fp = fopen($xml_file, 'r'))) { die('Cannot open XML data file: '.$xml_file); return false; } $bytes_to_parse = 512; while ($data = fread($fp, $bytes_to_parse)) { $parse = xml_parse($this-xml, $data, feof($fp)); if (!$parse) { die(sprintf(XML error: %s at line %d, xml_error_string(xml_get_error_code($this-xml)), xml_get_current_line_number($this-xml))); xml_parser_free($this-xml ); } } return true; } function startHandler($parser, $name, $attributes) { $data['name'] = $name; if ($attributes) { $data['attributes'] = $attributes; } $this-data[] = $data; } function dataHandler($parser, $data) { if ($data = trim($data)) { $index = count($this-data) - 1; // begin multi-line bug fix (use the .= operator) $this-data[$index]['content'] .= $data; // end multi-line bug fix } } function endHandler($parser, $name) { if (count($this-data) 1) { $data = array_pop($this-data); $index = count($this-data) - 1; $this-data[$index]['child'][] = $data; } } } $url = 'data.xml'; $myFile = new XMLParser($url); echo PRE; print_r($myFile-data); echo /PRE; $foo3 = foo3; ? here is a sample XML file ?xml version='1.0'? !DOCTYPE chapter SYSTEM /just/a/test.dtd [ !ENTITY plainEntity FOO entity !ENTITY systemEntity SYSTEM xmltest2.xml ] document data foo1 /data data foo2 /data data ?php echo $foo3; ? /data data foo4 /data data foo5 /data /document and what I get is: Array ( [0] = Array ( [name] = DOCUMENT [child] = Array ( [0] = Array ( [name] = DATA [content] = foo1 ) [1] = Array ( [name] = DATA [content] = foo2 ) [2] = Array ( [name] = DATA ) [3] = Array ( [name] = DATA [content] = foo4 ) [4] = Array ( [name] = DATA [content] = foo5 ) ) ) ) So I want $myFile-data[0][child][2][content] to be equal to $foo3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing php in html with IIS
Eric Lindsey wrote: How do I configure my IIS server to parse a specific .html file for php code? I know how to do this on apache, but windows scares me :-) So far, all the answers assume he wants to have *ALL* .html files parsed as PHP. He only wants *ONE* *SPECIFIC* .html file parsed. In IIS. I'm no IIS expert, but I don't think it's flexible enough to do that. Microsoft is so borg-like. Anyway, you might try mixing the answers you've got with different directories or even the IIS version of VirtualHosts to narrow things down to just the one .html file. If all else fails, install Apache :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Parsing php in html with IIS
apache will run on windows so you shouldnt fear:) Anyways go into the properties tab of the IIS web server, you need to register .php as a valid file extension, there is a list of all file extensions under that tab (its one of the tabs in there i cant remember). Add in .php . If you've already mapped the php .dll or whatever to parse php files in that same IIS properties area you should be good to go after adding in that extension map.. phpninja -Original Message- From: Eric Lindsey [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 15, 2004 2:02 PM To: [EMAIL PROTECTED] Subject: [PHP] Parsing php in html with IIS Gents, How do I configure my IIS server to parse a specific .html file for php code? I know how to do this on apache, but windows scares me :-) THANKS! Eric Lindsey Colorado Information Technologies Inc. http://www.coinfotech.com http://www.coinfotech.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing php in html with IIS
Gents, How do I configure my IIS server to parse a specific .html file for php code? I know how to do this on apache, but windows scares me :-) THANKS! Eric Lindsey Colorado Information Technologies Inc. http://www.coinfotech.com http://www.coinfotech.com/
Re: [PHP] Parsing php in html with IIS
On Wed, 15 Dec 2004 15:02:08 -0700, Eric Lindsey [EMAIL PROTECTED] wrote: How do I configure my IIS server to parse a specific .html file for php code? I know how to do this on apache, but windows scares me :-) http://www.php.net/manual/en/install.windows.iis.php -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing PHP
On Saturday, July 26, 2003, at 03:06 AM, Nikhil G. Daddikar wrote: I am using PHP to develop and web app. The app also has a scripting language for the *end user*. I was thinking if I could expose a very simple subset of PHP to them (foreach, if-then-else, variable assignments and comments) and then simply eval it. But I don't want them to use calls like system or do infinite loops etc. that will screw up the system. I was thinking if I had a PHPparser that returns tokens, then I can eliminate the call to unwanted funtions, etc. Any ideas on how I should proceed? use smarty http://smarty.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing PHP
I am using PHP to develop and web app. The app also has a scripting language for the *end user*. I was thinking if I could expose a very simple subset of PHP to them (foreach, if-then-else, variable assignments and comments) and then simply eval it. But I don't want them to use calls like system or do infinite loops etc. that will screw up the system. I was thinking if I had a PHPparser that returns tokens, then I can eliminate the call to unwanted funtions, etc. Any ideas on how I should proceed? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing PHP
There is the tokenizer extension... http://www.php.net/tokenizer This might give you a good start. -- Peter James [EMAIL PROTECTED] php|architect The Magazine for PHP Professionals http://www.phparch.com - Original Message - From: Nikhil G. Daddikar [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, July 26, 2003 1:06 AM Subject: [PHP] Parsing PHP I am using PHP to develop and web app. The app also has a scripting language for the *end user*. I was thinking if I could expose a very simple subset of PHP to them (foreach, if-then-else, variable assignments and comments) and then simply eval it. But I don't want them to use calls like system or do infinite loops etc. that will screw up the system. I was thinking if I had a PHPparser that returns tokens, then I can eliminate the call to unwanted funtions, etc. Any ideas on how I should proceed? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parsing PHP to create HTML only page
Hi All, I'm really just looking for some advice! I am looking to build a website which users will be able to logon and have a template based website generated for them, the output will have to be HTML so that these sites can be indexed by search engines, it will also have to change Apache conf files and DNS records. Perhaps someone knows of a similar open source project or could point me in the right direction. My idea is to create the site using PHP, making use of a number of different templates which will be PHP pages that have the same includes i.e Navigation, Header, Footer, Content etc. Once the pages have been generated (view source) all you have is the HTML, this is what I would like to achieve, but I'm unsure how to pass the pages to give me only HTML from the databases. Any help or advice would be greatly appreciated. -- Tony Burgess -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing PHP to create HTML only page
You can use phpnuke or similar to achieve this, all you need is to decide which database to use (you may use Host: header, or directory). But sure, this won't change your dns records or Apache conf files. Tony Burgess wrote: Hi All, I'm really just looking for some advice! I am looking to build a website which users will be able to logon and have a template based website generated for them, the output will have to be HTML so that these sites can be indexed by search engines, it will also have to change Apache conf files and DNS records. Perhaps someone knows of a similar open source project or could point me in the right direction. My idea is to create the site using PHP, making use of a number of different templates which will be PHP pages that have the same includes i.e Navigation, Header, Footer, Content etc. Once the pages have been generated (view source) all you have is the HTML, this is what I would like to achieve, but I'm unsure how to pass the pages to give me only HTML from the databases. Any help or advice would be greatly appreciated. -- Tony Burgess -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing PHP output
Dear folks, Has anyone ever been able to get a CGI to produce valid PHP output?? Whatever I do, my browser ALWAYS wants to open or save the non-parsed PHP text produced by the CGI file. And yes, I have set the proper ExecCGI and PHP entries in my vhosts.conf; and yes, I restarted the server. Basically, I open an existing php file (in a Perl CGI), and output its contents again to the Apache server. The CGI starts with sending this header: print Content-type: application/x-httpd-php\n\n; Then I output the text. But, no matter what I do, it will not parse the PHP code. I do not understand this. Regular PHP files in that dir work fine. There is, as far as I can see, no reason why this should not work. And the PHP file really needs to be generated from the CGI, as it needs to run as a specific user. Anyway, any help would be much appreciated, - Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Parsing PHP output
The problem is that you are sending this output to the browser and not the server. You can do this with XML because IE and Netscape have XML parsers built-in. You should create a form that will catch the data from CGI then handle it on the server. There might be other work arounds as well...however, I have only played with the XML stuff... Thanks, Ray Hunter -Original Message- From: Mark [mailto:[EMAIL PROTECTED]] Sent: Sunday, May 26, 2002 12:07 PM To: [EMAIL PROTECTED] Subject: [PHP] Parsing PHP output Dear folks, Has anyone ever been able to get a CGI to produce valid PHP output?? Whatever I do, my browser ALWAYS wants to open or save the non-parsed PHP text produced by the CGI file. And yes, I have set the proper ExecCGI and PHP entries in my vhosts.conf; and yes, I restarted the server. Basically, I open an existing php file (in a Perl CGI), and output its contents again to the Apache server. The CGI starts with sending this header: print Content-type: application/x-httpd-php\n\n; Then I output the text. But, no matter what I do, it will not parse the PHP code. I do not understand this. Regular PHP files in that dir work fine. There is, as far as I can see, no reason why this should not work. And the PHP file really needs to be generated from the CGI, as it needs to run as a specific user. Anyway, any help would be much appreciated, - Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parsing .php files not only under root dir
I would like the server on win2K to parse .php files whereever on the computer they are located. The server should run as service. What server allows this? Helmut