ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
BigMath.php File Reference

Go to the source code of this file.

Data Structures

class  Auth_OpenID_MathLibrary
 
class  Auth_OpenID_BcMathWrapper
 
class  Auth_OpenID_GmpMathWrapper
 

Namespaces

 OpenID
 This module contains code for dealing with associations between consumers and servers.
 

Functions

 Auth_OpenID_math_extensions ()
 Define the supported extensions. More...
 
 Auth_OpenID_detectMathLibrary ($exts)
 Detect which (if any) math library is available. More...
 
 Auth_OpenID_getMathLib ()
 
 Auth_OpenID_setNoMathSupport ()
 
 Auth_OpenID_noMathSupport ()
 

Function Documentation

◆ Auth_OpenID_detectMathLibrary()

Auth_OpenID_detectMathLibrary (   $exts)

Detect which (if any) math library is available.

Definition at line 364 of file BigMath.php.

Referenced by Auth_OpenID_getMathLib().

365 {
366  $loaded = false;
367 
368  $hasDl = function_exists('dl');
369  foreach ($exts as $extension) {
370  if (extension_loaded($extension['extension'])) {
371  return $extension;
372  }
373  }
374 
375  return false;
376 }
+ Here is the caller graph for this function:

◆ Auth_OpenID_getMathLib()

Auth_OpenID_getMathLib ( )

Definition at line 400 of file BigMath.php.

References $result, Auth_OpenID_detectMathLibrary(), Auth_OpenID_math_extensions(), Auth_OpenID_noMathSupport(), and Auth_OpenID_setNoMathSupport().

Referenced by Auth_OpenID_DiffieHellmanSHA1ServerSession\answer(), Auth_OpenID_DiffieHellman\Auth_OpenID_DiffieHellman(), Auth_OpenID_include_init(), Auth_OpenID_DiffieHellmanSHA1ConsumerSession\extractSecret(), Auth_OpenID_DiffieHellmanSHA1ServerSession\getDH(), and Auth_OpenID_DiffieHellmanSHA1ConsumerSession\getRequest().

401 {
402  // The instance of Auth_OpenID_MathWrapper that we choose to
403  // supply will be stored here, so that subseqent calls to this
404  // method will return a reference to the same object.
405  static $lib = null;
406 
407  if (isset($lib)) {
408  return $lib;
409  }
410 
412  $null = null;
413  return $null;
414  }
415 
416  // If this method has not been called before, look at
417  // Auth_OpenID_math_extensions and try to find an extension that
418  // works.
420  if ($ext === false) {
421  $tried = array();
422  foreach (Auth_OpenID_math_extensions() as $extinfo) {
423  $tried[] = $extinfo['extension'];
424  }
425  $triedstr = implode(", ", $tried);
426 
428 
429  $result = null;
430  return $result;
431  }
432 
433  // Instantiate a new wrapper
434  $class = $ext['class'];
435  $lib = new $class();
436 
437  return $lib;
438 }
$result
Auth_OpenID_math_extensions()
Define the supported extensions.
Definition: BigMath.php:343
Auth_OpenID_detectMathLibrary($exts)
Detect which (if any) math library is available.
Definition: BigMath.php:364
Auth_OpenID_setNoMathSupport()
Definition: BigMath.php:440
Auth_OpenID_noMathSupport()
Definition: BigMath.php:447
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Auth_OpenID_math_extensions()

Auth_OpenID_math_extensions ( )

Define the supported extensions.

An extension array has keys 'modules', 'extension', and 'class'. 'modules' is an array of PHP module names which the loading code will attempt to load. These values will be suffixed with a library file extension (e.g. ".so"). 'extension' is the name of a PHP extension which will be tested before 'modules' are loaded. 'class' is the string name of a Auth_OpenID_MathWrapper subclass which should be instantiated if a given extension is present.

You can define new math library implementations and add them to this array.

Definition at line 343 of file BigMath.php.

References $result.

Referenced by Auth_OpenID_getMathLib().

344 {
345  $result = array();
346 
347  if (!defined('Auth_OpenID_BUGGY_GMP')) {
348  $result[] =
349  array('modules' => array('gmp', 'php_gmp'),
350  'extension' => 'gmp',
351  'class' => 'Auth_OpenID_GmpMathWrapper');
352  }
353 
354  $result[] = array('modules' => array('bcmath', 'php_bcmath'),
355  'extension' => 'bcmath',
356  'class' => 'Auth_OpenID_BcMathWrapper');
357 
358  return $result;
359 }
$result
+ Here is the caller graph for this function:

◆ Auth_OpenID_noMathSupport()

Auth_OpenID_noMathSupport ( )

Definition at line 447 of file BigMath.php.

Referenced by Auth_OpenID_getDefaultAssociationOrder(), and Auth_OpenID_getMathLib().

448 {
449  return defined('Auth_OpenID_NO_MATH_SUPPORT');
450 }
+ Here is the caller graph for this function:

◆ Auth_OpenID_setNoMathSupport()

Auth_OpenID_setNoMathSupport ( )

Definition at line 440 of file BigMath.php.

Referenced by Auth_OpenID_getMathLib(), and Auth_OpenID_include_init().

441 {
442  if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) {
443  define('Auth_OpenID_NO_MATH_SUPPORT', true);
444  }
445 }
+ Here is the caller graph for this function: