-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathheader.php
More file actions
161 lines (134 loc) · 6.76 KB
/
header.php
File metadata and controls
161 lines (134 loc) · 6.76 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php //NOTE: cookies must be sent before any other data is sent to the client
header("Cache-Control: no-cache");
header("Pragma: no-cache");
// header("Access-Control-Allow-Origin: *");
//if (file_exists('../content/CEHRD')) echo '../content/CEHRD exists'; exit;
//if (file_exists('../content/CEHRD')) $LOOMA_SERVER = 'CEHRD';
// set $LOOMA_SERVER to the web server for this page
// $_SERVER['$SERVER_NAME'] values are "learning.cehrd.edu.np:, "looma.website",
// "india.looma.website", "test.looma.website",
// and for looma boxes: "looma", or "india.looma"
//UseCanonicalName On
//ServerName looma-local
// Also, Turn on error reporting - only for localhost & test debugging, not on production server or looma box
if ($_SERVER['SERVER_NAME'] === 'learning.cehrd.edu.np') {
$LOOMA_SERVER = 'CEHRD';
error_reporting(0);
} else if ( $_SERVER['SERVER_NAME'] === 'nepal.looma.website') {
$LOOMA_SERVER = 'CEHRD';
error_reporting(0);
} else if ( $_SERVER['SERVER_NAME'] === '54.213.0.169') {
$LOOMA_SERVER = 'CEHRD';
error_reporting(0);
} else if ($_SERVER['SERVER_NAME'] === 'looma.website') {
$LOOMA_SERVER = 'looma';
error_reporting(0);
} else if ( $_SERVER['SERVER_NAME'] === 'india.looma.website') {
$LOOMA_SERVER = 'INDIA';
error_reporting(0);
} else if ( $_SERVER['SERVER_NAME'] === 'india.looma') {
$LOOMA_SERVER = 'INDIA';
error_reporting(0);
} else if ( $_SERVER['SERVER_NAME'] === 'test.looma.website') {
$LOOMA_SERVER = 'test';
error_reporting(E_ALL);
} else if ( $_SERVER['SERVER_NAME'] === 'looma-laptop') {
$LOOMA_SERVER = 'looma-laptop';
error_reporting(E_ALL);
} else {
$LOOMA_SERVER = 'looma local';
error_reporting(E_ALL);
}
// set 'source' cookie and 'theme' cookie if needed, and refresh page
if (!isset($_COOKIE['source']) || $_COOKIE['source'] !== $LOOMA_SERVER ||
!isset($_COOKIE['theme']) || $_COOKIE['theme'] !== $LOOMA_SERVER) {
setcookie('source',$LOOMA_SERVER,0,"/");
setcookie('theme', $LOOMA_SERVER,0,"/");
header("Refresh:0"); //reload page to get cookies updated
exit;
}
// get operating environment of server
// settng global variables: $ENV_OS, $ENV_WINDOWS, $ENV_IP, $ENV_CPU
$ENV_OS = PHP_OS;
if ($ENV_OS === 'Darwin') $ENV_OS = 'MacOS';
//$ENV_OS = PHP_OS_FAMILY;
$ENV_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; // boolean - true for Windows
if ($ENV_WINDOWS) $ENV_CPU = shell_exec("echo %PROCESSOR_ARCHITECTURE%");
else $ENV_CPU = shell_exec('uname -m');
if ($ENV_WINDOWS)
$ENV_IP = getHostByName(getHostName());
else
$ENV_IP = shell_exec("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'");
/*
$ENV_IP = $_SERVER['SERVER_ADDR'];
if ($ENV_IP === '::1') $ENV_IP = '127.0.0.1';
*/
print "<!DOCTYPE html>";
// display Looma or CEHRD logo and title
if ($LOOMA_SERVER === 'CEHRD') {
print "<title>Learning Portal</title>";
print '<link rel="icon" type="image/png" href="images/logos/CEHRD-logo small.jpg">';
} else { //server default is 'looma'
print "<title>{$page_title}</title>";
print '<link rel="icon" type="image/png" href="images/logos/looma favicon yellow on blue.png">';
}
//echo 'source is ' . $_COOKIE['source']; exit;
?>
<html lang="en">
<head>
<!--
Author: Skip
Owner: VillageTech Solutions (villagetechsolutions.org)
Date: 2015 03
Revision: Looma 2.0.0
File: header.php
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Skip">
<meta name="project" content="Looma">
<meta name="url" content="https://looma.website">
<meta name="owner" content="Looma Education Corporation">
<meta name="copyright" content="Looma Education Corporation">
<meta name="mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-status-bar-style" content="black-translucent">
<meta name="description" content="Looma Education develops affordable technology
that brings a modern education with digital access to the world's knowledge to
everyone in Nepal, even those without Internet or electricity. Looma Online is
the completely online version of Looma which includes the official Nepali textbooks,
extensive educational media, and a UI for making lessons. For those without Internet,
Looma is delivered as Looma Box, a computer with projector in a small solar-powered box,
or Looma Server for school computer labs. ">
<?php
header_remove('X-Powered-By');
header_remove('Server');
require_once ('includes/looma-translate.php');
// require_once ('includes/mongo-connect.php');
require_once ('includes/looma-log-user-activity.php');
$documentroot = str_replace("Looma","",getenv("DOCUMENT_ROOT"));
//$documentroot is used in looma-utilities.php for "realpath" checking
?>
<!-- <div class="watermark">Under Construction</div> -->
<link rel="stylesheet" href="css/looma.css"> <!-- Looma CSS -->
<link rel="stylesheet" href="css/looma-keyboard.css"> <!-- Looma keyboard CSS -->
<?php /*retrieve 'theme' cookie from $_COOKIE and use it to load the correct 'css/looma-theme-xxxxxx.css' stylesheet*/
/* if ( $LOOMA_SERVER === 'CEHRD' ) $settheme = "CEHRD";
else if (isset($_COOKIE['theme'])) $settheme = $_COOKIE['theme'];
else $settheme = 'looma';
echo "<link rel='stylesheet' href='css/looma-theme-" . $settheme . ".css' id='theme-stylesheet'>";
*/
echo "<link rel='stylesheet' href='css/looma-theme-" . $_COOKIE['theme'] . ".css' id='theme-stylesheet'>";
// require_once('includes/looma-isloggedin.php');
function keyIsSet($key, $array) { return isset($array[$key]);} //compatibility shim for php 5.x "array_key_exists()"
// set correct PHP timezone for this server
if ($_SERVER['SERVER_NAME'] === 'learning.cehrd.edu.np') {
date_default_timezone_set("Asia/Kathmandu");
} else if ($_SERVER['SERVER_NAME'] === '54.214.229.222' || $_SERVER['SERVER_NAME'] === 'looma.website') {
date_default_timezone_set("America/Los_Angeles");
} else if ( $_SERVER['SERVER_NAME'] === 'india.looma.website') {
date_default_timezone_set("Asia/Kolkata");
} else {
date_default_timezone_set("America/Los_Angeles");
}
echo "<div id='timezone' hidden>" . date_default_timezone_get() . "</div>";
?>