diff --git a/src/Controller/ElopageBuysController.php b/src/Controller/ElopageBuysController.php
new file mode 100644
index 000000000..725700cd8
--- /dev/null
+++ b/src/Controller/ElopageBuysController.php
@@ -0,0 +1,119 @@
+paginate = [
+ 'contain' => ['ElopageUsers', 'AffiliatePrograms', 'Publishers', 'Orders', 'Products'],
+ ];
+ $elopageBuys = $this->paginate($this->ElopageBuys);
+
+ $this->set(compact('elopageBuys'));
+ }
+
+ /**
+ * View method
+ *
+ * @param string|null $id Elopage Buy id.
+ * @return \Cake\Http\Response|null
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
+ */
+ public function view($id = null)
+ {
+ $elopageBuy = $this->ElopageBuys->get($id, [
+ 'contain' => ['ElopageUsers', 'AffiliatePrograms', 'Publishers', 'Orders', 'Products'],
+ ]);
+
+ $this->set('elopageBuy', $elopageBuy);
+ }
+
+ /**
+ * Add method
+ *
+ * @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
+ */
+ public function add()
+ {
+ $elopageBuy = $this->ElopageBuys->newEntity();
+ if ($this->request->is('post')) {
+ $elopageBuy = $this->ElopageBuys->patchEntity($elopageBuy, $this->request->getData());
+ if ($this->ElopageBuys->save($elopageBuy)) {
+ $this->Flash->success(__('The elopage buy has been saved.'));
+
+ return $this->redirect(['action' => 'index']);
+ }
+ $this->Flash->error(__('The elopage buy could not be saved. Please, try again.'));
+ }
+ $elopageUsers = $this->ElopageBuys->ElopageUsers->find('list', ['limit' => 200]);
+ $affiliatePrograms = $this->ElopageBuys->AffiliatePrograms->find('list', ['limit' => 200]);
+ $publishers = $this->ElopageBuys->Publishers->find('list', ['limit' => 200]);
+ $orders = $this->ElopageBuys->Orders->find('list', ['limit' => 200]);
+ $products = $this->ElopageBuys->Products->find('list', ['limit' => 200]);
+ $this->set(compact('elopageBuy', 'elopageUsers', 'affiliatePrograms', 'publishers', 'orders', 'products'));
+ }
+
+ /**
+ * Edit method
+ *
+ * @param string|null $id Elopage Buy id.
+ * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
+ */
+ public function edit($id = null)
+ {
+ $elopageBuy = $this->ElopageBuys->get($id, [
+ 'contain' => [],
+ ]);
+ if ($this->request->is(['patch', 'post', 'put'])) {
+ $elopageBuy = $this->ElopageBuys->patchEntity($elopageBuy, $this->request->getData());
+ if ($this->ElopageBuys->save($elopageBuy)) {
+ $this->Flash->success(__('The elopage buy has been saved.'));
+
+ return $this->redirect(['action' => 'index']);
+ }
+ $this->Flash->error(__('The elopage buy could not be saved. Please, try again.'));
+ }
+ $elopageUsers = $this->ElopageBuys->ElopageUsers->find('list', ['limit' => 200]);
+ $affiliatePrograms = $this->ElopageBuys->AffiliatePrograms->find('list', ['limit' => 200]);
+ $publishers = $this->ElopageBuys->Publishers->find('list', ['limit' => 200]);
+ $orders = $this->ElopageBuys->Orders->find('list', ['limit' => 200]);
+ $products = $this->ElopageBuys->Products->find('list', ['limit' => 200]);
+ $this->set(compact('elopageBuy', 'elopageUsers', 'affiliatePrograms', 'publishers', 'orders', 'products'));
+ }
+
+ /**
+ * Delete method
+ *
+ * @param string|null $id Elopage Buy id.
+ * @return \Cake\Http\Response|null Redirects to index.
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
+ */
+ public function delete($id = null)
+ {
+ $this->request->allowMethod(['post', 'delete']);
+ $elopageBuy = $this->ElopageBuys->get($id);
+ if ($this->ElopageBuys->delete($elopageBuy)) {
+ $this->Flash->success(__('The elopage buy has been deleted.'));
+ } else {
+ $this->Flash->error(__('The elopage buy could not be deleted. Please, try again.'));
+ }
+
+ return $this->redirect(['action' => 'index']);
+ }
+}
diff --git a/src/Controller/TransactionsController.php b/src/Controller/TransactionsController.php
index f2c049403..afaf552f3 100644
--- a/src/Controller/TransactionsController.php
+++ b/src/Controller/TransactionsController.php
@@ -166,17 +166,23 @@ class TransactionsController extends AppController
echo "exception: ";
var_dump($e);
}
- $transactionBase64 = base64_encode($transaction->serializeToString());
- //echo "base64:
$transactionBase64
";
-
- $result = $this->JsonRpcRequestClient->request('puttransaction', [
- 'group' => 'd502c4254defe1842d71c484dc35f56983ce938e3c22058795c7520b62ab9123',
- 'transaction' => $transactionBase64
- ]);
-
- $timeUsed = microtime(true) - $startTime;
- $result['timeUsed'] = $timeUsed;
- return $this->returnJson($result);
+ if(is_array($transaction)) {
+ $timeUsed = microtime(true) - $startTime;
+ $transaction['timeUsed'] = $timeUsed;
+ return $this->returnJson($transaction);
+ } else {
+ $transactionBase64 = base64_encode($transaction->serializeToString());
+ //echo "base64:
$transactionBase64
";
+
+ $result = $this->JsonRpcRequestClient->request('puttransaction', [
+ 'group' => 'd502c4254defe1842d71c484dc35f56983ce938e3c22058795c7520b62ab9123',
+ 'transaction' => $transactionBase64
+ ]);
+
+ $timeUsed = microtime(true) - $startTime;
+ $result['timeUsed'] = $timeUsed;
+ return $this->returnJson($result);
+ }
//return $this->returnJson(['state' => 'success', 'timeUsed' => $timeUsed]);
}
$timeUsed = microtime(true) - $startTime;
diff --git a/src/Model/Entity/ElopageBuy.php b/src/Model/Entity/ElopageBuy.php
new file mode 100644
index 000000000..eca2f760b
--- /dev/null
+++ b/src/Model/Entity/ElopageBuy.php
@@ -0,0 +1,57 @@
+ true,
+ 'affiliate_program_id' => true,
+ 'publisher_id' => true,
+ 'order_id' => true,
+ 'product_id' => true,
+ 'product_price' => true,
+ 'payer_email' => true,
+ 'publisher_email' => true,
+ 'payed' => true,
+ 'success_date' => true,
+ 'event' => true,
+ 'elopage_user' => true,
+ 'affiliate_program' => true,
+ 'publisher' => true,
+ 'order' => true,
+ 'product' => true,
+ ];
+}
diff --git a/src/Model/Table/ElopageBuysTable.php b/src/Model/Table/ElopageBuysTable.php
new file mode 100644
index 000000000..065bb636f
--- /dev/null
+++ b/src/Model/Table/ElopageBuysTable.php
@@ -0,0 +1,140 @@
+setTable('elopage_buys');
+ $this->setDisplayField('id');
+ $this->setPrimaryKey('id');
+
+ $this->belongsTo('ElopageUsers', [
+ 'foreignKey' => 'elopage_user_id',
+ 'joinType' => 'INNER',
+ ]);
+ $this->belongsTo('AffiliatePrograms', [
+ 'foreignKey' => 'affiliate_program_id',
+ 'joinType' => 'INNER',
+ ]);
+ $this->belongsTo('Publishers', [
+ 'foreignKey' => 'publisher_id',
+ 'joinType' => 'INNER',
+ ]);
+ $this->belongsTo('Orders', [
+ 'foreignKey' => 'order_id',
+ 'joinType' => 'INNER',
+ ]);
+ $this->belongsTo('Products', [
+ 'foreignKey' => 'product_id',
+ 'joinType' => 'INNER',
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->integer('id')
+ ->allowEmptyString('id', null, 'create');
+
+ $validator
+ ->integer('product_price')
+ ->requirePresence('product_price', 'create')
+ ->notEmptyString('product_price');
+
+ $validator
+ ->scalar('payer_email')
+ ->maxLength('payer_email', 255)
+ ->requirePresence('payer_email', 'create')
+ ->notEmptyString('payer_email');
+
+ $validator
+ ->scalar('publisher_email')
+ ->maxLength('publisher_email', 255)
+ ->requirePresence('publisher_email', 'create')
+ ->notEmptyString('publisher_email');
+
+ $validator
+ ->boolean('payed')
+ ->requirePresence('payed', 'create')
+ ->notEmptyString('payed');
+
+ $validator
+ ->dateTime('success_date')
+ ->requirePresence('success_date', 'create')
+ ->notEmptyDateTime('success_date');
+
+ $validator
+ ->scalar('event')
+ ->maxLength('event', 255)
+ ->requirePresence('event', 'create')
+ ->notEmptyString('event');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['elopage_user_id'], 'ElopageUsers'));
+ $rules->add($rules->existsIn(['affiliate_program_id'], 'AffiliatePrograms'));
+ $rules->add($rules->existsIn(['publisher_id'], 'Publishers'));
+ $rules->add($rules->existsIn(['order_id'], 'Orders'));
+ $rules->add($rules->existsIn(['product_id'], 'Products'));
+
+ return $rules;
+ }
+
+ /**
+ * Returns the database connection name to use by default.
+ *
+ * @return string
+ */
+ public static function defaultConnectionName()
+ {
+ return 'loginServer';
+ }
+}
diff --git a/src/Model/Transactions/Transaction.php b/src/Model/Transactions/Transaction.php
index 7312712f6..7be390c85 100644
--- a/src/Model/Transactions/Transaction.php
+++ b/src/Model/Transactions/Transaction.php
@@ -97,6 +97,7 @@ class Transaction extends TransactionBase {
//echo 'sig Pair: '; var_dump($sigPair); echo "
";
$pubkey = $sigPair->getPubKey();
$signature = $sigPair->getEd25519();
+ echo "verify bodybytes:
" . bin2hex($bodyBytes) . '
';
if (!\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) {
$this->addError('Transaction::validate', 'signature for key ' . bin2hex($pubkey) . ' isn\'t valid ' );
return false;
@@ -192,7 +193,50 @@ class Transaction extends TransactionBase {
if(is_array($body)) {
return ['state' => 'error', 'msg' => 'error creating body transaction', 'details' => $body];
}
- $protoTransaction->setBodyBytes($body->serializeToString());
+
+ // validate signatures
+ $sigPairs = $sigMap->getProto()->getSigPair();
+
+ if(!$sigPairs || count($sigPairs) < 1) {
+ return ['state' => 'error', 'msg' => 'error no signatures found'];
+ }
+
+ //echo "verify bodybytes:
" . bin2hex($bodyBytes) . '
';
+ $created = new \Model\Messages\Gradido\TimestampSeconds();
+ $created->setSeconds($recevied->getSeconds());
+ $body->setCreated($created);
+ $bodyBytes = $body->serializeToString();
+ $createTrys = 0;
+ $createRight = false;
+ // check signature(s) and
+ // try to get created field of TransactionBody right, because it wasn't saved
+ foreach($sigPairs as $sigPair) {
+ //echo 'sig Pair: '; var_dump($sigPair); echo "
";
+ $pubkey = $sigPair->getPubKey();
+ $signature = $sigPair->getEd25519();
+ if(!$createRight) {
+ while($createTrys < 500) {
+ if(\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) {
+ $createRight = true;
+ break;
+ } else {
+ $createTrys++;
+ $created->setSeconds($created->getSeconds() - 1);
+ //$body->setCreated($created);
+ $bodyBytes = $body->serializeToString();
+ }
+ }
+ }
+
+ if (!\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) {
+ return ['state' => 'error', 'msg' => 'signature for key ' . bin2hex($pubkey) . ' isn\'t valid '];
+ }
+ }
+
+ $protoTransaction->setBodyBytes($bodyBytes);
+
+
+
return $protoTransaction;
}
diff --git a/src/Model/Transactions/TransactionBody.php b/src/Model/Transactions/TransactionBody.php
index 1d14a4c26..331e10fce 100644
--- a/src/Model/Transactions/TransactionBody.php
+++ b/src/Model/Transactions/TransactionBody.php
@@ -155,6 +155,9 @@ class TransactionBody extends TransactionBase {
{
$protoBody = new \Model\Messages\Gradido\TransactionBody();
$protoBody->setMemo($memo);
+
+ //$created->setSeconds($var);
+ //$protoBody->setCreated($created);
if(count($transaction->transaction_creations) == 1) {
//echo "is creation
";
$protoBody->setCreation(TransactionCreation::fromEntity($transaction->transaction_creations[0])->getProto());
diff --git a/src/Template/ElopageBuys/add.ctp b/src/Template/ElopageBuys/add.ctp
new file mode 100644
index 000000000..2bea72966
--- /dev/null
+++ b/src/Template/ElopageBuys/add.ctp
@@ -0,0 +1,33 @@
+
+
+
| = $this->Paginator->sort('id') ?> | += $this->Paginator->sort('elopage_user_id') ?> | += $this->Paginator->sort('affiliate_program_id') ?> | += $this->Paginator->sort('publisher_id') ?> | += $this->Paginator->sort('order_id') ?> | += $this->Paginator->sort('product_id') ?> | += $this->Paginator->sort('product_price') ?> | += $this->Paginator->sort('payer_email') ?> | += $this->Paginator->sort('publisher_email') ?> | += $this->Paginator->sort('payed') ?> | += $this->Paginator->sort('success_date') ?> | += $this->Paginator->sort('event') ?> | += __('Actions') ?> | +
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| = $this->Number->format($elopageBuy->id) ?> | += $this->Number->format($elopageBuy->elopage_user_id) ?> | += $this->Number->format($elopageBuy->affiliate_program_id) ?> | += $this->Number->format($elopageBuy->publisher_id) ?> | += $this->Number->format($elopageBuy->order_id) ?> | += $this->Number->format($elopageBuy->product_id) ?> | += $this->Number->format($elopageBuy->product_price) ?> | += h($elopageBuy->payer_email) ?> | += h($elopageBuy->publisher_email) ?> | += h($elopageBuy->payed) ?> | += h($elopageBuy->success_date) ?> | += h($elopageBuy->event) ?> | ++ = $this->Html->link(__('View'), ['action' => 'view', $elopageBuy->id]) ?> + = $this->Html->link(__('Edit'), ['action' => 'edit', $elopageBuy->id]) ?> + = $this->Form->postLink(__('Delete'), ['action' => 'delete', $elopageBuy->id], ['confirm' => __('Are you sure you want to delete # {0}?', $elopageBuy->id)]) ?> + | +
= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?>
+| = __('Payer Email') ?> | += h($elopageBuy->payer_email) ?> | +
|---|---|
| = __('Publisher Email') ?> | += h($elopageBuy->publisher_email) ?> | +
| = __('Event') ?> | += h($elopageBuy->event) ?> | +
| = __('Id') ?> | += $this->Number->format($elopageBuy->id) ?> | +
| = __('Elopage User Id') ?> | += $this->Number->format($elopageBuy->elopage_user_id) ?> | +
| = __('Affiliate Program Id') ?> | += $this->Number->format($elopageBuy->affiliate_program_id) ?> | +
| = __('Publisher Id') ?> | += $this->Number->format($elopageBuy->publisher_id) ?> | +
| = __('Order Id') ?> | += $this->Number->format($elopageBuy->order_id) ?> | +
| = __('Product Id') ?> | += $this->Number->format($elopageBuy->product_id) ?> | +
| = __('Product Price') ?> | += $this->Number->format($elopageBuy->product_price) ?> | +
| = __('Success Date') ?> | += h($elopageBuy->success_date) ?> | +
| = __('Payed') ?> | += $elopageBuy->payed ? __('Yes') : __('No'); ?> | +