Пример #1
0
Copyright (C) 2005  Philipp HŸgelmeyer <*****@*****.**>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
require '../lib/bootstrap.php';
ob_end_clean();
ob_start();
require_once 'lib/showNews.inc.php';
if (get_config('NEWS_RSS_EXPORT_ENABLE')) {
    $range = StudipNews::GetRangeFromRssID(Request::option('id'));
    if (is_array($range)) {
        Metrics::increment('core.news.rss_fetched');
        show_rss_news($range['range_id'], $range['range_type']);
    } else {
        header("Content-type: text/xml; charset=utf-8");
        echo "<?xml version=\"1.0\"?>\n<rss version=\"2.0\">\n</rss>\n";
    }
}
ob_end_flush();
Пример #2
0
 public function callbackToMetrics($callback_type)
 {
     if ($this->type) {
         $metric = sprintf('moocip.block.%s.%s', strtolower($this->type), substr(strtolower($callback_type), strlen('after_')));
         \Metrics::increment($metric);
     }
 }
Пример #3
0
    header("Content-Range: bytes {$start}-{$end}/{$filesize}");
    header("Content-Length: {$length}");
} elseif ($filesize) {
    header("Content-Length: {$filesize}");
}
header("Expires: Mon, 12 Dec 2001 08:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
if ($_SERVER['HTTPS'] == "on") {
    header("Pragma: public");
    header("Cache-Control: private");
} else {
    header("Pragma: no-cache");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    // HTTP/1.1
}
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Type: {$content_type}");
header("Content-Disposition: {$content_disposition}; filename=\"{$file_name}\"");
Metrics::increment('core.file_download');
if ($type != 5) {
    @readfile_chunked($path_file, $start, $end);
    if (in_array($type, array(0, 6)) && !$start) {
        TrackAccess($file_id, 'dokument');
    }
} else {
    echo $the_data;
}
//remove temporary file after zipping
if (Request::int('zip') || $type == 4) {
    @unlink($path_file);
}
Пример #4
0
 /**
  * Downloads a single file.
  *
  * @param DirectoryEntry $entry  Directory entry to download
  * @param bool           $inline Download as inline
  */
 protected function download_file(DirectoryEntry $entry, $inline)
 {
     $file = $entry->file;
     $storage = $file->getStorageObject();
     if (!$storage->exists() || !$storage->isReadable()) {
         throw new Exception('Cannot access file "' . $storage->getPath() . '"');
     }
     $entry->downloads += 1;
     $entry->store();
     Metrics::increment('core.personal_files.downloads');
     $this->initiateDownload($inline, $file->filename, $file->mime_type, $file->size, $storage->open('r'));
 }
Пример #5
0
function studip_default_exception_handler($exception)
{
    require_once 'lib/visual.inc.php';
    // send exception to metrics backend
    if (class_exists('Metrics')) {
        $exception_class = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', get_class($exception)));
        Metrics::increment('core.exception.' . $exception_class);
    }
    while (ob_get_level()) {
        ob_end_clean();
    }
    $layout = 'layouts/base.php';
    if ($exception instanceof AccessDeniedException) {
        $status = 403;
        $template = 'access_denied_exception';
    } else {
        if ($exception instanceof CheckObjectException) {
            $status = 403;
            $template = 'check_object_exception';
        } elseif ($exception instanceof LoginException) {
            $GLOBALS['auth']->login_if(true);
        } else {
            if ($exception instanceof Trails_Exception) {
                $status = $exception->getCode();
            } else {
                $status = 500;
            }
            error_log($exception->__toString());
            $template = 'unhandled_exception';
        }
    }
    header('HTTP/1.1 ' . $status . ' ' . $exception->getMessage());
    // ajax requests return JSON instead
    // re-use the http status code determined above
    if (!strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'], 'xmlhttprequest')) {
        header('Content-Type: application/json; charset=UTF-8');
        $template = 'json_exception';
        $layout = null;
    }
    try {
        $args = compact('exception', 'status');
        ob_start();
        echo $GLOBALS['template_factory']->render($template, $args, $layout);
    } catch (Exception $e) {
        ob_end_clean();
        echo 'Error: ' . htmlReady($e->getMessage());
    }
    exit;
}
Пример #6
0
    if ($open_cmd == 'z' && $rechte  && !Request::submitted("cancel")) {
        $folder_system_data["upload"]=$open_id;
        $folder_system_data["zipupload"]=$open_id;
    }


    //wurde Code fuer Verlinken uebermittelt (=id+"_l_"), wird entsprechende Variable gesetzt
    if ($open_cmd == 'l' && (!Request::submitted("cancel"))) {
        $folder_system_data["link"]=$open_id;
    }

    //wurde eine Datei hochgeladen/aktualisiert?
    $cmd = Request::get("cmd");
    if (($cmd=="upload") && (!Request::submitted("cancel")) && ($folder_system_data["upload"])) {
        if (!$folder_system_data["zipupload"]){
            Metrics::increment('core.file_upload');

            upload_item ($folder_system_data["upload"], TRUE, FALSE, $folder_system_data["refresh"]);
            $open = $dokument_id;
            $close = $folder_system_data["refresh"];
            $folder_system_data["upload"]='';
            $folder_system_data["refresh"]='';
        } elseif ($rechte && get_config('ZIP_UPLOAD_ENABLE')) {
            $uploaded_files = upload_zip_item();
            if ($uploaded_files !== false) {
                Metrics::count('core.file_upload', $uploaded_files);
            }
            $folder_system_data["upload"]='';
            $folder_system_data["zipupload"]='';
        }
        unset($cmd);
Пример #7
0
 /**
  * @return bool
  */
 function auth_validatelogin()
 {
     global $_language_path;
     //prevent replay attack
     if (!Seminar_Session::check_ticket(Request::option('login_ticket'))) {
         return false;
     }
     // check for direct link
     if (!$_SESSION['_language'] || $_SESSION['_language'] == "") {
         $_SESSION['_language'] = get_accepted_languages();
     }
     $_language_path = init_i18n($_SESSION['_language']);
     include 'config.inc.php';
     $this->auth["uname"] = Request::get('loginname');
     // This provides access for "loginform.ihtml"
     $this->auth["jscript"] = Request::get('resolution') != "";
     $this->auth['devicePixelRatio'] = Request::float('device_pixel_ratio');
     $check_auth = StudipAuthAbstract::CheckAuthentication(Request::get('loginname'), Request::get('password'));
     if ($check_auth['uid']) {
         $uid = $check_auth['uid'];
         if ($check_auth['need_email_activation'] == $uid) {
             $this->need_email_activation = $uid;
             $_SESSION['semi_logged_in'] = $uid;
             return false;
         }
         $user = $check_auth['user'];
         $this->auth["perm"] = $user->perms;
         $this->auth["uname"] = $user->username;
         $this->auth["auth_plugin"] = $user->auth_plugin;
         $this->auth_set_user_settings($user);
         Metrics::increment('core.login.succeeded');
         return $uid;
     } else {
         Metrics::increment('core.login.failed');
         $this->error_msg = $check_auth['error'];
         return false;
     }
 }
Пример #8
0
}

// all parameters ok, instantiate module and print data
foreach ($GLOBALS['EXTERN_MODULE_TYPES'] as $type) {
    if ($type["module"] == $module) {
        $module_obj = ExternModule::GetInstance($range_id, $module, $config_id, $default, $global_id);
    }
}

// Workaround to include data in scripts
if ($incdata) {
    $module_obj->config->config["Main"]["incdata"] = 1;
}

$args = $module_obj->getArgs();
foreach ($args as $arg) {
    $arguments[$arg] = Request::quoted($arg);
}

// declare Stud.IP encoding by default
header('Content-Type: text/html; charset=windows-1252');

if (Request::option('preview')) {
    $module_obj->printoutPreview();
} else {
    Metrics::increment('core.extern_page_request');
    $module_obj->printout($arguments);
}

?>