Jump to content

AutoPHP - Generate documents by sending variables from AutoIt to PHP


Jefrey
 Share

Recommended Posts

Hi folks!

I bring this little executable file and an AutoIt wrapper for it to generate documents (bills and incomes) by sending variables (strings, numbers or even arrays) to a PHP script you wrote.

This is the syntax:

themecli.exe <input> <output> <vars>

  • input: The input PHP file (the extension does not need to be .php, it can be anything, like .html, .txt, .bin, .wtf...), relative to @ScriptDir
  • output: The output HTML file to save, relative to @ScriptDir
  • vars: A base64-encoded JSON with all the variables (hard? Don't worry! See below:)

Looks confusing? Well, don't worry. That's why we have a wrapper!

Example, if we have this file "page.php":

Hello, <?=$user?>! How are you?

And do this with AutoIt (using my JSONgen UDF [ http://www.autoitscript.com/forum/index.php?showtopic=173797 ] which is already included in AutoPHP):

#include 'inc\autophp.au3'

$ojson = New_JSON()
JSON_AddElement($ojson, 'user', 'John Doe')
$json = JSON_GetJSON($ojson)

AutoPHP('page.php', 'hello.txt', $json)

Note that you don't need to base64-encode it. After running it, we will see a file named "hello.txt", and the content is:

Hello, John Doe! How are you?

On the PHP file you can also use loops and everything else supported in PHP4 (since it uses Bambalam PHP Compiler, it does not support PHP5 yet).

On the zip file there is an example of how to use it with loops.

License: same Bambalam PHP Compiler license: :P

[...]

let's just say that it's free, and I don't want to get sued. Ok? 

 

Tip: If you use wkhtmltox, you'll be able to convert the generated HTML file into PDF with just a few lines! See here: https://www.autoitscript.com/forum/topic/173611-wkhtmltox-autoit-objectclass-to-convert-html-filespages-into-pdf-and-images/ 

 

Download:

  •  AutoPHP.zip full script, dependencies and examples (everything you need to start using AutoPHP)
  •  phpthemecli-src.zip Themecli binary and source (Themecli is the tool that AutoPHP uses to run PHP code - since it's already included on AutoPHP UDF, you don't need to download it, unless you want to use it with another programming language)
Edited by Jefrey

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...