-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
131 lines (122 loc) · 5.58 KB
/
index.php
File metadata and controls
131 lines (122 loc) · 5.58 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
<?php
session_set_cookie_params(86400);
session_start();
$currentPage = 'index';
include_once(__DIR__ . '/components/header.php');
$config = require_once(__DIR__ . '/config/config.php');
require_once(__DIR__ . '/config/database.php');
$conn = (new Database(
$config['DB_HOST'],
$config['DB_USERNAME'],
$config['DB_PASSWORD'],
$config['DB_DATABASE']
))->getConnection();
$totalRecipes = Database::getTotalRecipeCount($conn);
?>
<main class="my-4">
<section class="container bg-color-6 py-4 px-5 border-radius-2 shadow">
<header class="text-center">
<img src="src/img/sem-desperdicio-logo.png" alt="Sem Desperdício" class="img-fluid" width="240">
<h1 class="text-color-2 h3">
Reduza o Desperdício de Alimentos com a Ajuda da Inteligência Artificial.
</h1>
<p>
A Organização das Nações Unidas (ONU) estima que 45% de todas as frutas e hortaliças produzidas sejam
perdidas, enquanto 30% de todo o alimento mundial é desperdiçado¹. Contribua para mudar essa realidade!
</p>
<div class="my-3">
Já ajudamos a criar mais de <span id="totalRecipes" class="text-color-2 font-weight-bold">
<?php echo $totalRecipes; ?>
</span>
refeições deliciosas e sustentáveis.
</div>
<?php include_once(__DIR__ . '/components/video.php'); ?>
</header>
<hr>
<section>
<form id="form" class="form">
<div class="form-group">
<textarea class="form-control" id="ingredients" rows="5" require></textarea>
</div>
<!---
<div class="form-group">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="mealPlannerSwitch">
<label class="custom-control-label" for="mealPlannerSwitch" id="mealPlannerSwitchLabel">
Ativar Planejador de Refeições da Semana
</label>
</div>
<small class="form-text text-muted">
O planejador de refeições da semana é uma funcionalidade que permite que você gere receitas para a semana inteira de uma só vez com base nos ingredientes que você tem em casa.
</small>
</div>
--->
<?php
// Verifique se a sessão para o contador de solicitações existe
if (!isset($_SESSION['request_count'])) {
$_SESSION['request_count'] = 0; // Inicialize o contador
}
// Verifique se o usuário já atingiu o limite de solicitações
if ($_SESSION['request_count'] >= 3) {
// Exiba uma mensagem ou realize qualquer ação desejada quando o limite for atingido
echo '
<div class="form-group">
<button type="submit" class="btn btn-color-2" id="generateRevenue"
class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback="onSubmit"
data-action="submit">
Gerar receita
</button>
';
} else {
// Se o usuário não atingiu o limite, renderize o botão
echo '
<div class="form-group">
<button type="submit" class="btn btn-color-2" id="generateRevenue"
class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback="onSubmit"
data-action="submit">
Gerar receita
</button>
</div>
<hr>
<p>
<small class="form-text text-muted">
<span class="text-danger">*</span> Você gerou <span id="requestCount">' . $_SESSION['request_count'] . '</span> de 3 solicitações. Aguarde 24 horas para gerar mais receitas.
</small>
';
}
?>
</form>
</section>
<section id="result" class="mb-2">
</section>
<section id="fontes">
<p class="fonte-titulo">
Fontes:
</p>
<ol class="fonte-lista">
<li>
<a target="_blank"
href="https://g1.globo.com/empreendedorismo/noticia/2022/06/16/sustentabilidade-empresas-vendem-alimentos-proprios-para-consumo-mas-com-defeitos-ou-perto-do-vencimento.ghtml"
title="Fonte: G1">
<span class="link-icon">→</span> ¹ Sustentabilidade: Empresas vendem alimentos próprios para
consumo, mas com defeitos ou perto do vencimento (G1)
</a>
</li>
<li>
<a target="_blank" href="https://www.bbc.com/portuguese/internacional-56377418" title="Fonte: BBC">
<span class="link-icon">→</span> ² Como os países ricos planejam combater o desperdício de
alimentos (BBC)
</a>
</li>
</ol>
</section>
</div>
</section>
</main>
<?php
include_once(__DIR__ . '/components/footer.php');
?>