-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfunctions.php
executable file
·80 lines (79 loc) · 2.49 KB
/
functions.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
<?php
function sanitize_input($input) {
return htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
}
function get_safe_value($con, $str) {
if ($str != '') {
$str = trim($str);
return mysqli_real_escape_string($con, sanitize_input($str));
}
}
function pr($arr){
echo'<pre>';
print_r($arr);
}
function prx($arr){
echo'<pre>';
print_r($arr);
die();
}
function get_total_price_by_month($con,$date){
$raised=0;
$resp=mysqli_query($con,"SELECT `donations`.`amount` from `donations` where `donations`.`payment_status`='1' and month(`donations`.`added_on`)=month('$date') and year(`added_on`)=year('$date')");
while($row=mysqli_fetch_assoc($resp)){
$raised=$raised+$row['amount'];
}
return $raised;
}
function get_total_price_by_date($con,$date){
$raised=0;
$resp=mysqli_query($con,"SELECT `donations`.`amount` from `donations` where `donations`.`payment_status`='1' and `donations`.`added_on` = '$date' and year(`added_on`)=year('$date')");
while($row=mysqli_fetch_assoc($resp)){
$raised=$raised+$row['amount'];
}
return $raised;
}
function get_total_spends_by_month($con,$date){
$raised=0;
$resp=mysqli_query($con,"SELECT `spends`.`amount` from `spends` where month(`spends`.`date`)=month('$date') and year(`date`)=year('$date')");
while($row=mysqli_fetch_assoc($resp)){
$raised=$raised+$row['amount'];
}
return $raised;
}
// by year
function get_total_price_by_year($con,$date){
$raised=0;
$resp=mysqli_query($con,"SELECT `donations`.`amount` from `donations` where `donations`.`payment_status`='1' and year(`added_on`)=year('$date')");
while($row=mysqli_fetch_assoc($resp)){
$raised=$raised+$row['amount'];
}
return $raised;
}
// total donations
function get_total_donations($con){
$raised=0;
$resp=mysqli_query($con,"SELECT `donations`.`amount` from `donations` where `donations`.`payment_status`='1'");
while($row=mysqli_fetch_assoc($resp)){
$raised=$raised+$row['amount'];
}
return $raised;
}
function get_api_data($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function get_api_data_post($url,$data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
?>