Skip to content

Commit 634fd49

Browse files
authored
Merge pull request openrails/openrails#285 from cjakeman/website/move-server
changes for new web-server
2 parents e4286b6 + a663b50 commit 634fd49

File tree

7 files changed

+86
-10
lines changed

7 files changed

+86
-10
lines changed

download/program/index.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
</p>
3131
</a>
3232
<p style="text-align: center;">
33-
<?php echo date('d F Y', filemtime("$file_path/$download_stable")) . ', ' . round(filesize("$file_path/$download_stable") / 1024 / 1024) . 'MB'; ?>
33+
<!-- Cannot set modification date to correct value so write it literally -->
34+
<!-- <?php echo date('d F Y', filemtime("$file_path/$download_stable")) . ', ' . round(filesize("$file_path/$download_stable") / 1024 / 1024) . 'MB'; ?> -->
35+
<?php echo '08 December 2018, ' . round(filesize("$file_path/$download_stable") / 1024 / 1024) . 'MB'; ?>
3436
</p>
3537
<!--<p class="alert alert-info">
3638
We're working hard on producing the next stable version. Please check back soon.

index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<!-- Button to trigger modal -->
4444
<a href="#modal1" role="button" class='btn download_button' data-toggle="modal">
4545
<span class='glyphicon glyphicon-download'></span>&nbsp; Download the installer
46-
<?php echo '(' . date('d F Y', filemtime("$file_path/$download_stable")) . ', ' . round(filesize("$file_path/$download_stable") / 1024 / 1024) . 'MB)'; ?>
46+
<?php echo '08 December 2018, ' . round(filesize("$file_path/$download_stable") / 1024 / 1024) . 'MB)'; ?>
4747
</a>
4848
</div>
4949
</div>

shared/head.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
// Better to move this section above track_visits.php
34
// As it is, someone with cookies disallowed gets new visitor attributes for every page visited, not just on every visit.
45
require_once('set_session_save_path.php'); // To avoid error 500 on this system

shared/mysql/track_visits.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@
5656
$made_to = str_replace('//', '/', $made_to); // home page is just '/', but other pages begin with '//' which must become single.
5757

5858
// In a timestamp field, NULL is replaced by current time automatically.
59-
$sql = "INSERT INTO tVisit (made_by, made_to, visited_on) VALUES('$id', '$made_to', NULL)";
60-
#echo "<br>$sql<br>";
59+
//$sql = "INSERT INTO tVisit (made_by, made_to, visited_on) VALUES('$id', '$made_to', NULL)";
60+
// But not on this server, so ask PHP for the date and time.
61+
$now = date("Y-m-d H:i:s");
62+
63+
/* DISABLED as leading to a 500 Server Error
64+
$sql = "INSERT INTO tVisit (made_by, made_to, visited_on) VALUES('$id', '$made_to', '$now')";
65+
echo "<br>$sql<br>";
6166
if (!mysqli_query($dbc, $sql)) { die('Error: ' . mysqli_error($dbc)); }
67+
*/
6268
?>

shared/set_session_save_path.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22
// Extra statement needed as session.save_path is null on this system.
33

