public static function front_main($data) { $data->name = __CLASS__; ?> <div id="module-<?php echo $data->ID; ?> " class="<?php echo $data->name; ?> front-single-module<?php echo file_module::FRONT_SAVE == true ? '-save' : ''; ?> "> <?php if ($data->post_title != '' && parent::display_title_on_front($data)) { ?> <h2 class="module_title"><?php echo $data->post_title; ?> </h2> <?php } ?> <?php if ($data->file_url != '') { global $coursepress; require_once $coursepress->plugin_dir . 'includes/classes/class.encryption.php'; $encryption = new CP_Encryption(); $file_size = cp_get_file_size($data->file_url); if ($file_size > 0) { $filesize = '<small>(' . esc_html($file_size) . ')</small>'; } else { $filesize = ''; } $data->file_url = $encryption->encode($data->file_url); $url = trailingslashit(home_url()) . '?fdcpf=' . $data->file_url; ?> <div class="file_holder"> <a href="<?php echo esc_url($url); ?> "/><?php echo isset($data->link_text) ? $data->link_text : $data->post_title; ?> <?php echo $filesize; ?> </a> </div> <?php } ?> </div> <?php }
public static function get_response_form($user_ID, $response_request_ID, $show_label = true) { global $coursepress; $response = file_input_module::get_response($user_ID, $response_request_ID); if (count((array) $response >= 1)) { require_once $coursepress->plugin_dir . 'includes/classes/class.encryption.php'; $encryption = new CP_Encryption(); $file_extension = strtoupper(pathinfo($response->guid, PATHINFO_EXTENSION)); $response->guid = $encryption->encode($response->guid); ?> <div class="module_file_response_answer"> <?php if ($show_label) { ?> <label><?php _e('Uploaded File', 'cp'); ?> </label> <?php } ?> <div class="front_response_content"> <a href="<?php echo trailingslashit(home_url()) . '?fdcpf=' . $response->guid; ?> "><?php _e('Download file ', 'cp'); echo ' ( ' . $file_extension . ' )'; ?> </a> </div> </div> <?php } else { _e('File not uploaded yet.', 'cp'); } ?> <div class="full regular-border-divider"></div> <?php }
function check_for_force_download_file_request() { if (isset($_GET['fdcpf'])) { ob_start(); require_once $this->plugin_dir . 'includes/classes/class.encryption.php'; $encryption = new CP_Encryption(); $requested_file = $encryption->decode($_GET['fdcpf']); $requested_file_obj = wp_check_filetype($requested_file); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check = 0, pre-check = 0'); header('Cache-Control: private', false); header('Content-Type: ' . $requested_file_obj["type"]); header('Content-Disposition: attachment; filename ="' . basename($requested_file) . '"'); header('Content-Transfer-Encoding: binary'); header('Connection: close'); /** * Filter used to alter header params. E.g. removing 'timeout'. */ $force_download_parameters = apply_filters('coursepress_force_download_parameters', array('timeout' => 60, 'user-agent' => $this->name . ' / ' . $this->version . ';')); echo wp_remote_retrieve_body(wp_remote_get($requested_file), $force_download_parameters); exit; } }