Browse Source

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

dev
Guillaume Bourgeois 5 years ago
parent
commit
024f5ceeda
2 changed files with 24 additions and 20 deletions
  1. +2
    -2
      common/config/main.php
  2. +22
    -18
      common/models/Producer.php

+ 2
- 2
common/config/main.php View File

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

+ 22
- 18
common/models/Producer.php View File

*/ */
public function getSecretKeyPayplug() 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 '' ; return '' ;
public function getApiKeyMailjet($type = 'private') public function getApiKeyMailjet($type = 'private')
{ {
$filename = '../../common/config/mailjet/api.key' ; $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…
Cancel
Save