More Than a Hobby..

11 Alternatives to Whatsapp that Actually Respect Your Privacy

When social media giant Facebook purchased everyone’s favorite mobile messenger “Whatsapp,” users were promised their data would be private and that they wouldn’t be subject to the shady things that Mark Zuckerberg and crew are known for. That promise is all but gone, leaving many of us seeking alternatives.

As time has gone on, more and more privacy has been taken away from Whatsapp users in the name of “analytical data.” Gone are the days when you could trust this app to be totally private and not expect to get data mined for valuable information – information that could easily be sold to advertisers.

Pretty bleak, right? So let’s lighten the mood by presenting you with a bunch of Whatsapp alternatives that aren’t made of broken promises and baby tears. Here are our top picks.

1. Riot.im



With a focus on rooms, conference calls and other pretty large-scale interactions, it’s easy to overlook that Riot functions as a perfectly good (and privacy-centric) messenger app as well. It’s an open-source app, so is constantly being iterated to have maximum security.

Its best privacy features include the fact that you don’t need to enter a phone number to use it, and end-to-end encryption (which you need to switch on manually), and control over message histories so you can change how much new users in chat rooms can and can’t see. Its based on the Matrix protocol, which has an excellent reputation as a secure communication platform (the French government even started using Riot for its confidential communications!).

Available on multiple platforms, and making it easy to send and receive all kinds of media from small documents to chunky video files, Riot.im is a great organizational platform as well as a secure messenger. Its green, clean UI kind of reminds of WhatsApp too, so those moving over won’t feel too homesick.

2. Wire

Availability: AndroidWeb


With end-to-end encryption and a no-nonsense interface, Wire is making some waves on the secure messaging scene. Made by Skype co-founder Janus Friis, Wire has some heavyweight design nous behind it.

You need to provide your your mobile number or email to use the app, though these aren’t shared with other users, who you can communicate with via a username. Timed messages are also an option, letting you self-destruct them between five seconds and one day after you send them.

3. KIK Messenger

Availability: iOSAndroid


KIK has developed a bit of a salacious reputation over the years as an app used for sexting, drug dealing and all manner of underhanded tomfoolery (as well as standard messaging, of course). If nothing else, that’s testament to one thing: it’s pretty darn private.

This free app doesn’t store your phone number, so you’re identifiable only by your username, and all messaging data is stored locally on your phone, leaving your privacy in your hands. KIK is therefore virtually unmoderated and perfect for the privacy-conscious.




The biggest WhatsApp competitor you probably haven’t heard of, LINE is a Japanese-developed app that offers a powerful feature set, conference calls, thousands of stickers, and a clean, customizable interface. It uses less data than WhatsApp during calls and end-to-end encryption.

While certain features require LINE to access your contacts list, location and so on, all of this is optional, and whatever data you send is encrypted on LINE’s servers. You can also set self-destruct timers to delete messages from LINE’s servers.

5. Wickr Me



In probably the best endorsement of a privacy-oriented messaging app, Wickr Me is apparently used by journalists, world leaders and other sorts who want to keep their private business private. (No names were specified, mind you, but that’s sort of the point, right?)

Like WhatsApp, Wickr Me uses your phone number to log in and contains all manner of silly and fun features like stickers and emojis. But that’s where the similarities end. Wickr doesn’t store your contacts on its servers, doesn’t keep metadata, and deletes messages irretrievably from your phone when you ask it to.

It’s free, doesn’t involve ads, and encrypts your data to high heaven. Good stuff.

6. Telegram



Telegram is perhaps the most worthy alternative to Whatsapp. For starters, it essentially has comparable features like voice and video messages, a phone number-based login system, stickers, emojis, chat bots, groups, channels and so much more. Along with those cool features, Telegram isn’t just a mobile app.

That’s right, you can use Telegram on Windows, Mac and even Linux with their desktop app. Alternatively, Telegram has a web chat application for all your messaging needs. Best of all, Telegram supports end-to-end encryption and respects your privacy.

7. Kontalk



Have you ever wanted to host your own “Whatsapp” service? With Kontalk, this is possible. This app is an open XMPP-based alternative to Whatsapp that you can keep entirely on your own server. This means you and only you will be in charge of the chat between you and your friends and family, making it the ultimate at respecting your privacy.

Kontalk has an app in the Google Play store as well as the F-Droid app store and a desktop client. If you’re looking for a solution that you can make entirely your own, this is the best choice.

8. Antox/Antidote

AvailabilityiOS (as Antidote)Android


Antox is a robust and privacy-respecting messenger application. It supports all of the standard chat features you’d expect. Antox (Antidote on iOS), unlike a lot of the items on this list, isn’t nailed down to one single app. That’s because it has many officially “blessed” apps for Android, iOS, Linux, Windows, macOS and even FreeBSD.

This ultimately is a messaging protocol, and a secure one at that. It’s under heavy development. Ultimately, Tox is very stable, although you should expect bugs once in a while. If you’re looking to oust Whatsapp from your life, don’t mind the risk of using a beta, and want a bit of variety, go with this app.

9. Signal



Signal is an app for Android, iPhone, macOS, Windows, Linux, and Chrome that is designed around a similar principle to Telegram. Private communication is based on your phone number, and they promise you’ll avoid SMS and MMS fees, as your number is just used as an ID and not the point of transmission.

As Signal is pretty much a more open-sourced Telegram clone, you’ll see comparable features to that service, such as group chats and broadcast messages. If you’ve used Telegram and want something more open, you should give this one a shot. Regardless of its “clone” status, it’s a worthy alternative to Whatsapp.

10. Threema



Threema is a mobile chat platform that puts your privacy first. Like some other apps on this list, it supports end-to-end encryption of text, images and your GPS location. It also synchronizes with your contacts, making it super easy to find people who are joining the service automatically.

The developers and owners of the service claim that “even we as the server operator have absolutely no way to read your messages,” so you know everything you say is protected and locked away from big companies and governments mining your data.

11. KakaoTalk

AvailabilityiOS/Apple WatchAndroid


KakaoTalk is a chat application for Android, iOS, Blackberry, Windows Phone, Windows and macOS designed to let the world chat on a one-on-one basis or with groups in mind. Like most modern chat applications, this app supports the sending of multimedia (pictures, videos, etc.).

The service might not be as well known as some of the others on this list, but don’t let that turn you off. It’s a well-designed program and is about as prolific as it gets. If you’ve tried everything on this list already and haven’t found what you want, perhaps you should give kakaoTalk a go.


Whatsapp used to be a good app, and by most standards, it still is. Facebook has beefed it up with features and made it incredibly competitive. However, seeing as how this platform is little more than a data-farm for advertisements, people should seriously consider switching to one of the apps on this list.

