Sign in.

@param array $args Dict with keys: `uname`, `upass`.
@return array An array of the form:
@code
(array)[
(int errno),
(dict){
'uid': (int uid),
'uname': (string uname),
'token': (string token)
}
]
@endcode
965511
public function adm_login($args) {
		$this->init();
		$logger = $this->logger;

		if ($this->store_is_logged_in())
			return [AdminStoreError::USER_ALREADY_LOGGED_IN];

		if (!isset($args['post']))
			return [AdminStoreError::DATA_INCOMPLETE];
		if (!Common::check_idict($args['post'], ['uname', 'upass']))
			return [AdminStoreError::DATA_INCOMPLETE];
		extract($args['post']);

		$usalt = $this->store->query(
			"SELECT usalt FROM udata WHERE uname=? LIMIT 1",
			[$uname]);
		if (!$usalt)
			# user not found
			return [AdminStoreError::USER_NOT_FOUND];
		$usalt = $usalt['usalt'];

		$udata = $this->store_match_password($uname, $upass, $usalt);
		if (!$udata) {
			# wrong password
			$logger->warning(
				"Zapmin: login: wrong password: '$uname'.");
			return [AdminStoreError::WRONG_PASSWORD];
		}

		// generate token
		$token = $this->generate_secret(
			$upass . $usalt . time(), $usalt);

		$sid = $this->store->insert('usess', [
			'uid'   => $udata['uid'],
			'token' => $token,
		], 'sid');
		if ($this->dbtype == 'mysql') {
			// mysql has no parametrized default values, and can't
			// invoke trigger on currently inserted table
			$expire_at = $this->store->stmt_fragment('datetime', [
				'delta' => $this->expiration,
			]);
			$this->store->query_raw(sprintf(
				"UPDATE usess SET expire=(%s) WHERE sid='%s'",
				$expire_at, $sid));
		}

		// token must be used by the router; this is a subset
		// of return value of get_safe_user_data() so it needs
		// a re-request after signing in
		$logger->info("Zapmin: login: OK: '$uname'.");
		return [0, [
			'uid' => $udata['uid'],
			'uname' => $udata['uname'],
			'token' => $token,
		]];
	}
61617
protected function encodeContent(array $args) {
        $data = [];
        foreach ($args as $key => $item) {
            $data[] = sprintf('"%s":"%s"', $key, $item);
        }
        $arg = '{'.implode(',', $data).'}';
        if (!empty($this->encryptKey)
            && $this->encryptType == self::AES) {
            return (new Aes($this->encryptKey))->encrypt($arg);
        }
        return $arg;
    }
1067174
public function loginHeaderAccessManagement($args)
    {
        if (!$args) {
            return;
        }

        // Define defaults
        $configs = array_merge([
            'url'     => OL_ZEUS_HOME,
            'title'   => OL_ZEUS_NAME,
        ], $args);

        // Change login head URL
        add_filter('login_headerurl', function () use ($configs) {
            if (!empty($configs['url'])) {
                return $configs['url'];
            }
        });

        // Change login head title
        add_filter('login_headertitle', function () use ($configs) {
            if (!empty($configs['title'])) {
                return $configs['title'];
            }
        });
    }
1078759
public function token_callback_text( $args ) {
		$name = isset( static::$options[ $args['id'] ] ) ? esc_attr( static::$options[ $args['id'] ] ) : '';
		$type = isset( $args['token'] ) ? 'password' : 'text';
		?>
		<label for="<?php esc_attr( $args['id'] ); ?>">
			<input class="ghu-callback-text" type="<?php esc_attr_e( $type ); ?>" id="<?php esc_attr( $args['id'] ); ?>" name="github_updater[<?php esc_attr_e( $args['id'] ); ?>]" value="<?php esc_attr_e( $name ); ?>">
		</label>
		<?php
	}
751276
private function prepare($args)
    {
        $bindings = array();

        // Two parameters (key, value).
        if (count($args) == 2) {
            $bindings[$args[0]] = $args[1];
        }
        // Array of parameters.
        elseif (is_array($args[0])) {
            $bindings = $args[0];
        }

        return $bindings;
    }
981566
public function buildQueryString($args = array()) {
		$args = array_merge($args, array("token" => $this->token));
		
		$query = "";
		if (isset($args)) {
			while (list($key, $val) = each($args)) {
				if ( strlen($query) > 0 ) {
					$query .= "&";
				} else {
					$query .= "?";
				}
				$query .= $key . '=' . $val;
			}
		}
		return $query;
	}
