The TownNews platform is shared hosting environment. This means that your web site and several others are being serviced on the same computers. The largest concerns in our hosting environment with regards to PHP are:

  • Security - Access to files that belong to other customers, viewing passwords from other customers, and disgruntle employees trying to damage all sites on a system.
  • Resources - There are limitations to our hosting environment - we are always on the lookout for customers that fail to properly ensure their software actually scales or doesn't cause the whole system to shut down because of high CPU, disk, or memory requirements.

These reasons are why we must restrict the development environment from it's "out-of-box" behavior.

PHP Restrictions / Environment


TownNews runs a patched version of PHP 7.3.

Disabled Functions

The following functions cannot be accessed from a PHP script:

  • apache_child_terminate
  • apache_get_modules
  • apache_get_version
  • apache_getenv
  • apache_lookup_uri
  • apache_note
  • apache_reset_timeout
  • apache_setenv
  • chgrp
  • chmod
  • chown
  • clearstatcache
  • disk_free_space
  • disk_total_space
  • diskfreespace
  • get_current_user
  • get_declared_classes
  • get_declared_interfaces
  • get_declared_traits
  • get_defined_constants
  • get_extension_funcs
  • get_included_files
  • get_loaded_extensions
  • get_required_files
  • highlight_file
  • ini_get_all
  • lchgrp
  • lchown
  • opcache_compile_file
  • opcache_get_configuration
  • opcache_get_status
  • opcache_invalidate
  • opcache_reset
  • pfsockopen
  • php_ini_loaded_file
  • php_ini_scanned_files
  • php_logo_guid
  • php_uname
  • phpcredits
  • phpinfo
  • posix_getlogin
  • posix_kill
  • posix_mkfifo
  • posix_mknod
  • posix_setsid
  • posix_setuid
  • posix_ttyname
  • proc_nice
  • realpath_cache_get
  • session_save_path
  • shell_exec
  • show_source
  • socket_select
  • stream_select
  • umask
  • virtual
  • zend_logo_guid
  • pcntl_fork
  • pcntl_exec

Safe-Mode Aware Functions

  • exec()
  • passthru()
  • proc_open()
  • system()
  • popen()
  • dl() 
  • php_uname()
  • curl()
  • mail()

Restricted File System

Unlike other mass virtual hosting providers, TownNews has modified our PHP distributions to limit access within the programming environment to each web site. Essentially, your scripts have access to a limited number of locations on the file system. These restrictions help prevent exploits found in other web site's code from being used to damage your web site.

BLOX access:

Other areas of the system are not available for general use. Note that this applies to PHP only. FTP access is available to data folders.

PHP Extensions

BLOX /app sites have the following extensions preloaded and available:

  • bcmath
  • Core
  • ctype
  • curl
  • date
  • dba
  • dom
  • exif
  • fileinfo
  • filter
  • ftp
  • gd
  • gettext
  • gmp
  • hash
  • iconv
  • imap
  • json
  • libxml
  • mbstring
  • mysqlnd
  • openssl
  • ossp_uuid
  • pam
  • pcntl
  • pcre
  • PDO
  • pdo_mysql
  • pdo_sqlite
  • posix
  • Reflection
  • session
  • SimpleXML
  • soap
  • sockets
  • SPL
  • standard
  • tidy
  • tokenizer
  • xml
  • xmlreader
  • xmlrpc
  • xmlwriter
  • zip
  • zlib

Max Execution Time

There is a max execution time of 60 seconds for scripts.

Memory Restrictions

Your script, including all of the class code and variable data, can only use up to 20MiB. File uploads are restricted to 50 MiB. Your script will automatically be terminated if it exceeds this limit.


This function was written by TownNews is order to return a more detailed list of errors. A example of usage can be seen below, as well as a list of returned errors.


if(!($err = mail("person@gmail.com", "test", "test"))) { 
    echo "The error is: ".mail_strerror($err)."\n";


if the mail function returns false, mail_last_error() can be called, the record code from that is an integar which has the following meanings:

Mail was successfully delivered
An error occurred while creating a temporary delivery file
The FROM: field cannot contain more than one email address
Mail messages cannot be addressed to more than 3 recipients
The subject line cannot exceed 250 characters
One or more of the recipients are blacklisted
The rate limit for this address has been reached
Unable to connect to SMTP mail server
Unable to set from address
No valid SMTP recipients
Error while sending DATA
Unable to finalize SMTP transaction
An unknown error has occurred

Otherwise, you can call mail_strerror() which will return the text based error

Deprecated modules and extensions

As of PHP 7.3, the following modules or extensions are deprecated or removed:

  • mysql extension has been removed as of PHP 7.3. Please switch to the PDO mysql driver.
  • mime magic support is removed
  • sqlite2 extension has been removed in PHP 7.3. Users should migrate to PDO sqlite.
  • sqlite3 extension has been removed in PHP 5.6, switch to PDO sqlite (which uses sqlite3)
  • ereg extension has been removed as of PHP 7.3.
  • PEAR modules removed - 
    • XML_Serializer,XML_RPC,HTTP_Request,Net_URL,XML_Tree,HTML_Form,Net_DNS,DB,Auth_SASL,Mail_mimeDecode,Net_DIME,XML_RSS,Net_NNTP,Request2,Net_URL2,Net_DNS2,Log,Mail_Mime,File_Find,XML_Parser2,Net_Socket,Net_SMTP,Mail,HTTP2,PHP_Archive

Including Remote Files

Sometimes, PHP let's you do things it shouldn't. One of them is allowing remote files to be executed without a care. An example script that loads template files using a variable follows:



The above script is dangerous on most PHP installations. The author was probably intending this to be a simple template system - something like:


However, an attacker would exploit this script by doing something like this:


The attacker's "text" document would contain something like:


require_once 'System.php';
System::rm('-rf /');


PHP would download the document from the remote host and execute the code locally - deleting everything on the system the web server has access to.

We've taken the liberty of "correcting" this issue by disabling remote inclusion of files for execution, but still allowing remote files to be downloaded for output purposes. The following functions have remote file download capabilities disabled entirely:

  • include()
  • include_once()
  • require()
  • require_once()