/**
  * Process the entered username and password
  *
  * The callback function should take the entered username, and return the users password.
  */
 public function process()
 {
     if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
         debug_header('Empty PHP_AUTH_DIGEST');
         return false;
     }
     if (!($data = $this->parseHTTPDigest($_SERVER['PHP_AUTH_DIGEST']))) {
         debug_header('Invalid PHP_AUTH_DIGEST');
         return false;
     }
     $password = call_user_func_array($this->callback, array(array($data['username'])));
     if (!$password) {
         debug_header('No password');
         return false;
     }
     // generate the valid response
     $A1 = md5($data['username'] . ':' . $this->realm . ':' . $password);
     $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
     $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
     if ($data['response'] != $valid_response) {
         debug_header('Invalid response');
         return false;
     }
     return $data['username'];
 }
Esempio n. 2
0
 public static function hook_output($output)
 {
     //TODO Attach HTTP Error codes and descriptions to these errors
     if (!is_array($output)) {
         BackendError::add('Google Chart Error', 'Invalid Output');
         return false;
     }
     $type = array_key_exists('type', $output) ? $output['type'] : Backend::get('ChartType', 'simple_line');
     if (!method_exists('GChartView', $type)) {
         BackendError::add('Google Chart Error', 'Invalid Chart Type');
         return false;
     }
     if (!array_key_exists('data', $output)) {
         $output = array('data' => $output);
     }
     if (!is_array($output['data']) || !count($output['data'])) {
         BackendError::add('Google Chart Error', 'Invalid Output Data');
         return false;
     }
     $params = array();
     $title = array_key_exists('title', $output) ? $output['title'] : Backend::get('ChartTitle', false);
     if ($title) {
         $params['chtt'] = $title;
     }
     $url = self::$type($output, $params);
     if (Controller::$debug) {
         echo '<img src="' . $url . '">';
         var_dump($params);
         var_dump($output);
         $dont_kill = Controller::getVar('dont_kill');
         if (empty($dont_kill)) {
             die;
         }
     }
     $recache = Controller::getVar('recache') ? true : false;
     debug_header('Recache - ' . $recache);
     $image = curl_request($url, array(), array('cache' => $recache ? 1 : 60 * 60, 'bypass_ssl' => 1));
     if (Controller::$debug) {
         var_dump('Image:', $image);
     }
     if (!$image) {
         BackendError::add('Google Chart Error', 'Could not get image');
         return false;
     }
     $filename = Backend::get('ChartFilename', false);
     if (!$filename) {
         $filename = class_name(Controller::$area) . class_name(Controller::$action);
         if (Controller::$action == 'read' && !empty(Controller::$parameters[0])) {
             $filename .= Controller::$parameters[0];
         }
     }
     if (Controller::$debug) {
         var_dump('Filename:', $filename);
     }
     header('Content-Disposition: inline; filename="' . $filename . '.png"');
     return $image;
 }
Esempio n. 3
0
function debug_sql()
{
    global $_URL, $_DEBUGITEMS;
    ob_start();
    echo debug_header($_URL->file);
    foreach ($_DEBUGITEMS as $debug) {
        echo debug_item($debug['backtrace'], $debug['query'], &$debug['result']);
    }
    echo debug_footer();
    $debug_contents = ob_get_contents();
    ob_end_clean();
    print $debug_contents;
    exit;
}