1142145
public static function arguments($args)
    {
        $argList = '';

        // If its a string return it
        if (is_string($args)) {
            return $args;
        }

        // If its not an array, Houston, we have a problem
        if (!is_array($args)) {
            throw new InvalidArgumentException();
        }

        // Build the argument list
        foreach ($args as $arg => $val) {
            $argList .= ' ' . $arg;
            if (!empty($val)) {
                $argList .= ' ' . $val;
            }
        }

        return trim($argList);
    }
1273551
public static function signature($args = [])
	{
		$values = array_map(function ($v) {
			return is_string($v)
				? "'$v'"
				: (is_bool($v)
					? !! $v ? 'true' : 'false'
					: $v);
		}, $args);
		return '(' . implode(', ', $values) . ')';
	}
1091719
function parseExtensionArgs($args)
    {
        // preferred_auth_policies is a space-separated list of policy
        // URIs
        $this->preferred_auth_policies = array();

        $policies_str = Auth_OpenID::arrayGet($args, 'preferred_auth_policies');
        if ($policies_str) {
            foreach (explode(' ', $policies_str) as $uri) {
                if (!in_array($uri, $this->preferred_auth_policies)) {
                    $this->preferred_auth_policies[] = $uri;
                }
            }
        }

        // max_auth_age is base-10 integer number of seconds
        $max_auth_age_str = Auth_OpenID::arrayGet($args, 'max_auth_age');
        if ($max_auth_age_str) {
            $this->max_auth_age = Auth_OpenID::intval($max_auth_age_str);
        } else {
            $this->max_auth_age = null;
        }
    }
100907
private function resolveArgs(array $args)
    {
        $resolved = [];
        foreach ($args as $argDefinition) {
            switch ($argDefinition['type']) {
                case 'lookup':
                    $resolved[] = $this->lookupRecursive($argDefinition['item']);
                    break;
                case 'value':
                    $resolved[] = $argDefinition['item'];
                    break;
            }
        }

        return $resolved;
    }
180343
public function verify(array $args, $sign = null) {
        if (is_null($sign)) {
            $sign = $args[$this->signKey];
        }
        return $this->sign($args) === $sign;
    }
515806
public static function arguments(array $args) : array
    {
        putenv("CODGER_DRY=1");
        foreach ($args as $key => $value) {
            if ($value === '-w') {
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-o') {
                putenv("CODGER_OVERWRITE=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-d') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_DUMP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-s') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_SKIP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
        }
        return array_values($args);
    }
686914
protected function serializeArguments(array $args)
    {
        // first we have to sort the args by key to avoid that different orders
        // lead to different cache entries!
        ksort($args);

        $result = '';
        $invalidKeys = array('userid', 'apikey', 'keyid', 'vcode');
        foreach ($args as $key => $value) {
            $key   = trim($key);
            $value = trim($value);
            if (empty($value) || in_array($key, $invalidKeys)) {
                // ignore the invalid keys...
                continue;
            }
            $result .= ';' . $key . '=' . $value;
        }

        return $result;
    }
373422
public function buildQuery(array $args = []): string
	{
		$out = array_merge(
			$this->payment->getArgs(), // Arguments of the payment
			$args, // Optional helper arguments
			['signature' => $this->payment->getSignature()] // Signature
		);

		$str = [];
		/** @var string|int $val */
		foreach ($out as $key => $val) {
			$str[] = rawurlencode((string) $key) . '=' . rawurlencode((string) $val);
		}

		return implode('&', $str);
	}
1216852
protected function _sign($params = array()) {
    $query = "";
    if (isset($params['sign_mode']) && $params['sign_mode'] == 1) {
      unset($params['items']);
    }
    if (is_array($params) && !empty($params)) {
      ksort($params);
      $query = $this->_buildQuery($params);
    }
    return md5($query . $this->clientSecret);
  }
1033864
function getAccessToken($args = array()) {/*{{{*/
    $r = $this->oAuthRequest($this->accessTokenURL(), $args);
    //var_dump($r);
    $token = $this->oAuthParseResponse($r);
    $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
    return $token;
  }
122600
private function parseArgs($args) {
        $command = $action = null;
        $params = [];
        foreach ($args as $argument) {
            if ('-' != $argument[0])
                if (null === $command)
                    $command = $argument;
                elseif (null === $action)
                    $action = $argument;
                else
                    $this->alert('Invalid argument ' . $argument . '!', ['command' => $command, 'action' => $action, 'serverArguments' => $_SERVER['argv'], 'processedArguments' => $args]);
            else {
                $argument = substr($argument, 1); // supports both  one - or two - ( - / -- )
                if ('-' == $argument[0])
                    $argument = substr($argument, 1);

                $argument = explode('=', $argument, 2);
                $params[$argument[0]] = isset($argument[1]) ? $argument[1] : true;
            }
        }
        return [
            'command' => $command,
            'action' => $action,
            'params' => $params
        ];
    }