/**
  * Get an approximate measure of the amount of data still to be consumed
  *
  * @return integer
  */
 public function getRemainingSize()
 {
     try {
         if (0 == $this->nIterators) {
             $this->rewind();
             // initialise simple consumers
         }
     } catch (Exception\InvalidTopic $e) {
         $logMsg = 'Invalid topic from ZookeeperConsumer::rewind(): Most likely cause is no topic yet as there is no data';
         error_log($logMsg);
     }
     $totalSize = 0;
     foreach ($this->iterators as $it) {
         $readBytes = $it->offset + $it->uncommittedOffset;
         if (null !== $it->messages) {
             $readBytes += $it->messages->validBytes();
         }
         $consumer = new SimpleConsumer($it->host, $it->port, $this->socketTimeout, $this->maxBatchSize);
         $offsets = $consumer->getOffsetsBefore($this->topic, $it->partition, SimpleConsumer::OFFSET_LAST, 1);
         if (count($offsets) > 0) {
             $remaining = $offsets[0] - $readBytes;
             // remaining bytes for this broker/partition
             if ($remaining > 0) {
                 $totalSize += $remaining;
             }
         }
         $consumer->close();
     }
     return $totalSize;
 }
Beispiel #2
0
     COM_updateSpeedlimit('login');
     //pass $loginname by ref so we can change it ;-)
     $status = SEC_remoteAuthentication($loginname, $passwd, $service, $uid);
     // end distributed (3rd party) remote authentication method
     // begin OpenID remote authentication method
 } elseif ($_CONF['user_login_method']['openid'] && $_CONF['usersubmission'] == 0 && !$_CONF['disable_new_user_registration'] && (isset($_GET['openid_login']) && $_GET['openid_login'] == '1')) {
     $query = array_merge($_GET, $_POST);
     if (isset($query['identity_url']) && $query['identity_url'] != 'http://') {
         $property = sprintf('%x', crc32($query['identity_url']));
         COM_clearSpeedlimit($_CONF['login_speedlimit'], 'openid');
         if (COM_checkSpeedlimit('openid', $_CONF['login_attempts'], $property) > 0) {
             displayLoginErrorAndAbort(82, $LANG12[26], $LANG04[112]);
         }
     }
     require_once $_CONF['path_system'] . 'classes/openidhelper.class.php';
     $consumer = new SimpleConsumer();
     $handler = new SimpleActionHandler($query, $consumer);
     if (isset($query['identity_url']) && $query['identity_url'] != 'http://') {
         $identity_url = $query['identity_url'];
         $ret = $consumer->find_identity_info($identity_url);
         if (!$ret) {
             COM_updateSpeedlimit('login');
             $property = sprintf('%x', crc32($query['identity_url']));
             COM_updateSpeedlimit('openid', $property);
             COM_errorLog('Unable to find an OpenID server for the identity URL ' . $identity_url);
             echo COM_refresh($_CONF['site_url'] . '/users.php?msg=89');
         } else {
             // Found identity server info.
             list($identity_url, $server_id, $server_url) = $ret;
             // Redirect the user-agent to the OpenID server
             // which we are requesting information from.
Beispiel #3
0
function dispatch()
{
    // generate a dictionary of arguments
    $query = formArgstoDict();
    // create consumer and handler objects
    $consumer = new SimpleConsumer();
    $handler = new SimpleActionHandler($query, $consumer);
    // extract identity url from arguments.  Will be null if absent from query.
    $identity_url = isset($query['identity_url']) ? $query['identity_url'] : null;
    if ($identity_url) {
        $ret = $consumer->find_identity_info($identity_url);
        if (!$ret) {
            setAlert(sprintf('Unable to find openid server for identity url %s', $identity_url));
        } else {
            // found identity server info
            list($identity_url, $server_id, $server_url) = $ret;
            // build trust root - this examines the script env and builds
            // based on your running location.  In practice this may be static.
            // You will likely want it to be your entire website, not just
            // this script.
            $trust_root = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
            // build url to application for use in creating return_to
            $app_url = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
            // create return_to url from app_url
            $return_to = $handler->createReturnTo($app_url, $identity_url);
            // handle the request
            $redirect_url = $consumer->handle_request($server_id, $server_url, $return_to, $trust_root);
            // redirect the user-agent to the server
            my_redirect($redirect_url);
        }
    } else {
        if (isset($query['openid.mode']) || isset($query['openid_mode'])) {
            // got a request from the server.  build a Request object and pass
            // it off to the consumer object.  OpendIDActionHandler handles
            // the various end cases (see above).
            $openid = $handler->getOpenID();
            $req = new ConsumerRequest($openid, $query, 'GET');
            $response = $consumer->handle_response($req);
            // let our SimpleActionHandler do the work
            $response->doAction($handler);
        }
    }
}