Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $wpdb;
- $wpdb->show_errors();
- //include the S3 class
- if (!class_exists('S3'))require_once('S3.php');
- //AWS access info
- if (!defined('awsAccessKey')) define('awsAccessKey', 'AKIAIDSHPHGVRUSFETCQ');
- if (!defined('awsSecretKey')) define('awsSecretKey', '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');
- //instantiate the class
- $s3 = new S3(awsAccessKey, awsSecretKey);
- //code($_POST,'post');
- //check whether a form was submitted
- if(isset($_POST['Submit'])){
- //retreive post variables
- $webinarName = $_FILES['theFile']['name'];
- // $fileTempName = $_FILES['theFile']['tmp_name'];
- if (!empty($_POST['theTitle'])) {
- $fileTitle = $_POST['theTitle'];
- $fileTitle = str_replace(' ', '-', $fileTitle);
- $fileTitle = strtolower($fileTitle);
- $fileTitle .= '-';
- $fileTitle .= mt_rand(1000, 9999);
- } else {
- $fileTitle = $webinarName;
- }
- if ($_FILES['theFile']['size'] != 0) {
- $webinarType = strcmp($_FILES['theFile']['type'], 'video/mp4');
- if($webinarType == 0) {
- $webinarFile = $fileTitle.'.mp4';
- $webinarTempName = $_FILES['theFile']['tmp_name'];
- } else {
- echo 'Webinar must be .mp4';
- }
- }
- if ($_FILES['thePDF']['size'] != 0){
- $pdfType = strcmp($_FILES['thePDF']['type'], 'application/pdf');
- if($pdfType == 0) {
- $pdfFile = $fileTitle.'.pdf';
- $pdfTempName = $_FILES['thePDF']['tmp_name'];
- } else {
- echo 'PDF must be .pdf';
- }
- }
- $theSite = $_POST['theSite'];
- $p = strpos($theSite, 'p');
- $s = strpos($theSite, 's');
- if((string)$p == "0") {
- $amazon_id = str_replace('p_', '', $theSite);
- $sec_id = 2; //elitetradersgroup
- } else if ((string)$s == "0") {
- $sec_id = str_replace('s_', '', $theSite);
- $amazon_id = $wpdb->get_var("SELECT amazon_section_id FROM bu_amazon_secondary_sections WHERE secondary_id = $sec_id");
- }
- if(!empty($webinarFile)) {
- $var_arr = array($amazon_code,$webinarFile);
- $vars = implode('J05h', $var_arr);
- $enc = base64_encode($vars);
- $url = get_bloginfo('url').'/webinar.php?wid='.$enc;
- //move the file
- if ($s3->putObjectFile($webinarTempName, "elitetradersgroup", $webinarFile, S3::ACL_PUBLIC_READ)) {
- $wpdb->insert('bu_amazon_archive',array('amazon_title' => $_POST['theTitle'], 'amazon_file' => $webinarFile, 'amazon_bucket' => $_POST['amazon_bucket'],'amazon_section_id' => $amazon_id, 'etg_link' => $url, 'amazon_secondary_section_id' => $sec_id));
- echo "<p>Webinar Successfully Uploaded.</p>";
- echo "<p>Please be sure to click the link and play the video to confirm that it works</p>";
- $webinar_id = $wpdb->get_var($wpdb->prepare("SELECT amazon_id FROM bu_amazon_archive WHERE amazon_file = '{$webinarFile}'"));
- echo '<p><a href="'.$url.'" target="_blank">Webinar</a></p>';
- } else {
- echo "<p><strong>Something went wrong while uploading your webinar... Please try again...</strong></p>";
- }
- }
- if(!empty($pdfFile)) {
- //move the file
- if ($s3->putObjectFile($pdfTempName, "elitetradersgroup", $pdfFile, S3::ACL_PUBLIC_READ)) {
- $url = 'http://elitetradersgroup.s3.amazonaws.com/'.$pdfFile;
- $wpdb->insert('bu_amazon_archive',array('amazon_title' => $_POST['theTitle'], 'amazon_file' => $pdfFile, 'amazon_bucket' => $_POST['amazon_bucket'],'amazon_section_id' => $amazon_id, 'etg_link' => $url, 'amazon_secondary_section_id' => $sec_id));
- echo "<p>PDF Successfully Uploaded.</p>";
- echo "<p>Please be sure to click the link and view the pdf to confirm it was done successfully</p>";
- $pdf_id = $wpdb->get_var($wpdb->prepare("SELECT amazon_id FROM bu_amazon_archive WHERE amazon_file = '{$pdfFile}'"));
- echo '<p><a href="'.$url.'" target="_blank">PDF</a></p>';
- } else {
- echo "<p><strong>Something went wrong while uploading your pdf... Please try again...</strong></p>";
- }
- }
- if (isset($_POST['positions'])) {
- $new_pos = $_POST['np-trades'];
- $cur_pos = $_POST['cur-trades'];
- $update_pos = $_POST['update-trades'];
- $positions = array(
- 'new_trade' => $new_pos,
- 'cur_trade' => $cur_pos,
- 'update_trade' => $update_pos
- );
- $wpdb->insert('bu_email_positions', $positions);
- $position_id = $wpdb->get_var($wpdb->prepare("SELECT position_id FROM bu_email_positions ORDER BY position_id DESC"));
- }
- if (isset($_POST['message'])) {
- $message = $_POST['message'];
- }
- if(isset($_POST['additional-webinar-selection'])) {
- $extra_webinar = $_POST['additional-webinar-selection'];
- }
- $email_array = array(
- 'email_title' => $_POST['theTitle'],
- 'webinar_id' => $webinar_id,
- 'position_id' => $position_id,
- 'pdf_id' => $pdf_id,
- 'sec_id' => $sec_id,
- 'message' => $message,
- 'additional_webinar_id' => $extra_webinar
- );
- $wpdb->insert('bu_email_archive', $email_array);
- $email_id = $wpdb->get_var($wpdb->prepare("SELECT email_id FROM bu_email_archive ORDER BY email_id DESC"));
- $check_query = "SELECT tn.*, tt.inf_tag_type FROM bu_inf_tag_name AS tn
- LEFT OUTER JOIN bu_inf_tag_type AS tt
- ON tn.inf_tag_type_id = tt.inf_tag_type_id
- WHERE tn.inf_tag_type_id = 2";
- $checks = $wpdb->get_results($wpdb->prepare($check_query));
- ?>
- <form id="inf_send_email" method="POST" action="send-email">
- <?php
- foreach ($checks as $check) {
- echo '<input type="checkbox" ';
- echo 'id="'.$check->inf_tag_id.'" name="tags[]" value="'.$check->inf_tag_id.'"><label for="'.$check->inf_tag_id.'">'.$check->inf_tag_name.'</label><br />';
- }
- ?>
- <input type="hidden" name="email_id" value="<?php echo $email_id; ?>" />
- <input type="hidden" name="sec_id" value="<?php echo $sec_id; ?>" />
- <input type="hidden" name="from" value="Elite Traders Group" />
- <input type="hidden" name="fromemail" value="donotreply@elitetradersgroup.com.au" />
- <input type="submit" name="submit" value="Submit" />
- </form>
- <?php
- } else {
- function show_hide_aupload() {
- $url = plugin_dir_url()."broker-uploader/amazon/";
- ?>
- <script type="text/javascript" src="<?php echo $url; ?>mootools.js"></script>
- <script type="text/javascript" src="<?php echo $url; ?>progress.js"></script>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery('#amazon-upload').submit(function(){
- // jQuery(this).hide();
- });
- jQuery('#theTitle').keyup(function(){
- var count = $(this).val().length;
- var limit = 80; //must be amazon_file limit - 10
- if(count > limit) {
- jQuery(this).val(jQuery(this).val().substr(0, limit));
- jQuery('#amazon_title_char_count').css('color','red');
- jQuery('#excess_warning').html("You may only have up to "+limit+" characters in the title. Excess characters have been truncated");
- jQuery('#excess_warning').show('fast');
- var count = $(this).val().length;
- } else {
- jQuery('#amazon_title_char_count').css('color','inherit');
- jQuery('#excess_warning').hide('fast');
- }
- jQuery('#amazon_title_char_count').html(count+"/"+limit+" characters used");
- });
- jQuery('#message-ta').keyup(function(){
- var count = $(this).val().length;
- var limit = 5000;
- if(count > limit) {
- jQuery(this).val(jQuery(this).val().substr(0, limit));
- jQuery('#message_char_count').css('color','red');
- jQuery('#message_excess_warning').html("You may only have up to "+limit+" characters in the title. Excess characters have been truncated");
- jQuery('#message_excess_warning').show('fast');
- var count = $(this).val().length;
- } else {
- jQuery('#message_char_count').css('color','inherit');
- jQuery('#message_excess_warning').hide('fast');
- }
- jQuery('#message_char_count').html(count+"/"+limit+" characters used");
- });
- jQuery("input:checkbox").change(function(){
- var div = '#'+jQuery(this).attr('value');
- if( jQuery(this).is(":checked") ) {
- jQuery(div).show('fast');
- } else {
- jQuery(div).hide('fast');
- }
- });
- });
- function showProgress() {
- var pb = document.getElementById("uploader");
- pb.innerHTML = '<img src="/wp-content/plugins/broker-uploader/amazon/uploading-1.gif" width="116" height ="119"/>';
- pb.style.display = '';
- }
- </script>
- <script type="text/javascript">
- window.addEvent('domready',function()
- {
- $$('form.upload').each(function(o_form)
- {
- o_form.fileUpload = new uploadProgress(o_form,{
- 's_actionHelper' : '<?php echo $url; ?>progress.php',
- 'i_interval' : 500
- });
- });
- });
- </script>
- <?php
- }
- add_action('wp_footer','show_hide_aupload');
- ?>
- <h3><a href="/broker-tools/amazon-upload/webinar-archive/">View Archive</a></h3>
- <style type="text/css">
- .sec_name, label {
- display: block;
- clear: right;
- }
- .sec_name {
- font-style: italic;
- }
- .title {
- font-weight: bold;
- margin:10px 0;
- }
- .radio {
- font-weight: normal;
- float: left;
- }
- input[type="radio"], input[type="checkbox"] {
- display: block;
- float: left;
- margin-right: 5px;
- }
- .option {
- display: block;
- float:left;
- width: 100%;
- }
- .opt-cont {
- margin-left: 10px;
- float:left;
- width:100%;
- }
- </style>
- <form action="" method="post" class="upload" enctype="multipart/form-data" id="amazon-upload">
- <label class="title" for="theTitle">Email Title</label>
- <input id="theTitle" type="text" name="theTitle" /><div id="amazon_title_char_count"></div><div id="excess_warning" style="display:none; font-weight: bold;color: red;"></div>
- <label class="title" for="theSite">Select Email From</label>
- <!-- <select id="theSite" name="theSite">-->
- <?php
- $sites = $wpdb->get_results($wpdb->prepare("SELECT * FROM bu_amazon_sections"));
- foreach ($sites as $site) {
- // echo '<option value="'.$site->amazon_section_id.'">'.$site->amazon_section_name.'</option>';
- // echo '<input type="radio" id="primary_'.$site->amazon_section_id.'" name="theSite" value="p_'.$site->amazon_section_id.'" /><label for="primary_'.$site->amazon_section_id.'">'.$site->amazon_section_name.'</label>';
- echo '<div class="option">';
- echo '<span class="sec_name">'.$site->amazon_section_name.'</span>';
- if ($site->has_secondary) {
- $secondaries = $wpdb->get_results($wpdb->prepare("SELECT * FROM bu_amazon_secondary_sections WHERE amazon_section_id = $site->amazon_section_id ORDER BY secondary_name ASC"));
- foreach($secondaries as $secondary) {
- $class = $secondary->secondary_name;
- $class = strtolower($class);
- $class = str_replace(" ","-",$class);
- echo '<div class="opt-cont">';
- echo '<input class="radio '.$class.'" type="radio" id="sec_'.$secondary->secondary_id.'" name="theSite" value="s_'.$secondary->secondary_id.'" /><label class="radio" for="sec_'.$secondary->secondary_id.'">'.$secondary->secondary_name.'</label>';
- echo '</div>';
- }
- }
- echo "</div>";
- } ?>
- <label class="title" for="theFile">.mp4 Video to Upload</label>
- <input id="theFile" name="theFile" type="file" accept="video/mp4" />
- <label class="title">Extras</label>
- <input type="checkbox" id="pdf" name="pdf" value="pdf-box"><label for="pdf">Include PDF</label>
- <input type="checkbox" id="positons" name="positions" value="positions-box"><label for="positons">Include Positions</label>
- <input type="checkbox" id="message" name="message" value="message-box"><label for="message">Include message</label>
- <input type="checkbox" id="additional-webinar" name="additional-webinar" value="additional-webinar-box"><label for="additional-webinar">Include Additional Webinar</label>
- <div id="pdf-box" style="display:none;">
- <label class="title" for="thePDF">.pdf File to Upload</label>
- <input id="thePDF" name="thePDF" type="file" accept="application/pdf" />
- </div>
- <div id="positions-box" style="display:none;">
- <label class="title">Positions Info</label>
- <label>New/Potential Trades</label>
- <input type="text" name="np-trades" />
- <label>Current Trades</label>
- <input type="text" name="cur-trades" />
- <label>Updates</label>
- <input type="text" name="update-trades" />
- </div>
- <div id="message-box" style="display:none;">
- <label class="title">Email Message</label>
- <textarea id="message-ta" name="message" cols="50" rows="10"></textarea>
- <div id="message_char_count"></div>
- <div id="message_excess_warning" style="display:none; font-weight: bold;color: red;"></div>
- </div>
- <div id="additional-webinar-box" style="display:none;">
- <label class="title">Select Additional Webinar</label>
- <select name="additional-webinar-selection">
- <option value="0" selected>Please Select</option>
- <?php
- $additional_webinars = $wpdb->get_results($wpdb->prepare("SELECT aa.amazon_id, aa.amazon_title, ass.amazon_section_name FROM bu_amazon_archive AS aa LEFT OUTER JOIN bu_amazon_sections AS ass ON aa.amazon_section_id = ass.amazon_section_id WHERE amazon_file_type_id = 1 ORDER BY upload_date DESC LIMIT 10"));
- foreach($additional_webinars as $additional_webinar) {
- echo '<option value="'.$additional_webinar->amazon_id.'">'.$additional_webinar->amazon_title.'('.$additional_webinar->amazon_section_name.')</option>';
- }
- ?>
- </select>
- </div>
- <!-- </select> -->
- <input type="hidden" value="elitetradersgroup" name="amazon_bucket" />
- <input name="Submit" type="submit" value="Upload" />
- <!---->
- </form>
- <div id="uploader" style="display:none;">
- <img src="/wp-content/plugins/broker-uploader/amazon/uploading-1.gif" width="116" height ="119"/>
- </div>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement