This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FileCache { | |
protected $cacheValidTime; | |
public $cacheIsValid = false; | |
protected $cacheFile; | |
function __construct($file, $valid = 86400) { | |
$this->setCacheFile($file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function file_size($file, $path = "") { | |
define("DOCUMENT_ROOT", dirname(__FILE__); // better you define this in the root | |
$bytes = array("B", "KB", "MB", "GB", "TB", "PB"); | |
$file_with_path = DOCUMENT_ROOT."/".$path."/".$file; | |
// replace (possible) double slashes with a single one | |
$file_with_path = str_replace("//", "/", $file_with_path); | |
$size = filesize($file_with_path); | |
$i = 0; | |
while ($size >= 1024) { //divide the filesize (in bytes) with 1024 to get "bigger" bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class local_date { | |
private $week_day; | |
private $day; | |
private $month; | |
private $year; | |
public function __construct() { | |
$this->week_day = date("l"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$values = array('google'=>'Google Search', 'link'=>'Link on some website', 'advert'=>'Advertisement', 'news'=>'News'); | |
$html_elements = array('before'=>'<span>', 'after'=>'</span><br />', 'label'=>'<label for="test"><b>Some label</b></label><br />'); | |
function dynamic_radio_group($formelement, $values, $html, $def_value = '') { | |
$radio_group = '<div>'."\n"; | |
$radio_group .= (!empty($html['label'])) ? $html['label']."\n" : ''; | |
if (isset($_REQUEST[$formelement])) { | |
$curr_val = stripslashes($_REQUEST[$formelement]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// First you need some code to get a database result set. | |
// Split the resultset into two arrays, one for the product groups and one for the categories. | |
$sql = "SELECT id, parent_id, name, var_name FROM prod_category ORDER BY parent_id, id ASC"; $categories = mysql_query($sql); | |
while ($obj = mysql_fetch_object($categories)) { | |
if (!empty($obj->parent_id)) { // there are options | |
$arr_options[$obj->id]['parent'] = $obj->parent_id; // the corresponding key (group id) | |
$arr_options[$obj->id]['label'] = $obj->name; | |
$arr_options[$obj->id]['value'] = $obj->var_name; | |
// this array is build to check later the existings of options against the option groups |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url_parts = parse_url("http://mail.finalwebsites.co.uk"); | |
$domain = $url_parts['host']; | |
$db = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME); | |
$res = $db->query("SELECT tld FROM domain_info ORDER BY LENGTH(tld) DESC"); | |
// "ORDER BY LENGTH(tld)" will give first the co.uk and then the uk | |
while ($arr = $res->fetch_array(MYSQLI_ASSOC)) { | |
$tmp_tld = substr($domain, -strlen(".".$arr['tld'])); | |
if ($tmp_tld == ".".$arr['tld']) { // You found the tld | |
$tld = ltrim($arr['tld'], "."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$random[] = '<a href="http://www.all4yourwebsite.com/" title="Website templates, dreamweaver templates, flash intro templates"><img src="images/banners/all4webBanner468_60.jpg" alt="all4yourWebsite.com - web design templates" /></a>'; | |
$random[] = '<a href="http://www.designers-website.eu/" title="Premium Web Design Templates"><img src="/images/banners/designers_website_468_60.jpg" alt="Designers Website" /></a>'; | |
// ad more banners if you like | |
$random[] = '<script type="text/javascript"><!-- | |
google_ad_client = "pub-xxxxxxxxxxx"; | |
google_ad_width = 468; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function create_form_field($formelement, $label = "", $db_value = "", $length = 25) { | |
$form_field = ($label != "") ? "<label for=\"".$formelement."\">".$label."</label>\n" : ""; | |
$form_field .= " <input name=\"".$formelement."\" type=\"text\" size=\"".$length."\" value=\""; | |
if (isset($_REQUEST[$formelement])) { | |
$form_field .= $_REQUEST[$formelement]; | |
} elseif (isset($db_value) && !isset($_REQUEST[$formelement])) { | |
$form_field .= $db_value; | |
} else { | |
$form_field .= ""; |
OlderNewer