Tag archives: script

How to check if an email from an educational institution?

This PHP snippet (function) allows you to check if an email address from an educational institution.


<?php
/**
 * @title          Check if it is a valid and university email address.
 *
 * @param          string $sEmail
 * @return         boolean
 */
function isUniversityEmail($sEmail)
{
    return preg_match('/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+edu$/i', $sEmail);
}
?>

Example of usage:


if (!isUniversityEmail('you@post.harvard.edu'))
    exit('You must have a valid and .edu email address to register for an account.');

Good code! ;-)

Continue reading

How to check if Apache's mod_rewrite is installed? | PHP Snippet

Hi everyone!

This is a snippet (function) that lets you know if the mod_rewrite of Apache is installed on a Web server.


<?php
/**
 * Check if Apache's mod_rewrite is installed.
 * 
 * @return boolean
 */
function isRewriteMod()
{
    if (function_exists('apache_get_modules'))
    {
        $aMods = apache_get_modules();
        $bIsRewrite = in_array('mod_rewrite', $aMods);
    }
    else
    {
        $bIsRewrite = (strtolower(getenv('HTTP_MOD_REWRITE')) == 'on');
    }

    return $bIsRewrite;
}
?>

How to use this?

Very simple, just look this example below:


if (!isRewriteMod()) exit('Please install Apache mod_rewrite module.');

Good code! ;-)

Continue reading

Get the favicon of a website | PHP Script Snippet

Here's a little feature that allows you to easily retrieve the favicon of a URL


<?php
/**
 * Get favicon from a URL.
 * 
 * @param string $sUrl
 * @return string The favicon image.
 */
function get_favicon($sUrl)
{
	$sApiUrl = 'http://www.google.com/s2/favicons?domain=';
	$sDomainName = get_domain($sUrl);
	
	return $sApiUrl . $sDomainName;
}

/**
 * Get domain name from a URL (helper function).
 * 
 * @param string $sUrl
 * @return string $sUrl Returns the URL to lower case and without the www. if present in the URL.
 */
function get_domain($sUrl)
{
        $sUrl = str_ireplace('www.', '', $sUrl);
        $sHost = parse_url($sUrl, PHP_URL_HOST);
        return $sHost;
}
?>

How to use this


<a href="http://www.php.net/manual ...

Continue reading

Check your Internet connection | PHP Script Snippet

To check if your Internet connection is enabled, a simple solution is this function:


<?php
/**
 * Check Internet Connection.
 * 
 * @param string $sCheckHost Default: http://www.google.com
 * @return boolean
 */
function check_internet_connection($sCheckHost = 'http://www.google.com') 
{
    return (bool) @fopen($sCheckHost, 'r');
}
?>

A function is a little more advanced:


<?php
/**
 * Check Internet Connection.
 * 
 * @param string $sCheckHost Default: www.google.com
 * @return boolean
 */
function check_internet_connection($sCheckHost = 'www.google.com') 
{
    return (bool) @fsockopen($sCheckHost, 80, $iErrno, $sErrStr, 5);
}
?>

Example of use:


<?php
$bIsConnected = check_internet_connection();
$sText = ($bIsConnected) ? '<p style="color:green">You are currently connected to the Internet.</p>' : '<p style="color:red">You are ...

Continue reading

Create your own community website with Dolphin

Create your own community website with Dolphin

Dolphin is a good community software written in PHP.
It offers many features such as profiles members, full ajax forum, gallery photos, groups, directory sites, video chat rooms, blog, Deskpot, iPhone and Android App, ...

All code is open source and available on the SVN repository except mobile applications where you must be a member to qualify Prenium code to post your application on mobile iTunes Store and Android Market

Site: BoonEx Dolphin.

Continue reading

Create your own Chatroulette

Create your own Chatroulette

Create you own chatroulette with this open source script.

Unlike other webcam chat scripts that need a flash or Red5 server for streaming audio and video, it works on all servers that support PHP and MySQL because it works on the principle of P2P (peer-to -peer) with the protocol developed by Adobe, the RTMP (Real Time Messaging Protocol).

It requires only an API key Adobe Stratus you can get here: https://www.adobe.com/cfusion/entitlement/index.cfm?e=cirrus

Also note that it is possible to run the roulette with a Red5 server for greater speed and better stability ...

Continue reading