· 6 years ago · Apr 09, 2020, 03:02 PM
1<?php
2include_once "../../include/dont_delete.php";
3
4if (function_exists('mostraDcp'))
5{
6 mostraDcp();
7
8}
9else
10{
11 echo '<html lang="pt-br">
12 <head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
13
14 <div align="center">
15 <table width="100%" border="0" style="padding:15px; border-color:#F00; border-style:solid; background-color:#FF6C70; font-family:Tahoma, Geneva, sans-serif; font-size:22px; color:white;">
16
17 <tr>
18
19 <td><center><b>Houve algum problema com a licença. <hr>Contate o desenvolvedor </b></center></td >
20
21 </tr>
22
23 </table>
24
25</div>
26</html>';
27 die($html);
28 exit(0);
29}
30
31$user = $_SESSION['cpf_usuario'];
32$user_id = $_SESSION['sess_id'];
33
34$count = 0;
35
36$user_pass = $user;
37
38include ('../../config.php');
39
40$sql = MySql::conectar()->prepare('SELECT DISTINCT
41 `tb_site.rifas`.`titulo`, `tb_site.test`.`number`, `tb_site.test`.`type`
42 FROM
43 `tb_site.test`
44 LEFT OUTER JOIN `tb_site.user` ON
45 (
46 `tb_site.user`.`id` = `tb_site.test`.`user_id`
47 )
48 INNER JOIN `tb_site.rifas` ON
49 (
50 `tb_site.rifas`.`id` = `tb_site.test`.`rifas_id`
51 )
52 WHERE
53 `tb_site.user`.`cpf_usuario` = ' . $user . '
54 GROUP BY
55 `tb_site.rifas`.`titulo`,`tb_site.test`.`number`');
56
57$sql->execute();
58$rifaindex = $sql->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC);
59
60include ("../../include/config.php"); //up1
61$sqly = "select id from `tb_site.user` where cpf_usuario='" . $user_pass . "'";
62
63$resp = mysqli_query($con, $sqly) or die(mysqli_error($con));
64$aa = 0;
65$userArray = [];
66while ($mrows = $resp->fetch_array(MYSQLI_ASSOC))
67{
68 $userss[$aa] = $mrows["id"];
69 $aa++;
70}
71$userArray = $userss;
72$userNums = implode(',', $userss);
73
74$imagePath = [];
75
76while (list($key, $value) = each($rifaindex))
77{
78
79 $tmpArray = [];
80 $numType = [];
81 $imgName = '';
82
83 foreach ($value as $val)
84 {
85 $tmpArray[] = $val['number'];
86 $numType[] = $val[type];
87 }
88
89 $numbers = implode(',', $tmpArray);
90 $nn[$count] = $numbers;
91
92 $count_num = count($tmpArray);
93
94 include ("../../include/config.php"); //up1
95 $sqls = "select * from `tb_site.rifas` where titulo='" . $key . "'";
96 $imgss = mysqli_query($con, $sqls) or die(mysqli_error($con));
97
98 while ($myrows = $imgss->fetch_array(MYSQLI_ASSOC))
99 {
100 $rifas_id = $myrows["id"];
101 $titulo = $myrows["titulo"];
102 $conteudo = $myrows["conteudo"];
103 $pagamento = $myrows["pagamento"];
104 $photo = $myrows["foto_video"];
105 $custo = $myrows["cost"];
106 $telefone = $myrows["numero_telefone"];
107 }
108 $rifas[$count] = $rifas_id;
109 $titulos[$count] = $titulo;
110 $conteudos[$count] = $conteudo;
111 $pagamentos[$count] = $pagamento;
112 $photos[$count] = $photo;
113 $custos[$count] = $custo;
114 $telefones[$count] = $telefone;
115
116 $sqli = "select image_name from `tb_site.test` where user_id in (" . $userNums . ") and rifas_id='" . $rifas_id . "' order by number DESC limit 1";
117 $imgs = mysqli_query($con, $sqli) or die(mysqli_error($con));
118
119 while ($myrow = $imgs->fetch_array(MYSQLI_ASSOC))
120 {
121 $imgName = $myrow["image_name"];
122 }
123
124 echo ' <tr>';
125 //echo '<td class="py-1">- '.$key.' - RIFA NUMEROS : '.$numbers;
126 echo '<td class="py-1">- ' . $key . '</td>';
127 echo '<td>R$ ' . $custo . '</td>';
128 echo '<td>R$ ' . $custo * $count_num . '</td>';
129
130 echo '<td>' . $numbers . '</td>';
131
132 echo '<td><a href="#" data-toggle="modal" data-target="#infoModal' . $count . '"> <img src="./arquivos/cifrao.png" alt="Dados para pagamento" ></a></td>';
133 //versao api whatsapp
134 //echo '<td><a href="https://api.whatsapp.com/send?phone='.$telefone.'"> <img src="./arquivos/whatsapp.png" alt="Gostaria de Saber Sobre a Rifa '.$key.'" style="width:42px;height:42px;border:0;"></a>'.$telefone.'</td>';
135 //versao com wa.me https://api.whatsapp.com/send?phone=&text=Teste&source=&data=
136 echo '<td><a href="https://api.whatsapp.com/send?phone=' . $telefone . '&text=Gostaria de Saber Sobre a Rifa ' . $key . '&source=&data=" target="_blank"> <img src="./arquivos/whatsapp.png" alt="Gostaria de Saber Sobre a Rifa ' . $key . '" style="width:42px;height:42px;border:0;"></a></td>';
137 echo "<td><form method=\"post\" action=\"\" enctype='multipart/form-data'>";
138
139 echo "<input type='file' name='file" . $count . "' />";
140
141 echo "<input type='submit' value='Enviar' name='but_upload" . $count . "'>";
142
143 // echo "<button type='button' id='pay-button' class='pay_btn' style='margin-left: 30px;' value='payment'>Dados Pagamento</button>";
144 //echo "<a style='color: #101010;background: #eceaea; padding: 5px; border: 1px solid gray;margin-left: 30px;' href='#' data-toggle='modal' data-target='#infoModal".$count."'>Dados Pagamento</a></td>";
145
146
147 if ($imgName != '')
148 {
149 $isImgs[$count] = true;
150 $imagePath[$count] = $endereco_site . "/imagens/uploads/comprovantes/" . $imgName;
151 echo "<td><img style='height: 100px; width: 100px; margin: 11px 5px 0px 20px;' class='img-responsive' src= $endereco_site/imagens/uploads/comprovantes/" . $imgName . " name='img-fluid" . $count . "' alt=''></td>";
152 }
153 else
154 {
155 $imagePath[$count] = "";
156 $isImgs[$count] = false;
157 }
158
159 echo "</form>";
160 //echo '</tr>';
161 $count++;
162}
163
164include ("../../include/config.php"); //up1
165for ($i = 0;$i < $count;$i++)
166{
167
168 if (isset($_POST['but_upload' . $i]))
169 {
170
171 $target_dir = "comprovantes/";
172 $target_file = $target_dir . basename($_FILES["file" . $i]["name"]);
173
174 $imgPath = $endereco_site . '/imagens/uploads/' . $target_dir;
175
176 // Select file type
177 $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
178
179 // Valid file extensions
180 $extensions_arr = array(
181 "jpg",
182 "jpeg",
183 "png",
184 "gif"
185 );
186
187 // Check extension
188 if (in_array($imageFileType, $extensions_arr))
189 {
190 $tamanho_letra = 50;
191
192 $aleatorio = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVXYZ") , 0, $tamanho_letra);
193 // Convert to base64
194 //$image_base64 = base64_encode(file_get_contents($_FILES['file']['tmp_name']) );
195 //$image = 'data:image/'.$imageFileType.';base64,'.$image_base64;
196 $temp = explode(".", $_FILES["file" . $i]["name"]);
197 $newfilename = 'comprovante_usuario_' . $aleatorio . '_' . round(microtime(true)) . '.' . end($temp);
198
199 // Insert record
200 if ($isImgs[$i] == true)
201 {
202 $query = "update `tb_site.test` set image_name='" . $newfilename . "' where user_id in (" . $userNums . ") and rifas_id='" . $rifas[$i] . "' and number in (" . $nn[$i] . ")";
203 }
204 else
205 {
206 $query = "update `tb_site.test` set image_name='" . $newfilename . "' where user_id in (" . $userNums . ") and rifas_id='" . $rifas[$i] . "' and number in (" . $nn[$i] . ")";
207 // $query = "update `tb_site.user` set image_name='".$newfilename."', numbers='".$nn[$i]."' where id='".$user_id."'";
208 // $query = "insert into comprovantes(name,user_id,numbers) values('".$newfilename."','".$user_id."','".$nn[$i]."')";
209
210 }
211
212 mysqli_query($con, $query) or die(mysqli_error($con));
213
214 // MOVE UPLODAR ENVIA COMPROVANTE
215 move_uploaded_file($_FILES["file" . $i]["tmp_name"], "../../imagens/uploads/comprovantes/" . $newfilename);
216
217 // echo '<script type="text/javascript">location.reload(true);</script>';
218 echo "<meta http-equiv='refresh' content='0.5;'>";
219 exit();
220 }
221
222 }
223}
224
225?>