/** * Menu callback for admin/people/neuflize-users-export * * Let admin download a csv file of existing users. */ function neuflize_users_export_csv_download($csv) { $datas = neuflize_users_export_get_users(); $csv = neuflize_users_export_csv_render($datas); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Type: application/csv;charset=utf-8"); header("Content-Disposition: attachment;"); header("Content-Transfer-Encoding: binary"); print $csv; drupal_exit(); }
/** * Möglichkeit, einen einzelnen Akteur als .vcf-Datei (VCard-Format) * zu exportieren. * TODO: Behebe invalidität (ein Zeilenumbruch zu viel) */ public function vcard_download() { global $user; $resultAkteur = db_select($this->tbl_akteur, 'a')->fields('a')->condition('AID', $this->akteur_id)->execute()->fetchObject(); $resultAdresse = db_select($this->tbl_adresse, 'ad')->fields('ad')->condition('ADID', $resultAkteur->adresse)->execute()->fetchObject(); //Generierung der .vcf-Datei $var .= "BEGIN:VCARD\r"; $var .= "VERSION:3.0\r\n"; $var .= "REV:" . date('Y-m-d H:i:s') . "\r\n"; $var .= "TITLE:" . $resultAkteur->name . "\r\n"; $var .= "N:" . str_replace(" ", ";", $resultAkteur->name) . "\r\n"; $var .= "FN:" . $resultAkteur->ansprechpartner . "\r\n"; $var .= "TZ:" . date('O') . "\r\n"; $var .= "EMAIL;TYPE=PREF,INTERNET:" . $resultAkteur->email . "\r\n"; $var .= "SOURCE:https://leipzger-ecken.de/download_vcard/" . $resultAkteur->AID . "\r\n"; $var .= "URL:https://leipziger-ecken.de/akteurprofil/" . $resultAkteur->AID . "\r\n"; if (!empty($resultAkteur->bild)) { $var .= "PHOTO;VALUE=URL;TYPE=JPEG:https://leipziger-ecken.de" . $resultAkteur->bild . "\r\n"; } if (!empty($resultAdresse->strasse) && !empty($resultAdresse->nr) && !empty($resultAdresse->plz)) { $var .= "ADR;TYPE=WORK:;;" . $resultAdresse->strasse . " " . $resultAdresse->nr . ";" . $resultAdresse->plz . ";Leipzig\r\n"; $var .= "LABEL;TYPE=WORK:" . $resultAdresse->strasse . " " . $resultAdresse->nr . ", " . $resultAdresse->plz . " Leipzig\r\n"; } if (!empty($resultAkteur->telefon)) { $var .= "TEL;TYPE=WORK,VOICE:" . $resultAkteur->telefon . "\r\n"; } if (!empty($resultAkteur->beschreibung)) { $numwords = 30; preg_match("/(\\S+\\s*){0,{$numwords}}/", $resultAkteur->beschreibung, $regs); $var .= "NOTE:" . trim($regs[0]) . "...\r\n"; } $var .= "END:VCARD\r"; $fileName = htmlspecialchars($resultAkteur->name); $fileName = str_replace(" ", "_", $fileName); $fileName = str_replace(".", "_", $fileName); header('Content-Length: ' . strlen($var)); header("Content-type:text/x-vCard; charset=utf-8"); header("Content-Disposition: attachment; filename=vcard_" . $fileName . ".vcf"); //header('Connection', 'close'); echo $var; drupal_exit(); }
function getDbStats($nodeid, $userid) { try { $node = node_load($nodeid); if (!$node) { echo json_encode(array(status => 0, message => "Request for stats is for an umknown node")); drupal_exit(); } $m = field_get_items("node", $node, "yesno_subtask_milestone_value"); $milestone = $m[0]["value"] == "" ? 0 : $m[0]["value"]; $t = field_get_items("node", $node, "yesno_threshold"); /* Cast this result to an int to ensure that the comparison in the query is correct - the query builder appears to examine the data type to decide whether or not to quote the value - probably does not matter in mysql but does not work in sqllite */ $threshold = (int) $t[0]["value"]; //Create a query to count the completed answers /*$query = db_select("yesno_responses",'r') ->fields('r', array("objectid")) ->condition("r.nodeid",$nodeid) ->groupBy("r.objectid"); $query->havingCondition("rcount",$threshold,">="); $query->addExpression("count(r.id)","rcount");*/ $query = db_select("yesno_response_summaries", "r")->fields('r', array("objectid"))->condition("r.nodeid", $nodeid)->condition("r.responsecount", $threshold, ">="); //Get the total number of completed answers based on the threshold $completed = $query->countQuery()->execute()->fetchField(); $result = $query->execute(); //$sql = "select count(*) from yesno_responses where nodeid = :nid"; //db_query($sql,array(":nid"=>$nodeid))->fetchField(); //Cannot use the summaries table here because these stats are user specific and the summaries table is task specific $query = db_select("yesno_responses", "r")->fields('r', array("answer", "objectid"))->condition("r.nodeid", $nodeid); //Get the total number of answers $answers = $query->countQuery()->execute()->fetchField(); $query->condition("r.userid", $userid); $contributions = $query->countQuery()->execute()->fetchField(); $query->groupBy('answer'); $query->addExpression("count(r.id)", "rcount"); $result = $query->execute(); $yes = 0; $no = 0; $dn = 0; while ($row = $result->fetchAssoc()) { switch ($row["answer"]) { case -1: $no = $row["rcount"]; break; case 0: $dn = $row["rcount"]; break; case 1: $yes = $row["rcount"]; break; } } $contributors = db_select("yesno_responses", "r")->fields("r", array("userid"))->distinct()->condition("r.nodeid", $nodeid)->countQuery()->execute()->fetchField(); //Counting of records needs more thinking about - how do we count answers? $totrecs = db_select("yesno_manifest_entries", "m")->condition("nodeid", $nodeid)->countQuery()->execute()->fetchField(); echo json_encode(array(status => 1, total => $totrecs, responses => $answers, completed => $completed, contributions => $contributions, contributors => $contributors, yes => $yes, no => $no, dontknow => $dn, milestone => $milestone, threshold => $threshold)); } catch (PDException $e) { echo json_encode(array(status => 0, message => "Could not parse data file! Reason: {$e->getMessage()}")); } }
/** * Processes variables for block.tpl.php. * * Prepares the values passed to the theme_block function to be passed * into a pluggable template engine. Uses block properties to generate a * series of template file suggestions. If none are found, the default * block.tpl.php is used. * * Most themes utilize their own copy of block.tpl.php. The default is located * inside "modules/block/block.tpl.php". Look in there for the full list of * variables. * * The $variables array contains the following arguments: * - $block * * @see block.tpl.php */ function scsmetronic_subtheme_preprocess_page(&$variables) { global $user; if (variable_get('scsmetronic_redirect_to_login') && $user->uid == 0 && arg(0) != 'user') { //header('Location: ' . url('user/login', array( 'absolute' => TRUE)), TRUE, 302); // Handle redirection to the login form. // using drupal_goto() with destination set causes a recursive redirect loop $login_path = 'user/login'; $code = 302; // The code in drupal_get_destination() doesn't preserve any query string // on 403 pages, so reproduce the part we want here. $path = isset($_GET['destination']) ? $_GET['destination'] : '<front>'; $query = drupal_http_build_query(drupal_get_query_parameters(NULL, array('q', 'destination'))); if ($query != '') { $path .= '?' . $query; } $destination = array('destination' => $path); header('Location: ' . url($login_path, array('query' => $destination, 'absolute' => TRUE)), TRUE, 302); drupal_exit(); } $variables['navbar_top'] = 'navbar-static-top'; $theme_header = theme_get_setting('theme_header', 'scsmetronic'); if (!empty($theme_header) && $theme_header !== 'default') { $variables['navbar_top'] = 'navbar-fixed-top'; } //Get the entire main menu tree $main_menu_name = theme_get_setting('theme_main_menu', 'scsmetronic'); $main_menu_tree = menu_tree_all_data($main_menu_name); $user_menu_tree = menu_tree_all_data('user-menu'); //Add the rendered output to the $main_menu_expanded variable $variables['main_menu_expanded'] = menu_tree_output($main_menu_tree); $variables['user_menu_expanded'] = menu_tree_output($user_menu_tree); if ($modal_form_paths = theme_get_setting('theme_modal')) { $modal_forms = explode("\r\n", $modal_form_paths); drupal_add_js(array('scsmetronic_forms_modal' => $modal_forms), 'setting'); } if ($user->uid) { $name = theme('username', array('account' => $user, 'link_path' => NULL)); } else { $name = variable_get('anonymous', t('Guest')); } $variables['loggedin_user_name'] = $name; $variables['image'] = scsmetronic_login_user_image($user); }
function adosspp_commerce_abonnes_csv_page_callback() { $datas = _abonnes_get_table_datas(); if (empty($datas)) { return; } $header = array(); foreach ($datas['header'] as $item) { $header[] = $item['data']; } $first_line = csv_convert_single_line_array_to_string($header); $csv = ''; $csv .= $first_line; $csv .= "\r\n"; $csv .= csv_convert_all_lines_array_to_string($datas["rows"]); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Type: application/csv;charset=utf-8"); header('Content-Disposition: attachment; filename="export.csv"'); header("Content-Transfer-Encoding: binary"); print $csv; drupal_exit(); }
/** * @function removeEvent * Returns interface for removing an event */ public function removeEvent() { $explodedpath = explode("/", current_path()); $event_id = $this->clearContent($explodedpath[1]); if (!user_is_logged_in() || !$this->event->isAuthorized($event_id, $this->user_id)) { drupal_access_denied(); drupal_exit(); } if (isset($_POST['submit'])) { $this->event->removeEvent($event_id); if (session_status() == PHP_SESSION_NONE) { session_start(); } drupal_set_message(t('Das Event wurde gelöscht.')); header("Location: " . $base_url . "/events"); // Und "Tschö mit ö..."! } else { $pathThisFile = $_SERVER['REQUEST_URI']; return '<div class="callout row"> <h4><strong>' . t('Möchten Sie dieses Event wirklich löschen?') . '</strong></h4><br /> <form action=' . $pathThisFile . ' method="POST" enctype="multipart/form-data"> <input name="event_id" type="hidden" id="eventEIDInput" value="' . $event_id . '" /> <a class="secondary button" href="javascript:history.go(-1)">Abbrechen</a> <input type="submit" class="button" id="eventSubmit" name="submit" value="Löschen"> </form></div>'; } }
/** * Routing behaviour * @returns $profileHTML; */ public function run() { if (isset($_POST['submit'])) { if ($this->target == 'update') { if (!$this->isAuthorized($this->akteur_id)) { drupal_access_denied(); drupal_exit(); } $this->akteurUpdaten(); } else { $this->akteurSpeichern(); } } else { // Load input-values via akteure-model if ($this->target == 'update') { if (!$this->isAuthorized($this->akteur_id)) { drupal_access_denied(); drupal_exit(); } else { # formerly: $this->akteurGetFields(); $this->__setSingleAkteurVars(reset($this->getAkteure(array('AID' => $this->akteur_id), 'complete'))); if (module_exists('aggregator')) { $this->rssFeed = aggregator_feed_load('aae-feed-' . $this->akteur_id); } } } } return $this->akteurDisplay(); }
/** * {@inheritdoc} */ public function exportToFile($name) { $content = $this->generateFileContent(); header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename=\"{$name}\";"); echo $content; drupal_exit(); }
function __construct($action) { parent::__construct(); global $user; if (!array_intersect(array('administrator', 'festival'), $user->roles)) { drupal_access_denied(); drupal_exit(); } else { # if update -> needs to be admin or global admin } if ($action == 'update') { $this->target = 'update'; } $explodedpath = explode('/', current_path()); $this->festival_id = $this->clearContent($explodedpath[1]); }
/** * @function getAkteurAdresse() * * Gibt Adresse eines Akteurs wieder, welche (wie im eventformular) zur * dynamischen Anzeige dient */ public function getAkteurAdresse($id) { $akteur_id = $this->clearContent($id); if (!is_numeric($akteur_id)) { // Festival = Get festival-admin-akteur $fAkteurId = db_select($this->tbl_festival, 'f')->fields('f', array('admin'))->condition('FID', str_replace('f', '', $akteur_id))->execute()->fetchObject(); $akteur_id = $fAkteurId->admin; } if (empty($akteur_id) || $akteur_id == 0) { drupal_exit(); } $akteurAdresse = db_select($this->tbl_akteur, 'a')->fields('a', array('adresse'))->condition('AID', $akteur_id)->execute()->fetchObject(); $resultAdresse = db_select($this->tbl_adresse, 'ad')->fields('ad')->condition('ADID', $akteurAdresse->adresse)->execute()->fetchObject(); echo json_encode($resultAdresse); drupal_exit(); }
function __construct($action = false) { parent::__construct(); $explodedpath = explode('/', current_path()); $this->event_id = $this->clearContent($explodedpath[1]); $this->event = new events(); $this->tagsHelper = new tags(); $this->adressHelper = new adressen(); // Sollen die Werte im Anschluss gespeichert oder geupdatet werden? if ($action == 'update') { $this->target = 'update'; if (!user_is_logged_in() || !$this->event->isAuthorized($this->event_id, $this->user_id)) { drupal_access_denied(); drupal_exit(); } } else { if (!user_is_logged_in()) { drupal_access_denied(); drupal_exit(); } } }
public function processRequest($apikey, $getParams, $postParams) { $this->apikey = $apikey; if ($apikey == null && isset($postParams['apikey'])) { $this->apikey = $postParams['apikey']; } $this->getParams = $getParams; $this->postParams = $postParams; $result = array('success' => 1); if (!$this->checkApiKey()) { $result = Nl2go_ResponseHelper::generateErrorResponse('Invalid or missing API key!', Nl2go_ResponseHelper::ERRNO_PLUGIN_CREDENTIALS_WRONG); } else { switch ($this->postParams['action']) { case 'test': $result['message'] = $this->test(); break; case 'getPost': $post = $this->getPost(); if (!$post) { $result = Nl2go_ResponseHelper::generateErrorResponse('Post with given id not found!', Nl2go_ResponseHelper::ERRNO_PLUGIN_OTHER); } else { $result = Nl2go_ResponseHelper::generateSuccessResponse(array('post' => $post)); } break; case 'getPluginVersion': $version = $this->getPluginVersion(); $result = Nl2go_ResponseHelper::generateSuccessResponse(array('version' => $version)); break; default: $result = Nl2go_ResponseHelper::generateErrorResponse('Invalid action!', Nl2go_ResponseHelper::ERRNO_PLUGIN_OTHER); break; } } drupal_json_output($result); drupal_exit(); }
function gd_js_ext () { ob_start(); header('Content-Type: text/javascript; charset=UTF-8'); echo '(function(global){ '."\n\n"; foreach ( \GD\Js\Registry::getInstance()->getVendorFiles() as $file ) { echo file_get_contents($file)."\n\n"; } foreach ( \GD\Js\Registry::getInstance()->getFiles() as $file ) { echo file_get_contents($file)."\n\n"; } echo 'GD.options.host = "'.GOVDASH_HOST.'";'."\n\n"; echo 'GD.options.themeList = ["table.css", "filter.css", "highcharts.css", "reportMenu.css", "report.css"];'."\n\n"; echo 'GD.options.themePath = "' . path_to_theme() . '/css/viewer/";'."\n\n"; echo 'GD.options.csrf = "' . drupal_get_token('services') . '";'."\n"; echo "\n\n"; echo file_get_contents(dirname(__FILE__) . '/js/apps/Ext.js')."\n\n"; echo 'global.GD_Highcharts = Highcharts;'."\n"; echo 'global.GD_jQuery = jQuery;'."\n"; echo "\n"; echo '})(typeof window === "undefined" ? this : window);'."\n"; gd_get_session_messages(); echo ob_get_clean(); drupal_exit(); }
/** * {@inheritdoc} */ public function redirectCallback() { $code = isset($_GET['code']) ? $_GET['code'] : FALSE; $error = isset($_GET['error']) ? $_GET['error'] : FALSE; if ($code) { // Get OAuth token. $options = array( 'data' => 'client_id=' . $this->getSetting('instagram_client_id') . '&client_secret=' . $this->getSetting('instagram_client_secret') . '&grant_type=authorization_code' . '&redirect_uri=' . $this->getSetting('instagram_redirect_uri') . '&code=' . $code, 'method' => 'POST', ); $request = drupal_http_request('https://api.instagram.com/oauth/access_token', $options); if ($request->code == 200) { $info = drupal_json_decode($request->data); // Redirect to photos w/ access token in the URL. drupal_goto('file-chooser-field-instagram/photos', array('query' => array('access_token' => $info['access_token']))); } drupal_exit(); } if ($error) { print isset($_GET['error_reason']) ? filter_xss($_GET['error_reason'] . ': ' . $_GET['error_description']) : ''; drupal_exit(); } }
/** * Delivery callback; transfer the file inline. * * @param mixed $file */ public static function deliverFileTransfer($file) { if (is_int($file)) { drupal_deliver_html_page($file); return; } elseif (!is_object($file) || !is_file($file->uri) || !is_readable($file->uri)) { drupal_deliver_html_page(MENU_NOT_FOUND); return; } // @todo Figure out if any other headers should be added. $headers = array('Content-Type' => mime_header_encode($file->filemime), 'Content-Disposition' => 'inline', 'Content-Length' => $file->filesize); // Let other modules alter the download headers. //drupal_alter('file_download_headers', $headers, $file); // Let other modules know the file is being downloaded. module_invoke_all('file_transfer', $file->uri, $headers); foreach ($headers as $name => $value) { drupal_add_http_header($name, $value); } $fd = fopen($file->uri, 'rb'); if ($fd !== FALSE) { while (!feof($fd)) { print fread($fd, DRUPAL_KILOBYTE); } fclose($fd); } else { watchdog('favicon', 'Unable to open @uri for reading.', array('@uri' => $file->uri)); drupal_deliver_html_page(MENU_NOT_FOUND); return; } // Perform end-of-request tasks. if (static::canCacheFile($file)) { drupal_page_footer(); } else { drupal_exit(); } }
function gd_get_js_library() { ob_start(); header('Content-Type: text/javascript; charset=UTF-8'); echo gd_get_js_library_contents(); drupal_exit(); }
/** * @param $dashboardNode * @param $reportNid * @return int|null */ function gd_dashboard_report_view ( $dashboardNode, $reportNid ) { ob_start(); try { if ( !gd_dashboard_access_view($dashboardNode) ) { return MENU_ACCESS_DENIED; } $DashboardConfig = new GD_DashboardConfig($dashboardNode); gd_datasource_set_active($DashboardConfig->getDatasource()); foreach ( $DashboardConfig->items as $item ) { if ( $reportNid == $item->content ) { $options = array(); if (isset($_GET['dashboardBuilder']) && $_GET['dashboardBuilder'] == TRUE) { $options['admin'] = TRUE; } if ( $DashboardConfig->isPublic() && arg(0) == 'public' ) { $options['public'] = TRUE; } $html = $DashboardConfig->getItemReportView($item, $options); $output = array('header'=>$html->header, 'body'=>$html->body, 'footer'=>$html->footer); $response = new stdClass(); $response->status = new stdClass(); $response->status->code = 200; $response->status->message = 'OK'; $response->data = $output; module_invoke_all('gd_ext_response_alter',$response); $messages = gd_get_session_messages(); if ( !empty($messages['error']) ) { $response->status->code = 500; $response->status->message = $messages['error']; } else { if ( !isset($_GET['callback']) && $DashboardConfig->isPublic() && arg(0) == 'public' ) { drupal_add_http_header('Cache-Control','no-transform,public,max-age=3600,s-maxage=3600'); drupal_add_http_header('Expires',gmdate('D, d M Y H:i:s \G\M\T', time() + 3600)); } } echo \GD\Utility\Json::getPayload($response,$_GET['callback']); } } echo ob_get_clean(); drupal_exit(); } catch ( Exception $e ) { gd_exception_handler($e); $response = new stdClass(); $response->status->code = 500; $response->status->message = $e->getMessage(); echo \GD\Utility\Json::getPayload($response,$_GET['callback']); echo ob_get_clean(); drupal_exit(); } }
/** * Form callback. */ function entityqueue_subqueue_delete_form($form, &$form_state, $queue, $subqueue) { $handler = entityqueue_get_handler($queue); // If they can't delete this subqueue, return access denied. if (!$handler->canDeleteSubqueue($subqueue)) { drupal_set_message(t('The %queue: %subqueue subqueue cannot be deleted.', array('%queue' => $queue->label, '%subqueue' => $subqueue->label)), 'warning'); drupal_access_denied(); drupal_exit(); } $form['#queue'] = $queue; $form['#subqueue'] = $subqueue; $form['subqueue_id'] = array('#type' => 'value', '#value' => $subqueue->subqueue_id); return confirm_form($form, t('Are you sure you want to delete %queue: %subqueue?', array('%queue' => $queue->label, '%subqueue' => $subqueue->label)), 'admin/structure/entityqueue/list/' . $queue->name . '/subqueues', NULL, t('Delete')); }
/** * Delivery callback to display an empty page. * * This function is used to print out a bare minimum empty page which still has * the scripts and styles necessary in order to trigger the overlay to close. */ function omega_override_overlay_deliver_empty_page() { $empty_page = '<html><head><title></title>' . drupal_get_css() . omega_get_js() . '</head><body class="overlay"></body></html>'; print $empty_page; drupal_exit(); }
/* This file is part of myTinyTodo. (C) Copyright 2010-2011 Max Pozdeev <*****@*****.**> Licensed under the GNU GPL v2+ license. See file COPYRIGHT for details. */ require_once 'init.inc'; $db = DBConnection::instance(); $field_id = (int) $_GET['fid']; $listId = (int) _get('list'); // We can't use have_write_access() because this is a GET request and have_write_access() requires a CSRF token in a POST request. // Since we're not modifying any data, we don't use a POST request. $onlyPublishedList = have_access('edit') ? false : true; $listData = $db->sqa("SELECT * FROM {mytinytodo_lists} WHERE field_id = ? " . ($onlyPublishedList ? "AND published=1" : ""), array($field_id)); if (!$listData) { echo 'No such list or access denied'; drupal_exit(); } $sqlSort = "ORDER BY compl ASC, "; if ($listData['sorting'] == 1) { $sqlSort .= "prio DESC, ddn ASC, duedate ASC, ow ASC"; } elseif ($listData['sorting'] == 2) { $sqlSort .= "ddn ASC, duedate ASC, prio DESC, ow ASC"; } else { $sqlSort .= "ow ASC"; } $data = array(); $q = $db->dq("SELECT *, duedate IS NULL AS ddn FROM {mytinytodo_todos} WHERE list_id = ? {$sqlSort}", array($listId)); while ($r = $q->fetch_assoc($q)) { $data[] = $r; } $format = _get('format');
/** * Handles file downloading and error states. * * @param $fid * The fid of the file specified to download. * @param $key * The hash key of a user's download. * @param \Symfony\Component\HttpFoundation\Request $request * The request of the page. */ public function download($fid, Request $request) { $user = \Drupal::currentUser(); // Error messages for various failed download states. $admin_message = $this->t('Please contact the site administrator if this message has been received in error.'); $error_messages = array(UC_FILE_ERROR_NOT_A_FILE => $this->t('The file you requested does not exist.'), UC_FILE_ERROR_TOO_MANY_BOGUS_REQUESTS => $this->t('You have attempted to download an incorrect file URL too many times.'), UC_FILE_ERROR_INVALID_DOWNLOAD => $this->t('The following URL is not a valid download link.') . ' ', UC_FILE_ERROR_TOO_MANY_LOCATIONS => $this->t('You have downloaded this file from too many different locations.'), UC_FILE_ERROR_TOO_MANY_DOWNLOADS => $this->t('You have reached the download limit for this file.'), UC_FILE_ERROR_EXPIRED => $this->t('This file download has expired.') . ' ', UC_FILE_ERROR_HOOK_ERROR => $this->t('A hook denied your access to this file.') . ' '); $ip = $request->getClientIp(); if ($user->hasPermission('view all downloads')) { $file_download = uc_file_get_by_id($fid); } else { $file_download = uc_file_get_by_uid($user->id(), $fid); } if (isset($file_download->filename)) { $file_download->full_path = uc_file_qualify_file($file_download->filename); } else { throw new AccessDeniedHttpException(); } // If it's ok, we push the file to the user. $status = UC_FILE_ERROR_OK; if (!$user->hasPermission('view all downloads')) { $status = $this->validateDownload($file_download, $user, $ip); } if ($status == UC_FILE_ERROR_OK) { $this->transferDownload($file_download, $ip); } else { drupal_set_message($error_messages[$status] . $admin_message, 'error'); // Kick 'em to the curb. >:) $this->redirectDownload($user->id()); } drupal_exit(); }
/** * define headers and make output excel-compatible. * Need this function because in some cases, the output has been generated * @param string $content * the content of the excel file. Usually contains a table; also this is HTML compatible * @param string $filename * the filename for the download file */ function cvwobase_download_as_excel_self_defined_content($content, $filename = 'result.xls') { header('Content-type: application/vnd.ms-excel; charset=UTF-8'); header('Content-Disposition: attachment; filename="' . $filename . '"'); $output = '<html>'; $output .= '<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"></head>'; $output .= '<body>'; $output .= $content; $output .= "</body></html>"; print $output; drupal_exit(); }
/** * @method: * Public method that is used to get the output based on the request */ public function get_output($download = FALSE) { $break_cache = isset($_GET['break_cache']) ? $_GET['break_cache'] : FALSE; //only cache if break_cache is not set if (!$break_cache) { $cached = $this->_cache(); $data = $cached; } //switches based on the format requested switch ($this->format) { case 'xml': drupal_add_http_header('Content-Type', 'application/xml; charset=utf-8'); if (empty($cached)) { $data = $this->_array_to_xml($this); } break; case 'csv': drupal_add_http_header('Content-Type', 'text/csv'); if (empty($cached)) { $data = $this->_array_to_csv($this); } break; case 'json': // drupal_add_http_header('Content-Type', 'application/json'); $download = TRUE; if (empty($cached)) { $data = $this->_array_to_json($this); } break; default: $data = ''; } //adds data into the cache if (empty($cached)) { $data = json_decode(json_encode($data), true); $this->_cache('set', $data); } //download the files once the parameter is set if (!empty($download) || isset($_GET['download']) && $_GET['download']) { //generates the download portion once download is required if ($this->format == 'json') { $file_path = $this->_download_json($data); } else { $file_path = $this->_download_project($data); } $filename = explode('/', $file_path); $filename = $filename[count($filename) - 1]; //sets all the headers for the download to work header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header('Content-Disposition: attachment; filename="' . $filename . '"'); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($file_path)); readfile("{$file_path}"); drupal_exit(); } $output = $data; return $output; }
public function rss() { // TODO: Add params to generate events for akteur/festival only header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $start = array('0' => array('date' => (new \DateTime(date()))->format('Y-m-d 00:00:00'), 'operator' => '>=')); $resultEvents = $this->events->getEvents(array('start' => $start)); ob_start(); include_once path_to_theme() . '/templates/events.rss.tpl.php'; drupal_exit(); }
/** * Download the archive * @param type $errorsInHeaders * @return boolean */ public function download($errorsInHeaders = FALSE) { if (file_exists($this->zipFileName) === FALSE) { $file_exists = FALSE; $file_size = 0; $error_code = 1; } else { $file_exists = TRUE; $error_code = 0; $file_size = filesize($this->zipFileName); } $headers = array('Content-Type: application/x-zip-compressed; name="filedepot_archive.zip"', 'Content-Length: ' . $file_size, 'Content-Disposition: attachment; filename="filedepot_archive.zip"', 'Cache-Control: private', 'Error-Code: ' . $error_code, 'FileSize: ' . $file_size); // This has to be manually done so we can still show error header information foreach ($headers as $value) { //drupal_add_http_header($name, $value); header($value); } if ($file_exists === TRUE) { $fp = fopen($this->zipFileName, 'rb'); while (!feof($fp)) { echo fread($fp, 1024); flush(); // this is essential for large downloads } fclose($fp); } else { echo ""; } drupal_exit(); }
function gd_health_medic_admin_api_treatment () { try { $response = 'OK'; switch ($_SERVER['REQUEST_METHOD']) { case 'GET' : break; case 'POST' : gd_health_medic_treatment_apply(json_decode($_POST['affected']), $_POST['treatment']); break; default: throw new Exception('Unsupported request method.'); } } catch ( Exception $e ) { drupal_add_http_header('Status', '500 System Error'); gd_get_session_messages(); LogHelper::log_error($e); $response = $e->getMessage(); } echo json_encode($response); drupal_exit(); }