ZCE # Week # 272

Question:

The dl() function is used to load PHP extensions on the sever at runtime. However, you want to disable it due to some security issue. Which of the following actions will perform to accomplish the task?

A. Add the dl() function in the disable_functions list in the PHP.ini configuration file.
B. Add the dl() function in the blocked_functions() list in the PHP.ini file
C. Set the enable_dl option to 0 in the PHP.ini file
D. Set the enable_dl option to 1 in the PHP.ini file

Explanation: 

The dl() function is used to load PHP extensions on the server at runtime. However, it can be the cause of some security issue.

To disable this function, you can perform the following actions:
  1. Set the enable_dl option to 0 in the PHP.ini file
  2. Add the dl() function in the disable_functions list in the PHP.ini configuration file.
Answer: A & C

ZCE # Week # 271

Question: 

You run the following PHP Script:

<?php
$value = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo $value;
?>

What will be the output of the script?

A. It will print the DNS resource records associated with the local Web Server.
B. It will print the standard host name for the local Web Server.
C. It will print the list of header information sent.
D. It will print the host name of the Internet host.

Explanation:

$_SERVER is an array containing information such as headers, paths, and script locations.

  • REMOTE_ADDR -- The IP address from which the user is viewing the current page.
  • REMOTE_HOST -- The host name from which the user is viewing the current page. The reverse dns lookup is based of the REMOTE_ADDR of the user.
  • REMOTE_PORT -- The port being used on the user's machine to communicate with the web server.
  • REMOTE_USER -- The authenticated user.
  • REDIRECT_REMOTE_USER -- The authenticated user if the request is internally redirected.

Related Functions:
  • gethostbyaddr Get the Internet host name corresponding to a given IP address 
  • gethostbyname Get the IPv4 address corresponding to a given Internet host name 
  • gethostbynamel Get a list of IPv4 addresses corresponding to a given Internet host name
  • checkdnsrrCheck DNS records corresponding to a given Internet host name or IP address
  • getmxrrGet MX records corresponding to a given Internet host name
  • dns_get_recordFetch DNS Resource Records associated with a hostname

Predefined variables:

PHP provides a large number of predefined variables to all scripts. The variables represent everything from external variables to built-in environment variables, last error messages to last retrieved headers. 

List of predefined variables of PHP

  • Superglobals -- Superglobals are built-in variables that are always available in all scopes.
  • $GLOBALS -- References all variables in global scope.
  • $_SERVER -- Server and execution environment information.
  • $_GET -- HTTP GET variables.
  • $_POST -- HTTP POST variables.
  • $_FILES -- HTTP File Upload variables.
  • $_SESSION -- Session variables.
  • $_ENV -- Environment variables.
  • $_COOKIE -- HTTP Cookies
  • $php_errormsg -- The previos error message.
  • $HTTP_RAW_POST_DATA -- Raw POST data.
  • $http_response_header -- HTTP response headers.
  • $argc -- The number of arguments passed to script.
  • $argv -- Array of arguments passed to script.
 

Answer:  D

ZCE # Week # 270

Question: 

Which function retrieves only the texts from an HTML file and leaves all HTML and PHP tags?

A. file_put_contents()
B. file_get_contents()
C. fgetss()
D. fgets()

Explanation:

file_put_contents --  Writes a string to a file
file_get_contents --  Reads entire file into a string
fgetss -- Gets line from file pointer and strip HTML tags
fgets -- Gets line from file pointer


Answer:  C