Просмотр исходного кода

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

refactoring
Guillaume Bourgeois 5 лет назад
Родитель
Сommit
024f5ceeda
2 измененных файлов: 24 добавлений и 20 удалений
  1. +2
    -2
      common/config/main.php
  2. +22
    -18
      common/models/Producer.php

+ 2
- 2
common/config/main.php Просмотреть файл

@@ -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 Просмотреть файл

@@ -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] ;
}
}
}
}

Загрузка…
Отмена
Сохранить