Each alternative to Whatsapp listed here has its own strengths as well as weaknesses. However, one thing they all have in common is that they’re miles removed from any sort of Facebook control.

This article was first published in September 2016 and was updated in March 2019.

PHP Cheat Sheet

Our PHP cheat sheet aims to help anyone trying to get proficient in or improve their knowledge of PHP. The programming language is among the most popular in web development. It’s in the heart of WordPress, the world’s most popular CMS, and also forms the base of other platforms like Joomla and Drupal. (Don’t miss our comparison of the three.)

Aside from that, PHP is an Open Source and thus free to use. Since its inception in 1995, it has had several releases. The latest version, PHP 7.2, came out at the end of 2017.

PHP is a server-side language, meaning that it executes on the server, not in the user’s browser (as opposed to, for example, JavaScript). PHP scripts produce HTML which is then passed on to the browser for interpretation. Consequently, the user doesn’t see the code itself but only the result.

php cheat sheethttps://websitesetup.org/wp-content/uploads/2018/05/php-cheat-sheet-640x208.png 640w, https://websitesetup.org/wp-content/uploads/2018/05/php-cheat-sheet-768x250.png 768w" sizes="(max-width: 750px) 100vw, 750px" style="box-sizing: border-box; border: 0px; vertical-align: middle; display: block; height: auto; max-width: 100%; margin-top: 10px; margin-bottom: 10px;">
By GgiaEsquema-proxy-internet.svg: Randomicc [CC BY-SA 3.0], from Wikimedia Commons

The programming language is relatively easy to learn for beginners, but it also offers a lot of advanced possibilities for veteran programmers.

For that reason, the following PHP cheat sheet is suitable for you no matter where you are in your journey. It covers the most important PHP concepts and functions and acts as a quick reference guide for those using PHP for web development.

We have a lot to cover, so let’s get right into it. If that’s not enough for you, we also have cheat sheets for HTMLCSS, and jQuery as well as the aforementioned JavaScript.

PHP Cheat Sheet

PHP Cheat Sheet – The Basics

We are starting off with the basics – how to declare PHP in a file, write comments and output data.

Including PHP in a File

PHP files end in .php. Besides PHP itself, they can contain text, HTML, CSS and JavaScript. In order for a browser to recognize PHP, you need to wrap it in brackets: <?php and ?>. Consequently, you can execute PHP in a page:

  1. <?php
  2. // place PHP code here
  3. ?>

Writing Comments

Like many other languages, PHP also has the ability to add comments. This is important for annotating your code for human readers but in a way that the browser doesn’t try to execute it. In PHP, you have several ways for that:

  • // — Denotes comments that only span one line
  • # — Another way of producing single-line comments
  • /*...*/ — Everything between /* and */ is not executed, also works across several lines

A common example of the use of comments are WordPress theme headers:

  1. /*
  2. Theme Name: Twenty Seventeen
  3. Theme URI: https://wordpress.org/themes/twentyseventeen/
  4. Author: the WordPress team
  5. Author URI: https://wordpress.org/
  6. Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.
  7. Version: 1.5
  8. License: GNU General Public License v2 or later
  9. License URI: http://www.gnu.org/licenses/gpl-2.0.html
  10. Text Domain: twentyseventeen
  11. Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
  12. This theme, like WordPress, is licensed under the GPL.
  13. Use it to make something cool, have fun, and share what you've learned with others.
  14. */

Outputting Data

In PHP, data is commonly output using echo or print. For example, the title of this blog post might be displayed on a page like this:

  1. <?php
  2. echo "<h1>PHP Cheat Sheet</h1>";
  3. ?>

The two commands echo and print are pretty much the same. The only difference is that the former has no return value and can take several parameters, while the latter has a return value of 1 and can only take one argument.

An important note: Like all other PHP commands, functions echo and print are not case sensitive. That means that when you write ECHOEcHoeCHO or any other variation, they will continue to work. As you will learn further on, that doesn’t apply to everything.

Writing PHP Functions

Functions are shortcuts for commonly used chunks of code. They make programming much easier because you don’t have to re-use long code snippets. Instead, you create them once and use the shortcuts when you need them.

It’s possible to create your own PHP functions but there also many built into the programming language. Much of this PHP cheat sheet is devoted to that.

The basic syntax to create a function:

  1. function NameOfTheFunction() {
  2. //place PHP code here
  3. }

Quick explanation: the first part is the function a name (reminder: function names are not case sensitive). After that, everything between the curly braces is what the function does when called.

Variables and Constants

Similarly to most other programming languages, PHP lets you work with variables and constants. These are pieces of code that store different kinds of information.

Defining Variables

To do anything with variables, you first need to define them. In PHP, you denote a variable using the $ sign and assign its value using =. A typical example:

  1. <?php
  2. $BlogPostTitle = "PHP Cheat Sheet";
  3. ?>

A few important points:

  • Variables need to start with a letter or underscore (_) and can only be comprised of alpha-numeric characters
  • PHP variables are case sensitive, that means $myVar and $myvar are not the same thing
  • If your variable consists of more than one word either write it $my_variable or $myVariable

Types of Data

Variables can take on different types of data:

  • Integers — Integers are non-decimal numbers between -2,147,483,648 and ,147,483,647. They must have at least one digit and no decimal point. Can be in decimal, hexadecimal or octal.
  • Floats — This is the name for numbers with a decimal point or in exponential form.
  • Strings — This simply means text, we will talk about it in detail further below.
  • Boolean values — Meaning true/false statements.
  • Arrays — Arrays are variables that store several values. We will talk about them in detail further below.
  • Objects — Objects store both data and information on how to process it.
  • Resources — These are references to functions and resources outside of PHP.
  • NULL — A variable that is NULL doesn’t have any value.

There is no need to declare PHP variables in a certain way. They automatically take on the type of the data they contain.

Variable Scope

Variables can be available in different scopes, meaning the part of a script you can access them. This can be globallocal and static.

Any variable declared outside of a function is available globally. That means it can be accessed outside of a function as well.

If you declare a variable inside a function, it will have a local scope. The consequence is that it can only be accessed within that function.

A way around this is to prepend a local variable with global. That way, it becomes part of the global scope.

  1. function myFunction() {
  2. global $a, $b;
  3. $b = $a - $b;
  4. }

In both cases, the variable becomes part of the $GLOBALS variable mentioned below.

Finally, it’s also possible to add static in front of a local variable. That way, it won’t be deleted after its function is executed and can be reused.

Predefined Variables

PHP also comes with a number of default variables called superglobals. That’s because they are accessible from anywhere, regardless of scope.

  • $GLOBALS — Used to access global variables from anywhere inside a PHP script
  • $_SERVER — Contains information about the locations of headers, paths and scripts
  • $_GET — Can collect data that was sent in the URL or submitted in an HTML form
  • $_POST — Used to gather data from an HTML form and to pass variables
  • $_REQUEST — Also collects data after submitting an HTML form

