/** * @param integer $id Identyfikator maski * @return array */ public function getServiceMasks($ids) { $serviceModel = new WsServiceSms(); $ids = $ids === null ? $ids : array_filter($ids); $dict = new Base_Dictionary(); if (empty($ids)) { return $dict->setSource('mask')->getDictionary(); } $select = $serviceModel->select()->where("id IN (" . implode(',', $ids) . ")")->where("ghost = ?", 'FALSE'); $serviceRows = $serviceModel->fetchAll($select); foreach ($serviceRows as $key => $serviceRow) { if ($key == 0) { $masks = $serviceRow->getMasks(); } else { $maskTmp = $serviceRow->getMasks(); $masks = array_intersect($masks, $serviceRow->getMasks()); } } if (empty($masks)) { throw new Logic_Exception("Brak masek dla wskazanej usługi!"); } $dicEntry = $dict->setSource('mask')->getDictionary(); if (true === empty($dicEntry)) { throw new Logic_Exception("Brak wprowadzonych masek w aplikacji!"); } foreach ($masks as $maskId) { $available[$maskId] = $dicEntry[$maskId]; } return $available; }
public function getDependentServices() { $model = new WsServiceSms(); $select = $model->select()->setIntegrityCheck(false)->from(array('wss' => 'service_sms'), array('*'), 'ws')->joinLeft(array('smec' => 'multiinfo_error_config'), 'smec.service_id = wss.id', array(), 'sms')->where('wss.ghost = ?', 'false')->where('smec.dict_id = ?', $this->dict_id); $rowSet = $model->fetchAll($select); return $rowSet; }
public function getErrorConfig($code, $message, $service_id) { $sql = $this->select()->where("error_code ilike '?' ", intval($code))->where("service_id = ?", $service_id); if (null === ($data = $this->fetchRow($sql))) { $service = new WsServiceSms(); $serviceRow = $service->fetchRow('id = ' . $service_id); $this->createRow(array('error_message' => $message, 'error_code' => $code, 'service_id' => $service_id, 'operator' => $serviceRow->operator_id))->save(); $data = $this->fetchRow($sql); // return $this->findByCode($code, $serviceRow->operator_id, $service_id); } return $data; }
public function sendsmsAction() { $model = new WsServiceImport(); $messageModel = new WsServiceImportMessage(); $importToSend = $model->getImportToSend(); $servicesModel = new WsServiceSms(); $cfg = Zend_Registry::get('config'); while ($current = $importToSend->current()) { $services = Zend_Json::decode($current->services); $service = $servicesModel->getService($services[0]); $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $service->service_hash); $http = new Zend_Controller_Request_Http(); $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/'; $config['wsdl'] = $host . 'sms/?wsdl'; $sms = new SmsSoapClient($config); if (!$model->checkStatus($current->id)) { $importToSend->next(); $current = $importToSend->current(); } if ($importToSend->valid()) { switch ($current->file_type) { case 1: $sms->registerNumber($current->phone_number)->registerContent($current->sms_text); $response = $sms->send(); break; case 2: $tags = Zend_Json::decode($current->tags); $msg = $current->sms_text; if (!empty($tags)) { foreach ($tags as $key => $tag) { $msg = preg_replace("/<" . $key . ">/", $tag, $msg); } } $sms->registerNumber($current->phone_number)->registerContent($msg); $response = $sms->send(); break; case 3: $sms->registerNumber($current->phone_number)->registerContent($current->sms_text); $response = $sms->send(); break; } if (isset($response->errorCode)) { $messageModel->changeStatus($current->msg_id, $response->errorCode, Zend_Json::encode($response->smsId)); } else { $messageModel->changeStatus($current->msg_id, $response->faultcode, NULL, $response->faultstring); } $importToSend->next(); } } }
/** * 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; }
/** * 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)); } }
public function checkstatusAction() { $request = $this->getRequest(); $id = $this->_helper->IdConvert->hexToStr($request->getParam('id')); $data = array(); if (!empty($id)) { try { $model = new SmsStorageStatus(); $lastStatus = $model->getSmsBySmsStorage($id, true); if (isset($lastStatus[0])) { if ($lastStatus[0]['status_dict'] < 4 || $lastStatus[0]['status_dict'] == 8 || $lastStatus[0]['status_dict'] == 9) { $http = new Zend_Controller_Request_Http(); $ip = $http->getServer('SERVER_ADDR'); $serviceModel = new WsServiceSms(); $service = $serviceModel->getService($lastStatus[0]['ws_service_sms_id']); $sms = new Logic_Sms($service, $ip); if ($lastStatus[0]['ws_package_sms_id'] === NULL) { $sms->info($lastStatus[0]['smsid']); } else { $sms->packageinfo($lastStatus[0]['smsid']); } } } $data = $model->getSmsBySmsStorage($id); $paginator = new Base_Paginator(new Base_Paginator_Adapter_Array($data, array('RowClass' => 'Row_SmsStorageStatus'))); $this->view->paginator = $paginator; if ($lastStatus[0]['ws_package_sms_id'] === NULL) { $this->view->headers = array('smsid', 'status_dict', 'messagePriority', 'idProt', 'conectorId', 'encoding', 'smsType', 'validTo', 'delivNotifRequest', 'sendDate', 'lastStatusChange', 'created_at'); } else { $this->view->headers = array('smsid', 'status_dict', 'numberOfMessages', 'numberOfMessagesLeftToSent', 'created_at'); } } catch (Logic_Service_Exception $ex) { $this->_helper->redirector('index'); $this->_helper->messenger('error', 'Nie udało się pobrać statusu'); return; } } else { $this->_helper->messenger('error', 'Brak ID!'); $this->_helper->redirector('index'); return; } }