Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Google Docs Guestlist
- Version: 2.0
- */
- /* Zend Gdata classes */
- $path = dirname(__FILE__);
- set_include_path(get_include_path() . PATH_SEPARATOR . $path);
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass('Zend_Http_Client');
- Zend_Loader::loadClass('Zend_Gdata');
- Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
- Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
- function admin_wpgc_guestlist_options(){
- ?><div class="wrap"><h2>GoogleDocs Guestlist</h2><?php
- if ($_REQUEST['submit']){
- update_wpgc_guestlist_options();
- }
- print_wpgc_guestlist_form();
- ?></div><?php
- }
- function update_wpgc_guestlist_options() {
- $ok = false;
- if($_REQUEST['wpgc_guestlist_google_username']) {
- update_option('wpgc_guestlist_google_username',$_REQUEST['wpgc_guestlist_google_username']);
- $ok = true;
- }
- if($_REQUEST['wpgc_guestlist_google_password']) {
- update_option('wpgc_guestlist_google_password',$_REQUEST['wpgc_guestlist_google_password']);
- $ok = true;
- }
- if($_REQUEST['wpgc_guestlist_google_spreadsheet_name']) {
- update_option('wpgc_guestlist_google_spreadsheet_name',$_REQUEST['wpgc_guestlist_google_spreadsheet_name']);
- $ok = true;
- }
- if($_REQUEST['wpgc_guestlist_google_worksheet_name']) {
- update_option('wpgc_guestlist_google_worksheet_name',$_REQUEST['wpgc_guestlist_google_worksheet_name']);
- $ok = true;
- }
- if($_REQUEST['wpgc_guestlist_wedding_planner_email_address']) {
- update_option('wpgc_guestlist_wedding_planner_email_address',$_REQUEST['wpgc_guestlist_wedding_planner_email_address']);
- $ok = true;
- }
- if($_REQUEST['wpgc_guestlist_wedding_planner']) {
- update_option('wpgc_guestlist_wedding_planner',$_REQUEST['wpgc_guestlist_wedding_planner']);
- $ok = true;
- }
- if($ok) {
- ?><div id="message" class="updated fade">
- <p>Options saved.</p>
- </div><?php
- }
- else {
- ?><div id="message" class="error fade">
- <p>Failed to save options.</p>
- </div><?php
- }
- }
- function print_wpgc_guestlist_form() {
- $default_username = get_option('wpgc_guestlist_google_username');
- $default_password = get_option('wpgc_guestlist_google_password');
- $default_spreadsheet = get_option('wpgc_guestlist_google_spreadsheet_name');
- $default_worksheet = get_option('wpgc_guestlist_google_worksheet_name');
- $default_email_address = get_option('wpgc_guestlist_wedding_planner_email_address');
- $default_wedding_planner = get_option('wpgc_guestlist_wedding_planner');
- ?>
- <form method="post">
- <label for="wpgc_guestlist_google_username">Google Username:
- <input type="text" name="wpgc_guestlist_google_username" value="<?=$default_username?>" />
- </label><i>Your Google account username with access to wedding spreadsheet</i>
- <br />
- <br />
- <label for="wpgc_guestlist_google_password">Google Password:
- <input type="password" name="wpgc_guestlist_google_password" value="<?=$default_password?>" />
- </label><i>Your Google password</i>
- <br />
- <br />
- <label for="wpgc_guestlist_google_spreadsheet_name">Google Spreadsheet Name:
- <input type="text" name="wpgc_guestlist_google_spreadsheet_name" value="<?=$default_spreadsheet?>" />
- </label><i>The name of your spreadsheet</i>
- <br />
- <br />
- <label for="wpgc_guestlist_google_worksheet_name">Google Worksheet Name:
- <input type="text" name="wpgc_guestlist_google_worksheet_name" value="<?=$default_worksheet?>" />
- </label><i>The name of your worksheet(e.g. Sheet1)</i>
- <br />
- <br />
- <label for="wpgc_guestlist_wedding_planner_email_address">Wedding Planner Email Address:
- <input type="text" name="wpgc_guestlist_wedding_planner_email_address" value="<?=$default_email_address?>" />
- </label><i>This account will be emailed every time there is a new RSVP</i>
- <br />
- <br />
- <label for="wpgc_guestlist_wedding_planner">Wedding Planner Name:
- <input type="text" name="wpgc_guestlist_wedding_planner" value="<?=$default_wedding_planner?>" />
- </label><i>Name of person to contact directly for questions, confirmations, or problems... (e.g. Bernard and Alice)</i>
- <br />
- <br />
- <br />
- <input type="submit" name="submit" value="Submit" />
- </form>
- <?php
- }
- function modify_menu() {
- add_options_page(
- 'GoogleDocs Guestlist', //page title
- 'GoogleDocs Guestlist', //subpage title
- 'manage_options', //access
- '__FILE__', //current file
- 'admin_wpgc_guestlist_options' //options function above
- );
- }
- /*
- Function: wpgc_clean
- Meant to clean up user input.... watching out for google docs injection attacks???? shrug
- */
- function wpgc_clean( $value , $strip = true) {
- return $value;
- //if ($strip) return strip_tags($value);
- //else return $value;
- }
- /*
- Function: wpgc_connect
- Helper function to connect to the Google docs spreadsheet.
- returns the google docs client object.
- */
- function wpgc_connect_get_client($user, $pass) {
- // Connect to your account
- $authService = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
- $httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $authService);
- $gdClient = new Zend_Gdata_Spreadsheets($httpClient);
- return $gdClient;
- }
- /*
- Function: wpgc_get_listFeed_for_guestcode
- This is a helper function. It connects to the Google docs spreadsheet, finds the right worksheet, and finds only the rows that have $guest_code as its guest code.
- TODO: Order the entries by some order
- */
- function wpgc_get_listFeed_for_guestcode($gdClient, $spreadsheet_name,$worksheet_name, $guest_code) {
- // Some variables
- $spreadsheet_key = '';
- $worksheet_key = '';
- // Find your spreadsheet id
- $feed = $gdClient->getSpreadsheetFeed('http://spreadsheets.google.com/feeds/spreadsheets/private/full');
- foreach($feed->entries as $entry) {
- if ($entry->title->text == $spreadsheet_name) {
- $id = split('/', $entry->id->text);
- $spreadsheet_key = $id[7];
- }
- }
- // Connect to your spreadsheet
- $query = new Zend_Gdata_Spreadsheets_DocumentQuery();
- $query->setSpreadsheetKey($spreadsheet_key);
- $feed = $gdClient->getWorksheetFeed($query);//LINE AT FAULT
- // Find your worksheet id that matches your title (hopefully a unique one)
- $i = 0;
- foreach($feed->entries as $entry) {
- if (
- (empty($worksheet_name) && $i == 00) ||
- (!empty($worksheet_name) && strcmp($entry->title->text,$worksheet_name)==0 )
- ) {
- $id = split('/', $entry->id->text);
- $worksheet_key = $id[8];
- }
- $i++;
- }
- // Run Query
- $query = new Zend_Gdata_Spreadsheets_ListQuery();
- $query->setSpreadsheetKey($spreadsheet_key);
- $query->setWorksheetId($worksheet_key);
- $query->setSpreadsheetQuery('code="'.$guest_code.'"'); // TODO: INJECTION threats?
- return $gdClient->getListFeed($query);
- }
- /*
- Name: wpgc_parse_entry
- Extract the values we care about from a listfeedentry
- */
- function wpgc_parse_entry($listFeedEntry) {
- $onerow_data = $listFeedEntry->getCustom();
- foreach($onerow_data as $column) {
- switch ($column->getColumnName()) {
- case ("title"):
- $entry["title"] = $column->getText();
- break;
- case ("firstname"):
- $entry["firstname"] = $column->getText();
- break;
- case ("surname"):
- $entry["surname"] = $column->getText();
- break;
- case ("address1"):
- $entry["address1"] = $column->getText();
- break;
- case ("address2"):
- $entry["address2"] = $column->getText();
- break;
- case ("address3"):
- $entry["address3"] = $column->getText();
- break;
- case ("city"):
- $entry["city"] = $column->getText();
- break;
- case ("county"):
- $entry["county"] = $column->getText();
- break;
- case ("postcode"):
- $entry["postcode"] = $column->getText();
- break;
- case ("country"):
- $entry["country"] = $column->getText();
- break;
- case ("email"):
- $entry["email"] = $column->getText();
- break;
- case ("telephone1"):
- $entry["telephone1"] = $column->getText();
- break;
- case ("telephone2"):
- $entry["telephone2"] = $column->getText();
- break;
- case ("language"):
- $entry["language"] = $column->getText();
- break;
- case ("invitedbr"):
- $entry["invitedbr"] = $column->getText();
- break;
- case ("attendingbr"):
- $entry["attendingbr"] = $column->getText();
- break;
- case ("inviteduk"):
- $entry["inviteduk"] = $column->getText();
- break;
- case ("attendinguk"):
- $entry["attendinguk"] = $column->getText();
- break;
- case ("messageforguest"):
- $entry["messageforguest"] = $column->getText();
- break;
- case ("messagefromguest"):
- $entry["messagefromguest"] = $column->getText();
- break;
- case ("dietaryrequirements"):
- $entry["dietaryrequirements"] = $column->getText();
- break;
- case ("kidsmeal"):
- $entry["kidsmeal"] = $column->getText();
- break;
- }
- }
- return $entry;
- }
- function wpgc_my_googledocsguestlist ($text) {
- //QUIT if the replacement string doesn't exist
- if (!strstr($text,'wpgc-googledocsguestlist')) return $text;
- // Key variables
- $user = get_option('wpgc_guestlist_google_username');
- $pass = get_option('wpgc_guestlist_google_password');
- $spreadsheet_name = get_option('wpgc_guestlist_google_spreadsheet_name');
- $worksheet_name = get_option('wpgc_guestlist_google_worksheet_name');
- $wedding_planner_email_address = get_option('wpgc_guestlist_wedding_planner_email_address');
- $wedding_planner = get_option('wpgc_guestlist_wedding_planner');
- //Configuration check
- if (!$user || !$pass || !$spreadsheet_name || !$worksheet_name || !$wedding_planner_email_address) {
- return "This plugin has not been fully configured. Please fill out all the entries under Settings->GoogleDocs Guestlist.";
- }
- $spreadsheet_key = '';
- $worksheet_key = '';
- $guest_code = $_POST['code'];
- $outputtext = '';
- $abort_and_reprint_form = false;
- // Login
- // if you have a code and NO answers, pass
- // if you have a code, but already answered, no pass
- // if you have bad code, no pass
- if (isset($_POST['motion'])) {
- switch ($_POST['motion']) {
- case ('update'):
- // (A) Save to the database
- try {
- // Connect and retrieve the listFeed for your guestcode
- $gdClient = wpgc_connect_get_client($user, $pass);
- $listFeed = wpgc_get_listFeed_for_guestcode($gdClient, $spreadsheet_name, $worksheet_name, $guest_code);
- // CHECK, did they already fill out the form?
- foreach ($listFeed->entries as $e) {
- $entry = wpgc_parse_entry($e);
- if ($entry['attendingbr'] || $entry['attendinguk']) {
- $abort_and_reprint_form = true;
- break;
- }
- }
- if ($abort_and_reprint_form) break;
- $messagefromguest = '';
- if (isset($_POST['messagefromguest'])) {
- $messagefromguest = wpgc_clean($_POST['messagefromguest']);
- }
- $attendingbr_attendees = array();
- $attendinguk_attendees = array();
- $your_message = '';
- if ($listFeed->count() == 0) {
- $abort_and_reprint_form = true;
- break;
- }
- // Construct
- for ($i=0; $i < $listFeed->count(); $i+=1) {
- // Grab the data from the http post and construct the array
- $newentry = array();
- if (isset($_POST['title'.$i])) {
- $newentry["title"] = stripslashes($_POST['title'.$i]);
- }
- if (isset($_POST['firstname'.$i])) {
- $newentry["firstname"] = stripslashes($_POST['firstname'.$i]);
- }
- if (isset($_POST['surname'.$i])) {
- $newentry["surname"] = stripslashes($_POST['surname'.$i]);
- }
- if (isset($_POST['address1'.$i])) {
- $newentry["address1"] = stripslashes($_POST['address1'.$i]);
- }
- if (isset($_POST['address2'.$i])) {
- $newentry["address2"] = stripslashes($_POST['address2'.$i]);
- }
- if (isset($_POST['address3'.$i])) {
- $newentry["address3"] = stripslashes($_POST['address3'.$i]);
- }
- if (isset($_POST['city'.$i])) {
- $newentry["cit"] = stripslashes($_POST['city'.$i]);
- }
- if (isset($_POST['county'.$i])) {
- $newentry["county"] = stripslashes($_POST['county'.$i]);
- }
- if (isset($_POST['country'.$i])) {
- $newentry["country"] = stripslashes($_POST['country'.$i]);
- }
- if (isset($_POST['postcode'.$i])) {
- $newentry["postcode"] = stripslashes($_POST['postcode'.$i]);
- }
- if (isset($_POST['email'.$i])) {
- $newentry["email"] = stripslashes($_POST['email'.$i]);
- }
- if (isset($_POST['telephone1'.$i])) {
- $newentry["telephone1"] = stripslashes($_POST['telephone1'.$i]);
- }
- if (isset($_POST['telephone2'.$i])) {
- $newentry["telephone2"] = stripslashes($_POST['telephone2'.$i]);
- }
- if (isset($_POST['language'.$i])) {
- $newentry["language"] = stripslashes($_POST['language'.$i]);
- }
- if (isset($_POST['invitedbr'.$i])) {
- $newentry["invitedbr"] = stripslashes($_POST['invitedbr'.$i]);
- }
- if (isset($_POST['attendingbr'.$i])) {
- $newentry["attendingbr"] = stripslashes($_POST['attendingbr'.$i]);
- }
- if (isset($_POST['inviteduk'.$i])) {
- $newentry["inviteduk"] = stripslashes($_POST['inviteduk'.$i]);
- }
- if (isset($_POST['attendinguk'.$i])) {
- $newentry["attendinguk"] = stripslashes($_POST['attendinguk'.$i]);
- }
- if (isset($_POST['messageforguest'.$i])) {
- $newentry["messageforguest"] = stripslashes($_POST['messageforguest'.$i]);
- }
- if (isset($_POST['messagefromguest'.$i])) {
- $newentry["messagefromguest"] = stripslashes($_POST['messagefromguest'.$i]);
- }
- if (isset($_POST['dietryrequirements'.$i])) {
- $newentry["dietryrequirements"] = stripslashes($_POST['dietryrequirements'.$i]);
- }
- if (isset($_POST['kidsmeal'.$i])) {
- $newentry["kidsmeal"] = stripslashes($_POST['kidsmeal'.$i]);
- }
- // for the comments from the quest, we'll only plug it into the first entry
- if ($i == 0) {
- $newentry["messagefromguest"] = stripslashes($messagefromguest);
- }
- // guest_code
- $newentry["code"] = $guest_code;
- // GO! Update the spreadsheet!
- // What if it fails? I suppose an exception gets thrown...
- $entry = $gdClient->updateRow($listFeed->entries[$i], $newentry);
- /*if !($entry instanceof Zend_Gdata_Spreadsheets_ListEntry) {
- //echo "Fail"
- throw new Something Exception
- }
- */
- $checked_entry = wpgc_parse_entry($entry);
- if ($i == 0) {
- $your_message = $checked_entry["messagefromguest"];
- }
- if (strcmp($checked_entry["attendingbr"],"Attending")==0) {
- $attendingbr_attendees[] = $checked_entry["firstname"] . " " . $checked_entry["surname"];
- }
- if (strcmp($checked_entry["attendinguk"],"Attending")==0) {
- $attendinguk_attendees[] = $checked_entry["firstname"] . " " . $checked_entry["surname"];
- }
- }
- // (B) Give user confirmation
- $emailreport = "NEW RSVP! \n";
- $outputtext .= '<b>Thank you for your response!</b><br/>';
- $outputtext .= "<br/>\n";
- $plural = '';
- if (sizeof($attendingbr_attendees) != 1) $plural = "s";
- $outputtext .= '<b>'.sizeof($attendingbr_attendees).'</b> guest'.$plural.' will be attending the BR Wedding';
- $emailreport .= sizeof($attendingbr_attendees).' guest'.$plural.' will be attending the BR Wedding';
- if (sizeof($attendingbr_attendees)) {
- $outputtext .= ":<br/>";
- $emailreport .= ":\n";
- } else {
- $outputtext .=".<br/>";
- $emailreport .=".\n";
- }
- for ($i=0; $i<sizeof($attendingbr_attendees); $i+=1) {
- if (empty($attendingbr_attendees[$i])) $attendingbr_attendees[$i] = "Guest";
- $outputtext .= htmlspecialchars($attendingbr_attendees[$i],ENT_QUOTES);
- $emailreport .= htmlspecialchars($attendingbr_attendees[$i],ENT_QUOTES);
- if ($i != sizeof($attendingbr_attendees)-1) {
- $outputtext .= ", ";
- $emailreport .= ", ";
- }
- }
- if (sizeof($attendingbr_attendees)) {
- $outputtext .= "<br/>\n";
- $emailreport .= "\n";
- }
- $outputtext .= "<br/>\n";
- $emailreport .= "\n";
- $plural = '';
- if (sizeof($attendinguk_attendees) != 1) $plural = "s";
- $outputtext .= '<b>'.sizeof($attendinguk_attendees).'</b> guest'.$plural.' will be attending the UK Wedding';
- $emailreport .= sizeof($attendinguk_attendees).' guest'.$plural.' will be attending the UK Wedding';
- if (sizeof($attendinguk_attendees)) {
- $outputtext .= ":<br/>";
- $emailreport .= ":\n";
- } else {
- $outputtext .=".<br/>";
- $emailreport .=".\n";
- }
- for ($i=0; $i<sizeof($attendinguk_attendees); $i+=1) {
- if (empty($attendinguk_attendees[$i])) $attendinguk_attendees[$i] = "Guest";
- $outputtext .= htmlspecialchars($attendinguk_attendees[$i],ENT_QUOTES);
- $emailreport .= htmlspecialchars($attendinguk_attendees[$i],ENT_QUOTES);
- if ($i != sizeof($attendinguk_attendees)-1) {
- $outputtext .= ", ";
- $emailreport .= ", ";
- }
- }
- if (sizeof($attendinguk_attendees)) {
- $outputtext .= "<br/>\n";
- $emailreport .="\n";
- }
- $outputtext .= "<br/>\n";
- $emailreport .= "\n";
- if (!empty($your_message)) {
- $outputtext .= "Your message will be delivered:<br/><blockquote>";
- $outputtext .= htmlspecialchars(stripslashes($your_message),ENT_QUOTES);
- $outputtext .= "</blockquote><br/>";
- $emailreport .= "They also wrote a message for you:\n";
- $emailreport .= stripslashes($your_message);
- $emailreport .= "\n";
- }
- $outputtext .= "<i>Thank you! Your response has been saved and your invitation code has been used. If you need to change your reply or have any questions, please contact " . $wedding_planner . " at <a href='". $wedding_planner_email_address ."'>". $wedding_planner_email_address ."</a>.</i>";
- $subject = "Wedding RSVP";
- $headers = 'From: '.$wedding_planner_email_address;
- mail($wedding_planner_email_address, $subject, $emailreport, $headers);
- } catch (Zend_Gdata_App_Exception $e) {
- $outputtext .= "<b>Oops, there was a small glitch.</b> Please try again, or contact ". $wedding_planner ." directly.";
- //$outputtext .= $e->getMessage() . " " . $e->getTraceAsString();
- }
- break;
- case('edit'):
- try {
- // Connect and retrieve the listFeed for your guestcode
- $gdClient = wpgc_connect_get_client($user, $pass);
- $listFeed = wpgc_get_listFeed_for_guestcode($gdClient, $spreadsheet_name, $worksheet_name, $guest_code);
- $listFeed = wpgc_get_listFeed_for_guestcode($gdClient, $spreadsheet_name, $worksheet_name, $guest_code);
- $already_replied = false;
- // CHECK, did they already fill out the form?
- foreach ($listFeed->entries as $e) {
- $entry = wpgc_parse_entry($e);
- if ($entry['attendingbr'] || $entry['attendinguk']) {
- $already_replied = true;
- break;
- }
- }
- // Careful... entries might be an empty set
- if ($listFeed->count() > 0 && !$already_replied) {
- // SUCCESS: We found a party
- $plural = '';
- if ($listFeed->count() != 1) $plural = "s";
- $outputtext .= "Thank you for replying online. We look forward to celebrating with you all! Please indicate whether each member of your party will be attending our wedding day events.<br/><br/><b>We have reserved ".$listFeed->count()." seat".$plural." in your honor.</b><br/>";
- // Initializing the form. And yes, it is one massive form for the whole page. We differentiate among the attendees by adding an index number after each input 'name', e.g. guestname3
- $outputtext .= '<form style="text-align: left" action="'.get_permalink().'" method="post">';
- // We use a for loop here because the index i is important to keep as a row identifier when we update the row information later.
- for ($i = 0; $i < $listFeed->count(); $i +=1) {
- $entry = wpgc_parse_entry($listFeed->entries[$i]);
- // Populating the sub-parts of the form for each guest
- $outputtext .= '<b>'.($i+1).'. Title:</b> <input name="Title'.$i.'" type="text" value="'. htmlspecialchars($entry["title"],ENT_QUOTES).'"/>';
- $outputtext .= "<br/>";
- $outputtext .= '<b>'.($i+1).'. First Name:</b> <input name="FirstName'.$i.'" type="text" value="'. htmlspecialchars($entry["firstname"],ENT_QUOTES).'"/>';
- $outputtext .= "<br/>";
- $outputtext .= '<b>'.($i+1).'. Surname:</b> <input name="Surname'.$i.'" type="text" value="'. htmlspecialchars($entry["surname"],ENT_QUOTES).'"/>';
- $outputtext .= "<br/>";
- $outputtext .= '<i>Attending BR:</i> <input name="attendingbr'.$i.'" type="radio" value="Attending" ';
- if (strcmp($entry["attendingbr"],"Attending")==0)
- $outputtext .= "checked='checked' ";
- $outputtext .= "/>Attending ";
- $outputtext .= '<input name="attendingbr'.$i.'" type="radio" value="Not Attending" ';
- if (strcmp($entry["attendingbr"],"Not Attending")==0)
- $outputtext .= 'checked="checked" ';
- $outputtext .= "/>Not Attending";
- $outputtext .= "<br/>";
- $outputtext .= '<i>Attending UK:</i> <input name="attendinguk'.$i.'" type="radio" value="Attending" ';
- if (strcmp($entry["attendinguk"],"Attending")==0)
- $outputtext .= "checked='checked' ";
- $outputtext .= "/>Attending ";
- $outputtext .= '<input name="attendinguk'.$i.'" type="radio" value="Not Attending" ';
- if (strcmp($entry["attendinguk"],"Not Attending")==0)
- $outputtext .= "checked='checked' ";
- $outputtext .= "/>Not Attending";
- $outputtext .= "<br/>\n";
- // Message for guest
- if (!empty($entry["messageforguest"])) {
- $outputtext .= '<blockquote>'.htmlspecialchars($entry["messageforguest"],ENT_QUOTES).'</blockquote>';
- }
- $outputtext .= '<input type="hidden" name="messageforguest'.$i.'" value="'.htmlspecialchars($entry["messageforguest"]).'"/>';
- $outputtext .= "<br/>\n";
- $outputtext .= "<br/>\n";
- }
- // Message from the Guests
- $outputtext .= "<b>Let us know how you're doing. Leave us a note!</b><br/>\n";
- $outputtext .= "<textarea name='messagefromguest'></textarea>"; // Note that old comments are not retrieved. We assume that you will only submit an RSVP once.
- $outputtext .= "<br/>\n";
- // Closing the form
- $outputtext .= "\n";
- $outputtext .= "<input type='hidden' name='motion' value='update'/>";
- $outputtext .= "<input type='hidden' name='code' value='". htmlspecialchars($guest_code,ENT_QUOTES)."'/>";
- $outputtext .= "<br/>\n";
- $outputtext .= "<button type='Submit'>Send my RSVP</button>";
- $outputtext .= " <a href='".get_permalink()."'>Cancel, I will reply later.</a>";
- $outputtext .= "</form>";
- } else {
- $outputtext .= "<b>No match.</b> Please try again. <i>If you have already RSVP'd, your code will no longer work. If you would like to change your response, or if you were not able to respond in the first place, please contact " . $wedding_planner . " at <a href='". $wedding_planner_email_address ."'>". $wedding_planner_email_address ."</a>.</i><br />";
- $outputtext .= "<br/>\n";
- $outputtext .= 'Please type in the code from your wedding invitation below:<br/>';
- $outputtext .= '<form style="text-align: left" action="'.get_permalink().'" method="post">';
- $outputtext .= '<input type="hidden" name="motion" value="edit"/>';
- $outputtext .= '<input type="text" name="code" /> ';
- $outputtext .= '<button type="Submit">Submit</button>';
- $outputtext .= '</form>';
- }
- } catch (Zend_Gdata_App_Exception $e) {
- $outputtext .= "Oops. You found an error. Please try again or contact " . $wedding_planner . " at <a href='". $wedding_planner_email_address ."'>". $wedding_planner_email_address ."</a> to confirm your response.";
- //$outputtext .= "[There was a error. Please consult the source code or an experienced programmer. :( ]";
- //$outputtext .= $e->getMessage() . " " . $e->getTraceAsString(); //PL DEBUG
- //detailed debug output below
- /* $rtn = "";
- $count = 0;
- foreach ($e->getTrace() as $frame) {
- $args = "";
- if (isset($frame['args'])) {
- $args = array();
- foreach ($frame['args'] as $arg) {
- if (is_string($arg)) {
- $args[] = "'" . $arg . "'";
- } elseif (is_array($arg)) {
- $args[] = "Array";
- } elseif (is_null($arg)) {
- $args[] = 'NULL';
- } elseif (is_bool($arg)) {
- $args[] = ($arg) ? "true" : "false";
- } elseif (is_object($arg)) {
- $args[] = get_class($arg);
- } elseif (is_resource($arg)) {
- $args[] = get_resource_type($arg);
- } else {
- $args[] = $arg;
- }
- }
- $args = join(", ", $args);
- }
- $rtn .= sprintf( "#%s %s(%s): %s(%s)\n",
- $count,
- $frame['file'],
- $frame['line'],
- $frame['function'],
- $args );
- $count++;
- }
- return $rtn;
- echo $rtn;*/
- }
- break;
- } //endswitch on post motion
- } //endif (isset)
- else {
- $outputtext .= "Please type in the code from your wedding invitation below:<br/>";
- $outputtext .= "<form style='text-align: left' action='".get_permalink()."' method='post'>";
- $outputtext .= "<input type='hidden' name='motion' value='edit'/>";
- $outputtext .= "<input type='text' name='code' value=\"1\" /> ";
- $outputtext .= "<button type='Submit'>Submit</button>";
- $outputtext .= "</form>";
- }
- // this is covers cases where someone re-posted an update ... it defends against attacks where someone is spamming the update and trying to overwrite entries
- // TODO This currently covers the case where someone has naively click back and resubmitted a form
- // TODO I haven't checked whether an attacker can use the feedback to determine which codes are valid.
- if ($abort_and_reprint_form) {
- $outputtext .= "<b>Sorry, our records were not changed.</b>";
- $outputtext .= "Please type in the code from your wedding invitation below:<br/>";
- $outputtext .= "<form style='text-align: left' action='".get_permalink()."' method='post'>";
- $outputtext .= "<input type='hidden' name='motion' value='edit'/>";
- $outputtext .= "<input type='text' name='code'/> ";
- $outputtext .= "<button type='Submit'>Submit</button>";
- $outputtext .= "</form>";
- }
- $text = str_replace('wpgc-googledocsguestlist', $outputtext, $text);
- return $text;
- }
- add_action('admin_menu', 'modify_menu');
- add_filter('the_content', 'wpgc_my_googledocsguestlist');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment