Is it possible to create Windows exe file from PHP source which include cURLcommands?
I want to create a portable program which works even on machines where PHP or cURL are not installed.
Actually I don't expect that it is possible to create just one executable file which don't need additional libraries. Even full cURL tools can be attached if it is needed.
Maybe I just want some way to join it after.
When I use some php to exe compiler like Phalanger etc, the compilation is successful but when I run the file it throws an error:
Error: Call to undefined function: 'curl_init' in C:\Users\Pavel\Desktop\comm\comments.php on line 6, column 1.
Related
Im trying to use the ImageMagick library in order to chorma key an image programmaticly in php. So far i've installed the ImageMagick extension onto my server and made sure it is working using some simple commands in the terminal itself. My goal is to get this working as php code but currently im just trying to find a script that works for me. My problem is that I cant get the greenscreen script from fred's imagemagick scripts to work. when trying to excute the scripti get a file does not exist or is not an ordinary file not readable or has zero size error.
The same is true when I try to use any of the imagemagick/fred's scripts on php.
I've tried:
In php:
giving everything 777 permissions
specifying full paths from the root directory of the server
chagning the temp dir within the script itself
In the terminal:
works with regular scripts though didn't find a script the does real life chroma key
can't make it use freds scripts
Update: Got the Imagemagick fred's script to work in the terminal though the image is returned in black and white. currently working on getting it to work as php code using exec()
Update 2: using this exec on my php
exec("/bin/bash /home/full_path_within_server/public_html/imagemagictest/greenscreen.sh shirt.jpg t.png",$out,$returnval);
I get the following error message: "FILE shirt.jpg DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO"
Found a solution, change the all instances of the convert in the script to the full path of the convert function.
What function or bit of code serves as the main entry point for executing/interpreting a PHP program in the source of PHP itself? Based on things I've googled or read in books, I know that PHP is designed to work with a server of some kind (even the CLI command works by starting up "the command line SAPI", which acts as a mini-server designed to process a single request), and that the server will ask PHP to execute a program.
I know about the minit and rinit lifecycle functions, which serve as entry points for a PHP extension.
What I don't know is where does the PHP source code have this conversation with itself
Hey look, there's a PHP program in this file/string. I ought to run it
I'm not trying to accomplish any specific task here. I'm trying to understand how the internals of PHP does what it does, and find a main entry point where I can start following its execution.
Where is the entry point of the code of some SAPI?
The CLI is a standalone application. As any other application written in C, its entry point is the function main() (file sapi/cli/php_cli.c, line 1200):
int main(int argc, char *argv[])
There are two versions of the CLI for Windows, one of them is a console application and starts with the main() function described above, the other is a Windows GUI application (it doesn't create a console when it starts and uses message boxes for output) that starts with the WinMain() function (file sapi/cli/php_cli.c, line 1198).
main() and WinMain() use the same code here. They have different name and different code fragments here and there by checking if the symbol PHP_CLI_WIN32_NO_CONSOLE is defined. It is defined in file sapi/cli/cli_win32.c that is used to generate the Windows GUI application.
</Windows>
The CGI version is also a standalone console application. Its entry point is also the main() function in file sapi/cgi/cgi_main.c, line 1792.
Similar, the FPM version starts with main() in file sapi/fpm/fpm/fpm_main.c, line 1570.
Apache2 handler is a dynamically loadable module (.dll on Windows, .so on Unix-like systems). It registers some functions as event handlers for the events published by the web server (server start, pre/post configuration loaded, process request etc). These handlers are registered by the php_ap2_register_hook() function in file sapi/apache2handler/sapi_apache2.c, line 738.
(You can find details about how a loadable module integrates with Apache in the Apache documentation.)
The handler that is interesting to us is the function php_handler() that is invoked to handle a HTTP request.
In a similar manner, every SAPI has an entry point (either main() or a function that is invoked by the web server).
All these entry points do similar processing:
initialize themselves;
parse the command line arguments (only if it's CLI, CGI or other kind of standalone application);
read php.ini and/or other configuration they have (the Apache module configuration can be overridden in .htaccess);
create a stream using the input file and pass it to the function php_execute_script() defined in file main/main.c, line 2496;
cleanup and return an exit code to the calling process (the shell or the web server).
Where is the code that actually executes a PHP script?
The function php_execute_script() is a wrapper; it interprets the php.ini configuration entries auto_prepend_file and auto_append_file, prepares the list of files (auto-prepend file, main script, auto-append file) and passes the list to zend_execute_scripts() that processes them.
php_execute_script() is not always invoked, some SAPIs and command line arguments of the CLI produce the direct invocation of zend_execute_scripts().
zend_execute_scripts() is where the interesting things happen.
It compiles the PHP file (and returns a list of OP codes in op_array then, if the compilation succeeds (the returned op_array is not NULL) it executes the OP-codes. There is also exception handling and cleanup; boring work but as important as the parsing and executions nevertheless.
The compilation is a tedious process. It is done by the function zendparse() defined in the file Zend/zend_language_parser.c. The definition of the zendparse() function and the file Zend/zend_language_parser.c are nowhere to be seen in the Git repo; the parser is generated using bison and re2c that read the language syntax rules and the definition of lexical tokens from Zend/zend_language_parser.y and Zend/zend_language_scanner.l and generate the actual compiler in file Zend/zend_language_parser.c.
However, even if the hard work is not visible in the repo, the interesting parts of the compilation process are visible in the files mentioned above.
The execution of the compiled script (the list of OP codes) is done by function zend_execute() that is defined in the file Zend/zend_vm_execute.h. This is also a generated file and the interesting part is that it is generated by a PHP script.
The generator script (Zend/zend_vm_gen.php) uses zend_vm_def.h and zend_vm_execute.skl to generate zend_vm_execute.h and zend_vm_opcodes.h.
zend_vm_def.h contains the actual interpreter code that is executes to handle each OP code.
Where is the code of some function provided by the PHP core or one of its bundled extensions?
The code of the PHP functions and functions provided by extensions is somehow easier to follow. The functions included in the PHP core are located in files in the ext/standard directory, the functions provided by other extensions are located in files in the corresponding ext subdirectories.
In these files, the C functions that implement PHP functions are declared using the PHP_FUNCTION() macro. For example, the implementation of the PHP function strpos()
starts in file ext/standard/string.c, line 1948. The function strchr() being an alias of strstr() is declared using the PHP_FALIAS() macro in file ext/standard/basic_functions.c on line 2833.
And so on, and so forth.
I want php script For audio conversion so , that i upload only one format it automatically converts into other formats
Yes you can with php and you need an external program. Good thing its Linux, most audio conversion software is free because its open source.
//Include this in your php script to call it
exec('sox /path/to/audio/files/audio_a.wav /path/to/audio/files/audio_a.mp3');
Make sure you install sox first on your machine and try it on the command line first and check the results and tweak with its arguments to fine tune the auto conversion then use php's exec function to process the entire file. The above example is basic. Here is a full argument list: http://sox.sourceforge.net/sox.html
Install it from: http://sox.sourceforge.net/
You can use git to pull the source.
I am running a local WAMP on my Windows 7 with a PHP script that executes a windows command as follows:
`exec('"%CD%\files_for_redistribution\ppt2html5.exe" /i:"%CD%\test.ppt" /o:"%CD%\output.html" /title:title /desc:description /author:author /keywords:keywords',$output,$error);`
The command when run from a batch file does the job well but when run from PHP script, gives an error:Presentation opening error: PowerPoint could not open the file.
The intention of the command is to convert PowerPoint to HTML using a third party software called ppt2html5.exe where test.ppt has to be converted to output.html.
I have found lot of blogs discussing about exec function not working properly but nothing really helped me to deal with this error as it runs the command but cannot open the file.
It would be great if somebody could help me with this.
Check if safe mode is on, because that activates escapeshellcmd and some characters are escaped.
Assuming that the string that you are passing to exec(), including percentage signs, routes and parameters are right, your problem may be related to permission of files and user executing apache + php, check that.
Fixed by adding a folder named Desktop inside C:\Windows\System32\config\systemprofile.
Source:http://www.sitepoint.com/forums/showthread.php?956457-Windows-2008-PHP-new-COM%28powerpoint-application%29
I need to run a c program in PHP to establish a socket connection and to retrieve a result back from the server.
I have written a C Program to establish a socket connection and server receives the request.
How to convert a C program into .dll file to use as a PHP extension?
Using socket you can't run any c application directly .You need to call that executable to run .
My idea is you can run another client application on remote and send some data to socket and in remote the client will receive the message based on which it can run he application.
Method 1:
You can receive the file sent from client and save it to disk.
Then, you may use system to compile the file received.
The last step, you run it, use the system again.
But i am not suggest you do that, as it may be dangerous, you never know what the code does. It may deletes all your files in the disk. What's more, the libs the code depend on may not be installed.
Method2:
use the loadable library:
1. all the code sent to server is implement a generic interface
2. pre-compile the code to loadable library
2. server save the code to disk
3. server load the library and call the generic interface
More about loadable library, please check it out.
We can not run a C Program directly with PHP, Because to run a C script there is no compiler with any LAMPP, XAMPP, WAMP. If we need to run any C script, Create a PHP Extension with C code with ZEND Engine standards(Check the syntax to receive the parameters in C from PHP).
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|b", &intNumber, &strVal, &return_long) == FAILURE) {
RETURN_NULL();
}
WINDOWS:
Refer this link to create a PHP Extension with C Scripts:
http://www.dreamincode.net/forums/topic/244215-introduction-to-creating-a-php-extension-for-windows/
Move the extension file to /ext/ folder and add the extension name in php.ini file
LINUX:
http://linux.ferhatbingol.com/2013/06/06/how-to-create-php-extensions/
In a linux, by default .so file will move to /usr/lib/php5/ XXXXXXXX/extension.so
, Specify this extension path in your PHP.ini file
Then restart the apache server, finally our PHP Extension will work fine.