4-
if(ini_get('session.save_path') == '') {
4+
if(ini_get('session.save_path') == '' || ini_get('session.save_path') == 'E:\PHPSave') {
55
// Cannot use recommended temp directory - leads to error 500
66
//ini_set('session.save_path', 'C:\Temp');
7-
ini_set('session.save_path', 'D:\web\openrails\web\sessions');
7+
$root = getenv("DOCUMENT_ROOT");
8+
ini_set('session.save_path', "$root\sessions");
89
}
9-
//echo "'" . ini_get('session.save_path') . "'";
10+
echo "'" . ini_get('session.save_path') . "'";
1011
?>

shared/track_visits.php

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
require_once('db_connect.php');
3+
4+
# Find site's root folder, e.g. D:/web/openrails/web
5+
$root = getenv("DOCUMENT_ROOT");
6+
$path = strtr($root, '\\', '/');
7+
8+
if (!isset($_SESSION['id']) || strlen($_SESSION['id']) < 10) {
9+
// Retrieve id from cookie or create a new one.
10+
$cookie_name = 'or_org3';
11+
if(isset($_COOKIE[$cookie_name])) {
12+
$id = $_COOKIE[$cookie_name];
13+
}else{
14+
$id = md5(date("Y-m-d H:i:s") . rand()); // Uses the MySQL DATETIME format plus random number
15+
setcookie($cookie_name, $id, 2147483647); // max time value to expire far into future (19-Jan-2038)
16+
$sql = "INSERT INTO tVisitor (id) VALUES('$id')";
17+
if (!mysqli_query($dbc, $sql)) { die('Error: ' . mysqli_error($dbc)); }
18+
19+
$ip = $_SERVER['REMOTE_ADDR']; // Always a real IP address but might be a proxy.
20+
$sql = "INSERT INTO tVisitor_Attribute (used_by, of_type, of_value) VALUES('$id', 'ip', '$ip')";
21+
if (!mysqli_query($dbc, $sql)) { die('Error: ' . mysqli_error($dbc)); }
22+
23+
if (isset($_SERVER['HTTP_REFERER'])){
24+
$referer = $_SERVER['HTTP_REFERER'];
25+
}else{
26+
$referer = 'unknown';
27+
}
28+
$sql = "INSERT INTO tVisitor_Attribute (used_by, of_type, of_value) VALUES('$id', 'referer', '$referer')";
29+
if (!mysqli_query($dbc, $sql)) { die('Error: ' . mysqli_error($dbc)); }
30+
31+
if (isset($_SERVER['HTTP_USER_AGENT'])){
32+
$agent = $_SERVER['HTTP_USER_AGENT'];
33+
}else{
34+
$agent = 'unknown';
35+
}
36+
$sql = "INSERT INTO tVisitor_Attribute (used_by, of_type, of_value) VALUES('$id', 'agent', '$agent')";
37+
if (!mysqli_query($dbc, $sql)) { die('Error: ' . mysqli_error($dbc)); }
38+
}
39+
// For visitors with cookies turned off, each visit to a webpage results in a new entry and several in Visit and Visitor_Attribute.
40+
// Could change this so each session will be as a different individual.
41+
// Not yet implemented.
42+
// menu.php must be changed to add echo '?', htmlspecialchars(SID); as the first parameter in every relative URL.
43+
// Should be detected automatically by the PHP server, but trials show this isn't the case for v5.2.8 as the setting.
44+
// ini_get("session.use_only_cookies") returns 1 meaning that the SID parameter is ignored by session_start().
45+
46+
// Using Session variables can be dangerous.
47+
// "Please note that if you have register_globals to On, global variables associated to $_SESSION variables are references,
48+
// so this may lead to some weird situations." Re-using $id and changing its value also changes $_SESSION['id']
49+
$_SESSION['id'] = $id;
50+
}
51+
52+
53+
// Record visit made to this webpage
54+
$folder = strtr(getcwd(), '\\', '/');
55+
$made_to = str_replace($path, '/', $folder); // Remove leading filepath to leave local URL
56+
$made_to = str_replace('//', '/', $made_to); // home page is just '/', but other pages begin with '//' which must become single.
57+
58+
// In a timestamp field, NULL is replaced by current time automatically.
59+
//$sql = "INSERT INTO tVisit (made_by, made_to, visited_on) VALUES('$id', '$made_to', NULL)";
60+
// But not on this server, so ask PHP for the date and time.
61+
$now = date("Y-m-d H:i:s");
62+
63+
/* DISABLED as leading to a 500 Server Error
64+
$sql = "INSERT INTO tVisit (made_by, made_to, visited_on) VALUES('$id', '$made_to', '$now')";
65+
echo "<br>$sql<br>";
66+
if (!mysqli_query($dbc, $sql)) { die('Error: ' . mysqli_error($dbc)); }
67+
*/
68+
?>

web.config

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
<configuration>
33
<system.webServer>
44
<handlers>
5-
<add name="HTML via FastCGI" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="D:\php528IIS\php-cgi.exe" resourceType="Unspecified" />
6-
<add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="D:\php528IIS\php-cgi.exe" resourceType="Unspecified" requireAccess="Script" />
7-
<add name="ActivePerl5.8" path="*.pl" verb="*" modules="IsapiModule" scriptProcessor="C:\Perl\bin\perl58.dll" resourceType="Unspecified" preCondition="bitness32" />
5+
<add name="HTML via FastCGI" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="D:\php7411-nts\php-cgi.exe" resourceType="Unspecified" />
86
</handlers>
97
<tracing>
108
<traceFailedRequests>

0 commit comments

Comments
 (0)