public static function display_ticket($code) { // parse the args from the ticket code $args = apply_filters('qsot-decode-ticket-code', array(), $code); // make sure we have the basic required data for loading the ticket if (!is_array($args) || !isset($args['order_id'], $args['order_item_id']) || empty($args['order_id']) || empty($args['order_item_id'])) { return false; } // make sure that the current user can view this ticket if (!self::_can_user_view_ticket($args)) { return false; } // load all the data needed to render the ticket $ticket = apply_filters('qsot-compile-ticket-info', false, $args['order_item_id'], $args['order_id']); // if ticket was not loaded, then fail if (!is_object($ticket)) { self::_no_access(__('There was a problem loading your ticket.', 'opentickets-community-edition')); exit; } // if the resulting ticket we a wp_error, print the message from the error, to be more specific about the problem if (is_wp_error($ticket)) { $message = __('There was a problem loading your ticket.', 'opentickets-community-edition') . '<br/><em>' . implode('</br>', $ticket->get_error_messages()) . '</em>'; self::_no_access($message); exit; } $errors = array(); // find out if any of the needed data is missing, or if any of it is in a format that is un expected, and generate a list of errors to report if (!isset($ticket->order, $ticket->order->id)) { $errors[] = __('the order', 'opentickets-community-edition'); } if (!isset($ticket->product, $ticket->product->id)) { $errors[] = __('the ticket product information', 'opentickets-community-edition'); } if (!isset($ticket->event, $ticket->event->ID)) { $errors[] = __('the event information', 'opentickets-community-edition'); } if (!isset($ticket->venue, $ticket->venue->ID)) { $errors[] = __('the venue information', 'opentickets-community-edition'); } if (!isset($ticket->order_item) || !is_array($ticket->order_item)) { $errors[] = __('the order item information', 'opentickets-community-edition'); } if (!isset($ticket->event_area, $ticket->event_area->ID)) { $errors[] = __('the event area information', 'opentickets-community-edition'); } // if there area any errors from above to report, then display an error message showing those problems if (!empty($errors)) { self::_no_access(sprintf(__('The following ticket data could not be loaded: %s', 'opentickets-community-edition'), '<br/>' . implode(',<br/>', $errors))); exit; } // do not display the ticket unless the order is complete if ('completed' != $ticket->order->get_status()) { self::_no_access(__('The ticket cannot be displayed, because the order is not complete.', 'opentickets-community-edition')); exit; } // determine the file location for the template and it's stylesheet $template = apply_filters('qsot-locate-template', '', array('tickets/basic-ticket.php'), false, false); $stylesheet = apply_filters('qsot-locate-template', '', array('tickets/basic-style.css'), false, false); // account for messed up Windows paths $stylesheet = str_replace(DIRECTORY_SEPARATOR, '/', $stylesheet); $abspath = str_replace(DIRECTORY_SEPARATOR, '/', ABSPATH); $stylesheet = str_replace($abspath, '/', $stylesheet); $stylesheet = site_url($stylesheet); // load the branding image ids from our settings page $branding_image_ids = self::$options->{'qsot-ticket-branding-img-ids'}; $branding_image_ids = is_scalar($branding_image_ids) ? explode(',', $branding_image_ids) : $branding_image_ids; // get the html for the ticket itself $out = self::_get_ticket_html(array('ticket' => $ticket, 'template' => $template, 'stylesheet' => $stylesheet, 'branding_image_ids' => $branding_image_ids)); $_GET = wp_parse_args($_GET, array('frmt' => 'html')); // do something different depending on the requested format switch ($_GET['frmt']) { case 'pdf': $title = $ticket->product->get_title() . ' (' . $ticket->product->get_price() . ')'; QSOT_pdf::from_html($out, $title); break; default: echo $out; break; } exit; }
fwrite($config_file, $contents, strlen($contents)); fclose($config_file); // remove any files that are marked to be removed, now that we have successfully written them to the new location, and pointed DOMPDF at them /* skip this for now */ /* if ( is_array( $remove_files ) && count( $remove_files ) ) foreach ( $remove_files as $remove_file ) if ( is_writable( $remove_file ) && ! is_dir( $remove_file ) && ! is_link( $remove_file ) ) @unlink( $remove_file ); */ } } } } if (defined('ABSPATH') && function_exists('add_action')) { QSOT_pdf::pre_init(); } } if (!class_exists('QSOT_cache_helper')) { class QSOT_cache_helper { // cached asset map, original_url => local_file_path protected static $cache_map = array(); // cache path protected static $cache_path = false; // is this a force recache? protected static $force_recache = null; // figure out the local path of the asset, based on the found url public static function find_local_path($url) { static $local = false, $local_url = false, $whats_old_in_seconds = false;