function smamo_booking_form() { $navn = isset($_POST['navn']) ? wp_strip_all_tags($_POST['navn']) : false; $email = isset($_POST['email']) ? wp_strip_all_tags($_POST['email']) : false; $firma = isset($_POST['firma']) ? wp_strip_all_tags($_POST['firma']) : false; $telefon = isset($_POST['telefon']) ? wp_strip_all_tags($_POST['telefon']) : false; $budget = isset($_POST['budget']) ? wp_strip_all_tags($_POST['budget']) : false; $about = isset($_POST['about']) ? $_POST['about'] : false; if (!$navn || !$email) { $response['error'] = 'Mangler vigtige oplysninger'; wp_die(json_encode($response)); } // Indstil about $about_string = ''; $i = 0; if (is_array($about)) { foreach ($about as $a) { $i++; $about_string .= $i === 1 ? $a : ', ' . $a; } } if (function_exists('slack')) { $text = $navn . ' har lige sendt en anmodning om et møde!'; $attachments = array(array('pretext' => '', 'color' => '#669999', 'fields' => array(array('title' => 'Navn', 'value' => $navn, 'short' => false), array('title' => 'Firma', 'value' => $firma, 'short' => false), array('title' => 'Email', 'value' => '<mailto:' . $email . '|' . $email . '>', 'short' => false), array('title' => 'Telefon', 'value' => '<tel:' . $telefon . '|' . $telefon . '>', 'short' => false), array('title' => 'Vil gerne holde møde om', 'value' => $about_string, 'short' => false), array('title' => 'Budget ca.', 'value' => $budget, 'short' => false)))); // Send $response['slack_curl'] = slack($text, $attachments); } wp_die(json_encode($response)); }
function smamo_puzzle_form() { $response = array(); $post_vars = array('state' => isset($_POST['state']) && $_POST['state'] !== '' ? true : false, 'solve-time' => isset($_POST['solve-time']) ? wp_strip_all_tags($_POST['solve-time']) : false, 'name' => isset($_POST['name']) ? wp_strip_all_tags($_POST['name']) : false, 'email' => isset($_POST['email']) ? wp_strip_all_tags($_POST['email']) : false); // state og solve-time skal være sat til true if (!$post_vars['state'] || !$post_vars['solve-time']) { $response['error'] = 'cheats!'; wp_die(json_encode($response)); } // Navn skal udfyldes if (!$post_vars['name']) { $response['error'] = 'Indtast et navn'; wp_die(json_encode($response)); } // Email skal udfyldes if (!$post_vars['email']) { $response['error'] = 'Indtast en email'; wp_die(json_encode($response)); } if (!$post_vars['state'] === '3') { $response['error'] = 'you shouldnt be here, son'; wp_die(json_encode($response)); } // Opret slack notifikation if (function_exists('slack')) { $text = $post_vars['name'] . ' har lige tilmeld sig nyhedsbrevet!'; $attachments = array(array('pretext' => '', 'color' => '#669999', 'fields' => array(array('title' => 'Navn', 'value' => $post_vars['name'], 'short' => false), array('title' => 'Email', 'value' => '<mailto:' . $post_vars['email'] . '|' . $post_vars['email'] . '>', 'short' => false), array('title' => 'Tid på puslespil', 'value' => $post_vars['solve-time'], 'short' => false)))); $response['slack_curl'] = slack($text, $attachments); } // Opret subscriber if (class_exists('MailChimp')) { $api_key = '40bbbefd42e7b7fd5e22c5e0e9ca61b3-us10'; $list_ID = '51f08ecfa7'; $response['mc-creds'] = array('key' => $api_key, 'list' => $list_ID); $MailChimp = new MailChimp($api_key); $result = $MailChimp->call('lists/subscribe', array('id' => $list_ID, 'email' => array('email' => $post_vars['email']), 'merge_vars' => array('NAME' => $post_vars['name']), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false)); $response['mailchimp'] = $result; } wp_die(json_encode($response)); }
$seek = 0; } $l = file_get_contents($f, false, null, $seek, 2048); if (strlen($l) == 2048) { $l .= "\n\nDisplaying just 2048 bytes"; $seek = $size; } else { $seek += strlen($l); } file_put_contents($seek_file_path, $seek); if ($l !== '') { slack($v['config'], $f, $l); } } catch (Exception $e) { if ($alert_errors) { slack($v['config'], $f, $e->getMessage()); } if ($output_errors) { echo $e->getMessage() . "\n"; } } } } function slack($config, $file, $msg) { $code = '```'; $data = "payload=" . json_encode($config + ['text' => "{$file}\n{$code}{$msg}{$code}"]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $config['url']); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);