This commit is contained in:
Manish Verma
2016-12-13 18:18:25 +05:30
parent fc98add11c
commit 2d8e640e9b
2314 changed files with 97798 additions and 75664 deletions

View File

@@ -7,10 +7,9 @@ use Config;
use Exception;
use Schema;
class LibraryController extends Controller
{
public static function getFileVersion()
{
class LibraryController extends Controller {
public static function getFileVersion() {
try {
$app = Config::get('app.version');
if ($app) {
@@ -23,8 +22,7 @@ class LibraryController extends Controller
}
}
public static function getDatabaseVersion()
{
public static function getDatabaseVersion() {
try {
$database = self::isDatabaseSetup();
if ($database == true) {
@@ -41,8 +39,7 @@ class LibraryController extends Controller
}
}
public static function isDatabaseSetup()
{
public static function isDatabaseSetup() {
try {
if (Schema::hasTable('settings_system')) {
return true;
@@ -52,30 +49,28 @@ class LibraryController extends Controller
}
}
public static function encryptByFaveoPublicKey($data)
{
public static function encryptByFaveoPublicKey($data) {
try {
$path = storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'public.key';
$path = storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public.key';
//dd($path);
$key_content = file_get_contents($path);
$public_key = openssl_get_publickey($key_content);
$encrypted = $e = null;
openssl_seal($data, $encrypted, $e, [$public_key]);
$encrypted = $e = NULL;
openssl_seal($data, $encrypted, $e, array($public_key));
$sealed_data = base64_encode($encrypted);
$envelope = base64_encode($e[0]);
$result = ['seal' => $sealed_data, 'envelope' => $envelope];
return json_encode($result);
} catch (Exception $ex) {
throw new Exception($ex->getMessage());
}
}
public static function decryptByFaveoPrivateKey($encrypted)
{
public static function decryptByFaveoPrivateKey($encrypted) {
try {
$encrypted = json_decode($encrypted);
if ($encrypted) {
@@ -83,12 +78,11 @@ class LibraryController extends Controller
$envelope = $encrypted->envelope;
$input = base64_decode($sealed_data);
$einput = base64_decode($envelope);
$path = storage_path('app'.DIRECTORY_SEPARATOR.'private.key');
$path = storage_path('app' . DIRECTORY_SEPARATOR . 'private.key');
$key_content = file_get_contents($path);
$private_key = openssl_get_privatekey($key_content);
$plaintext = null;
$plaintext = NULL;
openssl_open($input, $plaintext, $einput, $private_key);
return $plaintext;
}
} catch (Exception $ex) {
@@ -96,8 +90,8 @@ class LibraryController extends Controller
}
}
public static function _isCurl()
{
public static function _isCurl() {
return function_exists('curl_version');
}
}