示例#1
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     if ($GLOBALS['perm']->have_perm('admin')) {
         $this->redirect('admin/courses/index');
         return;
     }
     // we are defintely not in an lecture or institute
     closeObject();
     $_SESSION['links_admin_data'] = '';
     // measure performance of #index_action
     if ($action === 'index') {
         $this->performance_timer = Metrics::startTimer();
     }
 }
示例#2
0
文件: index.php 项目: samdubey/ads2
respond('/stocks/[i:product]/dec/[i:value]', StockCtrl::decrement());
//respond('/report/inventory.pdf', ReportCtrl::test());
respond('/report/inventory.pdf', ReportCtrl::inventory());
respond('/report/monthly.pdf', ReportCtrl::monthly());
respond('/report/weekly.pdf', ReportCtrl::weekly());
respond('/order/[i:id]/receipt.pdf', ReportCtrl::user_order_receipt());
respond('/sales', SalesCtrl::index());
respond('/sales/[i:id]', SalesCtrl::show());
respond('/return', RetExCtrl::index());
respond('/return/[i:id]', RetExCtrl::show());
respond('/dues', function ($req, $res) {
    $dues = Dues::all();
    $res->json($dues->as_array());
});
respond('/new_orders', function ($req, $res) {
    $n = Metrics::all();
    $n = $n[0];
    //echo $n->count;
    $count = array('count' => $n->count);
    $res->json($count);
});
respond('POST', '/sms', function ($req, $res) {
    $ctx = new ZMQContext();
    $push = new ZMQSocket($ctx, ZMQ::SOCKET_PUSH);
    $endpoint = "tcp://184.164.136.144:5566";
    $push->connect($endpoint);
    $input = $req->data();
    if ($input->number) {
        $data = array('id' => time(), 'number' => $input->number, 'message' => $input->message);
        $push->send(json_encode($data));
        $res->json($data);
示例#3
0
文件: download.php 项目: ratbird/hope
 /**
  * Downloads a bunch of files as a zip archive.
  *
  * @param Array  $files    Directory entries or files to download
  * @param String $filename Filename for the archive.
  */
 protected function download_files($files, $filename = 'Stud-IP.zip')
 {
     $files = (array) $files;
     $tmp_file = tempnam($GLOBALS['TMP_PATH'], 'doc');
     $zip = new ZipArchive();
     $open_result = $zip->open($tmp_file, ZipArchive::CREATE);
     if (true !== $open_result) {
         throw new Exception('Could not create zip file (' . $open_result . ')');
     }
     foreach ($files as $file) {
         $this->addToZip($zip, $file, '', $remove);
     }
     if (true !== ($close_result = $zip->close())) {
         throw new Exception('Could not close zip file (' . $close_result . ')');
     }
     array_map('unlink', $remove);
     Metrics::count('core.personal_files.downloads', count($files));
     // TODO: swap "Stud-IP.zip" with a more appropriate name
     $filename = basename($filename, '.zip') . '.zip';
     $this->initiateDownload(false, $filename, 'application/zip', filesize($tmp_file), fopen($tmp_file, 'r'));
     $this->download_remove = $tmp_file;
 }
示例#4
0
        return $this->_aStats;
    }
}
function printUsage($arg)
{
    echo 'Usage: php ' . basename($arg) . ' MetricsXml' . PHP_EOL;
    echo '    MetricsXml    - Metrics in PDepend xml format' . PHP_EOL;
    echo PHP_EOL;
    die("");
}
if (!isset($argv["1"]) || !$argv["1"]) {
    printUsage($argv["0"]);
}
$sMetricsXml = $argv["1"];
try {
    $oMetrics = new Metrics($sMetricsXml);
    if ($oMetrics->isExistingMetricsFile()) {
        $oMetrics->read();
        echo "Total Avg ccn\t= " . round($oMetrics->getTotalAverageCCN(), 3) . " (max: " . $oMetrics->getMaxCCN() . ")" . PHP_EOL;
        echo "Total Avg crap\t= " . round($oMetrics->getTotalAverageCrapIndex(), 3) . " (max: " . $oMetrics->getMaxCrapIndex() . ")" . PHP_EOL;
        echo "Total Avg NPath\t= " . round($oMetrics->getTotalAverageNPath(), 3) . " (max: " . $oMetrics->getMaxNPath() . ")" . PHP_EOL;
        echo "Total LLOC\t= " . $oMetrics->getTotalLLOC() . " (max: " . $oMetrics->getMaxLLOC() . ")" . PHP_EOL . PHP_EOL;
        $aStats = $oMetrics->getClassesStats();
        foreach ($aStats as $sClass => $aClass) {
            echo "Total for {$sClass}" . PHP_EOL;
            echo "\tAvg ccn \t= " . round($aClass['stat']['cnn'], 3) . " (max: " . $aClass['max']['cnn'] . ")" . PHP_EOL;
            echo "\tAvg crap\t= " . round($aClass['stat']['crap'], 3) . " (max: " . $aClass['max']['crap'] . ")" . PHP_EOL;
            echo "\tAvg npath\t= " . round($aClass['stat']['npath'], 3) . " (max: " . $aClass['max']['npath'] . ")" . PHP_EOL;
            echo "\tLLOC \t\t= " . $aClass['sum']['locExecutable'] . PHP_EOL . PHP_EOL;
        }
    } else {
示例#5
0
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* https://www.axibase.com/atsd/axibase-apache-2.0.pdf
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace axibase\atsdPHP;

require_once '../atsdPHP/models/Metrics.php';
require_once '../atsdPHP/HttpClient.php';
require_once '../atsdPHP/Utils.php';
$expression = 'name like \'nmon*\'';
$limit = 10;
$queryClient = new Metrics();
$params = array('limit' => $limit, 'expression' => $expression);
$responseMetrics = $queryClient->findAll($params);
$viewConfig = new ViewConfiguration('Metrics for expression: ' . $expression . "; limit: " . $limit, 'metrics', array('lastInsertTime' => 'unixtimestamp'));
$MetricsTbl = Utils::arrayAsHtmlTable($responseMetrics, $viewConfig);
$metric = "disk_used_percent";
$entity = "nurswgvml006";
$responseMetric = $queryClient->find($metric, array("entity" => $entity));
$viewConfig = new ViewConfiguration('Metric:' . $metric . ', entity: ' . $entity, 'metric', array('lastInsertTime' => 'unixtimestamp'));
$eattableEntity = Utils::arrayAsHtmlTable(array($responseMetric), $viewConfig);
$responseEntityAndTags = $queryClient->findEntityAndTags($metric);
$viewConfig = new ViewConfiguration('Entity and Tags for metric: ' . $metric, 'entAndTags');
$entityAndTagsTable = Utils::arrayAsHtmlTable($responseEntityAndTags, $viewConfig);
Utils::render(array($MetricsTbl, $eattableEntity, $entityAndTagsTable));
示例#6
0
 /**
  * Outputs the coverage report of a metrics instance.
  *
  * @param Metrics $metrics A metrics instance.
  */
 protected function _renderCoverage($metrics)
 {
     $stats = $metrics->data();
     foreach ($stats['files'] as $file) {
         $this->write("File: {$file}" . "\n\n");
         $lines = file($file);
         $coverage = $this->_collector->export($file);
         if (isset($stats['line'])) {
             $start = $stats['line']['start'];
             $stop = $stats['line']['stop'];
         } else {
             $start = 0;
             $stop = count($lines) - 1;
         }
         for ($i = $start; $i <= $stop; $i++) {
             $value = isset($coverage[$i]) ? $coverage[$i] : null;
             $line = str_pad($i + 1, 6, ' ', STR_PAD_LEFT);
             $line .= ':' . str_pad($value, 6, ' ');
             $line .= $lines[$i];
             if ($value) {
                 $this->write($line, 'n;green');
             } elseif ($value === 0) {
                 $this->write($line, 'n;red');
             } else {
                 $this->write($line);
             }
         }
         $this->write("\n\n");
     }
 }
示例#7
0
 /**
  * Connect to database
  * @method dbConnect
  * @static
  * @return {boolean}
  */
 static function dbConnect()
 {
     if (isset(self::$db)) {
         return false;
     }
     $driver_options = array('3' => 2);
     $arr = Pie_Config::get('db', 'connections', 'rs', false);
     if (!$arr) {
         throw new Exception("Missing connection details for rs");
     }
     extract($arr);
     self::$db = new PDO($dsn, $username, $password, $driver_options);
     if (!self::$db) {
         throw new Exception("Could not connect to db");
     }
     return true;
 }
示例#8
0
文件: files.php 项目: ratbird/hope
 /**
  * Upload a new file.
  *
  * @param String $folder_id Directory entry id of the folder to upload to
  */
 public function upload_action($folder_id, $page = 1)
 {
     if (!$this->full_access) {
         throw new AccessDeniedException();
     }
     PageLayout::setTitle(_('Datei hochladen'));
     $folder_id = $folder_id ?: $this->context_id;
     if ($folder_id === $this->context_id) {
         $directory = new RootDirectory($this->context_id);
     } else {
         $dirEntry = new DirectoryEntry($folder_id);
         $directory = $dirEntry->file;
     }
     $directory->checkAccess();
     if (Request::isPost()) {
         $title = Request::get('title');
         $description = Request::get('description', '');
         $restricted = Request::int('restricted', 0);
         $count = count($_FILES['file']['name']);
         $failed = array();
         for ($i = 0; $i < $count; $i++) {
             if ($_FILES['file']['error'][$i] !== 0) {
                 $failed[] = array($_FILES['file']['name'][$i], 'remote');
                 continue;
             }
             $filename = $_FILES['file']['name'][$i];
             $filesize = $_FILES['file']['size'][$i];
             $mimetype = $_FILES['file']['type'][$i];
             $tempname = $_FILES['file']['tmp_name'][$i];
             $fileExtension = explode('.', $filename);
             if (!empty($fileExtension) && !empty($this->userConfig['types'])) {
                 foreach ($this->userConfig['types'] as $typ) {
                     if ($typ['type'] == $fileExtension[count($fileExtension) - 1]) {
                         $failed[] = array($_FILES['file']['name'][$i], 'forbidden_type');
                     }
                 }
             }
             $restQuota = (int) $this->userConfig['quota'] - DiskFileStorage::getQuotaUsage($this->context_id);
             if ($filesize > $restQuota) {
                 $failed[] = array($_FILES['file']['name'][$i], 'quota');
             } else {
                 if ($filesize > (int) $this->userConfig['upload_quota']) {
                     $failed[] = array($_FILES['file']['name'][$i], 'upload_quota');
                 } else {
                     $filename = $directory->ensureUniqueFilename($filename);
                     $this_title = $title;
                     if ($this_title && $count > 1) {
                         $this_title .= ' ' . sprintf(_('(%u von %u)'), $i + 1, $count);
                     }
                     $new_file = $directory->createFile($filename, $description, $this->context_id);
                     $handle = $new_file->file;
                     $handle->restricted = $restricted;
                     $handle->mime_type = $mimetype;
                     $handle->size = $filesize;
                     try {
                         $handle->setContentFromFile($tempname);
                         $handle->update();
                     } catch (Exception $e) {
                         if (Studip\ENV === 'development') {
                             throw $e;
                         } else {
                             $failed[] = array($filename, 'local');
                             $handle->delete();
                         }
                     }
                 }
             }
         }
         if (!empty($failed)) {
             $remote = array_map('reset', array_filter($failed, function ($item) {
                 return $item[1] === 'remote';
             }));
             if (!empty($remote)) {
                 $message = MessageBox::error(_('Folgende Dateien wurden fehlerhaft hochgeladen:'), $remote);
                 PageLayout::postMessage($message);
             }
             $forbidden = array_map('reset', array_filter($failed, function ($item) {
                 return $item[1] === 'forbidden_type';
             }));
             if (!empty($forbidden)) {
                 $message = MessageBox::error(_('Der Upload folgender Dateien ist verboten:'), $forbidden);
                 PageLayout::postMessage($message);
             }
             $quota = array_map('reset', array_filter($failed, function ($item) {
                 return $item[1] === 'quota';
             }));
             if (!empty($quota)) {
                 $message = MessageBox::error(_('Für folgende Dateien ist der verbleibende Speicherplatz zu klein:'), $quota);
                 PageLayout::postMessage($message);
             }
             $upload = array_map('reset', array_filter($failed, function ($item) {
                 return $item[1] === 'upload_quota';
             }));
             if (!empty($upload)) {
                 $message = MessageBox::error(_('Folgende Dateien sind zu groß für den Upload:'), $upload);
                 PageLayout::postMessage($message);
             }
             $local = array_map('reset', array_filter($failed, function ($item) {
                 return $item[1] === 'local';
             }));
             if (!empty($local)) {
                 $message = MessageBox::error(_('Folgende Dateien konnten nicht gespeichert werden:'), $local);
                 PageLayout::postMessage($message);
             }
         }
         if ($count - count($failed) > 0) {
             Metrics::count('core.personal_files.uploads', $count - count($failed));
             $message = sprintf(_('%u Dateien wurden erfolgreich hochgeladen.'), $count - count($failed));
             PageLayout::postMessage(MessageBox::success($message));
         }
         $this->redirect('document/files/index/' . $folder_id . '/' . $page);
     }
     $this->folder_id = $folder_id;
     $this->page = $page;
     PageLayout::setTitle(_('Datei hochladen'));
 }
示例#9
0
 StudipAutoloader::addClassLookups(array('email_validation_class' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/phplib/email_validation.class.php', 'cssClassSwitcher' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/classes/cssClassSwitcher.inc.php', 'MediaProxy' => $GLOBALS['STUDIP_BASE_PATH'] . '/app/models/media_proxy.php', 'MyRealmModel' => $GLOBALS['STUDIP_BASE_PATH'] . '/app/models/my_realm.php', 'StudygroupModel' => $GLOBALS['STUDIP_BASE_PATH'] . '/app/models/studygroup.php', 'StudipPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/StudIPPlugin.class.php', 'AbstractStudipPortalPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPPortalPlugin.class.php', 'AbstractStudipSystemPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPSystemPlugin.class.php', 'AbstractStudipHomepagePlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPHomepagePlugin.class.php', 'AbstractStudipAdministrationPlugin' => $GLOBALS['STUDIP_BASE_PATH'] . '/lib/plugins/core/AbstractStudIPAdministrationPlugin.class.php'));
 // Trails
 $trails_classes = array('Trails_Dispatcher', 'Trails_Response', 'Trails_Controller', 'Trails_Inflector', 'Trails_Flash', 'Trails_Exception', 'Trails_DoubleRenderError', 'Trails_MissingFile', 'Trails_RoutingError', 'Trails_UnknownAction', 'Trails_UnknownController', 'Trails_SessionRequiredException');
 StudipAutoloader::addClassLookup($trails_classes, $GLOBALS['STUDIP_BASE_PATH'] . '/vendor/trails/trails.php');
 StudipAutoloader::addClassLookup('StudipController', $GLOBALS['STUDIP_BASE_PATH'] . '/app/controllers/studip_controller.php');
 StudipAutoloader::addClassLookup('AuthenticatedController', $GLOBALS['STUDIP_BASE_PATH'] . '/app/controllers/authenticated_controller.php');
 StudipAutoloader::addClassLookup('PluginController', $GLOBALS['STUDIP_BASE_PATH'] . '/app/controllers/plugin_controller.php');
 // Vendor
 StudipAutoloader::addClassLookups(array('PasswordHash' => $GLOBALS['STUDIP_BASE_PATH'] . '/vendor/phpass/PasswordHash.php', 'TCPDF' => $GLOBALS['STUDIP_BASE_PATH'] . '/vendor/tcpdf/tcpdf.php'));
 StudipAutoloader::addAutoloadPath($GLOBALS['STUDIP_BASE_PATH'] . '/vendor/mishal-iless/lib/ILess', 'ILess');
 // sample the request time and number of db queries every tenth time
 register_shutdown_function(function ($timer) {
     $timer('core.request_time', 0.1);
     $query_count = DBManager::get()->query_count;
     Metrics::gauge('core.database.queries', $query_count, 0.1);
 }, Metrics::startTimer());
 require 'lib/phplib/page_open.php';
 StudipFileloader::load('config_local.inc.php', $GLOBALS, compact('STUDIP_BASE_PATH'));
 require 'config.inc.php';
 require_once 'lib/functions.php';
 require_once 'lib/language.inc.php';
 require_once 'lib/visual.inc.php';
 require_once 'lib/deputies_functions.inc.php';
 //setup default logger
 Log::get()->setHandler($GLOBALS['TMP_PATH'] . '/studip.log');
 if (Studip\ENV == 'development') {
     Log::get()->setLogLevel(Log::DEBUG);
 } else {
     Log::get()->setLogLevel(Log::ERROR);
 }
 // set default time zone
示例#10
0
文件: Metrics.php 项目: ratbird/hope
 private static function sendMessage($message, $stat, $value, $sampleRate)
 {
     // cannot proceed without loaded PluginEngine
     if (!class_exists('PluginEngine')) {
         return;
     }
     if ($sampleRate < 1) {
         $rand = mt_rand() / mt_getrandmax();
         if ($rand > $sampleRate) {
             return;
         }
     }
     // cache the activated MetricsPlugins
     if (!self::$metricPlugins) {
         self::$metricPlugins = \PluginEngine::getPlugins('MetricsPlugin');
     }
     // call every MetricPlugin
     foreach (self::$metricPlugins as $plugin) {
         call_user_func_array(array($plugin, $message), array($stat, $value, $sampleRate));
     }
 }
示例#11
0
文件: folder.php 项目: ratbird/hope
    //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);
        }

    //wurde eine Datei verlinkt?
    if (($cmd=="link") && (!Request::submitted("cancel")) && ($folder_system_data["link"])) {
        if (link_item ($folder_system_data["link"], TRUE, FALSE, $folder_system_data["refresh"],FALSE)) {
            $open = $dokument_id;
            $close = $folder_system_data["refresh"];
            $folder_system_data["link"]='';
            $folder_system_data["refresh"]='';
            $folder_system_data["update_link"]='';
示例#12
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;
     }
 }
示例#13
0
<?php

require "../dues.php";
$admin = Metrics::all();
$n = $admin[0];
var_dump($n->count);
示例#14
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);
}

