-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
136 lines (112 loc) · 3.06 KB
/
index.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
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
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<html>
<head>
<title>Add a Prayer</title>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
});
</script>
</head>
<body>
<h1> Add a new prayer</h1>
<form action="addprayer.php" method="post">
<input type="radio" name="type" value="person" id="person" />
<label for="person">Person</label>
<br>
<input type="radio" name="type" value="event" id="event" />
<label for="event">Event</label>
<br>
<span id="form">
<label for=name>Name</label><br>
<input name=name type=test size=50 placeholder=name maxsize=250 required=true id=name />
<br>
<label for=detailsName>Details (Optional) </label><br>
<textarea rows=5 cols=25 id=detailsName name=details></textarea>
</span>
<br>
<input type=submit>
</form>
<hr>
<h3> A Person to Pray For:</h3> <p>
<?php
function GetDayFromFile($jsonp){
if($jsonp[0] !== '[' && $jsonp[0] !== '{'){
$jsonp = substr($jsonp, strpos($jsonp, '('));
}
$s = trim($jsonp,'();');
$w = substr($s, (strpos($s, "\"day\"")+9), (strpos($s, "\"Mass_R1\"") - strpos($s, "\"day\"")-11) );
$r = strip_tags($w);
//echo $r;
return $r;
}
$dayJsonp = file_get_contents('http://www.universalis.com/Europe.England/jsonpmass.js?callback=?');
$day = GetDayFromFile($dayJsonp);
echo "Received: ".$day;
/*
function createCxn(){
try {
$cxn = new mysqli("localhost", "jjprogra_prayers", "JJPRO_prayers", "jjprogra_prayers");
} catch (exception $e){
echo $e->getMessage();
}
if (!$cxn) {
echo 'Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error();
return FALSE;
} else return $cxn;
}
function runUpdateQuery($cxn, $query){
if ($cxn){
$results = $cxn->query($query);
if (!$results) {
echo ("FAIL");
echo ('Invalid query: ' . $cxn->error . "\n");
echo ('<br>Whole query: ' . $query);
return FALSE;
}
$numRows = $cxn->affected_rows;
return $results;
}
}
function getResultsAssoc($results){
if(!$results)
return false;
$data = array();
while ($row = $results->fetch_assoc()){
$data[] = $row;
}
return $data;
}
$cxn = createCxn();
//Get a random row from the table
$query = "SELECT COUNT('id') FROM `prayers`";
$result = getResultsAssoc(runUpdateQuery($cxn, $query));
$rows = $result[0]["COUNT('id')"];
$row = rand() % $rows;
//Get the data
$query = "SELECT `name`, `details` FROM `prayers` WHERE `id`= ".$row;
$result = getResultsAssoc(runUpdateQuery($cxn, $query));
$result = $result[0];
$msg = "Person: ".$result['name'];
if( !empty($result['details']) )
$msg .= "\n Details:".$result['details'];
echo $msg;
*/
/*
AT&T – [email protected]
Verizon – [email protected]
T-Mobile – [email protected]
Sprint PCS - [email protected]
Virgin Mobile – [email protected]
US Cellular – [email protected]
Nextel - [email protected]
Boost - [email protected]
Alltel – [email protected]
*/
?>
</p>
</body>
</html>