This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
start.php
executable file
·75 lines (55 loc) · 1.75 KB
/
start.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Elgg Mobile
* A Mobile Client For Elgg
*
* @package Elgg
* @subpackage Core
* @author kramnorth (Mark Harding)
* @link http://kramnorth.com
*
*/
function mobile_init(){
//elgg_extend_view('page/elements/head','mobile/metatags');
mobile_detect();
elgg_extend_view('css/elgg','mobile/css');
//set our default index page
if(elgg_get_viewtype() == "mobile"){
elgg_register_plugin_hook_handler('index', 'system','main_handler');
}
elgg_register_simplecache_view('mobile');
}
function main_handler($hook, $type, $return, $params) {
if ($return == true) {
// another hook has already replaced the front page
return $return;
}
if(!include_once(dirname(__FILE__) . '/pages/main.php')){
return false;
}
return true;
}
if($_SESSION['isMobile']){
elgg_set_viewtype('mobile');
}
function mobile_detect(){
$useragent= strtolower ( $_SERVER['HTTP_USER_AGENT'] );
//detect if there is a mobile device
if(preg_match('/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\/|samsung|sonyericsson|^sie-|nintendo/',$useragent)||preg_match('/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /',$useragent && !strstr($useragent,'ipad'))){
$mobile = true;
} else {
$mobile = false;
}
//if there is a mobile device
if($mobile == true){
if($_SESSION['view_desktop']){
elgg_extend_view('page/elements/head','mobile/desktop');
} else {
elgg_set_viewtype('mobile');
}
}
}
elgg_register_viewtype_fallback('mobile');
elgg_register_event_handler('init','system','mobile_init');
elgg_register_action("mobile/login",$CONFIG->pluginspath . "mobile/actions/login.php",'public');
?>