Esempio n. 1
0
 /**
  * 插件实现方法
  *
  * @access public
  * @return void
  */
 public static function render($agent)
 {
     $options = Typecho_Widget::widget('Widget_Options');
     $url_plugin = $options->pluginUrl . '/UserAgent/';
     //插件地址  ->  http://domain.com/usr/plugins/UserAgent/
     global $url_img, $icons;
     $url_img = $url_plugin . "img/";
     $icons = Typecho_Widget::widget('Widget_Options')->plugin('UserAgent')->icons;
     $show = Typecho_Widget::widget('Widget_Options')->plugin('UserAgent')->show;
     require_once 'useragent-os.php';
     $os = detect_os($agent);
     $os_img = self::img($os['code'], "/os/", $os['title']);
     $os_title = $os['title'];
     require_once 'useragent-webbrowser.php';
     $wb = detect_webbrowser($agent);
     $wb_img = self::img($wb['code'], "/net/", $wb['title']);
     $wb_title = $wb['title'];
     switch ($show) {
         case 1:
             $ua = "  " . $os_img . " " . $wb_img;
             break;
         case 2:
             $ua = "  (" . $os_title . " / " . $wb_title . ")";
             break;
         case 3:
             $ua = "  " . $os_img . "(" . $os_title . ") / " . $wb_img . "(" . $wb_title . ")";
             break;
         default:
             $ua = "  " . $os_img . $wb_img;
             break;
     }
     echo $ua;
 }
function detect_platform()
{
    global $useragent, $ua_show_text, $ua_text_links, $ua_hide_unknown_bool;
    if (strlen($detected_platform = detect_device()) > 0) {
        return $detected_platform;
    } elseif (strlen($detected_platform = detect_os()) > 0) {
        return $detected_platform;
    } else {
        $title = "Unknown";
        $link = "#";
        $code = "null";
        if ($ua_hide_unknown_bool == 'true' && $ua_show_text == 2) {
            return $title;
        }
    }
    // How should we display this?
    if ($ua_show_text == "1" && $ua_text_links != "0") {
        //image and linked text
        $detected_os = img($code, "/os/", $title) . " <a href='" . $link . "' title='" . $title . "' rel='nofollow'>" . $title . "</a>";
    } else {
        if ($ua_show_text == "1") {
            //image and text
            $detected_os = img($code, "/os/", $title) . " " . $title;
        } else {
            if ($ua_show_text == "2") {
                //image only
                $detected_os = img($code, "/os/", $title);
            } else {
                if ($ua_show_text == "3" && $ua_text_links != "0") {
                    //linked text only
                    $detected_os = "<a href='" . $link . "' title='" . $title . "' rel='nofollow'>" . $title . "</a>";
                } else {
                    if ($ua_show_text == "3") {
                        //text only
                        $detected_os = $title;
                    }
                }
            }
        }
    }
    return $detected_os;
}
Esempio n. 3
0
            $uas_os['name'] = "Nintendo Wii";
            $uas_os['code'] = "wii";
          }elseif(preg_match('/Nintendo DSi/i', $useragent)){
            $uas_os['namee'] = "Nintendo DSi";
            $uas_os['code'] = "ndsi";
          }elseif (preg_match('#SymbianOS/([.0-9a-zA-Z]+)#i', $useragent, $regmatch)){
            $uas_os['name'] = "SymbianOS";
            $uas_os['code'] = "symbian";*/
    } else {
        $uas_os['name'] = "Windows";
        $uas_os['code'] = "win";
        $uas_os['bits'] = "32";
    }
    return $uas_os;
}
$os_array = detect_os($_SERVER['HTTP_USER_AGENT']);
?>
            <p class="download-links">
              {% t index.monero_for %} <?php 
echo $os_array['name'];
?>
 
              <span>
                <a href="//downloads.getmonero.org/<?php 
echo $os_array['code'];
echo $os_array['bits'];
?>
" class="btn btn-grey pull-right">
                  <i class="fa fa-plus-circle icon_download" style="color: white; font-size: 20px;"></i> {% t index.c_download %}
                </a>
              </span>
 function os_info()
 {
     backtrace(detect_os(), 'p', 'OS type');
 }
function is_ubuntu()
{
    return detect_os('ubuntu');
}