docker container is working
This commit is contained in:
@ -71,12 +71,14 @@ function curlHelper($url, $APIKey){
|
||||
// Handle cURL errors
|
||||
if ($response === false) {
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
// Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /var/www/html/index.php on line 79
|
||||
//curl_close($ch);
|
||||
throw new Exception("cURL error while calling API: {$error}");
|
||||
}
|
||||
// Check HTTP status code
|
||||
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
// Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /var/www/html/index.php on line 79
|
||||
//curl_close($ch);
|
||||
|
||||
if ($httpStatus !== 200) {
|
||||
throw new Exception("API returned HTTP status {$httpStatus} (expected 200).");
|
||||
@ -92,7 +94,7 @@ function curlHelper($url, $APIKey){
|
||||
|
||||
// Password Generator API Function
|
||||
function getStandardPasswordFromAPI($passType){
|
||||
$apiUrl = "http://localhost:8189/get_password";
|
||||
$apiUrl = "http://0.0.0.0:5000/get_password";
|
||||
// Build the query string and full URL
|
||||
$query = http_build_query(['pwd_index' => $passType]);
|
||||
$url = rtrim($apiUrl, '?') . '?' . $query;
|
||||
@ -101,7 +103,7 @@ function getStandardPasswordFromAPI($passType){
|
||||
|
||||
// Password Generator API Function for Custom Password
|
||||
function getCustomPasswordFromAPI($passType, $payload){
|
||||
$url = 'http://localhost:8189/custom_password';
|
||||
$url = 'http://0.0.0.0:5000/custom_password';
|
||||
|
||||
// Initialise a cURL handle
|
||||
$ch = curl_init($url);
|
||||
@ -159,7 +161,7 @@ function getCustomPasswordFromAPI($passType, $payload){
|
||||
|
||||
// Password Count API Function
|
||||
function getPasswordCountFromAPI(){
|
||||
$apiUrl = "http://localhost:8189/get_count";
|
||||
$apiUrl = "http://0.0.0.0:5000/get_count";
|
||||
// Build the query string and full URL
|
||||
$url = rtrim($apiUrl, '?') ;
|
||||
return curlHelper($url, "total_passwords");
|
||||
@ -248,7 +250,7 @@ $rating = passwordTest_strength($final);
|
||||
<strong>Matt-Cloud Password API</strong><p>
|
||||
To get passwords, you may:<p>
|
||||
<code>
|
||||
curl -s https://<?php echo $_SERVER['SERVER_NAME'] ?>/get_password?pwd_index=N<br>
|
||||
curl -s <?php echo (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $_SERVER['SERVER_NAME'] ?>/get_password?pwd_index=N<br>
|
||||
{<br>
|
||||
"password": "-`(UncoloredSwiftly2099"<br>
|
||||
}
|
||||
@ -256,7 +258,7 @@ $rating = passwordTest_strength($final);
|
||||
Where N is an integer 0,1, or 2 for now.<p>
|
||||
To get verbose passwords, you may:<p>
|
||||
<code>
|
||||
curl -s https://<?php echo $_SERVER['SERVER_NAME'] ?>/verbose_password?pwd_index=N<br>
|
||||
curl -s <?php echo (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $_SERVER['SERVER_NAME'] ?>/verbose_password?pwd_index=N<br>
|
||||
{<br>
|
||||
"descriptor": {<br>
|
||||
"description": "This simple password is in the following format: !Password123 - this pulls from a list of 1291 simple words.",<br>
|
||||
@ -269,7 +271,7 @@ $rating = passwordTest_strength($final);
|
||||
</code><p>
|
||||
To get custom passwords, you may:<p>
|
||||
<code>
|
||||
curl -X POST https://<?php echo $_SERVER['SERVER_NAME'] ?>/custom_password \ <br>
|
||||
curl -X POST <?php echo (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $_SERVER['SERVER_NAME'] ?>/custom_password \ <br>
|
||||
H "Content-Type: application/json" \ <br>
|
||||
d '{ <br>
|
||||
"w_min":5, <br>
|
||||
@ -284,14 +286,14 @@ $rating = passwordTest_strength($final);
|
||||
</code><p>
|
||||
To get the API password count (but why tho?), you may:<p>
|
||||
<code>
|
||||
curl -s https://<?php echo $_SERVER['SERVER_NAME'] ?>/get_count<br>
|
||||
curl -s <?php echo (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $_SERVER['SERVER_NAME'] ?>/get_count<br>
|
||||
{<br>
|
||||
"total_passwords": 10<br>
|
||||
}
|
||||
</code><p>
|
||||
To view the password descriptor, you may <br>
|
||||
<code>
|
||||
curl -s https://<?php echo $_SERVER['SERVER_NAME'] ?>/get_info<br>
|
||||
curl -s <?php echo (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $_SERVER['SERVER_NAME'] ?>/get_info<br>
|
||||
</code>
|
||||
This will return the entire JSON descriptor variable <br>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user