Variable-handling Functions

Aside from that, there are a whole bunch of functions to work with variables:

  • boolval — Used to retrieve the boolean value of a variable
  • debug_zval_dump — Outputs a string representation of an internal zend value
  • empty — Checks whether a variable is empty or not
  • floatval — Get the float value of a variable (doubleval is another possibility)
  • get_defined_vars — Returns an array of all defined variables
  • get_resource_type — Returns the resource type
  • gettype — Retrieves the variable type
  • import_request_variables — Import GET/POST/Cookie variables into the global scope
  • intval — Find the integer value of a variable
  • is_array — Checks whether a variable is an array
  • is_bool — Finds out if a variable is a boolean
  • is_callable — Verify whether you can call the contents of a variable as a function
  • is_countable — Check whether the contents of a variable are countable
  • is_float — Find out if the type of a variable is float, alternatives: is_double and is_real
  • is_int — Check if the type of a variable is an integer, is_integer and is_long also works
  • is_iterable — Verify that a variable’s content is an iterable value
  • is_null — Checks whether a variable’s value is NULL
  • is_numeric — Find out if a variable is a number or a numeric string
  • is_object — Determines whether a variable is an object
  • is_resource — Check if a variable is a resource
  • is_scalar — Tests if a variable is a scalar
  • is_string — Find out whether the type of a variable is a string
  • isset — Determine if a variable has been set and is not NULL
  • print_r — Provides human-readable information about a variable
  • serialize — Generates a representation of a value that is storable
  • settype — Sets a variable’s type
  • strval — Retrieves the string value of a variable
  • unserialize — Creates a PHP value from a stored representation
  • unset — Unsets a variable
  • var_dump — Dumps information about a variable
  • var_export — Outputs or returns a string representation of a variable that can be parsed


Aside from variables, you can also define constants which also store values. In contrast to variables their value can not be changed, it’s locked in.

In PHP you can define a constant:

  1. define(name, value, true/false)

The first is the name, the second the constant’s value and the third parameter whether its name should be case sensitive (the default is false).

Constants are useful since they allow you to change the value for an entire script in one place instead of having to replace every instance of it. They are also global in nature, meaning they can be accessed from anywhere.

Aside from user-defined constants, there also a number of default PHP constants:

  • __LINE__ — Denotes the number of the current line in a file
  • __FILE__ — Is the full path and filename of the file
  • __DIR__ — The directory of the file
  • __FUNCTION__ — Name of the function
  • __CLASS__ — Class name, includes the namespace it was declared in
  • __TRAIT__ — The trait name, also includes the namespace
  • __METHOD__ —  The class method name
  • __NAMESPACE__ — Name of the current namespace

PHP Arrays – Grouped Values

Arrays are a way to organize several values in a single variable so that they can be used together. While functions are for blocks of code, arrays are for the values – a placeholder for larger chunks of information.

In PHP there are different types of arrays:

  • Indexed arrays – Arrays that have a numeric index
  • Associative arrays – Arrays where the keys are named
  • Multidimensional arrays – Arrays that contain one or more other arrays

Declaring an Array in PHP

Arrays in PHP are created with the array() function.

  1. <?php
  2. $cms = array("WordPress", "Joomla", "Drupal");
  3. echo "What is your favorite CMS? Is it " . $cms[0] . ", " . $cms[1] . " or " . $cms[2] . "?";
  4. ?>

Array keys can either be strings or integers.

Array Functions

PHP offers a multitude of default functions for working with arrays:

  • array_change_key_case — Changes all keys in an array to uppercase or lowercase
  • array_chunk — Splits an array into chunks
  • array_column — Retrieves the values from a single column in an array
  • array_combine — Merges the keys from one array and the values from another into a new array
  • array_count_values — Counts all values in an array
  • array_diff — Compares arrays, returns the difference (values only)
  • array_diff_assoc — Compares arrays, returns the difference (values and keys)
  • array_diff_key — Compares arrays, returns the difference (keys only)
  • array_diff_uassoc — Compares arrays (keys and values) through a user callback function
  • array_diff_ukey — Compares arrays (keys only) through a user callback function
  • array_fill — Fills an array with values
  • array_fill_keys — Fills an array with values, specifying keys
  • array_filter — Filters the elements of an array via a callback function
  • array_flip — Exchanges all keys in an array with their associated values
  • array_intersect — Compare arrays and return their matches (values only)
  • array_intersect_assoc — Compare arrays and return their matches (keys and values)
  • array_intersect_key — Compare arrays and return their matches (keys only)
  • array_intersect_uassoc — Compare arrays via a user-defined callback function (keys and values)
  • array_intersect_ukey — Compare arrays via a user-defined callback function (keys only)
  • array_key_exists — Checks if a specified key exists in an array, alternative: key_exists
  • array_keys — Returns all keys or a subset of keys in an array
  • array_map — Applies a callback to the elements of a given array
  • array_merge — Merge one or several arrays
  • array_merge_recursive — Merge one or more arrays recursively
  • array_multisort — Sorts multiple or multi-dimensional arrays
  • array_pad — Inserts a specified number of items (with a specified value) into an array
  • array_pop — Deletes an element from the end of an array
  • array_product — Calculate the product of all values in an array
  • array_push — Push one or several elements to the end of the array
  • array_rand — Pick one or more random entries out of an array
  • array_reduce — Reduce the array to a single string using a user-defined function
  • array_replace — Replaces elements in the first array with values from following arrays
  • array_replace_recursive — Recursively replaces elements from later arrays into the first array
  • array_reverse — Returns an array in reverse order
  • array_search — Searches the array for a given value and returns the first key if successful
  • array_shift — Shifts an element from the beginning of an array
  • array_slice — Extracts a slice of an array
  • array_splice — Removes a portion of the array and replaces it
  • array_sum — Calculate the sum of the values in an array
  • array_udiff — Compare arrays and return the difference using a user function (values only)
  • array_udiff_assoc — Compare arrays and return the difference using a default and a user function (keys and values)
  • array_udiff_uassoc — Compare arrays and return the difference using two user functions (values and keys)
  • array_uintersect — Compare arrays and return the matches via user function (values only)
  • array_uintersect_assoc — Compare arrays and return the matches via a default user function (keys and values)
  • array_uintersect_uassoc — Compare arrays and return the matches via two user functions (keys and values)
  • array_unique — Removes duplicate values from an array
  • array_unshift — Adds one or more elements to the beginning of an array
  • array_values — Returns all values of an array
  • array_walk — Applies a user function to every element in an array
  • array_walk_recursive — Recursively applies a user function to every element of an array
  • arsort — Sorts an associative array in descending order according to the value
  • asort — Sorts an associative array in ascending order according to the value
  • compact — Create an array containing variables and their values
  • count — Count all elements in an array, alternatively use sizeof
  • current — Returns the current element in an array, an alternative is pos
  • each — Return the current key and value pair from an array
  • end — Set the internal pointer to the last element of an array
  • extract — Import variables from an array into the current symbol table
  • in_array — Checks if a value exists in an array
  • key — Fetches a key from an array
  • krsort — Sorts an associative array by key in reverse order
  • ksort — Sorts an associative array by key
  • list — Assigns variables as if they were an array
  • natcasesort — Sorts an array using a “natural order” algorithm independent of case
  • natsort — Sorts an array using a “natural order” algorithm
  • next — Advance the internal pointer of an array
  • prev — Move the internal array pointer backwards
  • range — Creates an array from a range of elements
  • reset — Set the internal array pointer to its first element
  • rsort — Sort an array in reverse order
  • shuffle — Shuffle an array
  • sort — Sorts an indexed array in ascending order
  • uasort — Sorts an array with a user-defined comparison function
  • uksort — Arrange an array by keys using a user-defined comparison function
  • usort — Categorize an array by values using a comparison function defined by the user

