Wedstrijd toegevoegd

[insert_php]
global $current_user; get_currentuserinfo();
[/insert_php]

[insert_php]

include “api/v2/hidden/dbase.php”;// ServerName
$servername = “localhost”;
// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);
// Check
if (!$conn) {
die(“Connection failed: ” . mysqli_connect_error());
}

$sql =”SELECT device_id FROM tragatta_linkeddevices WHERE user_id = ‘$current_user->user_login'”;
$result2 = mysqli_query($conn, $sql);
$obj = $result2->fetch_object();
$device_id =$obj->device_id;

if($_POST && isset($_POST[‘wedstrijd’])) {
$wedstrijd =$_POST[‘wedstrijd’];
$datum = date(‘Y-m-d’,strtotime($_POST[‘startdate’]));
$tijd = $_POST[‘starttime’];
$ronden = $_POST[’rounds’];
function random_str($length, $keyspace = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-‘) {
$str = ”;
$max = mb_strlen($keyspace, ‘8bit’) – 1;
for ($i = 0; $i < $length; ++$i) { $str .= $keyspace[random_int(0, $max)]; } return $str; } $wedstrijdID = random_str(18); $sql = "INSERT INTO tragattaWedstrijd VALUES ('$device_id','$wedstrijd','$datum','$tijd','$ronden','$wedstrijdID','nog niet gestart','3600')"; $result = $conn->query($sql);
$app_nam = $wedstrijd;
$startti = $tijd;
$startda = $datum;
$endtime = $tijd;
$enddate = $datum;
$purpose = ‘zeilen’;
$informa = ‘Aantal ronden: ‘.$ronden;
$sql = “SELECT emailaddress from tragatta_linkeddevices WHERE device_id=’$device_id'”;
$result2 = mysqli_query($conn, $sql);
while($row2 = mysqli_fetch_assoc($result2)) {
$emailAddress= $row2[’emailaddress’];
}

$alt=”Scan deze code om deel te nemen aan de regatta met de tragatta App.”;
$size = “200”;
$align = “”;
$class = “”;
$credit_footer = “

“;
$preoutput = ‘

‘;
$content = ‘wedstrijd/’.$wedstrijdID;
$output = “”;
$image = ‘https://chart.googleapis.com/chart?chs=’ . $size . ‘x’ . $size . ‘&cht=qr&chld=H|1&chl=’ . $content;
if ($align == “right”) {
$align = ‘ align=”right”‘;
}
if ($align == “left”) {
$align = ‘ align=”left”‘;
}
if ($class != “”) {
$class = ‘ class=”‘ . $class . ‘”‘;
}

$output = $preoutput . ‘' . $alt . '‘;

$organ_name = “Tragatta”;
$organ_Address= “info@tragatta.one”;
$from_name = “Tragatta”;
$domain = “TRAGATTA”;
$mime_boundary = “—-Meeting Booking—-“.MD5(TIME());
$subject = “Deel deze QR-code”;
$from = “info@tragatta.one”;
$replyto = “info@tragatta.one”;
$headers = ‘From: ‘ . $from. “\r\nReply-To: ” . $replyto . “\n”;
$headers .= “MIME-Version: 1.0\n”;
$headers .= “Content-Type: multipart/alternative; boundary=\”$mime_boundary\”\n”;
$headers .= “Content-class: urn:content-classes:calendarmessage\n”;

//Create Email Body (HTML)
$message = “–$mime_boundary\r\n”;
$message .= “Content-Type: text/html; charset=UTF-8\n”;
$message .= “Content-Transfer-Encoding: 8bit\n\n”;
$message .= “\n”;
$message .= “\n”;
$message .= ‘

‘.$output . $credit_footer .’

‘;
$message .= “\n”;
$message .= “\n”;
$message .= “–$mime_boundary\r\n”;

$ical = ‘BEGIN:VCALENDAR’ . “\r\n” .
‘PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN’ . “\r\n” .
‘VERSION:2.0’ . “\r\n” .
‘METHOD:REQUEST’ . “\r\n” .
‘BEGIN:VEVENT’ . “\r\n” .
‘ORGANIZER;CN=”‘.$organ_name.'”:MAILTO:’.$organ_Address. “\r\n” .
‘ATTENDEE;CN=”‘.$from_name.'”;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:’.$emailAddress. “\r\n” .
‘UID:’.date(“Ymd\TGis”, strtotime($startti)).rand().”@”.$domain.”\r\n” .
‘DTSTAMP:’.date(“Ymd\TGis”). “\r\n” .
‘DTSTART:’.date(“Ymd”, strtotime($startda)).”T”.date(“His”, strtotime($startti)). “\r\n” .
‘DTEND:’.date(“Ymd”, strtotime($enddate)).”T”.date(“His”, strtotime($endtime)). “\r\n” .
‘SUMMARY:’ . $app_nam. “\r\n” .
‘LOCATION:’ . $domain . “\r\n” .
‘BEGIN:VALARM’ . “\r\n” .
‘TRIGGER:-PT15M’ . “\r\n” .
‘ACTION:DISPLAY’ . “\r\n” .
‘DESCRIPTION:Reminder’ . “\r\n” .
‘END:VALARM’ . “\r\n” .
‘END:VEVENT’. “\r\n” .
‘END:VCALENDAR’. “\r\n”;

$message .= ‘Content-Type: text/calendar;name=”meeting.ics”;method=REQUEST’.”\n”;
$message .= “Content-Transfer-Encoding: 8bit\n\n”;
$message .= $ical;

$flags = ‘-f ‘ . BOUNCED_EMAIL_ADDRESS;

mail($emailAddress, $subject, $message, $headers, $flags);

}

header(‘Location: https://www.tragatta.one/wedstrijden/’);

[/insert_php]