PHP: how to create SWF (Ming or another solution)? - php

I wish to create SWF (Flash) files with PHP but what is the best option for that nowadays? When I use Google I find all kinds of old pages about this subject, but not much is happening in this field lately, it seems....
Ming is no longer part of PHP 5.3, and I can't figure out how to install it with PECL.
('pecl install ming' doesn't work... but neither does any pecl package I try, so I guess I do it all wrong...)
On http://pecl.php.net/package/ming it says the package has been superseded. My broken english tells me that means another package is now a better solution? But which package then?
Is anybody actually using PHP to create SWF's or is this a bad idea anyway?

Depending on what what the final swf should contain there are a few options:
get libming running with your php installation
swfmill - if you need fonts or simple images embedded into a swf (xml -> swf)
mxmlc - official free compiler from Adobe, takes ActionScript3 or Flex Input if you need more complex stuff (as3 / mxml -> swf)
Haxe - similar approach as mxmlc, uses Haxe instead of ActionScript, very fast (hx -> swf)
Sam Haxe - similar to swfmill, written in Haxe (xml -> swf)

There are number of utilities that can create SWFs from various source formats: flex, haxe, laszlo etc. You could generate such a source (e.g. xml) in php on the fly and invoke a compiler via exec to produce an swf.

You just want to invoke the mxmlc compiler on the server, there's a command line for it. We did this recently for a project where we dynamically create a .swf file every time a user uploads a font, the .swf embeds that font and then the web service returns a path to the generated .swf which our parent .swf then loads in.

Related

PHP as independent application ( binary, compile, pack, no php on host )

If I would like to distribute PHP application with installer(package system of OS) how should I proceed? I don't want PHP files to be there, just working application, so when I type 'app' into console, it ends up being launching application, without need to install PHP on system(no php installation on host required). I would also like the application to have patch-able byte-code, so it's in parts, loaded when needed and only part needs to be replaced on update.
What I would do now is following:
->Compile PHP with extensions for specific platform.
->Make binary application which launches '/full/php app' when app is launched.
->Pack it in installer in a way, that there would be binary added to path when added, launching specific installation of PHP which is alongside the app with argument of start point->App would be running.
Problem is:
Maybe I don't want my PHP files to be exposed(in application, there will be available source anyway) is there some ready made stuff to do this? Is there some better way than I proposed?
Alternative: Modifying OP Cache to work with "packing" application to deliver byte codes to modified OP Cache which just reads the cache.
My suggestion would be a tiny tool I just finished, for almost exactly the same problem. (Oh yes I tried all the others but they're old and rusty, sometimes they're stuck with 4.x syntax, have no support, have no proper documentation, etc)
So here's RapidEXE:
http://deneskellner.com/sw/rapidexe
In the classical way, it's not a really-real compiler, just a glorified packer, but does exactly what you need: the output exe will be standalone, carrying everything with it and transparently building an ad-hoc runtime environment. Don't worry, it all happens very fast.
It uses PHP 7.2 / Win64 by default but has 5.x too, for XP compatibility.
It's freeware, obviously. (MIT License.)
(Just telling this because I don't want anyone to think I'm advertising or something. I just took a few minutes to read the guidelines about own-product answers and I'm trying to stay within the Code of the Jedi here.)
However...
I would also like the application to have patch-able byte-code, so it's in parts, loaded when needed and only part needs to be replaced on update.
It's easier to recompile the exe. You can extract the payload pieces of course but the source pack is one big zip; there seems to be no real advantage of handling it separately. Recompiling a project is just one command.
Maybe I don't want my PHP files to be exposed(in application, there will be available source anyway)
In this case, the exe contains your source compressed but eventually they get extracted into a temp folder. They're deleted immediately after run but, well, this is no protection whatsoever. Obfuscation seems to be the only viable option.
If something goes wrong, feel free to comment or drop me a line on developer-at-deneskellner-dot-com. (I mean, I just finished it, it's brand new, it may misbehave so consider it something like a beta for now.)
Happy compiling!
PHP doesn't do that natively, but here are a few ideas:
Self-extracting archive
Many archival programs allow you to create a self-extracting archive and some even allow to run a program after extraction. Configure it so that it extracts php.exe and all your code to a temp folder and then runs ir from there; deleting after the script has complete.
Transpilers/compilers
There's the old HPHC which translates PHP code to C++, and its wikipedia age also contains links to other, similar projects. Perhaps you can take advantage of those.
Modified PHP
PHP itself is opensource. You should be able to modify it withot too much difficulty to take the source code from another location, like some resource compiled directly inside the php.exe.
Use Zend Guard tool that compiles and converts the plain-text PHP scripts into a platform-independent binary format known as a 'Zend Intermediate Code' file. These encoded binary files can then be distributed instead of the plain text PHP. Zend Guard loaders are available for Windows and Linux platform that enables PHP to run the scripts encoded by Zend Guard.
Refer to http://www.zend.com/en/products/zend-guard
I would like to add another answer for anyone who might be Googling for answers.
Peach Pie compiler/runtime
There is an alternative method to run (and build apps from) .php source codes, without using the standard php.exe runtime. The solution is based on C#/.NET and is actually able to compile php source files to .NET bytecode.
This allows you to distribute your program without exposing its source code.
You can learn more about the project at:
https://www.peachpie.io/
You've got 3 overlapping questions.
1. Can I create a stand-alone executable from a PHP application?
Answered in this question. TL;DR: yes, but it's tricky, and many of the tools you might use are semi-abandoned.
2. Can I package my executable for distribution on client machines?
Yes, though it depends on how you answer question 1. If you use the .Net compiler, your options are different to the C++ option.
3. Can I protect my source code once I've created the application?
Again, depends on how you answer question 1. Many compilers include an "obfuscator" option which makes it hard to make sense of any information you get from decompiling the app. However, a determined attacker can probably get through that (this is why software piracy is possible).

Minor adjustments on a PDF file with PHP

What I'd like to do
I'd like to allow a user to download a dynamically generated pdf file (certificate). I was thinking of creating a pdf template and just write the user's name on it with PHP, that's the only thing that will be dynamic about this.
How I'd like to do it
Since the application is for a client and I have no idea on what server will he use it I'd like to know if there are ways of achieving this without any extra extensions or whatsoever to be installed on the server. I can assume he has PHP > 5.
Basically read the template pdf and write a string to it then save it to be able to offer for download, all this with PHP?
doing this with pure php on your own will get very messy, so i recommend using FPDF in combination with FPDI (to open your templates). both can easily be added to your projects sources, so you don't need to install any extensions (unless you want to compress your PDFs - in that case you'll need zlib installed).

I want to write multiple images to an odt file either in python or php

I want to write multiple image files to a odt file. I will be specifying a dir and the script will take it from there thru a loop. But where do i start? I have never done anything like this before!
I found this python code, which can convert html 2 python... so we can parse an html first and then call this one. But there is no reference on how to use this.
html2odt code
Atlast I found a PHP way to write odt direct! Its well documented.
http://www.odtphp.com/
I have also written a complete practical solution in php. You can upload multiple images and get the odt document generated.
The code is hosted at http://code.google.com/p/images2odt/
The first post is done here.
For anyone wanting to use the Python code will need a Python interpreter version 2.6. It might also work with version 2.7. It's mainly used in Linux but there are Windows and Mac versions as well. You will also need the files listed in the from and import statements. These files are in some of the other folders. It looks like it is a part of a much bigger Linux package. One last thing, Python scripts usually takes their arguments from a command line.
Additional info:
I looked over the setup.py file and it told me that this is an API library for open documents called odfpy. The version is 0.9.2. The link it has for the documentation is broken. A google search for odfpy came up with a place to download a more recent version (0.9.4) in a tarbell here:
http://pypi.python.org/pypi/odfpy
The documentation can be found here in an Open Office document:
https://joinup.ec.europa.eu/software/odfpy/document/api-odfpyodt

Finding latest release links on website for C++ Application

Basically I have written a game plugin that will allow server admins to update their administration tools from within game rather than having to go download it and install it. The releases are updated regularly, and the beta versions are nightly builds.
I am trying to find a way to grab the links from the website, but I cannot think of anyway to do this off of the top of my head. Was hoping someone here might be able to suggest something that would work.
http://www.sourcemod.net/snapshots.php
Thats the website, basically I am trying to grab the links for the latest stable branch, and latest development branch.
The solution is simple and can be broken down into a few steps:
Fetching the links & files: Use cURL/cURLpp or Poco C++. They are easy but you may spend a few hours to learn :)
Processing/Extracting the links: Use TidyHTML to make sure the HTML is converted to valid XHTML and use XPath to extract the links. Can use libxml2 & libxslt. I'd prefer Qt C++
Fetch the extracted links and save them to pre-defined paths. Boost Filesystem may ease your task with file system.
Note that if I were to do this (well, I've done this before), I'd use only Qt C++ as it provides everything I need. Btw, Qt C++ has a dead simple way to send GET/POST requests & fetch files :) Good luck!
EDIT:
Qt C++ XML also provides CSS-like selectors which avoids you using any other libraries: http://doc.trolltech.com/4.6/qt4-6-intro.html#dom-access-api
In short: Just go for Nokia Qt C++ in all the steps. Download from: http://qt.nokia.com/downloads
you could ask them if they have some sort of web service to call?
i.e. you could request the latest version which would return a revision number, you compare that against your current version, if an update is required you call another web service to request the location of the files to download.

PHP Application Flow Graph (or function call graph)

Happens that I've ended up working on a big PHP program and I need a program (or easy to install script) which draws a flow control/call graph of a PHP application (ie; must work over multiple PHP files).
Already saw stuff like Graphviz, not sure which one works for PHP?
Any suggestions?
Cheers!
I have never used any tool that can do that statically (i.e. from source files), but here's a way to get a callgraph when executing a script/application.
First, you need to install the Xdebug extension -- on a development/testing server (don't install it on a production server : it's quite bad for performances ^^ )
Then, you can use its profiling features to generate a .cachegrindout file corresponding to the execution of a page-load.
After that, you can load that .cachegrindout file with KCacheGrind (On linux -- I don't think there's a windows version) ; KCacheGrind can generate call-graphs from .cachegrindout files.
And here's an example of callgraph you can get :
(source: pascal-martin.fr)
(Here's, it's been generated from a .cachegrindout file obtained while loading a page of Dotclear, a blogging software)
Doxygen can do it statically. Just doxygen -d to create a config file, then edit it to create callgraphs.

Categories