vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Styles (https://vborg.vbsupport.ru/forumdisplay.php?f=230)
-   -   Mobile, Cell, Phone, PDA, iPhone Style (https://vborg.vbsupport.ru/showthread.php?t=174375)

testbot 10-10-2009 03:02 PM

yea, it's in this thread. it takes some plugin and template tweaking but it works. we've received some pretty good revenue from it.

wacnstac 10-10-2009 08:11 PM

Hmmm, I don't see a plugin for it.

testbot 10-10-2009 09:31 PM

you have to create it.

here. below is my setup. you should only have to change the styleid to your mobile styleid (this will make it so the plugin only runs when it's mobile - less is better) and your google options. i marked the parts you should change.

Create Plugin
Product: vBulletin
Hook Location: global_start
Title: Mobile AdSense Top
Execution Order: 5
Plugin PHP Code:
Code:

/*** Change to your mobile style id ***/
if ($styleid==20){
/*** End Change to your mobile style id ***/
        function read_global($var) {
          return isset($_SERVER[$var]) ? $_SERVER[$var]: '';
        }

        function google_append_url(&$url, $param, $value) {
          $url .= '&' . $param . '=' . urlencode($value);
        }

        function google_append_globals(&$url, $param) {
          google_append_url($url, $param, $GLOBALS['google'][$param]);
        }

        function google_append_color(&$url, $param) {
          global $google_dt;
          $color_array = split(',', $GLOBALS['google'][$param]);
          google_append_url($url, $param,
                            $color_array[$google_dt % sizeof($color_array)]);
        }

        function google_set_screen_res() {
          $screen_res = read_global('HTTP_UA_PIXELS');
          if ($screen_res == '') {
            $screen_res = read_global('HTTP_X_UP_DEVCAP_SCREENPIXELS');
          }
          if ($screen_res == '') {
            $screen_res = read_global('HTTP_X_JPHONE_DISPLAY');
          }
          $res_array = split('[x,*]', $screen_res);
          if (sizeof($res_array) == 2) {
            $GLOBALS['google']['u_w'] = $res_array[0];
            $GLOBALS['google']['u_h'] = $res_array[1];
          }
        }

        function google_set_muid() {
          $muid = read_global('HTTP_X_DCMGUID');
          if ($muid != '') {
            $GLOBALS['google']['muid'] = $muid;
          }
          $muid = read_global('HTTP_X_UP_SUBNO');
          if ($muid != '') {
            $GLOBALS['google']['muid'] = $muid;
          }
          $muid = read_global('HTTP_X_JPHONE_UID');
          if ($muid != '') {
            $GLOBALS['google']['muid'] = $muid;
          }
          $muid = read_global('HTTP_X_EM_UID');
          if ($muid != '') {
            $GLOBALS['google']['muid'] = $muid;
          }
        }

        function google_get_ad_url() {
          $google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?';
          foreach ($GLOBALS['google'] as $param => $value) {
            if ($param == 'client') {
              google_append_url($google_ad_url, $param,
                                'ca-mb-' . $GLOBALS['google'][$param]);
            } else if (strpos($param, 'color_') === 0) {
              google_append_color($google_ad_url, $param);
            } else if (strpos($param, 'url') === 0) {
              $google_scheme = ($GLOBALS['google']['https'] == 'on')
                  ? 'https://' : 'http://';
              google_append_url($google_ad_url, $param,
                                $google_scheme . $GLOBALS['google'][$param]);
            } else {
              google_append_globals($google_ad_url, $param);
            }
          }
          google_append_url($google_ad_url, 'dt',
                            round(1000 * array_sum(explode(' ', microtime()))));
          return $google_ad_url;
        }
/**** YOUR SETTINGS ***/
        $GLOBALS['google']['ad_type']='text_image';
        $GLOBALS['google']['channel']='xxxx';
        $GLOBALS['google']['client']='pub-xxxx';
        $GLOBALS['google']['color_border']='336699';
        $GLOBALS['google']['color_bg']='FFFFFF';
        $GLOBALS['google']['color_link']='0000FF';
        $GLOBALS['google']['color_text']='000000';
        $GLOBALS['google']['color_url']='008000';
        $GLOBALS['google']['format']='mobile_single';
        $GLOBALS['google']['https']=read_global('HTTPS');
        $GLOBALS['google']['ip']=read_global('REMOTE_ADDR');
        $GLOBALS['google']['markup']='chtml';
        $GLOBALS['google']['oe']='utf8';
        $GLOBALS['google']['output']='chtml';
/*** END YOUR SETTINGS ***/       
        $GLOBALS['google']['ref']=read_global('HTTP_REFERER');
        $GLOBALS['google']['url']=read_global('HTTP_HOST') . read_global('REQUEST_URI');
        $GLOBALS['google']['useragent']=read_global('HTTP_USER_AGENT');       
        $google_dt = time();
        google_set_screen_res();
        google_set_muid();

        $google_ad_handle = @fopen(google_get_ad_url(), 'r');
        if ($google_ad_handle) {
          while (!feof($google_ad_handle)) {
            $mobile_ad_top .= fread($google_ad_handle, 8192);
          }
          fclose($google_ad_handle);
        }
}


Styles & Templates> Style Manager>Ad Location Templates>ad_navbar_below & ad_footer_start
Code:

<div>
        <!-- Mobile Ad -->
        $mobile_ad_top
        <!-- /Mobile Ad -->
</div>


wacnstac 10-13-2009 02:37 AM

This thing rocks. Probably the best hack/style I've ever seen. I am however having several nagging issues.

I am running the latest version of this style, the browser detect, and the mobile options hack. I have the boxes checked next to both my PC style and the mobile style in the style manager. Everything works for the most part. I have two forums using this:

http://www.michigan-sportsman.com/forum/
http://www.ohiosportsman.com/forum/
and both are properly detected and shown on the default BB browser. Using Opera Mini, only the first site gets detected properly.

Also several PC users are complaining that they are seeing the mobile style (it is getting automatically detected for them). I have no idea how to track down what user agent they are using.

Mr. W 10-13-2009 02:54 AM

Wacnstac,

____ I have a couple of questions for you.

Quote:

Originally Posted by wacnstac (Post 1898934)
and both are properly detected and shown on the default BB browser. Using Opera Mini, only the first site gets detected properly.

____ Curious. Can you tell me what model of Blackberry you are using? Using a Pearl 8120, I find that certain buttons don't show up, although they primarily have to do with buttons that have to do with moderation actions. This is even when I log in using user accounts with sufficient permissions, such as a Super Mod or Administrator account.

____ However, when I use Opera Mini, I'm then I am able to see all of those buttons.

____ One thing I should note though, is that I haven't tried installing the auto-detect thing, although it's something I plan on doing.

Quote:

Originally Posted by wacnstac (Post 1898934)
Also several PC users are complaining that they are seeing the mobile style (it is getting automatically detected for them). I have no idea how to track down what user agent they are using.

____ Now that is strange. Does it ever happen to you personally? I'd recommend trying it with Firefox, IE, and Opera. Or at least Firefox and IE. Those are the most common browsers. If you can, it might not be a bad idea to try Safari as well. It's less common, but probably the most common after FF, IE, and Opera.

____ Also, have you tried asking the users what browsers they are using? That's what I'd do.

wacnstac 10-13-2009 03:09 AM

Don't quite understand your question about Opera Mini. The first URL renders fine in it (the mobile style), The second URL renders the full site with images and everything. Opera does not get detected.

Would love to know how to get my hands on the "useragent" data so I could tell exactly what browser a user is using.

dartho 10-13-2009 03:46 AM

G'day , get your users to visit http://vbdev.org/test-mob-detect.php and to copy and paste what shows up on the screen to you. This will tell you whether the browser is being detected as a mobile device, and also give you useragent info.

wacnstac 10-13-2009 10:41 AM

Well the device that doesn't render one of the websites properly shows:
Opera/9.80 (J2ME/MIDP; Opera Mini/4.2.14912/756; U; en)
Presto/2.2.0

Don't know what part(s) of that I need to enter to get it auto recognized.....

wacnstac 10-13-2009 12:08 PM

So here's what one user who gets the mobile style shows for a user agent:

HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; PalmSource/Palm-D062; Blazer/4.5) 16;320x320
HTTP_ACCEPT: text/html, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml , image/png, image/jpeg, image/gif, image/bmp, image/vnd.wap.wbmp, application/octet-stream, image/pjpeg, */*;q=0.1, */*,text/html;q=0.062,image/gif;q=0.062,image/x-jng;q=0.062,video/x-mng;q=0.062,image/x-mng;q=0.062,image/bmp;q=0.062,image/x-bmp;q=0.062

wacnstac 10-13-2009 12:42 PM

I am experiencing the following error now while browsing the mobile style:

"Warning: preg_match() [function.pre-match]: unknown modifier 'M' in [path]/global.php(238) : eval()'d code on line 117

This error started occurring after I tried to add J2ME/MIDP to the list of mobile browsers in the XML file that does the auto detect. I have since removed it and the error went away. Any thoughts on how to add J2ME/MIDP?


All times are GMT. The time now is 07:56 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02120 seconds
  • Memory Usage 1,769KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete