I've written a framework (it's been a year) which will render AS3 code as HTML5
I want to reach into a swf and parse the guts into my framework so that you can upload an AS3 swf and get the HTML5 equivalent back.
Any ideas on how to parse a swf/fla using php?
** edit **
As a reference, google does something similiar to this. However, swiffy only parses AS2 code.
** edit 2 **
For further clarification, I only want to be able to parse a swf for layout props and actionscript. I've got the rest figured out.
Take a look at SWFTools - that can dump the code out of SWFs apparently, and has source code, though you could use the command line utilities from PHP and parse the output to get the actionscript sections out. God knows what you will do with it then.
https://github.com/iborodikhin/php-swiffy/
use this lib and implement like this
require_once('php-swiffy-master/vendor/autoload.php');
$swiffy = new Swiffy\Client();
$html = $swiffy->convert("test.swf");
$myfile = fopen("test.html", "w");
if(!empty($html)){
fwrite($myfile, $html);
fclose($myfile);
}
Related
I want to convert any pdf,docx,doc file into html code using php. with same style as in pdf. I am not getting proper solution.
Config::set('pdftohtml.bin', 'C:/poppler-0.37/bin/pdftohtml.exe');
// change pdfinfo bin location
Config::set('pdfinfo.bin', 'C:/poppler-0.37/bin/pdfinfo.exe');
// initiate
$pdf = new Gufy\PdfToHtml\Pdf($item);
// convert to html and return it as [Dom Object](https://github.com/paquettg/php-html-parser)
$html = $pdf->html();
Not working for me.
I had a similar problem and i found a github that i used with word docs. It worked fairly good then but i havent tested it of late. try it.
https://github.com/benbalter/Convert-Word-Documents-to-HTML
I think that this post could help you in a first time. With this one, you'll be able to convert any pdf into HTML code using PHP.
After this, you can use the help provided by this post to convert .doc and .docx to PDF using PHP.
I think that you can now built a function for each document extension that you want to convert into HTML.
Good luck.
I've come across a web service which presents an API for converting documents. I haven't tested it very thoroughly but it does seem to produce decent results at converting Word to HTML:
https://cloudconvert.org/
My webpage allows users to select items from a dropdown list and has a table. Javascript prints out each dropdown-list-item (plus extra info that javascript pulls from the XML file) in a new table row that javascript creates.
I want to be able to write the table information to disk.
If I was using Javascript, I would use document.getElementByID("table") to parse through the nodes and put that info into variables that I could write. However, most documentation I find says Javascript is not used for writing to disk. So, I think I should use php.
What is the php equivalent of Javascript's 'document' object?
In Javascript I don't need to define any new objects to use it, I can use 'document' anytime.
I think in php I have to use new DOMDocument. and then load the html.
Most of the php examples show loadHTML(string) and loadHTMLFile();
I don't want to load HTML from a string that I write inside the tags.
And I don't want to load HTML from the .htm file because that's the original file and Javascript has changed the user's file based on their selections from the dropdown menu.
I want to access the elements of the current document using php.
So, how does php refer to the current document?
The page I'm working on is http://music.collwyncraig.info/hajimama/setlist.htm
I think your thoughts about the architecture are wrong. There is a way how the programming languages interact with each other.
php is a preprocessor and generates - what ever u want - usually html, containing javascript, css, and whatever...
javascript is a dynamic language that interacts in the generated html documents or calls by ajax other services that deliver html, javascript, css or whatever is needed
and html - that is document object that is displayed and can be modified during the runtime by javascript an styled by css, etc...
So when u call in your documents javascript functions - the basic php has already done its job.
Instead of printing all generated contents from php directly to the screen, you can store it first in a var.
For example:
$myContent = "<html><head>...</head><body><h1>Whatever...</h1></body>";
so with that you can do the following to print it on the screen:
print "myContent"; // and it is shown on the screen
or
$myFile = "testFile.html";
$fh = fopen($myFile, 'w') or die("can't open file");
$myContent = "<html><head>...</head><body><h1>Whatever...</h1></body>";
fwrite($fh, $myContent);
$myContent = "Whatever2";
fwrite($fh, $myContent);
fclose($fh);
So the contents of your file would be:
<html><head>...</head><body><h1>Whatever...</h1></body>Whatever2
This generated document can then be called by loadHTML or used in which way you
want.
This just as a hint into which direction you can think - there are quite multiple ways of solution - so without knowing more about what u really want - it is quite not easy to mention a proper solution.
$_SERVER['SCRIPT_NAME'] for the main file.
or
__FILE__ for the full path to the file where this was called.
PHP doesn't have any builtin' DOM Manipulator like jQuery - html output is usually generated through some template engine of your choice or manually.
If you want DOM manipulation like jQuery, you might want to try out PHPQuery
http://code.google.com/p/phpquery/
My fellow friend is building site in flash and he uses XML files to access data in Flash.
I want to build editable CMS so that client can edit stuff.
Now I don't' have any experience with XML.
I know PHP, HTML and Mysql very well.
So how can I change those already build XML files using Mysql and PHP?
Maybe going through
http://library.creativecow.net/articles/brimelow_lee/php_mysql/video-tutorial.php
will clear things for you.
Though, use it only to understand the concepts of XML and how it relates to mysql, php and swf. For real work look at libraries that deal with XML such as serializer mentioned in AvatarKava's answer.
Output the XML using PHP in exactly the same way the example XML file does and then put this at the top of your code:
header('Content-type: text/xml');
To create the XML file from the database just ouput the data the way you normally would adding XML tags in the right place. Eg:
<news>
<?
while($item = mysql_fetch_array($data)){
?>
<item>
<url><?=$item['url']; ?></url>
<title><?=$item['title']; ?></title>
</item>
}
?>
</news>
If you need more assistance, provide the XML file that was given to you with the flash file as a reference.
You probably should look at the PEAR XML Serializer Package. It makes it easy to convert a multi-dimensional array into XML.
Here's a decent tutorial: http://articles.sitepoint.com/article/xml-php-pear-xml_serializer
may be i am going to ask some stupid question but i don't have any idea about php
that's why i want to know it i never worked in php and now i have to do it so please provide me some useful tips,
i have XML file that is coming from a different URL and i want to save it on the server then i have to read it and extract it to a page in proper format and some modification in data.
You can use DOM
$dom = new DOMDocument();
$dom->load('http://www.example.com');
This would load the XML from the remote URL. You can then process it as needed. See my previous answers on various topics using DOM. To save the file to your server after your processed it, you use
$dom->save('filename.xml');
Loading the file with $dom->load() will only work if you have allow_url_fopen enabled in your php.ini. If not, you have to use cURL to download the remote file first.
Maybe this should be helpfull to you: http://www.php.net/manual/en/function.simplexml-load-file.php
If you're have dificulte to get the XML file from the remote host you can use combine with above simplexml-load-string
$path_to_xml = 'http://some.com/file.xml';
$xml = simplexml_load_string( file_get_content($path_to_xml) );
I have a lots (500ish) xml files from An old ASP and VBscript that was running on an old windows server. The user could click a link to download the requested xml file, or click a link to view how the xml file will look, once its imported into their system...
If clicked to view the output, this opened a popup window were the xml filename is passed via URL & using the xslt template file this would display the output.
example url = /transform.php?action=transform&xmlProtocol=AC_Audiology.xml
Now were using PHP5 im trying to get something that resembles the same output.
we started looking into xslt_create(); but this is an old function from php4
I'm looking for the best method to deploy this.
The main php page should check & capture the $_GET['xmlProtocol'] value.
pass this to the xslt template page as data;
were it will be output in html.
a general point in the right direction would be great!
You can find the documentation (+examples) of the "new" XSL(T) extension at http://docs.php.net/xsl.
php
// Transform.php
if(isset($_GET['action']) && $_GET['action'] == 'transform') {
// obviously you would never trust the input and would validate first
$xml_file = AFunctionValidateAndGetPathToFile($_GET['xmlProtocol']);
// Load up the XML File
$xmlDoc = new DOMDocument;
$xmlDoc->load($xml_file);
// Load up the XSL file
$xslDoc = new DomDocument;
$xslDoc->load("xsl_template_file.xsl");
$xsl = new XSLTProcessor;
$xsl->importStyleSheet($xslDoc);
// apply the transformation
echo $xsl->transformToXml($xmlDoc);
}
I had a similar problem about two years ago. I was using PHP5 but needed to use xslt_create(); or an equivalent. Ultimately, I switched to PHP4.
You can probably set your server to use PHP5 everywhere except for files in a certain folder. I believe that's what I did so I could process XSL files using PHP4 but the majority of the site still used PHP5.
It's possible that things have changed in the last two years and PHP5 has better support for something like xslt_create(); ---- I haven't been following recent changes.
Hope this helps!