PHP Strings

In programming speech strings are nothing more than text. As we have settled earlier, they are also a valid value for variables.

Defining Strings

In PHP there are several ways to define strings:

  • Single quotes — This is the simplest way. Just wrap your text in ' markers and PHP will handle it as a string.
  • Double quotes — As an alternative you can use ". When you do, it’s possible to use the escape characters below to display special characters.
  • heredoc — Begin a string with <<< and an identifier, then put the string in a new line. Close it in another line by repeating the identifier. heredoc behaves like double-quoted strings.
  • nowdoc — Is what heredoc is for double-quoted strings but for single quotes. It works the same way and eliminates the need for escape characters.

Note: Strings can contain variables, arrays, and objects.

Escape Characters

  • \n — Linefeed
  • \r — Carriage return
  • \t — Horizontal tab
  • \v — Vertical tab
  • \e — Escape
  • \f — Form feed
  • \\ — Backslash
  • \$ — Dollar sign
  • /' — Single quote
  • \" — Double quote
  • \[0-7]{1,3} — Character in octal notation
  • \x[0-9A-Fa-f]{1,2} — Character in hexadecimal notation
  • \u{[0-9A-Fa-f]+} — String as UTF-8 representation

String Functions

  • addcslashes() — Returns a string with backslashes in front of specified characters
  • addslashes() — Returns a string with backslashes in front of characters that need to be escaped
  • bin2hex() — Converts a string of ASCII characters to hexadecimal values
  • chop() — Removes space or other characters from the right end of a string
  • chr() — Returns a character from a specified ASCII value
  • chunk_split() — Splits a string into a series of smaller chunks
  • convert_cyr_string() — Converts a string from a Cyrillic character set to another
  • convert_uudecode() — Decodes a uuencoded string
  • convert_uuencode() — Encodes a string using uuencode
  • count_chars() — Returns information about the characters in a string
  • crc32() — Calculates a 32-bit CRC for a string
  • crypt() — Returns a hashed string
  • echo() — Outputs one or several strings
  • explode() — Breaks down a string into an array
  • fprintf() — Writes a formatted string to a specified output stream
  • get_html_translation_table() — Returns the translation table used by htmlspecialchars() and htmlentities()
  • hebrev() — Transforms Hebrew text to visual text
  • hebrevc() — Converts Hebrew text to visual text and implements HTML line breaks
  • hex2bin() — Translate hexadecimal values to ASCII characters
  • html_entity_decode() — Turns HTML entities to characters
  • htmlentities() — Converts characters to HTML entities
  • htmlspecialchars_decode() — Transforms special HTML entities to characters
  • htmlspecialchars() — Switches predefined characters to HTML entities
  • implode() — Retrieves a string from the elements of an array, same as join()
  • lcfirst() — Changes a string’s first character to lowercase
  • levenshtein() — Calculates the Levenshtein distance between two strings
  • localeconv() — Returns information about numeric and monetary formatting for the locale
  • ltrim() — Removes spaces or other characters from the left side of a string
  • md5() — Calculates the MD5 hash of a string and returns it
  • md5_file() — Calculates the MD5 hash of a file
  • metaphone() — Provides the metaphone key of a string
  • money_format() — Returns a string as a currency string
  • nl_langinfo() — Gives specific locale information
  • nl2br() — Inserts HTML line breaks for each new line in a string
  • number_format() — Formats a number including grouped thousands
  • ord() — Returns the ASCII value of a string’s first character
  • parse_str() — Parses a string into variables
  • print() — Outputs one or several strings
  • printf() — Outputs a formatted string
  • quoted_printable_decode() — Converts a quoted-printable string to 8-bit binary
  • quoted_printable_encode() — Goes from 8-bit string to a quoted-printable string
  • quotemeta() — Returns a string with a backslash before metacharacters
  • rtrim() — Strips whitespace or other characters from the right side of a string
  • setlocale() — Sets locale information
  • sha1() — Calculates a string’s SHA-1 hash
  • sha1_file() — Does the same for a file
  • similar_text() — Determines the similarity between two strings
  • soundex() — Calculates the soundex key of a string
  • sprintf() — Returns a formatted string
  • sscanf() — Parses input from a string according to a specified format
  • str_getcsv() — Parses a CSV string into an array
  • str_ireplace() — Replaces specified characters in a string with specified replacements (case-insensitive)
  • str_pad() — Pads a string to a specified length
  • str_repeat() — Repeats a string a preset number of times
  • str_replace() — Replaces specified characters in a string (case-sensitive)
  • str_rot13() — Performs ROT13 encoding on a string
  • str_shuffle() — Randomly shuffles the characters in a string
  • str_split() — Splits strings into arrays
  • str_word_count() — Returns the number of words in a string
  • strcasecmp() — Case-insensitive comparison of two strings
  • strcmp() — Binary safe string comparison (case sensitive)
  • strcoll() — Compares two strings based on locale
  • strcspn() — Returns the number of characters found in a string before the occurrence of specified characters
  • strip_tags() — Removes HTML and PHP tags from a string
  • stripcslashes() — Opposite of addcslashes()
  • stripslashes() — Opposite of addslashes()
  • stripos() — Finds the position of the first occurrence of a substring within a string (case insensitive)
  • stristr() — Case-insensitive version of strstr()
  • strlen() — Returns the length of a string
  • strnatcasecmp() — Case-insensitive comparison of two strings using a “natural order” algorithm
  • strnatcmp() — Same as the aforementioned but case sensitive
  • strncasecmp() — String comparison of a defined number of characters (case insensitive)
  • strncmp() — Same as above but case-sensitive
  • strpbrk() — Searches a string for any number of characters
  • strpos() — Returns the position of the first occurrence of a substring in a string (case sensitive)
  • strrchr() — Finds the last occurrence of a string within another string
  • strrev() — Reverses a string
  • strripos() — Finds the position of the last occurrence of a string’s substring (case insensitive)
  • strrpos() — Same as strripos() but case sensitive
  • strspn() — The number of characters in a string with only characters from a specified list
  • strstr() — Case-sensitive search for the first occurrence of a string inside another string
  • strtok() — Splits a string into smaller chunks
  • strtolower() — Converts all characters in a string to lowercase
  • strtoupper() — Same but for uppercase letters
  • strtr() — Translates certain characters in a string, alternative: strchr()
  • substr() — Returns a specified part of a string
  • substr_compare() — Compares two strings from a specified start position up to a certain length, optionally case sensitive
  • substr_count() — Counts the number of times a substring occurs within a string
  • substr_replace() — Replaces a substring with something else
  • trim() — Removes space or other characters from both sides of a string
  • ucfirst() — Transforms the first character of a string to uppercase
  • ucwords() — Converts the first character of every word in a string to uppercase
  • vfprintf() — Writes a formatted string to a specified output stream
  • vprintf() — Outputs a formatted string
  • vsprintf() — Writes a formatted string to a variable
  • wordwrap() — Shortens a string to a given number of characters

