Category Archives: PHP

Define website base url

In a config file you can have:

[php]

DEFINE(‘HTTP_ROOT’, $_SERVER[‘HTTP_HOST’]);
DEFINE(‘HTTP_FOLDER’, dirname($_SERVER[‘PHP_SELF’]) . ‘/’);
DEFINE(‘BASE_URL’, "http://" . HTTP_ROOT . HTTP_FOLDER);

[/php]

 

Then you’ll use BASE_URL as the root of your website.

php Send Html Emails

$to = 'bob@example.com';

$subject = 'Website Change Reqest';

$headers = "From: " . strip_tags($_POST['req-email']) . "rn";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "rn";
$headers .= "CC: susan@example.comrn";
$headers .= "MIME-Version: 1.0rn";
$headers .= "Content-Type: text/html; charset=ISO-8859-1rn";

$message = "whatever decent html";

mail($to, $subject, $message, $headers);

Curl https pages

(As found here)

We can simply configure cURL to accept any server(peer) certificate. This isn’t optimal from a security point of view, but if you’re not passing sensitive information back and forth, this is probably alright. Simply add the following line before calling curl_exec():

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Detect Mobile by Regex

Mobile phones:

iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Mobile Safari|Android|Opera Mini

Tablets:

ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle|Safari

 

Old oku settings:

Configuration->Design->Default Cofig:

Current Package Name – Current Package Name

Templates, Skin (Images / CSS), Layout, Default: modern

iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Mobile Safari|Android|Opera Mini – toku

ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle|Safari – modern