function settings_output() { global $wp_scripts; if (isset($_POST['action'])) { //flush wp super cache if (function_exists('wp_cache_no_postid')) { wp_cache_no_postid(0); } switch ($_POST['action']) { case 'cdn_js_load': /*$this->cdn_js_load(); $this->cdntools_baseuris = unserialize(get_option('cdntools_baseuris')); $this->cdntools_loadedfiles = unserialize(get_option('cdntools_loadedfiles')); //if nothing is loaded this will trigger an E_NOTICE*/ //REMOVED FOR WP 2.8 COMPATIBILITY break; case 'cdn_remove_js': $this->cdn_remove_container(CDNTOOLS_PREFIX . 'wp_js'); unset($this->cdntools_baseuris[CDNTOOLS_PREFIX . 'wp_js']); $this->cdntools_loadedfiles = null; break; case 'cdn_remove_attachments': foreach ($this->cdntools_baseuris as $container_name => $baseuri) { if ($container_name != CDNTOOLS_PREFIX . 'wp_js') { $this->cdn_remove_container($container_name); } $this->cdntools_sideload_uploads = 0; update_option('cdntools_sideload_uploads', 0); } break; case 'cdn_upload_all_attachments': $this->cdntools_sideload_uploads = 1; update_option('cdntools_sideload_uploads', 1); $json_arr = $this->cdn_upload_all_attachments(); break; case 'cdn_upload_all_files': $this->cdntools_sideload_uploads = 1; update_option('cdntools_sideload_uploads', 1); $json_arr = $this->cdn_upload_all_attachments(); //$this->cdn_js_load(); //REMOVED FOR WP 2.8 COMPATIBILITY $this->cdntools_baseuris = unserialize(get_option('cdntools_baseuris')); $this->cdntools_loadedfiles = unserialize(get_option('cdntools_loadedfiles')); //if nothing is loaded this will trigger an E_NOTICE break; case 'cdn_remove_all_files': foreach ($this->cdntools_baseuris as $container_name => $baseuri) { $this->cdn_remove_container($container_name); } $this->cdntools_sideload_uploads = 0; update_option('cdntools_sideload_uploads', 0); $this->cdntools_loadedfiles = unserialize(get_option('cdntools_loadedfiles')); //if nothing is loaded this will trigger an E_NOTICE break; case 'reset_cdntools': delete_option('cdntools_googleajax'); delete_option('cdntools_primarycdn'); delete_option('cdntools_loadedfiles'); delete_option('cdntools_baseuris'); delete_option('cdntools_authname'); delete_option('cdntools_authkey'); delete_option('cdntools_adminscripts'); delete_option('cdntools_sideload_uploads'); delete_option('cdntools_logretention'); delete_option('cdntools_servicenet'); delete_option('cdntools_advanced_options'); delete_option('cdntools_prefix'); $this->cdntools_googleajax = null; $this->cdntools_primarycdn = null; $this->cdntools_loadedfiles = null; $this->cdntools_baseuris = array(); $this->cdntools_authname = null; $this->cdntools_authkey = null; $this->cdntools_adminscripts = null; $this->cdntools_sideload_uploads = null; $this->cdntools_logretention = null; $this->cdntools_servicenet = null; $this->cdntools_advanced_options = null; } } ?> <div class="wrap"> <h2>CDN Tools</h2> <form method="post" action="options.php"> <?php settings_fields('cdn-options-group'); ?> <table class="form-table"> <tr> <th>Use Google AJAX CDN:</th> <td><select name="cdntools_googleajax"> <?php $true = null; $false = null; $set = 'selected="selected"'; $this->cdntools_googleajax ? $true = $set : ($false = $set); ?> <option value="1" <?php echo $true; ?> >True</option> <option value="0" <?php echo $false; ?> >False</option> </select></td> </tr> <tr> <td colspan="2">Google libraries will replace prototype, jquery, dojo, and mootools. Google will trump any other CDN you have enabled as well. This is free so you should enable this.</td> </tr> <tr> <th>Primary CDN:</th> <td><select name="cdntools_primarycdn"> <?php $amazon = null; $cloudfiles = null; $none = null; switch ($this->cdntools_primarycdn) { case 'cloudfiles': $cloudfiles = 'selected="selected"'; $cdn_name = 'Cloud Files'; break; case 'cloudfront': $amazon = 'selected="selected"'; $cdn_name = 'Amazon S3/CloudFront'; break; default: $none = 'selected="selected"'; $cdn_name = 'None Selected'; break; } ?> <option value="0" <?php echo $none; ?> >None</option> <option value="cloudfiles" <?php echo $cloudfiles; ?> >Cloud Files</option> <!--option value="amazon" <?php echo $amazon; ?> >Amazon S3/CloudFront</option--> </select></td> </tr> <tr> <td colspan="2">Select none if you do not have a CDN account and wish to only use the Google CDN feature for JS. Once you have selected a CDN and entered your credentials, click save changes and then click the "Load Files" button that appears near CDN Status.</td> </tr> <tr class="cdn-auth"> <th>Username:</th> <td><input type="text" name="cdntools_authname" value="<?php echo $this->cdntools_authname; ?> " /></td> </tr> <tr class="cdn-auth"> <th>API Key:</th> <td><input type="text" style="width:260px" name="cdntools_authkey" value="<?php echo $this->cdntools_authkey; ?> " /></td> </tr> <tr> <th> Advanced Options: </th> <td><select name="cdntools_advanced_options"> <?php $advanced_true = null; $advanced_false = null; if ($this->cdntools_advanced_options) { $advanced_true = 'selected="selected"'; } else { $advanced_false = 'selected="selected"'; } ?> <option value='0' <?php echo $advanced_false; ?> >Disabled</option> <option value='1' <?php echo $advanced_true; ?> >Enabled</option> </select> </td> </tr> <tr> <td colspan="2">Enabling advanced options will allow you to modify settings that are outside the standard use cases. You can also troubleshoot/reset various aspects of the plugin if you are having issues.</td> </tr> <?php if ($this->cdntools_advanced_options) { $advanced_display = ''; } else { $advanced_display = 'display:none'; } ?> <tr style="<?php echo $advanced_display; ?> "> <th>Enable CDN Side Loading:</th> <?php $sideloadcheck = $this->cdntools_sideload_uploads ? 'checked="checked"' : ''; ?> <td><input type="checkbox" name="cdntools_sideload_uploads" value="1" <?php echo $sideloadcheck; ?> /></td> </tr> <tr style="<?php echo $advanced_display; ?> "> <td colspan="2">Check this to enable side loading of uploads to your CDN. Uploads will also be kept locally in the event that you wish to turn off the CDN/remove this plugin. Once you configure your CDN you probably want to turn this on.</td> </tr> <tr style="<?php echo $advanced_display; ?> "> <th>Enable CDN Log Retention:</th> <?php $logretentioncheck = $this->cdntools_logretention ? 'checked="checked"' : ''; ?> <td><input type="checkbox" name="cdntools_logretention" value="1" <?php echo $logretentioncheck; ?> /></td> </tr> <tr style="<?php echo $advanced_display; ?> "> <td colspan="2">Check this to enable CDN log retention. If enabled, logs will be periodically (at unpredictable intervals) compressed and uploaded to a ".CDN_ACCESS_LOGS" container in the form of "container_name.YYYYMMDDHH-XXXX.gz". After enabling or disabling this option, you will need to re-upload your attachments to Cloud Files (click the "Load Attachments" button below).</td> </tr> <tr style="<?php echo $advanced_display; ?> "> <th>Enable Servicenet Connection:</th> <?php $servicenetcheck = $this->cdntools_servicenet ? 'checked="checked"' : ''; ?> <td><input type="checkbox" name="cdntools_servicenet" value="1" <?php echo $servicenetcheck; ?> /></td> </tr> <tr style="<?php echo $advanced_display; ?> "> <td colspan="2">Check this to enable the Servicenet connection to Cloud Files. If enabled, traffic to Cloud Files will use Rackspace's internal network to upload data to Cloud Files. This internal connection will almost always be faster than non-servicenet connections, and bandwidth on servicenet is free. However, servicenet connections will only work if this blog is hosted on a server that is hosted by Rackspace or Slicehost. <b>Rackspace Cloud Sites does not currently support the servicenet.</b></td> </tr> <!--tr style="<?php echo $advanced_display; ?> "> <th>Load wp-admin Javascripts:</th> <?php $adminupcheck = $this->cdntools_adminscripts ? 'checked="checked"' : ''; ?> <td><input type="checkbox" name="cdntools_adminscripts" value="1" <?php echo $adminupcheck; ?> /></td> </tr> <tr style="<?php echo $advanced_display; ?> "> <td colspan="2">Check this if you want the wp-admin javascript files to be put on your CDN. Typically you will want to leave this unchecked.</td> </tr--> <tr style="<?php echo $advanced_display; ?> "> <th>CDN Container Prefix:</th> <td><input type="text" name="cdntools_prefix" value="<?php echo $this->cdntools_prefix; ?> " /> </td> </tr> <tr style="<?php echo $advanced_display; ?> "> <td colspan="2">This option is only useful if you want to load multiple blogs into a single CDN account. Before changing this you should remove all files from the CDN or you will have issues!</td> </tr> <tr> <td> <input type="hidden" name="action" value="update" /> <input type="submit" class="button-primary" value="Save Changes" /> </td> </tr> </table> </form> <?php if (!function_exists('curl_init')) { echo '<p style="color:red">To upload files to the CDN, you must have curl support installed for PHP.</p>'; } ?> <div id="cdn_status" style="width:75%"> <table> <tr> <td style="font-size:24px;">CDN Status</td> <td style="font-size:24px"> | </td> <td style="color:blue;text-align:center;font-size:24px"><?php echo $cdn_name; ?> </td> <td style="font-size:24px"> | </td> <td id="load_remove_button"><?php if (empty($this->cdntools_baseuris) && !$none) { ?> <form method="post" action=""> <input type="hidden" name="action" value="cdn_upload_all_files" /> <p><input style="font-size:48em" type="submit" class="button-primary" value="Load Files" onclick="return(confirm('This action will load every WordPress attachment up into your CDN. The page will take a bit to reload and then an AJAX progress meter will start. Do not navigate away from the page during the upload!'))" /></p> </form> <?php } else { if (!$none) { ?> <form method="post" action=""> <input type="hidden" name="action" value="cdn_remove_all_files" /> <p><input type="submit" class="button-primary" value="Remove Files" onclick="return(confirm('This action will remove all files from your CDN. You should only do this if you wish to remove the plugin or to troubleshoot. And yes, this will take awhile!'))" /></p> </form> <?php } } ?> </td> <td id="load_percent" style="color:green;font-weight:bold;font-size:24px;display:none">0.00% </td> <td id="loading" style="display:none"> <img src="images/wpspin_light.gif" alt="" style="border:0" /> </td> </tr> </table> <?php if ($none) { ?> <p style="font-size:11px;color:#333333">Options to load/unload attachment data will appear here when you have configured a CDN for use.</p> <?php } else { //$js_load_status = ( is_array( $this->cdntools_loadedfiles ) )?'<span style="color:green">JS Loaded</span>':'<span style="color:red">JS Unloaded</span>'; //REMOVED FOR WP 2.8 COMPATIBILITY $attachment_load_status = count($this->cdntools_baseuris) > 1 || !empty($this->cdntools_baseuris) && !isset($this->cdntools_baseuris[CDNTOOLS_PREFIX . 'wp_js']) ? '<span style="color:green">Attachment Data Present</span>' : '<span style="color:red">No Attachment Data</span>'; $sideload_status = $this->cdntools_sideload_uploads ? '<span style="color:green">Side Loading Enabled</span>' : '<span style="color:red">Side Loading Disabled</span>'; ?> <p><?php echo $sideload_status . ' | ' . $attachment_load_status; ?> </p> <?php if ($this->cdntools_advanced_options) { $display = 'display:block;'; } else { $display = 'display:none;'; } ?> <div style="<?php echo $display; ?> " id="cdntools_advanced_options_div"> <p style="font-size:24px;color:orange">Other Advanced Tools</p> <form method="post" action=""> <input type="hidden" name="action" value="cdn_upload_all_attachments" /> <p><input type="submit" class="button-primary" value="Load Attachments" onclick="return(confirm('This action will load every wordpress attachment up into your CDN. This uses AJAX so while the percentage is going up don\'t reload or navigate away!'))" /></p> </form> <form method="post" action=""> <input type="hidden" name="action" value="cdn_remove_attachments" /> <p><input type="submit" class="button-primary" value="Remove Attachments" onclick="return(confirm('Are you sure you want to remove all attachments from the CDN? This will disable automatic sideloading as well.'))" /></p> </form> <!--form method="post" action=""> <p> <input type="hidden" name="action" value="cdn_js_load" /> <input type="submit" class="button-primary" value="Load JS" onclick="return(confirm('Loading Javascript to the CDN could take a few minutes, please be patient and only click OK if you are ready!'))"/> </p> </form> <form method="post" action=""> <input type="hidden" name="action" value="cdn_remove_js" /> <p><input type="submit" class="button-primary" value="Remove JS" onclick="return(confirm('Are you sure you want to remove all Javascript from your CDN?'))" /></p> </form--> <form method="post" action=""> <input type="hidden" name="action" value="reset_cdntools" /> <p><input type="submit" class="button-primary" value="Reset CDN Tools" onclick="return(confirm('This will remove all settings and reset CDN Tools to a default state. Before doing this you should remove all files from the CDN. Sure you want to do it?'))" /></p> </form> </div> <?php } ?> </div> </div> <?php if ($json_arr) { ?> <script type="text/javascript"> uploadArr = eval('(<?php echo $json_arr; ?> )'); activeNum = 0; numComplete = 0; itsBusted = 0; total = uploadArr.length; if (uploadArr.length > 0) { jQuery('#loading').show(); jQuery('#load_percent').show(); jQuery('#load_remove_button').hide(); setConfirmUnload(true); } fillConnectionQueue(); //this will prevent too many ajax requests from stacking up. function fillConnectionQueue() { while(activeNum < 4 && uploadArr.length > 0 && itsBusted == 0) { var attachment = uploadArr.shift(); activeNum++; queueAjax(attachment); } } function queueAjax(attachment) { jQuery.ajax({ type: "post", url: "admin-ajax.php", data: { 'action': 'cdn_attachment_upload_ajax', 'path': attachment['path'], 'post_id': attachment['post_id'], 'cookie': encodeURIComponent(document.cookie) }, timeout: 95000, error: function(request,error) { alert('A timeout on upload has occurred. Please contact the developer and provide them this information:\n'+error+'\n'+decodeURIComponent(this.data)) activeNum--; fillConnectionQueue(); }, success: function(response) { activeNum--; fillConnectionQueue(); //wp returns a 0 after all ajax calls for reasons that are beyond my //ability to comprehend. let's strip it off. var truncated_response = response.substring(0, response.length - 1); if(truncated_response == 'true') { numComplete++; var percent_complete = Math.round(parseInt(numComplete)/parseInt(total) * 10000)/100; jQuery('#load_percent').html(percent_complete+'%'); if(percent_complete == 100) { jQuery('#loading').hide(); setConfirmUnload(false); window.location.href=window.location.href; //reload } } else { if(!confirm('A file failed to upload. CDN Tools will behave inconsistently if all files do not upload successfully! You should contact the developer with this info:\n'+truncated_response+'\n\n Click Okay to continue uploading, or cancel to abort.')) { itsBusted = 1; setConfirmUnload(false); //something failed, we don't want to have that confirm any more } } } }); } function setConfirmUnload(val) { window.onbeforeunload = (val) ? unloadMessage : null; } function unloadMessage() { return 'Leaving this page will cause the content load to be incomplete!'; } </script> <?php } ?> <?php if (CDNTOOLS_DEBUG == true) { ?> <select> <option>List of Loaded JS</option> <?php foreach ($this->cdntools_loadedfiles as $value) { echo '<option>' . $value . '</option>' . "\n"; } echo '</select>'; print_r($this->cdntools_baseuris); foreach ($wp_scripts->registered as $object) { echo $object->handle . ' ' . $object->src . ' '; print_r($object->deps); echo '<br>'; } } }
function ceo_paypal_ipn() { $req = 'cmd=_notify-validate'; // Get each element of IPN request foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&{$key}={$value}"; } $header = ''; $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); // assign posted variables to local variables $num_cart_items = isset($_POST['num_cart_items']) ? (int) $_POST['num_cart_items'] : '1'; $count = 1; $item_name = array(); $item_number = array(); while ($count <= $num_cart_items) { $item_name[$count] = isset($_POST['item_name' . $count]) ? $_POST['item_name' . $count] : ''; $item_number[$count] = isset($_POST['item_number' . $count]) ? $_POST['item_number' . $count] : ''; $count++; } $payment_status = isset($_POST['payment_status']) ? $_POST['payment_status'] : ''; $payment_amount = isset($_POST['mc_gross']) ? $_POST['mc_gross'] : ''; $payment_currency = isset($_POST['mc_currency']) ? $_POST['mc_currency'] : ''; $txn_id = isset($_POST['txn_id']) ? $_POST['txn_id'] : ''; $shipping = isset($_POST['shipping']) ? $_POST['shipping'] : ''; // $receiver_email = (isset($_POST['receiver_email'])) ? $_POST['txn_id'] : ''; $business = isset($_POST['business']) ? $_POST['business'] : ''; $payer_email = isset($_POST['payer_email']) ? $_POST['payer_email'] : ''; $first_name = isset($_POST['first_name']) ? $_POST['first_name'] : ''; $last_name = isset($_POST['last_name']) ? $_POST['last_name'] : ''; $address_name = isset($_POST['address_name']) ? $_POST['address_name'] : ''; $address_street = isset($_POST['address_street']) ? $_POST['address_street'] : ''; $address_city = isset($_POST['address_city']) ? $_POST['address_city'] : ''; $address_state = isset($_POST['address_state']) ? $_POST['address_state'] : ''; $address_zip = isset($_POST['address_zip']) ? $_POST['address_zip'] : ''; $address_country = isset($_POST['address_country']) ? $_POST['address_country'] : ''; $memo = isset($_POST['memo']) ? $_POST['memo'] : ''; $email_message = ''; $comiceasel_config = get_option('comiceasel-config'); delete_option('ceo_paypal_receiver'); if (!$fp) { $email_message .= "HTTP Error - Host could not connect to paypal.\r\n"; } else { fputs($fp, $header . $req); $res = ''; while (!feof($fp)) { $res .= fgets($fp, 1024); } if ($payment_status == 'Completed') { $comiceasel_options = get_option('comiceasel_options'); $count = 1; foreach ($item_number as $item_sub_number) { $post_id = (int) $item_number[$count]; if (strstr(strtolower($item_name[$count]), 'original')) { $post_id = (int) $item_number[$count]; update_post_meta($post_id, 'buyorig-status', __('Sold', 'comiceasel')); $email_message .= 'Comic ID #' . $post_id . " Set to SOLD\r\n\r\n"; // Flush the cache on the item in question. if (defined('WP_CACHE') && WP_CACHE == true) { wp_cache_no_postid($post_id); } } $count++; } } elseif (strcmp($res, "INVALID") == 0) { $email_message .= "Invalid Transaction\r\n"; } $email_message .= __('Transaction URL', 'comiceasel') . ': ' . home_url() . "\r\n"; $email_message .= __('Number Items', 'comiceasel') . ': ' . $num_cart_items . "\r\n"; $count = 1; foreach ($item_name as $item_sub_name) { $email_message .= __('Item Name', 'comiceasel') . ' [' . $count . ']: ' . $item_sub_name . "\r\n"; $email_message .= __('Item Number', 'comiceasel') . ' [' . $count . ']: ' . $item_number[$count] . "\r\n"; $count++; } $email_message .= __('Payment Status', 'comiceasel') . ': ' . $payment_status . "\r\n"; $email_message .= __('Payment Amount', 'comiceasel') . ': ' . $payment_amount . "\r\n"; $email_message .= __('Shipping', 'comiceasel') . ': ' . $shipping . "\r\n"; $email_message .= __('Payment Currency', 'comiceasel') . ': ' . $payment_currency . "\r\n"; $email_message .= __('TXN_ID', 'comiceasel') . ': ' . $txn_id . "\r\n"; $email_message .= __('Paypal Receiver', 'comiceasel') . ': ' . $business . "\r\n\r\n"; $email_message .= __('Payer Name', 'comiceasel') . ': ' . $first_name . ' ' . $last_name . "\r\n"; $email_message .= __('Payer Email', 'comiceasel') . ': ' . $payer_email . "\r\n\r\n"; $email_message .= __('to Name', 'comiceasel') . ': ' . $address_name . "\r\n"; $email_message .= __('Street', 'comiceasel') . ': ' . $address_street . "\r\n"; $email_message .= __('City', 'comiceasel') . ': ' . $address_city . "\r\n"; $email_message .= __('State', 'comiceasel') . ': ' . $address_state . "\r\n"; $email_message .= __('Zip', 'comiceasel') . ': ' . $address_zip . "\r\n"; $email_message .= __('Country', 'comiceasel') . ': ' . $address_country . "\r\n\r\n"; if (!empty($memo)) { $email_message .= __('Memo', 'comiceasel') . ': ' . $memo . "\r\n"; } /* foreach ($_POST as $post_info) { $email_message .= $post_info; } */ update_option('ceo_paypal_receiver', $email_message); if (isset($comiceasel_config['buy_comic_email'])) { wp_mail($comiceasel_config['buy_comic_email'], __('Comic Easel: Notification of Transaction - Buy Comic', 'comiceasel'), $email_message); } } fclose($fp); exit; }