浏览网站时,有的时候,会告诉你,无权进入一些页面。例如:一些技术性的论坛,刚进去的时候,只能看看贴子,并且只能在一定的区域看,不能 发贴等。做电子商务时,电子商务的后台是一个比较大的系统,不同的人进去会看到不同的页面,如果能看到同一个页面,也许允许的操作也不一样,这些机制是怎 么实现的呢。下面就个人愚见分析几种情况 一,简单session控制 实现原理和方法: 用户登录后台,输入用户名和密码,对用户的用户名和密码进行验证,验证通过后,可以把用户的一些基本信息放到session里面当用户访问后台的其他页面时,去判断一下session是否存在,并且没有过期。不过,后台管理员权限一样,没有区分 1,后台页面共用的基本类,我们可以在基本类的里加以判断,或者在基本类外面在extends一层,加以判断,去check一下session。 2,直接重写一个check_login.php每个后台页面都包涵这个页面,通过这个页面加以判断,check一下session。 二,菜单控制…
php判断手机移动设备 Mobile-Detect
Mobile Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
You may consider this script as being part of the RESS (Responsive Web Design with Server-Side Component) movement. You can find out more on the topic by reading these articles: Improve Mobile Support With Server-Side-Enhanced Responsive Design and RESS: Responsive Design + Server Side Components.
You can also benefit from Mobile Detect by using any of the 3rd party plugins available for: WordPress, Drupal, Joomla, Magento, etc.
Current development status:
Packagist status:
Here are some code examples:
// Include and instantiate the class. require_once 'Mobile_Detect.php'; $detect = new Mobile_Detect; // Any mobile device (phones or tablets). if ( $detect->isMobile() ) { } // Any tablet device. if( $detect->isTablet() ){ } // Exclude tablets. if( $detect->isMobile() && !$detect->isTablet() ){ } // Check for a specific platform with the help of the magic methods: if( $detect->isiOS() ){ } if( $detect->isAndroidOS() ){ } // Alternative method is() for checking specific properties. // WARNING: this method is in BETA, some keyword properties will change in the future. $detect->is('Chrome') $detect->is('iOS') $detect->is('UC Browser') // [...] // Batch mode using setUserAgent(): $userAgents = array( 'Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19', 'BlackBerry7100i/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/103', // [...] ); foreach($userAgents as $userAgent){ $detect->setUserAgent($userAgent); $isMobile = $detect->isMobile(); $isTablet = $detect->isTablet(); // Use the force however you want. } // Get the version() of components. // WARNING: this method is in BETA, some keyword properties will change in the future. $detect->version('iPad'); // 4.3 (float) $detect->version('iPhone') // 3.1 (float) $detect->version('Android'); // 2.1 (float) $detect->version('Opera Mini'); // 5.0 (float) // [...]
项目地址:https://github.com/serbanghita/Mobile-Detect
下载附件:Mobile-Detect-2.8.13