Add phpdoc package header to some files.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to run config authentication (ie no authentication).
|
||||
*
|
||||
* @package phpMyAdmin-Auth-Config
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
* Thanks to Piotr Roszatycki <d3xter at users.sourceforge.net> and
|
||||
* Dan Wilson who built this patch for the Debian package.
|
||||
*
|
||||
* @package phpMyAdmin-Auth-Cookie
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
@@ -221,7 +222,7 @@ if (top != self) {
|
||||
// use fieldset, don't show doc link
|
||||
PMA_select_language(true, false);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<br />
|
||||
<!-- Login form -->
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* Set of functions used to run http authentication.
|
||||
* NOTE: Requires PHP loaded as a Apache module.
|
||||
*
|
||||
* @package phpMyAdmin-Auth-HTTP
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to run single signon authentication.
|
||||
*
|
||||
* @package phpMyAdmin-Auth-Signon
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Swekey
|
||||
*/
|
||||
|
||||
function Swekey_auth_check()
|
||||
{
|
||||
global $cfg;
|
||||
@@ -8,7 +11,7 @@ function Swekey_auth_check()
|
||||
if (! isset($_SESSION['SWEKEY'])) {
|
||||
$_SESSION['SWEKEY'] = array();
|
||||
}
|
||||
|
||||
|
||||
$_SESSION['SWEKEY']['ENABLED'] = (! empty($confFile) && file_exists($confFile));
|
||||
|
||||
// Load the swekey.conf file the first time
|
||||
@@ -17,21 +20,21 @@ function Swekey_auth_check()
|
||||
$_SESSION['SWEKEY']['VALID_SWEKEYS'] = array();
|
||||
$valid_swekeys = split("\n",@file_get_contents($confFile));
|
||||
foreach ($valid_swekeys as $line) {
|
||||
if (ereg("^[0-9A-F]{32}:.+$", $line) != false)
|
||||
{
|
||||
if (ereg("^[0-9A-F]{32}:.+$", $line) != false)
|
||||
{
|
||||
$items = explode(":", $line);
|
||||
if (count($items) == 2)
|
||||
$_SESSION['SWEKEY']['VALID_SWEKEYS'][$items[0]] = trim($items[1]);
|
||||
}
|
||||
$_SESSION['SWEKEY']['VALID_SWEKEYS'][$items[0]] = trim($items[1]);
|
||||
}
|
||||
else if (ereg("^[A-Z_]+=.*$", $line) != false) {
|
||||
$items = explode("=", $line);
|
||||
$_SESSION['SWEKEY']['CONF_'.trim($items[0])] = trim($items[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set default values for settings
|
||||
if (! isset($_SESSION['SWEKEY']['CONF_SERVER_CHECK']))
|
||||
$_SESSION['SWEKEY']['CONF_SERVER_CHECK'] = "";
|
||||
$_SESSION['SWEKEY']['CONF_SERVER_CHECK'] = "";
|
||||
if (! isset($_SESSION['SWEKEY']['CONF_SERVER_RNDTOKEN']))
|
||||
$_SESSION['SWEKEY']['CONF_SERVER_RNDTOKEN'] = "";
|
||||
if (! isset($_SESSION['SWEKEY']['CONF_SERVER_STATUS']))
|
||||
@@ -41,25 +44,25 @@ function Swekey_auth_check()
|
||||
if (! isset($_SESSION['SWEKEY']['CONF_ENABLE_TOKEN_CACHE']))
|
||||
$_SESSION['SWEKEY']['CONF_ENABLE_TOKEN_CACHE'] = true;
|
||||
if (! isset($_SESSION['SWEKEY']['CONF_DEBUG']))
|
||||
$_SESSION['SWEKEY']['CONF_DEBUG'] = false;
|
||||
$_SESSION['SWEKEY']['CONF_DEBUG'] = false;
|
||||
}
|
||||
|
||||
// check if a web key has been authenticated
|
||||
if ($_SESSION['SWEKEY']['ENABLED']) {
|
||||
if ($_SESSION['SWEKEY']['ENABLED']) {
|
||||
if (empty($_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY']))
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function Swekey_auth_error()
|
||||
{
|
||||
if (! isset($_SESSION['SWEKEY']))
|
||||
if (! isset($_SESSION['SWEKEY']))
|
||||
return null;
|
||||
|
||||
if (! $_SESSION['SWEKEY']['ENABLED'])
|
||||
if (! $_SESSION['SWEKEY']['ENABLED'])
|
||||
return null;
|
||||
|
||||
require_once './libraries/auth/swekey/authentication.inc.php';
|
||||
@@ -68,31 +71,31 @@ function Swekey_auth_error()
|
||||
<script>
|
||||
function Swekey_GetValidKey()
|
||||
{
|
||||
var valids = "<?php
|
||||
foreach ($_SESSION['SWEKEY']['VALID_SWEKEYS'] as $key => $value)
|
||||
var valids = "<?php
|
||||
foreach ($_SESSION['SWEKEY']['VALID_SWEKEYS'] as $key => $value)
|
||||
echo $key.',';
|
||||
?>";
|
||||
var connected_keys = Swekey_ListKeyIds().split(",");
|
||||
for (i in connected_keys)
|
||||
for (i in connected_keys)
|
||||
if (connected_keys[i] != null && connected_keys[i].length == 32)
|
||||
if (valids.indexOf(connected_keys[i]) >= 0)
|
||||
return connected_keys[i];
|
||||
|
||||
|
||||
|
||||
if (connected_keys.length > 0)
|
||||
if (connected_keys[0].length == 32)
|
||||
return "unknown_key_" + connected_keys[0];
|
||||
|
||||
|
||||
return "none";
|
||||
}
|
||||
|
||||
var key = Swekey_GetValidKey();
|
||||
|
||||
|
||||
function timedCheck()
|
||||
{
|
||||
if (key != Swekey_GetValidKey())
|
||||
{
|
||||
window.location.search = "?swekey_reset";
|
||||
window.location.search = "?swekey_reset";
|
||||
}
|
||||
else
|
||||
setTimeout("timedCheck()",1000);
|
||||
@@ -102,14 +105,14 @@ function Swekey_auth_error()
|
||||
</script>
|
||||
<?php
|
||||
|
||||
if (! empty($_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY']))
|
||||
if (! empty($_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY']))
|
||||
return null;
|
||||
|
||||
if (count($_SESSION['SWEKEY']['VALID_SWEKEYS']) == 0)
|
||||
return sprintf($GLOBALS['strSwekeyNoKeyId'], $GLOBALS['cfg']['Server']['auth_swekey_config']);
|
||||
if (count($_SESSION['SWEKEY']['VALID_SWEKEYS']) == 0)
|
||||
return sprintf($GLOBALS['strSwekeyNoKeyId'], $GLOBALS['cfg']['Server']['auth_swekey_config']);
|
||||
|
||||
require_once "./libraries/auth/swekey/swekey.php";
|
||||
|
||||
|
||||
Swekey_SetCheckServer($_SESSION['SWEKEY']['CONF_SERVER_CHECK']);
|
||||
Swekey_SetRndTokenServer($_SESSION['SWEKEY']['CONF_SERVER_RNDTOKEN']);
|
||||
Swekey_SetStatusServer($_SESSION['SWEKEY']['CONF_SERVER_STATUS']);
|
||||
@@ -121,7 +124,7 @@ function Swekey_auth_error()
|
||||
$caFile = __FILE__;
|
||||
$pos = strrpos($caFile, '/');
|
||||
if ($pos === false)
|
||||
$pos = strrpos($caFile, '\\'); // windows
|
||||
$pos = strrpos($caFile, '\\'); // windows
|
||||
$caFile = substr($caFile, 0, $pos + 1).'musbe-ca.crt';
|
||||
// echo "\n<!-- $caFile -->\n";
|
||||
// if (file_exists($caFile))
|
||||
@@ -131,10 +134,10 @@ function Swekey_auth_error()
|
||||
if (file_exists($caFile))
|
||||
Swekey_SetCAFile($caFile);
|
||||
else if (! empty($caFile) && (substr($_SESSION['SWEKEY']['CONF_SERVER_CHECK'], 0, 8) == "https://"))
|
||||
return "Internal Error: CA File $caFile not found";
|
||||
|
||||
return "Internal Error: CA File $caFile not found";
|
||||
|
||||
$result = null;
|
||||
parse_str($_SERVER['QUERY_STRING']);
|
||||
parse_str($_SERVER['QUERY_STRING']);
|
||||
if (isset($swekey_id)) {
|
||||
unset($_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY']);
|
||||
if (! isset($_SESSION['SWEKEY']['RND_TOKEN'])) {
|
||||
@@ -147,24 +150,24 @@ function Swekey_auth_error()
|
||||
if (! $res) {
|
||||
$result = $GLOBALS['strSwekeyAuthFailed'] . ' (' . Swekey_GetLastError() . ')';
|
||||
}
|
||||
else {
|
||||
else {
|
||||
$_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY'] = $swekey_id;
|
||||
$_SESSION['SWEKEY']['FORCE_USER'] = $_SESSION['SWEKEY']['VALID_SWEKEYS'][$swekey_id];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result = $GLOBALS['strSwekeyNoKey'];
|
||||
$result = $GLOBALS['strSwekeyNoKey'];
|
||||
if ($_SESSION['SWEKEY']['CONF_DEBUG'])
|
||||
{
|
||||
$result .= "<br>".$swekey_id;
|
||||
$result .= "<br>".$swekey_id;
|
||||
}
|
||||
unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file
|
||||
unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
unset($_SESSION['SWEKEY']);
|
||||
else
|
||||
unset($_SESSION['SWEKEY']);
|
||||
|
||||
$_SESSION['SWEKEY']['RND_TOKEN'] = Swekey_GetFastRndToken();
|
||||
if (strlen($_SESSION['SWEKEY']['RND_TOKEN']) != 64) {
|
||||
@@ -185,14 +188,14 @@ function Swekey_auth_error()
|
||||
if (url.indexOf("?") > 0)
|
||||
url = url.substr(0, url.indexOf("?"));
|
||||
Swekey_SetUnplugUrl(key, "pma_login", url + "?session_to_unset=<?php echo session_id();?>");
|
||||
var otp = Swekey_GetOtp(key, <?php echo '"'.$_SESSION['SWEKEY']['RND_TOKEN'].'"';?>);
|
||||
var otp = Swekey_GetOtp(key, <?php echo '"'.$_SESSION['SWEKEY']['RND_TOKEN'].'"';?>);
|
||||
window.location.search="?swekey_id=" + key + "&swekey_otp=" + otp;
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
return $GLOBALS['strSwekeyAuthenticating'];
|
||||
return $GLOBALS['strSwekeyAuthenticating'];
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -211,7 +214,7 @@ function Swekey_login($input_name, $input_go)
|
||||
|
||||
if (isset($_SESSION['SWEKEY']) && $_SESSION['SWEKEY']['ENABLED']) {
|
||||
echo '<script type="text/javascript">';
|
||||
if (empty($_SESSION['SWEKEY']['FORCE_USER']))
|
||||
if (empty($_SESSION['SWEKEY']['FORCE_USER']))
|
||||
echo 'var user = null;';
|
||||
else
|
||||
echo 'var user = "'.$_SESSION['SWEKEY']['FORCE_USER'].'";';
|
||||
@@ -221,7 +224,7 @@ function Swekey_login($input_name, $input_go)
|
||||
{
|
||||
window.open("http://phpmyadmin.net/auth_key");
|
||||
}
|
||||
|
||||
|
||||
var input_username = document.getElementById("<?php echo $input_name; ?>");
|
||||
var input_go = document.getElementById("<?php echo $input_go; ?>");
|
||||
var swekey_status = document.createElement('img');
|
||||
@@ -240,7 +243,7 @@ function Swekey_login($input_name, $input_go)
|
||||
input_username.value = user;
|
||||
}
|
||||
input_username.readOnly = true;
|
||||
|
||||
|
||||
if (input_username.nextSibling == null)
|
||||
input_username.parentNode.appendChild(swekey_status);
|
||||
else
|
||||
@@ -267,5 +270,5 @@ if (isset($_GET['swekey_reset']))
|
||||
{
|
||||
unset($_SESSION['SWEKEY']);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -1,16 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Library that provides common functions that are used to help integrating Swekey Authentication in a PHP web site
|
||||
* Library that provides common functions that are used to help integrating Swekey Authentication in a PHP web site
|
||||
* Version 1.0
|
||||
*
|
||||
*
|
||||
* History:
|
||||
* 1.2 Use curl (widely installed) to query the server
|
||||
* Fixed a possible tempfile race attack
|
||||
* Random token cache can now be disabled
|
||||
* 1.1 Added Swekey_HttpGet function that support faulty servers
|
||||
* Support for custom servers
|
||||
* 1.0 First release
|
||||
*
|
||||
* Random token cache can now be disabled
|
||||
* 1.1 Added Swekey_HttpGet function that support faulty servers
|
||||
* Support for custom servers
|
||||
* 1.0 First release
|
||||
*
|
||||
* @package Swekey
|
||||
*/
|
||||
|
||||
|
||||
@@ -24,11 +25,11 @@ define ("SWEKEY_ERR_INVALID_OTP",911); // The otp was not correct
|
||||
|
||||
/**
|
||||
* Those errors are considered as an attack and your site will be blacklisted during one minute
|
||||
* if you receive one of those errors
|
||||
* if you receive one of those errors
|
||||
*/
|
||||
define ("SWEKEY_ERR_BADLY_ENCODED_REQUEST",920);
|
||||
define ("SWEKEY_ERR_INVALID_RND_TOKEN",921);
|
||||
define ("SWEKEY_ERR_DEV_NOT_FOUND",922);
|
||||
define ("SWEKEY_ERR_BADLY_ENCODED_REQUEST",920);
|
||||
define ("SWEKEY_ERR_INVALID_RND_TOKEN",921);
|
||||
define ("SWEKEY_ERR_DEV_NOT_FOUND",922);
|
||||
|
||||
/**
|
||||
* Default values for configuration.
|
||||
@@ -40,7 +41,7 @@ define ('SWEKEY_DEFAULT_STATUS_SERVER', 'https://auth-status.musbe.net');
|
||||
/**
|
||||
* The last error of an operation is alway put in this global var
|
||||
*/
|
||||
|
||||
|
||||
global $gSwekeyLastError;
|
||||
$gSwekeyLastError = 0;
|
||||
|
||||
@@ -72,13 +73,13 @@ if (! isset($gSwekeyTokenCacheEnabled))
|
||||
|
||||
/**
|
||||
* Change the address of the Check server.
|
||||
* If $server is empty the default value 'http://auth-check.musbe.net' will be used
|
||||
* If $server is empty the default value 'http://auth-check.musbe.net' will be used
|
||||
*
|
||||
* @param server The protocol and hostname to use
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_SetCheckServer($server)
|
||||
{
|
||||
{
|
||||
global $gSwekeyCheckServer;
|
||||
if (empty($server))
|
||||
$gSwekeyCheckServer = SWEKEY_DEFAULT_CHECK_SERVER;
|
||||
@@ -88,13 +89,13 @@ function Swekey_SetCheckServer($server)
|
||||
|
||||
/**
|
||||
* Change the address of the Random Token Generator server.
|
||||
* If $server is empty the default value 'http://auth-rnd-gen.musbe.net' will be used
|
||||
* If $server is empty the default value 'http://auth-rnd-gen.musbe.net' will be used
|
||||
*
|
||||
* @param server The protocol and hostname to use
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_SetRndTokenServer($server)
|
||||
{
|
||||
{
|
||||
global $gSwekeyRndTokenServer;
|
||||
if (empty($server))
|
||||
$gSwekeyRndTokenServer = SWEKEY_DEFAULT_RND_SERVER;
|
||||
@@ -104,13 +105,13 @@ function Swekey_SetRndTokenServer($server)
|
||||
|
||||
/**
|
||||
* Change the address of the Satus server.
|
||||
* If $server is empty the default value 'http://auth-status.musbe.net' will be used
|
||||
* If $server is empty the default value 'http://auth-status.musbe.net' will be used
|
||||
*
|
||||
* @param server The protocol and hostname to use
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_SetStatusServer($server)
|
||||
{
|
||||
{
|
||||
global $gSwekeyStatusServer;
|
||||
if (empty($server))
|
||||
$gSwekeyStatusServer = SWEKEY_DEFAULT_STATUS_SERVER;
|
||||
@@ -125,21 +126,21 @@ function Swekey_SetStatusServer($server)
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_SetCAFile($cafile)
|
||||
{
|
||||
{
|
||||
global $gSwekeyCA;
|
||||
$gSwekeyCA = $cafile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the random token caching
|
||||
* Because everybody has full access to the cache file, it can be a DOS vulnerability
|
||||
* Because everybody has full access to the cache file, it can be a DOS vulnerability
|
||||
* So disable it if you are running in a non secure enviromnement
|
||||
*
|
||||
* @param $enable
|
||||
* @param $enable
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_EnableTokenCache($enable)
|
||||
{
|
||||
{
|
||||
global $gSwekeyTokenCacheEnabled;
|
||||
$gSwekeyTokenCacheEnabled = ! empty($enable);
|
||||
}
|
||||
@@ -147,31 +148,31 @@ function Swekey_EnableTokenCache($enable)
|
||||
|
||||
/**
|
||||
* Return the last error.
|
||||
*
|
||||
*
|
||||
* @return The Last Error
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_GetLastError()
|
||||
{
|
||||
{
|
||||
global $gSwekeyLastError;
|
||||
return $gSwekeyLastError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last result.
|
||||
*
|
||||
*
|
||||
* @return The Last Error
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_GetLastResult()
|
||||
{
|
||||
{
|
||||
global $gSwekeyLastResult;
|
||||
return $gSwekeyLastResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a synchronous request to the server.
|
||||
* This function manages timeout then will not block if one of the server is down
|
||||
* This function manages timeout then will not block if one of the server is down
|
||||
*
|
||||
* @param url The url to get
|
||||
* @param response_code The response code
|
||||
@@ -179,12 +180,12 @@ function Swekey_GetLastResult()
|
||||
* @access private
|
||||
*/
|
||||
function Swekey_HttpGet($url, &$response_code)
|
||||
{
|
||||
{
|
||||
global $gSwekeyLastError;
|
||||
$gSwekeyLastError = 0;
|
||||
global $gSwekeyLastResult;
|
||||
$gSwekeyLastResult = "<not set>";
|
||||
|
||||
|
||||
// use curl if available
|
||||
if (function_exists('curl_init'))
|
||||
{
|
||||
@@ -205,7 +206,7 @@ function Swekey_HttpGet($url, &$response_code)
|
||||
else
|
||||
error_log("SWEKEY_ERROR:Could not find CA file $gSwekeyCA getting $url");
|
||||
}
|
||||
|
||||
|
||||
curl_setopt($sess, CURLOPT_SSL_VERIFYHOST, '2');
|
||||
curl_setopt($sess, CURLOPT_SSL_VERIFYPEER, '2');
|
||||
curl_setopt($sess, CURLOPT_CONNECTTIMEOUT, '20');
|
||||
@@ -215,12 +216,12 @@ function Swekey_HttpGet($url, &$response_code)
|
||||
{
|
||||
curl_setopt($sess, CURLOPT_CONNECTTIMEOUT, '3');
|
||||
curl_setopt($sess, CURLOPT_TIMEOUT, '5');
|
||||
}
|
||||
|
||||
curl_setopt($sess, CURLOPT_RETURNTRANSFER, '1');
|
||||
}
|
||||
|
||||
curl_setopt($sess, CURLOPT_RETURNTRANSFER, '1');
|
||||
$res=curl_exec($sess);
|
||||
$response_code = curl_getinfo($sess, CURLINFO_HTTP_CODE);
|
||||
$curlerr = curl_error($sess);
|
||||
$curlerr = curl_error($sess);
|
||||
curl_close($sess);
|
||||
|
||||
if ($response_code == 200)
|
||||
@@ -229,7 +230,7 @@ function Swekey_HttpGet($url, &$response_code)
|
||||
return $res;
|
||||
}
|
||||
|
||||
if (! empty($response_code))
|
||||
if (! empty($response_code))
|
||||
{
|
||||
$gSwekeyLastError = $response_code;
|
||||
error_log("SWEKEY_ERROR:Error $gSwekeyLastError ($curlerr) getting $url");
|
||||
@@ -237,41 +238,41 @@ function Swekey_HttpGet($url, &$response_code)
|
||||
}
|
||||
|
||||
$response_code = 408; // Request Timeout
|
||||
$gSwekeyLastError = $response_code;
|
||||
$gSwekeyLastError = $response_code;
|
||||
error_log("SWEKEY_ERROR:Error $curlerr getting $url");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// use pecl_http if available
|
||||
if (class_exists('HttpRequest'))
|
||||
{
|
||||
// retry if one of the server is down
|
||||
// retry if one of the server is down
|
||||
for ($num=1; $num <= 3; $num++ )
|
||||
{
|
||||
$r = new HttpRequest($url);
|
||||
$options = array('timeout' => '3');
|
||||
|
||||
|
||||
if (substr($url,0, 6) == "https:")
|
||||
{
|
||||
$sslOptions = array();
|
||||
$sslOptions = array();
|
||||
$sslOptions['verifypeer'] = true;
|
||||
$sslOptions['verifyhost'] = true;
|
||||
|
||||
$capath = __FILE__;
|
||||
$name = strrchr($capath, '/');
|
||||
if (empty($name)) // windows
|
||||
$name = strrchr($capath, '\\');
|
||||
$capath = substr($capath, 0, strlen($capath) - strlen($name) + 1).'musbe-ca.crt';
|
||||
|
||||
$name = strrchr($capath, '\\');
|
||||
$capath = substr($capath, 0, strlen($capath) - strlen($name) + 1).'musbe-ca.crt';
|
||||
|
||||
if (! empty($gSwekeyCA))
|
||||
$sslOptions['cainfo'] = $gSwekeyCA;
|
||||
|
||||
$options['ssl'] = $sslOptions;
|
||||
|
||||
$options['ssl'] = $sslOptions;
|
||||
}
|
||||
|
||||
$r->setOptions($options);
|
||||
|
||||
// try
|
||||
|
||||
// try
|
||||
{
|
||||
$reply = $r->send();
|
||||
$res = $reply->getBody();
|
||||
@@ -287,19 +288,19 @@ function Swekey_HttpGet($url, &$response_code)
|
||||
|
||||
$gSwekeyLastResult = $res;
|
||||
return $res;
|
||||
}
|
||||
// catch (HttpException $e)
|
||||
}
|
||||
// catch (HttpException $e)
|
||||
// {
|
||||
// error_log("SWEKEY_WARNING:HttpException ".$e." getting ".$url);
|
||||
// }
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
$response_code = 408; // Request Timeout
|
||||
$gSwekeyLastError = $response_code;
|
||||
$gSwekeyLastError = $response_code;
|
||||
error_log("SWEKEY_ERROR:Error ".$gSwekeyLastError." getting ".$url);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
global $http_response_header;
|
||||
$res = @file_get_contents($url);
|
||||
$response_code = substr($http_response_header[0], 9, 3); //HTTP/1.0
|
||||
@@ -308,15 +309,15 @@ function Swekey_HttpGet($url, &$response_code)
|
||||
$gSwekeyLastResult = $res;
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
$gSwekeyLastError = $response_code;
|
||||
error_log("SWEKEY_ERROR:Error ".$response_code." getting ".$url);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Random Token from a Token Server
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* You should better use Swekey_GetFastRndToken() for performance
|
||||
* @access public
|
||||
*/
|
||||
@@ -324,26 +325,26 @@ function Swekey_GetRndToken()
|
||||
{
|
||||
global $gSwekeyRndTokenServer;
|
||||
return Swekey_HttpGet($gSwekeyRndTokenServer.'/FULL-RND-TOKEN', $response_code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Half Random Token from a Token Server
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* Use this value if you want to make your own Swekey_GetFastRndToken()
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* Use this value if you want to make your own Swekey_GetFastRndToken()
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_GetHalfRndToken()
|
||||
{
|
||||
global $gSwekeyRndTokenServer;
|
||||
return Swekey_HttpGet($gSwekeyRndTokenServer.'/HALF-RND-TOKEN', $response_code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Half Random Token
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* This function get a new random token and reuse it.
|
||||
* Get a Half Random Token
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* This function get a new random token and reuse it.
|
||||
* Token are refetched from the server only once every 30 seconds.
|
||||
* You should always use this function to get half random token.
|
||||
* You should always use this function to get half random token.
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_GetFastHalfRndToken()
|
||||
@@ -357,7 +358,7 @@ function Swekey_GetFastHalfRndToken()
|
||||
if (isset($_SESSION['rnd-token-date']))
|
||||
if (time() - $_SESSION['rnd-token-date'] < 30)
|
||||
$res = $_SESSION['rnd-token'];
|
||||
|
||||
|
||||
// If not we try to get it from a temp file (PHP >= 5.2.1 only)
|
||||
if (strlen($res) != 32 && $gSwekeyTokenCacheEnabled)
|
||||
{
|
||||
@@ -369,7 +370,7 @@ function Swekey_GetFastHalfRndToken()
|
||||
if ($modif != false)
|
||||
if (time() - $modif < 30)
|
||||
{
|
||||
$res = @file_get_contents($cachefile);
|
||||
$res = @file_get_contents($cachefile);
|
||||
if (strlen($res) != 32)
|
||||
$res = "";
|
||||
else
|
||||
@@ -378,9 +379,9 @@ function Swekey_GetFastHalfRndToken()
|
||||
$_SESSION['rnd-token-date'] = $modif;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we don't have a valid RT here we have to get it from the server
|
||||
if (strlen($res) != 32)
|
||||
{
|
||||
@@ -394,29 +395,29 @@ function Swekey_GetFastHalfRndToken()
|
||||
$file = fopen($cachefile , "x");
|
||||
if ($file != FALSE)
|
||||
{
|
||||
@fwrite($file, $res);
|
||||
@fwrite($file, $res);
|
||||
@fclose($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $res."00000000000000000000000000000000";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Random Token
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* This function generates a unique random token for each call but call the
|
||||
* Get a Random Token
|
||||
* The RT is a 64 vhars hexadecimal value
|
||||
* This function generates a unique random token for each call but call the
|
||||
* server only once every 30 seconds.
|
||||
* You should always use this function to get random token.
|
||||
* You should always use this function to get random token.
|
||||
* @access public
|
||||
*/
|
||||
function Swekey_GetFastRndToken()
|
||||
{
|
||||
$res = Swekey_GetFastHalfRndToken();
|
||||
if (strlen($res) == 64)
|
||||
return substr($res, 0, 32).strtoupper(md5("Musbe Authentication Key" + mt_rand() + date(DATE_ATOM)));
|
||||
|
||||
return substr($res, 0, 32).strtoupper(md5("Musbe Authentication Key" + mt_rand() + date(DATE_ATOM)));
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -435,11 +436,11 @@ function Swekey_CheckOtp($id, $rt, $otp)
|
||||
global $gSwekeyCheckServer;
|
||||
$res = Swekey_HttpGet($gSwekeyCheckServer.'/CHECK-OTP/'.$id.'/'.$rt.'/'.$otp, $response_code);
|
||||
return $response_code == 200 && $res == "OK";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Values that are associated with a key.
|
||||
* The following values can be returned by the Swekey_GetStatus() function
|
||||
* The following values can be returned by the Swekey_GetStatus() function
|
||||
*/
|
||||
define ("SWEKEY_STATUS_OK",0);
|
||||
define ("SWEKEY_STATUS_NOT_FOUND",1); // The key does not exist in the db
|
||||
@@ -452,7 +453,7 @@ define ("SWEKEY_STATUS_UNKOWN",201); // We could not connect to the authentica
|
||||
|
||||
/**
|
||||
* Values that are associated with a key.
|
||||
* The Javascript Api can also return the following values
|
||||
* The Javascript Api can also return the following values
|
||||
*/
|
||||
define ("SWEKEY_STATUS_REPLACED",100); // This key has been replaced by a backup key
|
||||
define ("SWEKEY_STATUS_BACKUP_KEY",101); // This key is a backup key that is not activated yet
|
||||
@@ -460,7 +461,7 @@ define ("SWEKEY_STATUS_NOTPLUGGED",200); // This key is not plugged in the compu
|
||||
|
||||
|
||||
/**
|
||||
* Return the text corresponding to the integer status of a key
|
||||
* Return the text corresponding to the integer status of a key
|
||||
*
|
||||
* @param status The status
|
||||
* @return The text corresponding to the status
|
||||
@@ -483,10 +484,10 @@ function Swekey_GetStatusStr($status)
|
||||
case SWEKEY_STATUS_UNKOWN : return 'Unknow Status, could not connect to the authentication server';
|
||||
}
|
||||
return 'unknown status '.$status;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If your web site requires a key to login you should check that the key
|
||||
* If your web site requires a key to login you should check that the key
|
||||
* is still valid (has not been lost or stolen) before requiring it.
|
||||
* A key can be authenticated only if its status is SWEKEY_STATUS_OK
|
||||
* @param id The id of the swekey
|
||||
@@ -499,8 +500,8 @@ function Swekey_GetStatus($id)
|
||||
$res = Swekey_HttpGet($gSwekeyStatusServer.'/GET-STATUS/'.$id, $response_code);
|
||||
if ($response_code == 200)
|
||||
return intval($res);
|
||||
|
||||
|
||||
return SWEKEY_STATUS_UNKOWN;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to build NHibernate dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-Codegen
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -269,7 +270,7 @@ class TableProperty
|
||||
}
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
|
||||
function handleNHibernateXMLBody($db, $table, $crlf)
|
||||
{
|
||||
$lines=array();
|
||||
@@ -295,7 +296,7 @@ class TableProperty
|
||||
$lines[]="</hibernate-mapping>";
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
|
||||
function cgGetOption($optionName)
|
||||
{
|
||||
global $what;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @package phpMyAdmin-Export-CSV
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-CSV
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-HTMLExcel
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-HTMLWord
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to build dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-Latex
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
* Set of functions used to build OpenDocument Spreadsheet dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-ODS
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
* Set of functions used to build OpenDocument Text dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-ODT
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Produce a PDF report (export) from a query
|
||||
*
|
||||
* @package phpMyAdmin-Export-PDF
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -292,7 +293,7 @@ class PMA_PDF extends TCPDF
|
||||
}
|
||||
}
|
||||
|
||||
// loop through the data; any column whose contents
|
||||
// loop through the data; any column whose contents
|
||||
// is greater than the column size is resized
|
||||
/**
|
||||
* @todo force here a LIMIT to avoid reading all rows
|
||||
|
@@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Set of functions used to build SQL dumps of tables
|
||||
*
|
||||
* @package phpMyAdmin-Export-SQL
|
||||
* @version $Id$
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
@@ -244,13 +245,13 @@ function PMA_exportHeader()
|
||||
// so that a utility like the mysql client can interpret
|
||||
// the file correctly
|
||||
if (isset($GLOBALS['charset_of_file']) && isset($mysql_charset_map[$GLOBALS['charset_of_file']])) {
|
||||
// $cfg['AllowAnywhereRecoding'] was true so we got a charset from
|
||||
// $cfg['AllowAnywhereRecoding'] was true so we got a charset from
|
||||
// the export dialog
|
||||
$set_names = $mysql_charset_map[$GLOBALS['charset_of_file']];
|
||||
} else {
|
||||
// by default we use the connection charset
|
||||
$set_names = $mysql_charset_map[$GLOBALS['charset']];
|
||||
}
|
||||
$set_names = $mysql_charset_map[$GLOBALS['charset']];
|
||||
}
|
||||
$head .= $crlf
|
||||
. '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;' . $crlf
|
||||
. '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;' . $crlf
|
||||
@@ -350,7 +351,7 @@ function PMA_exportDBFooter($db)
|
||||
}
|
||||
|
||||
if ($procedure_names) {
|
||||
$text .=
|
||||
$text .=
|
||||
PMA_exportComment()
|
||||
. PMA_exportComment($GLOBALS['strProcedures'])
|
||||
. PMA_exportComment();
|
||||
@@ -358,13 +359,13 @@ function PMA_exportDBFooter($db)
|
||||
foreach($procedure_names as $procedure_name) {
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$text .= 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($procedure_name) . $delimiter . $crlf;
|
||||
}
|
||||
}
|
||||
$text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
|
||||
}
|
||||
}
|
||||
|
||||
if ($function_names) {
|
||||
$text .=
|
||||
$text .=
|
||||
PMA_exportComment()
|
||||
. PMA_exportComment($GLOBALS['strFunctions'])
|
||||
. PMA_exportComment();
|
||||
@@ -372,13 +373,13 @@ function PMA_exportDBFooter($db)
|
||||
foreach($function_names as $function_name) {
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$text .= 'DROP FUNCTION IF EXISTS ' . PMA_backquote($function_name) . $delimiter . $crlf;
|
||||
}
|
||||
}
|
||||
$text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf;
|
||||
}
|
||||
}
|
||||
|
||||
if ($event_names) {
|
||||
$text .=
|
||||
$text .=
|
||||
PMA_exportComment()
|
||||
. PMA_exportComment($GLOBALS['strEvents'])
|
||||
. PMA_exportComment();
|
||||
@@ -386,7 +387,7 @@ function PMA_exportDBFooter($db)
|
||||
foreach($event_names as $event_name) {
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$text .= 'DROP EVENT ' . PMA_backquote($event_name) . $delimiter . $crlf;
|
||||
}
|
||||
}
|
||||
$text .= PMA_DBI_get_definition($db, 'EVENT', $event_name) . $delimiter . $crlf . $crlf;
|
||||
}
|
||||
}
|
||||
@@ -442,7 +443,7 @@ function PMA_getTableDefStandIn($db, $view, $crlf) {
|
||||
* @param string the end of line sequence
|
||||
* @param string the url to go back in case of error
|
||||
* @param boolean whether to include creation/update/check dates
|
||||
* @param boolean whether to add semicolon and end-of-line at the end
|
||||
* @param boolean whether to add semicolon and end-of-line at the end
|
||||
*
|
||||
* @return string resulting schema
|
||||
*
|
||||
@@ -844,7 +845,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
// a possible error: the table has crashed
|
||||
$tmp_error = PMA_DBI_getError();
|
||||
if ($tmp_error) {
|
||||
return PMA_exportOutputHandler(PMA_exportComment($GLOBALS['strInUse'] . ' (' . $tmp_error . ')'));
|
||||
return PMA_exportOutputHandler(PMA_exportComment($GLOBALS['strInUse'] . ' (' . $tmp_error . ')'));
|
||||
}
|
||||
|
||||
if ($result != FALSE) {
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Sample export to Texy! text.
|
||||
* Export to Texy! text.
|
||||
*
|
||||
* @package phpMyAdmin-Export-Texy
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* Set of functions used to build XLS dumps of tables
|
||||
*
|
||||
* @version $Id$
|
||||
* @package phpMyAdmin-Export-XLS
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* Set of functions used to build YAML dumps of tables
|
||||
*
|
||||
* @version $Id$
|
||||
* @package phpMyAdmin-Export-YAML
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
|
Reference in New Issue
Block a user