?>
示例#15
0
<?php

/*
* Copyright 2015 Axibase Corporation or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* https://www.axibase.com/atsd/axibase-apache-2.0.pdf
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace axibase\atsdPHP;

require_once '../atsdPHP/models/Metrics.php';
require_once '../atsdPHP/HttpClient.php';
require_once '../atsdPHP/Utils.php';
$expression = 'name like \'nmon*\'';
$limit = 10;
$queryClient = new Metrics();
$params = array('limit' => $limit, 'expression' => $expression);
$metricsResponse = $queryClient->findAll($params);
var_dump($metricsResponse);
示例#16
0
 /**
  * @test
  */
 public function shouldMergeThat()
 {
     $object = new Metrics($this->coverage);
     $that = new Metrics($this->coverage);
     $object->merge($that);
     $this->assertSame(6, $object->getStatements());
     $this->assertSame(4, $object->getCoveredStatements());
     $this->assertSame(400 / 6, $object->getLineCoverage());
 }
示例#17
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);
     }
 }
示例#18
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;
}
示例#19
0
文件: sendfile.php 项目: ratbird/hope
    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);
}
            $iCrap = $aClass['stat']['crap'];
            $iNpath = $aClass['stat']['npath'];
            $iCcnMax = $aClass['max']['cnn'];
            $iCrapMax = $aClass['max']['crap'];
            $iNpathMax = $aClass['max']['npath'];
            $iLoc = $aClass['sum']['locExecutable'];
            echo "Total for {$sClass}" . PHP_EOL;
            echo "\tAvg cnn = {$iCcn} (max: {$iCcnMax})" . PHP_EOL;
            echo "\tAvg crap = {$iCrap} (max: {$iCrapMax})" . PHP_EOL;
            echo "\tAvg npath = {$iNpath} (max: {$iNpathMax})" . PHP_EOL;
            echo "\tAvg locExecutable = {$iLoc}" . PHP_EOL . PHP_EOL;
        }
    }
}
try {
    $oMetrics = new Metrics($sMetricsXml);
    $oMetrics->read();
    $oMetrics->echoResults();
} catch (Exception $oE) {
    $sMsg = $oE->getMessage() . ' ' . $oE->getTraceAsString();
    echo $sMsg;
}
/**
 * Based off of http://www.artima.com/weblogs/viewpost.jsp?thread=210575
 * comp(m) = cyclomatic complexity
 * cov(m) = code coverage
 *
 * C.R.A.P. Level is based off of the file and not the method.
 *
 * @param int $cyclomatic_complexity Enter description here...
 * @param int $code_coverage         Enter description here...
示例#21
0
文件: rss.php 项目: ratbird/hope
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();
示例#22
0
session_start();
// Used for including files
if (!defined("_ABSPATH")) {
    define("_ABSPATH", dirname(dirname(__FILE__)));
}
require_once _ABSPATH . '/confs/config-inc.php';
require_once _ABSPATH . '/lib/settings.php';
require_once _ABSPATH . '/lib/Smarty.php';
require_once _ABSPATH . '/lib/functions.php';
require_once _ABSPATH . '/db/nessquikDB.php';
require_once _ABSPATH . '/lib/User.php';
require_once _ABSPATH . '/lib/Metrics.php';
$db = nessquikDB::getInstance();
$tpl = SmartyTemplate::getInstance();
$_usr = User::getInstance();
$_met = Metrics::getInstance();
$tpl->template_dir = _ABSPATH . '/templates/';
$tpl->compile_dir = _ABSPATH . '/templates_c/';
if ($_GET) {
    $action = import_var('action', 'G');
} else {
    $action = import_var('action', 'P');
}
if (!$_usr->is_editor($allowed_editors)) {
    exit;
}
switch ($action) {
    case "show_graph_categories":
        $categories = $_met->get_graph_categories();
        $tpl->assign(array('categories' => $categories));
        $tpl->display('metric_categories.tpl');