Archive for the ‘ PHP ’ Category
This code is still beta, use at your own risk. __db_host = $host; $this->__db_username = $username; $this->__db_password = $password; $this->__db_name = $db_name; $this->connect(); } /** * Initialize our table object [ READ MORE ]
__db_host = $host; $this->__db_username = $username; $this->__db_password = $password; $this->__db_name = $db_name; $this->connect(); } /** * Initialize our table object [ READ MORE ]
This is a quick and dirty screen scraper for quantcast.com. It currently only grabs the site rank and description. Usage: $q = new QuantCast('cnet.com'); echo 'Rank: ' . $q->getRank() . ''; echo 'Desc: ' . $q->getDescription() . ''; Class Source Code: class QuantCast { public $siteName; private $siteContents; public function __construct($siteName){ $this->siteName = strtolower(str_replace('http://', '', $siteName)); [ READ MORE ]
$q = new QuantCast('cnet.com'); echo 'Rank: ' . $q->getRank() . ''; echo 'Desc: ' . $q->getDescription() . '';
class QuantCast { public $siteName; private $siteContents; public function __construct($siteName){ $this->siteName = strtolower(str_replace('http://', '', $siteName)); [ READ MORE ]
This class requires PHP 5.2+ and the MySQLi extension. It will not work with the regular MySQL extension. An object representing a table is created on the fly that will allow you to do inserts, updates etc. Please see comments in the code for usage. init('user_table'); * $user->get("user_id = 4343"); [ READ MORE ]
init('user_table'); * $user->get("user_id = 4343"); [ READ MORE ]
Just a simple php mime type array $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', [ READ MORE ]
$mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', [ READ MORE ]
This array can be used to build out a Country drop down list. 'AFGHANISTAN', 'AL'=>'ALBANIA', 'DZ'=>'ALGERIA', 'AS'=>'AMERICAN SAMOA', 'AD'=>'ANDORRA', 'AO'=>'ANGOLA', 'AI'=>'ANGUILLA', 'AQ'=>'ANTARCTICA', 'AG'=>'ANTIGUA AND BARBUDA', 'AR'=>'ARGENTINA', 'AM'=>'ARMENIA', 'AW'=>'ARUBA', 'AU'=>'AUSTRALIA', 'AT'=>'AUSTRIA', 'AZ'=>'AZERBAIJAN', 'BS'=>'BAHAMAS', 'BH'=>'BAHRAIN', 'BD'=>'BANGLADESH', 'BB'=>'BARBADOS', 'BY'=>'BELARUS', 'BE'=>'BELGIUM', 'BZ'=>'BELIZE', [ READ MORE ]
'AFGHANISTAN', 'AL'=>'ALBANIA', 'DZ'=>'ALGERIA', 'AS'=>'AMERICAN SAMOA', 'AD'=>'ANDORRA', 'AO'=>'ANGOLA', 'AI'=>'ANGUILLA', 'AQ'=>'ANTARCTICA', 'AG'=>'ANTIGUA AND BARBUDA', 'AR'=>'ARGENTINA', 'AM'=>'ARMENIA', 'AW'=>'ARUBA', 'AU'=>'AUSTRALIA', 'AT'=>'AUSTRIA', 'AZ'=>'AZERBAIJAN', 'BS'=>'BAHAMAS', 'BH'=>'BAHRAIN', 'BD'=>'BANGLADESH', 'BB'=>'BARBADOS', 'BY'=>'BELARUS', 'BE'=>'BELGIUM', 'BZ'=>'BELIZE', [ READ MORE ]
Pull weather data from Google's weather API (http://www.google.com/ig/api?weather=10027). This class grabs the raw data (xml) and creates a nicely formatted associative array containing the weather information. Example: $w = new googleWeather(); $w->enable_cache = 1; $w->cache_path = '/var/www/mysite.com/cache'; $ar_data = $w->get_weather_data(10027); print_r($ar_data); echo $ar_data['forecast'][0]['day_of_week']; Source: <?php /** * Grabs weather data from Google.com's weather API and return a nicely formatted array * [ READ MORE ]
$w = new googleWeather(); $w->enable_cache = 1; $w->cache_path = '/var/www/mysite.com/cache'; $ar_data = $w->get_weather_data(10027); print_r($ar_data); echo $ar_data['forecast'][0]['day_of_week'];
<?php /** * Grabs weather data from Google.com's weather API and return a nicely formatted array * [ READ MORE ]