コード例 #1
0
ファイル: Generic.php プロジェクト: knatorski/SMS
 /**
  * Walidacja poprawności parametrów
  * @param array $data
  */
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     $wsServiceSmsModel = new WsServiceSms();
     $wsServiceSmsRow = $wsServiceSmsModel->findOne($data['service_id']);
     foreach (array('crt', 'pem') as $type) {
         $this->getElement($type)->addFilter(new Zend_Filter_File_Rename(array('target' => $wsServiceSmsRow->service_login . ".{$type}")));
         $certFileName[$type] = $this->_receiveFiles($type);
     }
     try {
         Logic_Ws_Cert::isCertificateValid($certFileName['crt']);
     } catch (Exception $exc) {
         $this->getElement('crt')->addError($exc->getMessage());
         $isValid = false;
     }
     return $isValid;
 }
コード例 #2
0
ファイル: Cert.php プロジェクト: knatorski/SMS
 /**
  * Zapisuje pliki certyfikatów do docelowej lokalizacji.
  * @todo Dodać logowanie zmian na pliku, żeby było wiadomo kto i kiedy podmienił certyfikat
  * @param integer $idService
  * @param array $files
  */
 public function saveCertificateFiles($idService, $files)
 {
     $model = new WsServiceSms();
     $config = Zend_Registry::get('config');
     $dict = new Base_Dictionary();
     $wsServiceSmsRow = $model->findOne($idService);
     if (null === $wsServiceSmsRow) {
         throw new Exception("Cannot find service row!");
     }
     $fileName = $this->_generateFileName($wsServiceSmsRow->service_login);
     $operators = $dict->setSource('operator_gsm')->getDictionary();
     foreach ($files as $type => $file) {
         if (false === is_file($file)) {
             throw new Logic_Exception("Certificate files does not exists!");
         }
         $currentFilePath[$type] = $config['services'][$operators[$wsServiceSmsRow->operator_id]]['pathTo' . ucfirst($type)] . $fileName . ".{$type}";
         if (true === is_file($currentFilePath[$type])) {
             $this->_archiveCertificateFile($currentFilePath[$type]);
         }
         $movedFile = $this->_moveCertificateFile($file, $currentFilePath[$type]);
         $this->_saveCertificatesToDb($idService, $this->_getCrtFileInfo($movedFile));
     }
 }