Skip to content

Commit f15b7a2

Browse files
authored
Merge pull request #1 from cmu-delphi/master
sync to delphi
2 parents caf875f + 3f7f8a8 commit f15b7a2

30 files changed

+9634
-2103
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Status
2-
[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast)](#)
2+
3+
[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-crowdcast)](#)
34

45
# About
5-
The Epicast website for collecting flu forecasts.
6+
7+
The Crowdcast website for collecting flu forecasts.
68

79
The site is live at:
8-
- https://delphi.midas.cs.cmu.edu/epicast/
9-
- https://epicast.net/
10-
- https://epicast.org/
10+
- https://delphi.cmu.edu/crowdcast
1111

1212
A live demo is available at http://demo.epicast.net/ (User ID is `00000000`)

deploy.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
"version": 1,
44
"actions": [
55

6-
"// css is actually php",
7-
{
8-
"type": "move",
9-
"src": "site/css/.htaccess",
10-
"dst": "/var/www/html/crowdcast/css/.htaccess",
11-
"add-header-comment": true
12-
},
136
"// .htaccess file",
147
{
158
"type": "move",
@@ -60,7 +53,20 @@
6053
"src": "site/images/flags/",
6154
"dst": "/var/www/html/crowdcast/images/flags/",
6255
"match": "^.*\\.png$"
56+
},
57+
"// tutorials",
58+
{
59+
"type": "move",
60+
"src": "site/images/",
61+
"dst": "/var/www/html/crowdcast/images/",
62+
"match": "^.*\\.(gif|mp4)$"
63+
},
64+
"// benchmark data",
65+
{
66+
"type":"move",
67+
"src":"site/data/",
68+
"dst":"/var/www/html/crowdcast/data/",
69+
"match":"^.*\\.csv$"
6370
}
64-
6571
]
6672
}

site/admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ function sortInt(&$a, &$b) {
5252
}
5353
}
5454
//Round info
55-
if(getEpiweekInfo($output) !== 1) {
55+
if(getEpiweekInfo($dbh, $output) !== 1) {
5656
fail('Error loading round info');
5757
}
5858
if(isset($_REQUEST['x'])) {
5959
$output['epiweek']['round_epiweek'] = addEpiweeks($output['epiweek']['round_epiweek'], -1);
6060
}
6161
//Load the userbase
62-
if(getUserbase($output, $sortField, $sortDir) !== 1) {
62+
if(getUserbase($dbh, $output, $sortField, $sortDir) !== 1) {
6363
fail('Error loading userbase');
6464
}
6565
//Stats

site/api.php

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
<?php
2-
session_start();
3-
require_once('common/settings.php');
4-
require_once('common/utils.php');
5-
require_once('common/database.php');
6-
7-
//Connect to the database
8-
$dbh = databaseConnect($dbHost, $dbPort, $dbUser, $dbPass, $dbName);
9-
10-
//Create the output array
11-
$output = array('result' => 0);
12-
if(!$dbh) {
13-
//Couldn't connect to the database
14-
$output['result'] = -100;
15-
} else {
16-
//Connected successfully
17-
if($_REQUEST['action'] == 'forecast' || $_REQUEST['action'] == 'autosave') {
18-
$output['action'] = $_REQUEST['action'];
19-
$hash = mysql_real_escape_string($_REQUEST['hash']);
20-
$temp = array();
21-
if(getUserByHash($temp, $hash) == 1) {
22-
$forecast = array();
23-
foreach($_REQUEST['f'] as $f) {
24-
array_push($forecast, floatval(mysql_real_escape_string($f)));
25-
}
26-
if(getEpiweekInfo($temp) == 1) {
27-
if(count($forecast) >= 1 && count($forecast) <= 53) {
28-
//Save the forecast
29-
$regionID = intval(mysql_real_escape_string($_REQUEST['region_id']));
30-
$commit = ($_REQUEST['action'] == 'forecast');
31-
if(saveForecast($temp, $temp['user_id'], $regionID, $forecast, $commit) == 1) {
32-
//Success
33-
$output['result'] = 1;
34-
} else {
35-
//Failed to save forecast
36-
$output['result'] = -5;
37-
}
38-
} else {
39-
//Size of forecast array is wrong
40-
$output['result'] = -4;
41-
}
42-
} else {
43-
//Failed to get round info
44-
$output['result'] = -3;
45-
}
46-
} else {
47-
//Invalid user
48-
$output['result'] = -2;
49-
}
50-
} else {
51-
//Unknown action
52-
$output['result'] = -1;
53-
}
54-
}
55-
echo json_encode($output);
56-
?>
1+
<?php
2+
session_start();
3+
require_once('common/settings.php');
4+
require_once('common/utils.php');
5+
require_once('common/database.php');
6+
7+
//Connect to the database
8+
$dbh = databaseConnect($dbHost, $dbPort, $dbUser, $dbPass, $dbName);
9+
10+
//Create the output array
11+
$output = array('result' => 0);
12+
if(!$dbh) {
13+
//Couldn't connect to the database
14+
$output['result'] = -100;
15+
} else {
16+
//Connected successfully
17+
if($_REQUEST['action'] == 'forecast' || $_REQUEST['action'] == 'autosave') {
18+
$output['action'] = $_REQUEST['action'];
19+
$hash = mysqli_real_escape_string($dbh, $_REQUEST['hash']);
20+
$temp = array();
21+
if(getUserByHash($dbh, $temp, $hash) == 1) {
22+
$forecast = array();
23+
foreach($_REQUEST['f'] as $f) {
24+
array_push($forecast, floatval(mysqli_real_escape_string($dbh, $f)));
25+
}
26+
if(getEpiweekInfo($dbh, $temp) == 1) {
27+
if(count($forecast) >= 1 && count($forecast) <= 53) {
28+
//Save the forecast
29+
$regionID = intval(mysqli_real_escape_string($dbh, $_REQUEST['region_id']));
30+
$commit = ($_REQUEST['action'] == 'forecast');
31+
if(saveForecast($dbh, $temp, $temp['user_id'], $regionID, $forecast, $commit) == 1) {
32+
//Success
33+
$output['result'] = 1;
34+
} else {
35+
//Failed to save forecast
36+
$output['result'] = -5;
37+
}
38+
} else {
39+
//Size of forecast array is wrong
40+
$output['result'] = -4;
41+
}
42+
} else {
43+
//Failed to get round info
44+
$output['result'] = -3;
45+
}
46+
} else {
47+
//Invalid user
48+
$output['result'] = -2;
49+
}
50+
} else {
51+
//Unknown action
52+
$output['result'] = -1;
53+
}
54+
}
55+
echo json_encode($output);
56+
?>

0 commit comments

Comments
 (0)