Free WebSchools.com

Google




Blog ForumsLive chat WebhostingLink TO UsSEO ToolsResources


HOME

PHP Introduction
Php Installation
PHP Basic Scripts
PHP variables
PHP operators
PHP Conditional statement
PHP functions
PHP Arrays

PHP Objects & classes
PHP with Forms
PHP Files
PHP With Database
PHP session
PHP cookies
PHP Regular Expressions
PHP Server Environment
PHP Graphics
PHP Advance

PHP server environment



In this chapter we will study the technique for communicating with remote machines and for gaining input from serevr. we will study
  • how to pipe data to and from external applications
  • other ways of sending shell commands and displaying the results on the browser
  • the security implixcations of interprocess communication from a php script


popen - initiate pipe streams to or from a process
The popen() function executes the command specified by the string command. It creates a pipe between the calling program and the executed command, and returns a pointer to a stream that can be used to either read from or write to the pipe.




pclose -- Closes process file pointer exec -- Execute an external program. it is the function you pass command too the shell.the function requires astring representing the path to the command that you want to run.

system() -- the system() command is similar to exec() function. in that it launches an external application.system() prints the output of the shell command directly to the browser.The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.


The passthru() function is similar to the exec() function in that it executes a command. This function should be used in place of exec() or system() when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the Content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly

escapeshellcmd() escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands. This function should be used to make sure that any data coming from user input is escaped before this data is passed to the exec() or system() functions, or to the backtick operator.

Following characters are preceded by a backslash: #&;`|*?~<>^()[]{}$\, \x0A and \xFF. ' and " are escaped only if they are not paired. In Windows, all these characters plus % are replaced by a space instead.