Aug.19

Detecting Android, iPhone, iPod, iPad and BlackBerry browser with PHP

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$ua_checker = array(
  'android'=>preg_match('/android/', $ua),
  'iphone'=>preg_match('/iphone|ipod|ipad/', $ua),
  'blackberry'=>preg_match('/blackberry/', $ua)
);
if ($ua_checker['android']) {
  // up to you
}
else if ($ua_checker['iphone']) {
  // up to you
}
else if ($ua_checker['blackberry']) {
  // up to you
}
Web Programming

Aug.19

Detecting Android, iPhone, iPod, iPad and BlackBerry browser with JavaScript

var ua = navigator.userAgent.toLowerCase();
var ua_checker = {
  android: ua.match(/android/),
  iphone: ua.match(/(iphone|ipod|ipad)/),
  blackberry: ua.match(/blackberry/)
};
if (ua_checker.android) {
  // up to you
}
else if (ua_checker.iphone) {
  // up to you
}
else if (ua_checker.blackberry) {
  // up to you
}
Web Programming

Aug.04

รวมลิงค์ด้านการโปรแกรมด้วย CodeIgniter

http://codeigniter.com/

http://codeigniter.com/wiki/modules/
http://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home

http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html

http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/

http://codeigniter.com/wiki/Yaml_with_Symfony_Yaml/
http://components.symfony-project.org/yaml/

http://codeigniter.com/wiki/Carabiner/
http://codeigniter.com/forums/viewthread/117966
https://github.com/dreamerslab/Carabiner
https://github.com/dreamerslab/ci.view

http://dreamerslab.com/blog/en/codeigniter-view-library/

Web Programming

Jun.11

PHP – Check for bot visit

function is_bot () {
    $botlist = array("googlebot", "mediapartners-google", "feedfetcher-google", ... );
    $bottest = strtolower($_SERVER['HTTP_USER_AGENT']);
    foreach($botlist as $bot) {
        if(strpos($bottest,$bot)!==false) {
            $thebot = $bot;
            break;
        }
    }
    return ( $thebot ? $thebot : false );
}

-*-

Web Programming,Web SEO

Jun.02

WordPress – Related Posts

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
    echo 'Related Posts';
    $first_tag = $tags[0]->term_id;
    $args=array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'showposts'=>5,
        'caller_get_posts'=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php endwhile;
    }
}
?>

-*-

Web Programming,Web SEO