blob: 3fd8cdb99462ddae95c57fa3250f84b32707ac11 (
plain)
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
|
<?php
// Subpage Database script - stores all the data in a simple dokuwiki table
// All data is stored in a page with extension .log and the same name than current page
// How to use this:
//
// <form>
// action script crowdfunding.php
// thanks "Thank you for register in. You can join the call in [[https://meet.jit.si/GTA-Webinar|this link]]"
// Fieldset "About you"
// hidden "Lang" "=en"
// hidden "Date" "=@DATE@"
// Textbox "Name"
// email "E-Mail" !
// select "Country" "Afghanistan|Åland Islands|Albania|"
// yesno "Subscribe me for e-mail updates?" "=true value" "!false value"
// submit "Register in"
// </form>
ob_start();
use dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface;
class helper_plugin_bureaucracy_handler_crowdfunding implements bureaucracy_handler_interface {
/**
* Log the form fields to DokuWiki's debug log
*/
public function redirect($url) {
ob_start();
header('Location: '.$url);
ob_end_flush();
die();
}
public function handleData($fields, $thanks)
{
ob_start();
global $INFO;
$n = 0;
$m = 0;
foreach($fields as $row){
if ($n != 0) {
if ($row->opt["label"] === 'E-Mail') {
$line = $line . ' | <' . $row->opt["value"] . '>';
} else {
$line = $line . ' | ' . $row->opt["value"];
}
if ($row->opt["label"] === 'Medio de Pago') {
$pago = $row->opt["value"] ;
}
if ($n === 1) {
$lang = $row->opt["value"];
}
}
$n++;
}
$filepath = $INFO['filepath'];
// unifica el registro si viene de idioma español
$store_tmp = str_replace("/es/","/",$filepath);
$store = str_replace(".txt",".log.txt",$store_tmp);
// // Abre el fichero para obtener el contenido existente
if(!is_file($store)){
foreach($fields as $row){
if ($m != 0) {
$header = $header . ' ^ ' . $row->opt["label"];
}
$m++;
}
$header = substr($header, 1);
file_put_contents($store, "$header\n"); // Save our content to the file.
}
$actual = file_get_contents($store);
$line = substr($line, 1);
$actual .= "$line\n";
// // Escribe el contenido al fichero
file_put_contents($store, $actual);
//
if ($pago === "PayPal") {
echo "<script type='text/javascript'>window.open('https://paypal.com', '_blank');</script>";
echo $thanks;
exit;
// exit;
}
// dbglog($line);
return $thanks;
}
}
|