PHP Operators

Operators allow you to perform operations with values, arrays and variables. There are several different types.

Arithmetic Operators

Your standard mathematic operators.

  • + — Addition
  • - — Subtraction
  • * — Multiplication
  • / — Division
  • % — Modulo (the remainder of value divided by another)
  • ** — Exponentiation

Assignment Operators

Besides the standard assignment operator (=), you also have the following options:

  • += — a += b is the same as a = a + b
  • -= — a -= b is the same as a = a – b
  • *= — a *= b is the same as a = a * b
  • /= — a /= b is the same as a = a / b
  • %= — a %= b is the same as a = a % b

Comparison Operators

  • == — Equal
  • === — Identical
  • != — Not equal
  • <> — Not equal
  • !== — Not identical
  • < — Less than
  • > — Greater than
  • <= — Less than or equal to
  • >= — Greater than or equal to
  • <=> — Less than, equal to, or greater than

Logical Operators

  • and — And
  • or — Or
  • xor — Exclusive or
  • ! — Not
  • && — And
  • || — Or

Bitwise Operators

  • & — And
  • | — Or (inclusive or)
  • ^ — Xor (exclusive or)
  • ~ — Not
  • << — Shift left
  • >> — Shift right

Error Control Operator

You can use the @ sign to prevent expressions from generating error messages. This is often important for security reasons, for example to keep confidential information safe.

Execution Operator

PHP supports one execution operator, which is `` (backticks). These are not single-quotes! PHP will attempt to execute the contents of the backticks as a shell command.

Increment/Decrement Operators

  • ++$v — Increments a variable by one, then returns it
  • $v++ — Returns a variable, then increments it by one
  • --$v — Decrements the variable by one, returns it afterward
  • $v-- — Returns the variable then decrements it by one

String Operators

  • . — Used to concatenate (mean combine) arguments
  • .= — Used to append the argument on the right to the left-side argument

Loops in PHP

Loops are very common in programming. They allow you to run through the same block of code under different circumstances. PHP has several different ones.

For Loop

This type goes through a block of code a specified number of times:

  1. for (starting counter value; ending counter value; increment by which to increase) {
  2. // code to execute goes here
  3. }

Foreach Loop

A loop using foreach runs through each element in an array:

  1. foreach ($InsertYourArrayName as $value) {
  2. // code to execute goes here
  3. }

While Loop

Loops through a block of code as long as a specified condition is true.

  1. while (condition that must apply) {
  2. // code to execute goes here
  3. }

Do…While Loop

The final PHP loop runs a code snippet once, then repeats the loop as long as the given condition is true.

  1. do {
  2. // code to execute goes here;
  3. } while (condition that must apply);

Conditional Statements

If/else statements are similar to loops. They are statements for running code only under certain circumstances. You have several options:

If Statement

Executes code if one condition is true.

  1. if (condition) {
  2. // code to execute if condition is met
  3. }


Runs a piece of code if a condition is true and another if it is not.

  1. if (condition) {
  2. // code to execute if condition is met
  3. } else {
  4. // code to execute if condition is not met
  5. }


Executes different code snippets for more than two conditions.

  1. if (condition) {
  2. // code to execute if condition is met
  3. } elseif (condition) {
  4. // code to execute if this condition is met
  5. } else {
  6. // code to execute if none of the conditions are met
  7. }

Switch Statement

Selects one of several blocks of code to execute.

  1. switch (n) {
  2. case x:
  3. code to execute if n=x;
  4. break;
  5. case y:
  6. code to execute if n=y;
  7. break;
  8. case z:
  9. code to execute if n=z;
  10. break;
  11. // add more cases as needed
  12. default:
  13. code to execute if n is neither of the above;
  14. }

Working with Forms in PHP

PHP is often used for handling web forms. In particular, the aforementioned $_GET and $_POSThelp to collect data sent via a form. Both are able to catch values from input fields, however, their usage differs.

Using GET vs POST

GET collects data via URL parameters. That means all variable names and their values are contained in the page address.

The advantage of this is that you’re able to bookmark the information. Keep in mind that it also means that the information is visible to everyone. For that reason, GET is not suitable for sensitive information such as passwords. It also limits the amount of data that can be sent in ca 2000 characters.

POST, on the other hand, uses the HTTP POST method to pass on variables. This makes the data invisible to third parties, as it is sent in the HTTP body. You are not able to bookmark it.

With POST, there are no limits to the amount of information you can send. Aside from that, it also has advanced functionality and is therefore preferred by developers.

Form Security

The most important issue when it comes to web forms is security. If not set up properly, they are vulnerable to cross-scripting attacks. The hackers add scripts to unsecured web forms to use them for their own purpose.

PHP also offers tools to thwart those attacks, namely:

  • htmlspecialchars()
  • trim()
  • stripslashes()

You will notice that we have encountered all of these function in the previous section on strings. When you include them in the script that collects the form data, you can effectively strip harmful scripts of the characters they need for functioning, rendering them unusable.

Required Fields, Error Messages and Data Validation

Aside from that, PHP is able to define required fields (you can’t submit the form without filling them out), display error messages if some information is missing and to validate data. We have already talked about the necessary tools to do so.

