Selaa lähdekoodia

Vérification relatives à l'existence des fichiers de conf (payplug, mailjet)

dev
Guillaume Bourgeois 5 vuotta sitten
vanhempi
commit
024f5ceeda
2 muutettua tiedostoa jossa 24 lisäystä ja 20 poistoa
  1. +2
    -2
      common/config/main.php
  2. +22
    -18
      common/models/Producer.php

+ 2
- 2
common/config/main.php Näytä tiedosto

@@ -46,14 +46,14 @@ return [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => 'laboiteapain',
'name' => 'distrib',
'domain' => (($serverName != 'localhost') ? '.' : '') . Yii::getAlias('@domainName'),
'path' => '/',
]
],
'session' => [
'class' => 'yii\web\Session',
'name' => 'PHPLABOITEAPAINSESSID',
'name' => 'PHPDISTRIBSESSID',
'cookieParams' => [
'domain' => (($serverName != 'localhost') ? '.' : '') . Yii::getAlias('@domainName'),
'httpOnly' => true,

+ 22
- 18
common/models/Producer.php Näytä tiedosto

@@ -440,12 +440,14 @@ class Producer extends ActiveRecordCommon
*/
public function getSecretKeyPayplug()
{
$handle = fopen($this->getFilenameSecretKeyPayplug(), "r") ;
$filesize = filesize($this->getFilenameSecretKeyPayplug()) ;
if($handle && $filesize) {
$secretKey = fread($handle, $filesize);
fclose($handle);
return $secretKey ;
if(file_exists($this->getFilenameSecretKeyPayplug())) {
$handle = fopen($this->getFilenameSecretKeyPayplug(), "r") ;
$filesize = filesize($this->getFilenameSecretKeyPayplug()) ;
if($handle && $filesize) {
$secretKey = fread($handle, $filesize);
fclose($handle);
return $secretKey ;
}
}
return '' ;
@@ -454,18 +456,20 @@ class Producer extends ActiveRecordCommon
public function getApiKeyMailjet($type = 'private')
{
$filename = '../../common/config/mailjet/api.key' ;
$handle = fopen($filename, "r") ;
$filesize = filesize($filename) ;
if($handle && $filesize) {
$apiKeys = fread($handle, $filesize);
fclose($handle);
$apiKeysArray = explode(':', $apiKeys) ;
if(count($apiKeysArray) == 2) {
if($type == 'private') {
return $apiKeysArray[1] ;
}
else {
return $apiKeysArray[0] ;
if(file_exists($filename)) {
$handle = fopen($filename, "r") ;
$filesize = filesize($filename) ;
if($handle && $filesize) {
$apiKeys = fread($handle, $filesize);
fclose($handle);
$apiKeysArray = explode(':', $apiKeys) ;
if(count($apiKeysArray) == 2) {
if($type == 'private') {
return $apiKeysArray[1] ;
}
else {
return $apiKeysArray[0] ;
}
}
}
}

Loading…
Peruuta
Tallenna