This question is in reference to:
Free (preferably) PHP RTF to HTML converter?
I'm trying to execute that last line of code in my php:
exec(rtf2htm file.rtf file.html)
I understand what parameters need to go within the parentheses, I just do not know how to write it. I've looked at multiple examples along with the php documentation and still I remain confused, so could someone show me how it is written? rtf2htm refers to a PHP file which converts RTF to HTML.
Ultimately what I am trying to do is convert the content of numerous RTF docs to HTML, maintaining the formatting, while not creating tags such as<head> or <body> which programs like Word or TextEdit generate when converting to HTML.
rtf2htm is not a php script, it is a program installed on the server. exec() is used to call external applications.
EDIT: After looking up this script, it seems that it is indeed a php script. But it has been coded to be usable from the command line only.
This should work:
<?php
exec('php /path/to/rtf2htm /path/to/source.rtf /path/to/output.html');
?>
Related
I have this situation trying to disable a sequence into a .php file (the black commented lines, back-to-top text button);
I've read about block commenting in notepad ++ and setting the language of the file but the comment it looks like is not implemented properly.
What I've done :
-File / Open the .php file,
(already it looks like it is viewed in php language judging by the colors)
-Selection between 355-359 lines and Block Comment (ctrl+shift+Q).After that, I've added the text but it doesn't look like the other existing comments.
Any thoughts? Thanks,
PHP comments only work when you are inside PHP mode (between <?php and ?>).
When you are outputting HTML, you need HTML comments which take the form <!-- comment which does not include two adjacent hyphens -->.
The PHP within an HTML comment will still execute and the results will be output to the browser. It looks like your PHP only outputs data and doesn't do any significant processing, so that will probably be sufficient. You might, especially in other cases, be better off simply deleting the code and then restoring it from your version control system's history later.
For that part of code you should comment using:
<!-- your comment -->
As you are using html (you closed the part of your php code by ?> )
I m using the php function file_get_contents to parse a php file. But it seems that as soon as it is reading the php tags the file_get_contents is malfunctioning.
I checked the function with a normal text file, its functioning perfectly. But even if it finds php tags in a text file, the file is being half read. How can i find a way to get the full contents.
Is the file local? Or are you trying to get a remote file? How did you check that the content is not read? Echoing it to a browser might trick you because of the < char in <?php
Use htmlspecialchars or <pre> to view the whole text. Or just look at the source of the page.
I am using PEAR text_diff class to get comparison of text. It works correct for plain text, but when I try to compare text with HTML tags, It gives wrong result
is there any way to compare two HTML blocks and in result display text that pre-serv its HTML and show differences like svn
In my experience, these two are fantastic:
https://github.com/cygri/htmldiff (Python)
http://www.w3.org/People/Bos/#jpegxmp (C, must be compiled)
Yes, none of the programs are written in plain PHP. You just run them via PHP:
// Python script:
$html_diff = shell_exec ('python /path/to/htmldiff version1.html version2.html');
// C program:
$html_diff = shell_exec ('/path/to/htmldiff --start-delete="<span class=\'delete\'>" --end-delete="</span>" --start-insert="<span class=\'insert\'>" --end-insert="</span>" version1.html version2.html');
Since they aren't written in PHP, you can enjoy the incredible high speed :)
I'm not sure which OS you're on, but I always use Meld on Ubuntu for diff:ing non-versioned files. It doesn't have any problems diffing HTML code (or anything else afaik):
http://meldmerge.org/
You can do this right in javascript itself. Check out google-diff-match-patch.
Diff demo here.
I'm trying to get Perl to read an offline pcap file and save the output into XML file so I can work with it in PHP.
I can't use PHP because its not my server but I can Perl. So my aim is to convert the PCAP file into XML so I have fun with it.
I have no idea where to start and have looked at the Perl Net::Pcap but I just don't understand the language.
Any ideas on what I should do?
Thank-you
Paul
Using Net::Pcap is a decent idea, although figuring out the format you'd want to write out the capture in doesn't seem all that easy. My favourite solution would be to use tshark (the command line version of wireshark) like so:
tshark -r $dmp_filename -Tpsml
This would give you the output in a XML standard format.
Of course if you don't have tshark, not very helpful...
I want to create a PHP script that grabs the content of a website. So let's say it grabs all the source code for that website and I say which lines of code I need.
Is there a function in PHP that allows you too do this or is it impossible?
Disclaimer: I'm not going to use this for any illegal purposes at all and not asking you too write any code, just tell me if its possible and if you can how I'd go about doing it. Also I'm just asking in general, not for any specific reason. Thanks! :)
file('http://the.url.com') returns an array of lines from a url.
so for the 24th line do this:
$lines = file('http://www.whatever.com');
echo $lines[23];
This sounds like a horrible idea, but here we go:
Use file_get_contents() to get the file. You cannot get the source if the web server first processes it, so you may need to use an extension like .txt. Unless you password protect the file, obviously anybody can get it.
Use explode() with the \n delimiter to split the source code into lines.
Use array_slice() to get the lines you need.
eval() the code.
Note: if you just want the HTML output, then ignore the bit about the source in step 1 and obviously you can skip the whole eval() thing.