Author:
erics , August 3rd, 2013
pear upgrade pear
pear - D auto_discover = 1 install pear . amazonwebservices . com / sdk
require 'AWSSDKforPHP/aws.phar' ;
http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/installation.html#installing-via-pear http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/quick-start.html http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html
Categories: How-To's , Technology Tags: Amazon , AWS , howto , PEAR , php , SDK , tips
| No comments
Author:
erics , October 25th, 2012
$ URL = 'http' ;
if ( $ _SERVER [ "HTTPS" ] == "on" ) {
$ URL . = "s" ;
}
$ URL . = '://' . $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] ;
Categories: How-To's , Technology Tags: $_SERVER , apache , howto , HTTP_HOST , php , REQUEST_URI , Server , tips , URL
| No comments
Author:
erics , October 22nd, 2012
Add this to your theme’s functions.php file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* Add the [private] shortcode. */
add_shortcode ( 'private' , 'is_user_logged_in_shortcode' ) ;
/* Add the [public] shortcode. */
add_shortcode ( 'public' , 'is_user_not_logged_in_shortcode' ) ;
function is_user_logged_in_shortcode ( $ attr , $ content = null ) {
/* If it is a feed or the user is not logged in, return nothing. */
if ( is_feed ( ) || ! is_user_logged_in ( ) || is_null ( $ content ) )
return '' ;
/* Return the content. */
return do_shortcode ( $ content ) ;
}
function is_user_not_logged_in_shortcode ( $ attr , $ content = null ) {
/* If it is a feed or the user is logged in, return nothing. */
if ( is_feed ( ) || is_user_logged_in ( ) || is_null ( $ content ) )
return '' ;
/* Return the content. */
return do_shortcode ( $ content ) ;
}
Categories: How-To's , Technology Tags: howto , Members-Only , php , Provate , public , ShortCode , tips , WordPress
| No comments
Author:
erics , October 21st, 2012
$ valid = validateEmailAddress ( 'yourName@yourDomain.com' ) ;
function validateEmailAddress ( $ email = '' ) {
// returns 1 for valid and 0 for invalid
return ( int ) ( filter_var ( $ email , FILTER_VALIDATE_EMAIL ) && preg_match ( '/@.+\./' , $ email ) ) ;
}
Categories: How-To's , Technology Tags: Email , FILTER_VALIDATE_EMAIL , filter_var , php , preg_match , Valid , Validate
| No comments
Author:
erics , October 19th, 2012
The do/while statement is sometimes used to break out of a block of code when an error condition occurs. For example:
do {
// do some stuff
if ( $ error_condition )
break ;
// do some other stuff
} while ( false ) ;
Because the condition for the loop is false, the loop is executed only once, regardless of what happens inside the loop. However, if an error occurs, the code after the break is not […]
Categories: How-To's , Technology Tags: Block , break , Code , Code Block , Error , Error Handling , Errors , php
| No comments
Author:
erics , October 10th, 2012
$ s3 -> create_object ( '<bucket_name>' , 'folder/' , array ( 'body' = > '' ) ) ;
~ OR ~
$ s3 -> create_object ( '<bucket_name>' , 'folder/' , array ( 'body' = > '' , 'contentType' = > 'application/x-directory' ) ) ;
Categories: How-To's , Technology Tags: Amazon , AWS , Create , create_object , directory , howto , php , tips
| No comments
Author:
erics , October 1st, 2012
Add the parameter label_ids=true. For example:
{ html_radios name = "yourName" label_ids = true options = $ yourOptions selected = $ smarty . request . yourName separator = "<br/>" }
Categories: How-To's , Technology Tags: howto , html , html_radios , ID , Missing , php , Radio , Radio Button , Radios , Smarty , tips
| No comments
Author:
erics , September 12th, 2012
$ now = time ( ) ;
$ this_year = strtotime ( '1 July' ) ;
$ delta = $ this_year - $ now ;
if ( $ delta > 0 ) {
// this year's anniversary date is still to come, use it
$ anniversary = $ this_year ;
} else {
// nope, use next year's date
$ anniversary = strtotime ( '1 July +1 year' ) ;
}
Categories: How-To's , Technology Tags: Anniversary , Date , howto , Next date , php , tips
| No comments
Author:
erics , August 8th, 2012
if ( ! function_exists ( 'yourFunctionName' ) ) {
function yourFunctionName ( ) {
//your function definition goes here
}
}
Categories: How-To's , Technology Tags: Cannot Redeclare Function , Error , Fatal Error , howto , php , tips
| No comments
Author:
erics , May 11th, 2012
$protocol = (!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] !== ‘off’) ? “https:” : “http:”;
Categories: How-To's , Technology Tags: $_SERVER , 443 , 80 , howto , http , https , php , Port 443 , Port 80 , Protocol , tips
| No comments