For example, you can simply define variables for your form fields and use the empty() function to check if they have values. After that, create a simple if/else statement to either send the submitted data or output an error message.

The next step is to check the submitted data for validity. For that, PHP offers a number of filters such as FILTER_VALIDATE_EMAIL to make sure a submitted email address has the right format.

PHP Filters

Filters are used to validate and filter data that is coming from insecure sources. As mentioned, a common example is user input. PHP offers a number of filter functions and constants for that:

Filter Functions

  • filter_has_var() — Checks if a variable of the specified type exists
  • filter_id() — Returns the ID belonging to a named filter
  • filter_input() — Retrieves a specified external variable by name and optionally filters it
  • filter_input_array() — Pulls external variables and optionally filters them
  • filter_list() — Returns a list of all supported filters
  • filter_var_array() — Gets multiple variables and optionally filters them
  • filter_var() — Filters a variable with a specified filter

Filter Constants

  • FILTER_VALIDATE_BOOLEAN — Validates a boolean
  • FILTER_VALIDATE_EMAIL — Certifies an e-mail address
  • FILTER_VALIDATE_FLOAT — Confirms a float
  • FILTER_VALIDATE_INT — Verifies an integer
  • FILTER_VALIDATE_IP — Validates an IP address
  • FILTER_VALIDATE_REGEXP — Confirms a regular expression
  • FILTER_SANITIZE_EMAIL — Removes all illegal characters from an e-mail address
  • FILTER_SANITIZE_ENCODED — Removes/Encodes special characters
  • FILTER_SANITIZE_MAGIC_QUOTES — Applies addslashes()
  • FILTER_SANITIZE_NUMBER_FLOAT — Removes all characters, except digits, +- and .,eE
  • FILTER_SANITIZE_NUMBER_INT — Gets rid of all characters except digits and + –
  • FILTER_SANITIZE_SPECIAL_CHARS — Removes special characters
  • FILTER_SANITIZE_FULL_SPECIAL_CHARS — Converts special characters to HTML entities
  • FILTER_SANITIZE_STRING — Removes tags/special characters from a string, alternative: FILTER_SANITIZE_STRIPPED
  • FILTER_SANITIZE_URL — Rids all illegal characters from a URL
  • FILTER_UNSAFE_RAW —Do nothing, optionally strip/encode special characters
  • FILTER_CALLBACK — Call a user-defined function to filter data

HTTP Functions in PHP

PHP also has the functionality to manipulate data sent to the browser from the web server.

HTTP Functions

  • header() — Sends a raw HTTP header to the browser
  • headers_list() — A list of response headers ready to send (or already sent)
  • headers_sent() — Checks if and where the HTTP headers have been sent
  • setcookie() — Defines a cookie to be sent along with the rest of the HTTP headers
  • setrawcookie() — Defines a cookie (without URL encoding) to be sent along

Working with MySQL

Many platforms that are based on PHP work with a MySQL database in the background. For that reason, it’s important to be familiar with the functions that allow you to work with them.

MySQL Functions

  • mysqli_affected_rows() — The number of affected rows in the previous MySQL operation
  • mysqli_autocommit() — Turn auto-committing database modifications on or off
  • mysqli_change_user() — Changes the user of the specified database connection
  • mysqli_character_set_name() — The default character set for the database connection
  • mysqli_close() — Closes an open database connection
  • mysqli_commit() — Commits the current transaction
  • mysqli_connect_errno() — The error code from the last connection error
  • mysqli_connect_error() — The error description from the last connection error
  • mysqli_connect() — Opens a new connection to the MySQL server
  • mysqli_data_seek() — Moves the result pointer to an arbitrary row in the result set
  • mysqli_debug() — Performs debugging operations
  • mysqli_dump_debug_info() — Dumps debugging information into a log
  • mysqli_errno() — The last error code for the most recent function call
  • mysqli_error_list() — A list of errors for the most recent function call
  • mysqli_error() — The last error description for the most recent function call
  • mysqli_fetch_all() — Fetches all result rows as an array
  • mysqli_fetch_array() — Fetches a result row as an associative, a numeric array, or both
  • mysqli_fetch_assoc() — Fetches a result row as an associative array
  • mysqli_fetch_field_direct() — Metadata for a single field as an object
  • mysqli_fetch_field() — The next field in the result set as an object
  • mysqli_fetch_fields() — An array of objects that represent the fields in a result set
  • mysqli_fetch_lengths() — The lengths of the columns of the current row in the result set
  • mysqli_fetch_object() — The current row of a result set as an object
  • mysqli_fetch_row() — Fetches one row from a result set and returns it as an enumerated array
  • mysqli_field_count() — The number of columns for the most recent query
  • mysqli_field_seek() — Sets the field cursor to the given field offset
  • mysqli_field_tell() — The position of the field cursor
  • mysqli_free_result() — Frees the memory associated with a result
  • mysqli_get_charset() — A character set object
  • mysqli_get_client_info() — The MySQL client library version
  • mysqli_get_client_stats() — Returns client per-process statistics
  • mysqli_get_client_version() — The MySQL client library version as an integer
  • mysqli_get_connection_stats() — Statistics about the client connection
  • mysqli_get_host_info() — The MySQL server hostname and the connection type
  • mysqli_get_proto_info() — The MySQL protocol version
  • mysqli_get_server_info() — Returns the MySQL server version
  • mysqli_get_server_version() — The MySQL server version as an integer
  • mysqli_info() — Returns information about the most recently executed query
  • mysqli_init() — Initializes MySQLi and returns a resource for use with mysqli_real_connect()
  • mysqli_insert_id() — Returns the auto-generated ID used in the last query
  • mysqli_kill() — Asks the server to kill a MySQL thread
  • mysqli_more_results() — Checks if there are more results from a multi query
  • mysqli_multi_query() — Performs one or more queries on the database
  • mysqli_next_result() — Prepares the next result set from mysqli_multi_query()
  • mysqli_num_fields() — The number of fields in a result set
  • mysqli_num_rows() — The number of rows in a result set
  • mysqli_options() — Sets extra connect options and affect behavior for a connection
  • mysqli_ping() — Pings a server connection or tries to reconnect if it has gone down
  • mysqli_prepare() — Prepares an SQL statement for execution
  • mysqli_query() — Performs a query against the database
  • mysqli_real_connect() — Opens a new connection to the MySQL server
  • mysqli_real_escape_string() — Escapes special characters in a string for use in an SQL statement
  • mysqli_real_query() — Executes an SQL query
  • mysqli_reap_async_query() — Returns the result from async query
  • mysqli_refresh() — Refreshes tables or caches or resets the replication server information
  • mysqli_rollback() — Rolls back the current transaction for the database
  • mysqli_select_db() — Changes the default database for the connection
  • mysqli_set_charset() — Sets the default client character set
  • mysqli_set_local_infile_default() — Unsets a user-defined handler for the LOAD LOCAL INFILE command
  • mysqli_set_local_infile_handler() — Sets a callback function for the LOAD DATA LOCAL INFILE command
  • mysqli_sqlstate() — Returns the SQLSTATE error code for the last MySQL operation
  • mysqli_ssl_set() — Establishes secure connections using SSL
  • mysqli_stat() — The current system status
  • mysqli_stmt_init() — Initializes a statement and returns an object for use with mysqli_stmt_prepare()
  • mysqli_store_result() — Transfers a result set from the last query
  • mysqli_thread_id() — The thread ID for the current connection
  • mysqli_thread_safe() — Returns if the client library is compiled as thread-safe
  • mysqli_use_result() — Initiates the retrieval of a result set from the last query executed using the mysqli_real_query()
  • mysqli_warning_count() — The number of warnings from the last query in the connection

