-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from VirgilSecurity/develop
Add VirgilAgent (v5.1.0)
- Loading branch information
Showing
11 changed files
with
182 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
vendor | ||
.env | ||
for-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* Copyright (C) 2015-2019 Virgil Security Inc. | ||
* Copyright (C) 2015-2019 Virgil Security Inc. | ||
* | ||
* All rights reserved. | ||
* | ||
|
@@ -35,25 +35,73 @@ | |
* Lead Maintainer: Virgil Security Inc. <[email protected]> | ||
*/ | ||
|
||
namespace Virgil\Http\VirgilAgent; | ||
|
||
/** | ||
* @return string | ||
* Class HttpVirgilAgent | ||
* @package Virgil\Http\Curl | ||
*/ | ||
function extension_helper() | ||
class HttpVirgilAgent | ||
{ | ||
$params = [ | ||
// php -v | ||
'PHP Version' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, | ||
// php-config --extension-dir | ||
'PHP Extension Dir' => PHP_EXTENSION_DIR, | ||
// php -i | grep System | ||
'OS Version' => PHP_OS, | ||
]; | ||
|
||
foreach ($params as $key => $value) { | ||
echo $key . ": " . $value . "\n"; | ||
/** | ||
* @var string | ||
*/ | ||
private $name = 'Virgil-agent'; | ||
/** | ||
* @var string | ||
*/ | ||
private $product = 'sdk'; | ||
/** | ||
* @var string | ||
*/ | ||
private $family = 'php'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
return true; | ||
} | ||
/** | ||
* @return string | ||
*/ | ||
public function getFormatString() | ||
{ | ||
$os = strtolower(php_uname('s')); | ||
return $this->product . ";" . $this->family . ";" . $os . ";" . $this->getVersion(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private function getVersion() | ||
{ | ||
$composerLock = 'composer.lock'; | ||
$packageName = 'virgil/crypto'; | ||
$version = 'unknown'; | ||
|
||
$path = __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR; | ||
|
||
extension_helper(); | ||
if(!is_dir($path) || !in_array($composerLock, scandir($path))) | ||
return $version; | ||
|
||
$composerLockFile = file_get_contents($path.$composerLock); | ||
$composerLockFileToArray = json_decode($composerLockFile); | ||
|
||
$packages = $composerLockFileToArray->packages; | ||
|
||
foreach ($packages as $package) { | ||
if($packageName == $package->name) { | ||
$version = $package->version; | ||
if('v'==$version[0]) { | ||
$version = ltrim($version, 'v'); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
return $version; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
$virgil_crypto_php = 'virgil_crypto_php'; | ||
|
||
$result = [ | ||
'VIRGIL_CRYPTO_PHP_EXTENSION' => $virgil_crypto_php, | ||
'IS_VIRGIL_CRYPTO_PHP_EXTENSION_LOADED' => extension_loaded($virgil_crypto_php), | ||
'OS' => PHP_OS, | ||
'PHP' => PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION, | ||
'PATH_TO_EXTENSIONS_DIR' => PHP_EXTENSION_DIR, | ||
'PATH_TO_PHP.INI' => php_ini_loaded_file(), | ||
]; | ||
|
||
var_dump($result); | ||
exit(); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.