Parcourir la source

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

dev
Guillaume Bourgeois il y a 5 ans
Parent
révision
024f5ceeda
2 fichiers modifiés avec 24 ajouts et 20 suppressions
  1. +2
    -2
      common/config/main.php
  2. +22
    -18
      common/models/Producer.php

+ 2
- 2
common/config/main.php Voir le fichier

@@ -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 Voir le fichier

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

Chargement…
Annuler
Enregistrer