Date and Time

Of course, PHP functions for date and time should not be missing from any PHP cheat sheet.

Date/Time Functions

  • checkdate() — Checks the validity of a Gregorian date
  • date_add() — Adds a number of days, months, years, hours, minutes and seconds to a date object
  • date_create_from_format() — Returns a formatted DateTime object
  • date_create() — Creates a new DateTime object
  • date_date_set() — Sets a new date
  • date_default_timezone_get() — Returns the default timezone used by all functions
  • date_default_timezone_set() — Sets the default timezone
  • date_diff() — Calculates the difference between two dates
  • date_format() — Returns a date formatted according to a specific format
  • date_get_last_errors() — Returns warnings or errors found in a date string
  • date_interval_create_from_date_string() — Sets up a DateInterval from relative parts of a string
  • date_interval_format() — Formats an interval
  • date_isodate_set() — Sets a date according to ISO 8601 standards
  • date_modify() — Modifies the timestamp
  • date_offset_get() — Returns the offset of the timezone
  • date_parse_from_format() — Returns an array with detailed information about a specified date, according to a specified format
  • date_parse() — Returns an array with detailed information about a specified date
  • date_sub() — Subtracts days, months, years, hours, minutes and seconds from a date
  • date_sun_info() — Returns an array containing information about sunset/sunrise and twilight begin/end for a specified day and location
  • date_sunrise() — The sunrise time for a specified day and location
  • date_sunset() — The sunset time for a specified day and location
  • date_time_set() — Sets the time
  • date_timestamp_get() — Returns the Unix timestamp
  • date_timestamp_set() — Sets the date and time based on a Unix timestamp
  • date_timezone_get() — Returns the time zone of a given DateTime object
  • date_timezone_set() — Sets the time zone for a DateTime object
  • date() — Formats a local date and time
  • getdate() — Date/time information of a timestamp or the current local date/time
  • gettimeofday() — The current time
  • gmdate() — Formats a GMT/UTC date and time
  • gmmktime() — The Unix timestamp for a GMT date
  • gmstrftime() — Formats a GMT/UTC date and time according to locale settings
  • idate() — Formats a local time/date as an integer
  • localtime() — The local time
  • microtime() — The current Unix timestamp with microseconds
  • mktime() — The Unix timestamp for a date
  • strftime() — Formats a local time and/or date according to locale settings
  • strptime() — Parses a time/date generated with strftime()
  • strtotime() — Transforms an English textual DateTime into a Unix timestamp
  • time() — The current time as a Unix timestamp
  • timezone_abbreviations_list() — Returns an array containing dst, offset, and the timezone name
  • timezone_identifiers_list() — An indexed array with all timezone identifiers
  • timezone_location_get() — Location information for a specified timezone
  • timezone_name_from_abbr() — Returns the timezone name from an abbreviation
  • timezone_name_get() — The name of the timezone
  • timezone_offset_get() — The timezone offset from GMT
  • timezone_open() — Creates a new DateTimeZone object
  • timezone_transitions_get() — Returns all transitions for the timezone
  • timezone_version_get() — Returns the version of the timezonedb

Date and Time Formatting

  • d — 01 to 31
  • j — 1 to 31
  • D — Mon through Sun
  • l — Sunday through Saturday
  • N — 1 (for Mon) through 7 (for Sat)
  • w — 0 (for Sun) through 6 (for Sat)
  • m — Months, 01 through 12
  • n — Months, 1 through 12
  • F — January through December
  • M — Jan through Dec
  • Y — Four digits year (e.g. 2018)
  • y — Two digits year (e.g. 18)
  • L — Defines whether it’s a leap year (1 or 0)
  • a — am and pm
  • A — AM and PM
  • g — Hours 1 through 12
  • h — Hours 01 through 12
  • G — Hours 0 through 23
  • H — Hours 00 through 23
  • i — Minutes 00 to 59
  • s — Seconds 00 to 59

PHP Errors

Finally, for the times that things don’t go smoothly and you need to find out where the problem lies, PHP also offers functionality for errors.

Error Functions

  • debug_backtrace() — Used to generate a backtrace
  • debug_print_backtrace() — Prints a backtrace
  • error_get_last() — Gets the last error that occurred
  • error_log() — Sends an error message to the web server’s log, a file or a mail account
  • error_reporting() — Specifies which PHP errors are reported
  • restore_error_handler() — Reverts to the previous error handler function
  • restore_exception_handler() — Goes back to the previous exception handler
  • set_error_handler() — Sets a user-defined function to handle script errors
  • set_exception_handler() — Sets an exception handler function defined by the user
  • trigger_error() — Generates a user-level error message, you can also use user_error()

Error Constants

  • E_ERROR — Fatal run-time errors that cause the halting of the script and can’t be recovered from
  • E_WARNING — Non-fatal run-time errors, execution of the script continues
  • E_PARSE — Compile-time parse errors, should only be generated by the parser
  • E_NOTICE — Run-time notices that indicate a possible error
  • E_CORE_ERROR — Fatal errors at PHP initialization, like an E_ERROR in PHP core
  • E_CORE_WARNING — Non-fatal errors at PHP startup, similar to E_WARNING but in PHP core
  • E_COMPILE_ERROR — Fatal compile-time errors generated by the Zend Scripting Engine
  • E_COMPILE_WARNING — Non-fatal compile-time errors by the Zend Scripting Engine
  • E_USER_ERROR — Fatal user-generated error, set by the programmer using trigger_error()
  • E_USER_WARNING — Non-fatal user-generated warning
  • E_USER_NOTICE — User-generated notice by trigger_error()
  • E_STRICT — Suggestions by PHP to improve your code (needs to be enabled)
  • E_RECOVERABLE_ERROR — Catchable fatal error caught by a user-defined handle
  •  E_DEPRECATED — Enable this to receive warnings about a code which is not future-proof
  • E_USER_DEPRECATED — User-generated warning for deprecated code
  • E_ALL — All errors and warnings except E_STRICT


DNS-325 HOWTO Build lighttpd

HOWTO Build lighttpd

First, set up your crosscompile toolchain. Download build_lighttpd_pa1.tgz. Extract, edit the file to correct the bug in tar xvfz zips/.tar.gz –> tar xvzf zips/$APP-$APP_VER.tar.gz and then execute.

Quick helper: Also note that you need to create a /zips/ folder (or add it to the above script right after [if ! -f zips ]), otherwise the script breaks

Transfer the result, dns323_lighttpd-1.4.13.tar.gz, to /mnt/HD_a2 and extract it lnx_bin/busybox3 tar xvz -f dns323_lighttpd-1.4.13.tar.gz

Create a file, index.html, located in /mnt/HD_a2/www:

    Hello World from DNS-323

Create a file, lighttpd.conf, located in /mnt/HD_a2/lnx_bin:

server.document-root = "/mnt/HD_a2/www/"
server.port = 3000
mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"

Now, let lighttpd analyze the file using ./lighttpd -t -f lighttpd.conf and if that worked out, start the server using ./lighttpd -D -f lighttpd.conf

Access your server on port 3000, e.g.

Notes on the application

The default path for the mod_-files are compiled into the application to be /mnt/HD_a2/lnx_bin/lib using the -DLIBRARY_DIR directive. To have the modules in another directory, change the build script or start the server with argumet -m PATH

Note on lighttpd version

Beginning with 1.5.0, lighttpd depends on glib2.

Notes on using port 80 for lighttpd

For fun-plug v0.5 click here and look for Port 80 for fun-plug versions 0.3 & 0.4 see below…

Since the DNS-323 Admin service (webs) uses port 80 in order to use port 80 for lighttpd you'll need to do the following:

  1. Modify ligttpd.conf file to include “server.port = 80”
  2. Stop the lighttpd service
  3. Stop the 'webs' service
  4. Start the lighttpd service

or use the two scripts below and make sure you put them in ./fun_plug.d/start directory with the correct CHMOD settings so they run automatically.

The admin service on your DNS-323 will now be available on port 81. To access:

Here's the 'lighttpd.sh' script:

# This script was modified by Paul on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with admwebs.sh (created) which is
# called from this script. lighttpd.sh stops (via admwebs.sh) the
# web admin service and then starts lighttpd on port 80. The web admin
# now (automatically) starts on port 81 after a few seconds. The admin
# service tests for use on port 80. If it's in use then bumps to the 
# next available port (in this case it's bumped to port 81).
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
# USE "netstat -tln" to verify that both port 80 & 81 are in use.

lighttpd_start() {

    # make sure, upload directory exists
    # path must match server.upload-dirs in lighttpd.conf file!
    mkdir -p ${VOL1}/tmp
    chmod 01777 ${VOL1}/tmp

    if [ -x "${SBINDIR}/lighttpd" ]; then
        echo "Stopping WEB admin"
        /mnt/HD_a2/fun_plug.d/start/admwebs.sh stop
        echo "Starting lighttpd... "
        ${SBINDIR}/lighttpd -f ${ETCDIR}/lighttpd.conf 1>/dev/null 2>/dev/null </dev/null
        echo "Starting WEB admin on port 81"
        /mnt/HD_a2/fun_plug.d/start/admwebs.sh start
        echo "done!" 
        echo "ERROR: lighttpd not found or not executable"

lighttpd_stop() {
    killall lighttpd

lighttpd_status() {
    if [ -n "$(pidof lighttpd)" ]; then
        echo "running"
        echo "stopped"

case "$1" in
        sleep 1
        echo "Usage: $0 start|stop|restart|status"

Here's the 'admwebs.sh' script:

# This script was created by Paul on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with lighttpd.sh (also modified) which
# calls this script. When used from lighttpd.sh it stops the
# web admin service then starts lighttpd on port 80. The web admin
# service notices that something is on port 80 and then starts on
# port 81.
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
# NOTE2: (2/14/08)
#  Updated this script to remove "Starting" webs. Apparently
#  if you start webs you will not be able to add users
#  webs is set to automatically restart if the /web/webs service
#  is stopped.

admwebs_start() {
    if [ -x "/web/webs" ]; then
#       echo "Starting webs... "
#       /web/webs & > /dev/null
        echo "/webs/webs service will start automatically in 45 sec"
        echo "ERROR: /web/webs not found or not executable"

admwebs_stop() {
    killall webs

admwebs_status() {
    if [ -n "$(pidof webs)" ]; then
        echo "running"
        echo "stopped"

case "$1" in
        sleep 1
        echo "Usage: $0 start|stop|restart|status"

Easy Ways

  • A pre-compiled variant can be found here
  • lighttpd is also included in fonz's fun_plug pack, a comprehensive fun_plug package that's easy to implement and great for first time users. php is a separate package that can be added easily. Instructions are provided.

Lighttpd for Windows Users

if you don't speak linux gibberish:

Before you begin:

Install Putty on your PC: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Install Netscan on your PC: http://www.softperfect.com/products/networkscanner/

Run Netscan. click the Options tab, then the Additional subtab. Click all the buttons. in the box on the bottom type 22, 23, 80, 443, 8080. Click OK.

Click the IP box, then click the range of your network in the box that pops up.

these files must be in these locations in Volume_1 of the DNS-323:

lighttpd.sh in /ffp/start

lighttpd.conf in ffp/etc/examples

these files are installed by default when fun plug runs the first time

Create these folders:




Run Putty. You will get a black box with an octet: # and a green cursor. you will enter the commands below at the green cursor. the octet is shown as a

reference point.

this command will copy the lighttpd configuration file /examples to ffp/etc:

# cd /ffp/etc

# cp examples/lighttpd.conf /ffp/etc/lighttpd.conf

this makes the lighttpd shell file in the /ffp/start directory executeable:

# cd /ffp/start

# chmod +x lighttpd.sh

it will not start if lighttpd.conf is not in /ffp/etc

to manually start lighttpd:

# sh /ffp/start/lighttpd.sh start

If it's running you will see port 8080 open on your DNS-323 when you Start Scanning in Netscan

Lighttpd with SQLite

Update extensions path in php.ini to point to '/ffp/lib/php/extensions/no-debug-non-zts-20 060613/'

Installation of SQLite

Configuration of PHP

  • Add some lines to /ffp/etc/php.ini if you need support for SQL in PHP (Create file if needed):


  • Restart ligthttpd (As root):

/ffp/start/lighttpd.sh restart